[byzanz] Port to GTK+ 3 and libpanelapplet-4.0
- From: Christopher Aillon <caillon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [byzanz] Port to GTK+ 3 and libpanelapplet-4.0
- Date: Thu, 17 Feb 2011 23:05:34 +0000 (UTC)
commit 43237225c0b1cdc0e07f5becbba5cf0cae0876fa
Author: Christopher Aillon <caillon redhat com>
Date: Thu Feb 17 12:21:27 2011 -0800
Port to GTK+ 3 and libpanelapplet-4.0
configure.ac | 13 ++++--
gifenc/gifenc.c | 4 +-
gifenc/gifenc.h | 20 +++++-----
src/Makefile.am | 1 -
src/byzanzapplet.c | 8 +---
src/byzanzencoder.c | 12 +++---
src/byzanzencoder.h | 4 +-
src/byzanzencoderbyzanz.c | 14 +++---
src/byzanzencodergif.c | 54 ++++++++++++------------
src/byzanzencodergif.h | 2 +-
src/byzanzencodergstreamer.c | 13 +++++-
src/byzanzlayer.h | 2 +-
src/byzanzlayercursor.c | 28 ++++++------
src/byzanzlayerwindow.c | 46 +++++++++++----------
src/byzanzlayerwindow.h | 2 +-
src/byzanzrecorder.c | 58 +++++++++++++++++---------
src/byzanzrecorder.h | 14 +++---
src/byzanzselect.c | 41 ++++++++++---------
src/byzanzselect.h | 2 +-
src/byzanzserialize.c | 61 +++++++++++++---------------
src/byzanzserialize.h | 14 +++---
src/byzanzsession.c | 14 +++---
src/byzanzsession.h | 14 +++---
src/paneltogglebutton.c | 91 ++++++++++++++++++++++++++---------------
src/paneltogglebutton.h | 2 +-
src/record.c | 13 ++++--
src/screenshot-utils.c | 14 ++++---
27 files changed, 309 insertions(+), 252 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 45516a6..ced96dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,18 +63,21 @@ AC_DEFINE_DIR(DATADIR, "${datadir}", [datadir])
dnl Check for essential libraries first:
dnl ====================================
-CAIRO_REQ="1.8.10"
-GTK_REQ="2.17.10"
+CAIRO_REQ="1.10"
+GTK_REQ="3.0.0"
GTHREAD_REQ="2.6.0"
-APPLET_REQ="2.31.2"
+APPLET_REQ="2.91.6"
XDAMAGE_REQ="1.0"
GST_REQ="0.10.24"
-PKG_CHECK_MODULES(GTK, cairo >= $CAIRO_REQ gtk+-2.0 >= $GTK_REQ x11 gio-2.0)
+PKG_CHECK_MODULES(GTK, cairo >= $CAIRO_REQ gtk+-3.0 >= $GTK_REQ x11 gio-2.0)
PKG_CHECK_MODULES(GTHREAD, xdamage >= $XDAMAGE_REQ gthread-2.0 >= $GTHREAD_REQ)
-PKG_CHECK_MODULES(APPLET, libpanelapplet-3.0 >= $APPLET_REQ)
+LIBPANEL_APPLET="libpanelapplet-4.0"
+PKG_CHECK_MODULES(APPLET, $LIBPANEL_APPLET >= $APPLET_REQ)
+appletdir=`$PKG_CONFIG --variable=libpanel_applet_dir $LIBPANEL_APPLET`
+AC_SUBST(appletdir)
PKG_CHECK_MODULES(GST, gstreamer-app-0.10 >= $GST_REQ gstreamer-0.10 >= $GST_REQ)
diff --git a/gifenc/gifenc.c b/gifenc/gifenc.c
index 07c20b5..50c98d5 100644
--- a/gifenc/gifenc.c
+++ b/gifenc/gifenc.c
@@ -530,14 +530,14 @@ gboolean
gifenc_dither_rgb_with_full_image (guint8 *target, guint target_rowstride,
guint8 *full, guint full_rowstride,
const GifencPalette *palette, const guint8 *data, guint width, guint height,
- guint rowstride, GdkRectangle *rect_out)
+ guint rowstride, cairo_rectangle_int_t *rect_out)
{
int x, y, c;
gint *this_error, *next_error;
guint8 this[3], alpha;
gint err[3] = { 0, 0, 0 };
guint32 pixel;
- GdkRectangle area = { width, height, 0, 0 };
+ cairo_rectangle_int_t area = { width, height, 0, 0 };
g_return_val_if_fail (palette != NULL, FALSE);
g_return_val_if_fail (palette->alpha, FALSE);
diff --git a/gifenc/gifenc.h b/gifenc/gifenc.h
index 531e1e6..b24b2a2 100644
--- a/gifenc/gifenc.h
+++ b/gifenc/gifenc.h
@@ -99,16 +99,16 @@ void gifenc_dither_rgb (guint8 * target,
guint height,
guint rowstride);
gboolean gifenc_dither_rgb_with_full_image
- (guint8 * target,
- guint target_rowstride,
- guint8 * full,
- guint full_rowstride,
- const GifencPalette * palette,
- const guint8 * data,
- guint width,
- guint height,
- guint rowstride,
- GdkRectangle * rect_out);
+ (guint8 * target,
+ guint target_rowstride,
+ guint8 * full,
+ guint full_rowstride,
+ const GifencPalette * palette,
+ const guint8 * data,
+ guint width,
+ guint height,
+ guint rowstride,
+ cairo_rectangle_int_t * rect_out);
/* from quantize.c */
void gifenc_palette_free (GifencPalette * palette);
diff --git a/src/Makefile.am b/src/Makefile.am
index 151a970..90126d1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -91,7 +91,6 @@ install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(schemas_DATA) ;
endif
-appletdir = $(datadir)/gnome-panel/applets
applet_in_files = org.gnome.ByzanzApplet.panel-applet.in
applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
diff --git a/src/byzanzapplet.c b/src/byzanzapplet.c
index 44ceaaa..f069bf5 100644
--- a/src/byzanzapplet.c
+++ b/src/byzanzapplet.c
@@ -41,7 +41,6 @@ typedef struct {
GtkWidget * button; /* recording button */
GtkWidget * image; /* image displayed in button */
- GtkTooltips * tooltips; /* our tooltips */
GtkWidget * dialog; /* file chooser */
GFile * file; /* file selected for recording */
GType encoder_type; /* last selected encoder type or 0 if none */
@@ -137,8 +136,7 @@ byzanz_applet_update (gpointer data)
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
state_info[state].stock_icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_tooltips_set_tip (priv->tooltips, priv->button,
- _(state_info[state].tooltip), NULL);
+ gtk_widget_set_tooltip_text (priv->button, _(state_info[state].tooltip));
return TRUE;
}
@@ -182,7 +180,7 @@ byzanz_applet_session_notify (AppletPrivate *priv)
static int method_response_codes[] = { GTK_RESPONSE_ACCEPT, GTK_RESPONSE_APPLY, GTK_RESPONSE_OK, GTK_RESPONSE_YES };
static void
-byzanz_applet_select_done (GdkWindow *window, const GdkRectangle *area, gpointer data)
+byzanz_applet_select_done (GdkWindow *window, const cairo_rectangle_int_t *area, gpointer data)
{
AppletPrivate *priv = data;
@@ -418,8 +416,6 @@ byzanz_applet_fill (PanelApplet *applet, const gchar *iid, gpointer data)
g_free (ui_path);
g_object_unref (action_group);
- priv->tooltips = gtk_tooltips_new ();
-
method = panel_applet_gconf_get_string (priv->applet, "method", NULL);
priv->method = byzanz_select_method_lookup (method);
g_free (method);
diff --git a/src/byzanzencoder.c b/src/byzanzencoder.c
index f899e7a..9c175ef 100644
--- a/src/byzanzencoder.c
+++ b/src/byzanzencoder.c
@@ -31,7 +31,7 @@ typedef struct _ByzanzEncoderJob ByzanzEncoderJob;
struct _ByzanzEncoderJob {
GTimeVal tv; /* time this job was enqueued */
cairo_surface_t * surface; /* image to process */
- GdkRegion * region; /* relevant region of image */
+ cairo_region_t * region; /* relevant region of image */
};
static void
@@ -40,7 +40,7 @@ byzanz_encoder_job_free (ByzanzEncoderJob *job)
if (job->surface)
cairo_surface_destroy (job->surface);
if (job->region)
- gdk_region_destroy (job->region);
+ cairo_region_destroy (job->region);
g_slice_free (ByzanzEncoderJob, job);
}
@@ -80,7 +80,7 @@ byzanz_encoder_run (ByzanzEncoder * encoder,
ByzanzEncoderClass *klass = BYZANZ_ENCODER_GET_CLASS (encoder);
guint width, height;
cairo_surface_t *surface;
- GdkRegion *region;
+ cairo_region_t *region;
guint64 msecs;
gboolean success;
@@ -107,7 +107,7 @@ byzanz_encoder_run (ByzanzEncoder * encoder,
/* decode */
success = klass->process (encoder, output, msecs, surface, region, cancellable, error);
cairo_surface_destroy (surface);
- gdk_region_destroy (region);
+ cairo_region_destroy (region);
if (!success)
return FALSE;
}
@@ -349,7 +349,7 @@ byzanz_encoder_new (GType encoder_type,
void
byzanz_encoder_process (ByzanzEncoder * encoder,
cairo_surface_t *surface,
- const GdkRegion *region,
+ const cairo_region_t *region,
const GTimeVal * total_elapsed)
{
ByzanzEncoderJob *job;
@@ -364,7 +364,7 @@ byzanz_encoder_process (ByzanzEncoder * encoder,
job = g_slice_new (ByzanzEncoderJob);
job->surface = cairo_surface_reference (surface);
- job->region = gdk_region_copy (region);
+ job->region = cairo_region_copy (region);
job->tv = *total_elapsed;
g_async_queue_push (encoder->jobs, job);
diff --git a/src/byzanzencoder.h b/src/byzanzencoder.h
index 54f816e..f67e978 100644
--- a/src/byzanzencoder.h
+++ b/src/byzanzencoder.h
@@ -76,7 +76,7 @@ struct _ByzanzEncoderClass {
GOutputStream * stream,
guint64 msecs,
cairo_surface_t * surface,
- const GdkRegion * region,
+ const cairo_region_t * region,
GCancellable * cancellable,
GError ** error);
gboolean (* close) (ByzanzEncoder * encoder,
@@ -96,7 +96,7 @@ ByzanzEncoder * byzanz_encoder_new (GType encoder_type,
/*
void byzanz_encoder_process (ByzanzEncoder * encoder,
cairo_surface_t * surface,
- const GdkRegion * region,
+ const cairo_region_t * region,
const GTimeVal * total_elapsed);
void byzanz_encoder_close (ByzanzEncoder * encoder,
const GTimeVal * total_elapsed);
diff --git a/src/byzanzencoderbyzanz.c b/src/byzanzencoderbyzanz.c
index 868a45b..0a8b8b8 100644
--- a/src/byzanzencoderbyzanz.c
+++ b/src/byzanzencoderbyzanz.c
@@ -42,13 +42,13 @@ byzanz_encoder_byzanz_setup (ByzanzEncoder * encoder,
}
static gboolean
-byzanz_encoder_byzanz_process (ByzanzEncoder * encoder,
- GOutputStream * stream,
- guint64 msecs,
- cairo_surface_t * surface,
- const GdkRegion * region,
- GCancellable * cancellable,
- GError ** error)
+byzanz_encoder_byzanz_process (ByzanzEncoder * encoder,
+ GOutputStream * stream,
+ guint64 msecs,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ GCancellable * cancellable,
+ GError ** error)
{
return byzanz_serialize (stream, msecs, surface, region, cancellable, error);
}
diff --git a/src/byzanzencodergif.c b/src/byzanzencodergif.c
index bb80339..07bd2fc 100644
--- a/src/byzanzencodergif.c
+++ b/src/byzanzencodergif.c
@@ -109,16 +109,16 @@ byzanz_encoder_write_image (ByzanzEncoderGif *gif, guint64 msecs, GError **error
}
static gboolean
-byzanz_encoder_gif_encode_image (ByzanzEncoderGif * gif,
- cairo_surface_t * surface,
- const GdkRegion * region,
- GdkRectangle * area_out)
+byzanz_encoder_gif_encode_image (ByzanzEncoderGif * gif,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ cairo_rectangle_int_t * area_out)
{
- GdkRectangle extents, area, *rects;
+ cairo_rectangle_int_t extents, area, rect;
guint8 transparent;
guint i, n_rects, stride, width;
- gdk_region_get_clipbox (region, &extents);
+ cairo_region_get_extents (region, &extents);
transparent = gifenc_palette_get_alpha_index (gif->gifenc->palette);
stride = cairo_image_surface_get_stride (surface);
width = gifenc_get_width (gif->gifenc);
@@ -130,32 +130,32 @@ byzanz_encoder_gif_encode_image (ByzanzEncoderGif * gif,
}
/* render changed parts */
- gdk_region_get_rectangles (region, &rects, (int *) &n_rects);
- memset (area_out, 0, sizeof (GdkRectangle));
+ n_rects = cairo_region_num_rectangles (region);
+ memset (area_out, 0, sizeof (cairo_rectangle_int_t));
for (i = 0; i < n_rects; i++) {
+ cairo_region_get_rectangle (region, i, &rect);
if (gifenc_dither_rgb_with_full_image (
- gif->cached_tmp + width * rects[i].y + rects[i].x, width,
- gif->image_data + width * rects[i].y + rects[i].x, width,
+ gif->cached_tmp + width * rect.y + rect.x, width,
+ gif->image_data + width * rect.y + rect.x, width,
gif->gifenc->palette,
- cairo_image_surface_get_data (surface) + (rects[i].x - extents.x) * 4
- + (rects[i].y - extents.y) * stride,
- rects[i].width, rects[i].height, stride, &area)) {
- area.x += rects[i].x;
- area.y += rects[i].y;
+ cairo_image_surface_get_data (surface) + (rect.x - extents.x) * 4
+ + (rect.y - extents.y) * stride,
+ rect.width, rect.height, stride, &area)) {
+ area.x += rect.x;
+ area.y += rect.y;
if (area_out->width > 0 && area_out->height > 0)
- gdk_rectangle_union (area_out, &area, area_out);
+ gdk_rectangle_union ((const GdkRectangle*)area_out, (const GdkRectangle*) &area, (GdkRectangle*)area_out);
else
*area_out = area;
}
}
- g_free (rects);
return area_out->width > 0 && area_out->height > 0;
}
static void
-byzanz_encoder_swap_image (ByzanzEncoderGif * gif,
- GdkRectangle * area)
+byzanz_encoder_swap_image (ByzanzEncoderGif * gif,
+ cairo_rectangle_int_t * area)
{
guint8 *swap;
@@ -166,16 +166,16 @@ byzanz_encoder_swap_image (ByzanzEncoderGif * gif,
}
static gboolean
-byzanz_encoder_gif_process (ByzanzEncoder * encoder,
- GOutputStream * stream,
- guint64 msecs,
- cairo_surface_t * surface,
- const GdkRegion * region,
- GCancellable * cancellable,
- GError ** error)
+byzanz_encoder_gif_process (ByzanzEncoder * encoder,
+ GOutputStream * stream,
+ guint64 msecs,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ GCancellable * cancellable,
+ GError ** error)
{
ByzanzEncoderGif *gif = BYZANZ_ENCODER_GIF (encoder);
- GdkRectangle area;
+ cairo_rectangle_int_t area;
if (!gif->has_quantized) {
if (!byzanz_encoder_gif_quantize (gif, surface, error))
diff --git a/src/byzanzencodergif.h b/src/byzanzencodergif.h
index b4c75f0..02d9dee 100644
--- a/src/byzanzencodergif.h
+++ b/src/byzanzencodergif.h
@@ -41,7 +41,7 @@ struct _ByzanzEncoderGif {
gboolean has_quantized; /* qantization has happened already */
guint8 * image_data; /* width * height of encoded image */
- GdkRectangle cached_area; /* area that is saved in cached_data */
+ cairo_rectangle_int_t cached_area; /* area that is saved in cached_data */
guint8 * cached_data; /* cached_area.{width x height} sized area of image */
guint64 cached_time; /* timestamp the cached image corresponds to */
diff --git a/src/byzanzencodergstreamer.c b/src/byzanzencodergstreamer.c
index 8802ea5..e8e9cf7 100644
--- a/src/byzanzencodergstreamer.c
+++ b/src/byzanzencodergstreamer.c
@@ -39,9 +39,10 @@ byzanz_encoder_gstreamer_need_data (GstAppSrc *src, guint length, gpointer data)
GstBuffer *buffer;
cairo_t *cr;
cairo_surface_t *surface;
- GdkRegion *region;
+ cairo_region_t *region;
GError *error = NULL;
guint64 msecs;
+ int i, num_rects;
if (!byzanz_deserialize (encoder->input_stream, &msecs, &surface, ®ion, encoder->cancellable, &error)) {
gst_element_message_full (GST_ELEMENT (src), GST_MESSAGE_ERROR,
@@ -71,7 +72,15 @@ byzanz_encoder_gstreamer_need_data (GstAppSrc *src, guint length, gpointer data)
}
cr = cairo_create (gst->surface);
cairo_set_source_surface (cr, surface, 0, 0);
- gdk_cairo_region (cr, region);
+
+ num_rects = cairo_region_num_rectangles (region);
+ for (i = 0; i < num_rects; i++) {
+ cairo_rectangle_int_t rect;
+ cairo_region_get_rectangle (region, i, &rect);
+ cairo_rectangle (cr, rect.x, rect.y,
+ rect.width, rect.height);
+ }
+
cairo_fill (cr);
cairo_destroy (cr);
diff --git a/src/byzanzlayer.h b/src/byzanzlayer.h
index 45ff632..518087f 100644
--- a/src/byzanzlayer.h
+++ b/src/byzanzlayer.h
@@ -45,7 +45,7 @@ struct _ByzanzLayerClass {
gboolean (* event) (ByzanzLayer * layer,
GdkXEvent * event);
- GdkRegion * (* snapshot) (ByzanzLayer * layer);
+ cairo_region_t * (* snapshot) (ByzanzLayer * layer);
void (* render) (ByzanzLayer * layer,
cairo_t * cr);
};
diff --git a/src/byzanzlayercursor.c b/src/byzanzlayercursor.c
index 8659a39..8358493 100644
--- a/src/byzanzlayercursor.c
+++ b/src/byzanzlayercursor.c
@@ -30,7 +30,7 @@ G_DEFINE_TYPE (ByzanzLayerCursor, byzanz_layer_cursor, BYZANZ_TYPE_LAYER)
static void
byzanz_layer_cursor_read_cursor (ByzanzLayerCursor *clayer)
{
- Display *dpy = gdk_x11_drawable_get_xdisplay (BYZANZ_LAYER (clayer)->recorder->window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (BYZANZ_LAYER (clayer)->recorder->window));
clayer->cursor_next = XFixesGetCursorImage (dpy);
if (clayer->cursor_next)
@@ -86,9 +86,9 @@ byzanz_layer_cursor_setup_poll (ByzanzLayerCursor *clayer)
}
static void
-byzanz_recorder_invalidate_cursor (GdkRegion *region, XFixesCursorImage *cursor, int x, int y)
+byzanz_recorder_invalidate_cursor (cairo_region_t *region, XFixesCursorImage *cursor, int x, int y)
{
- GdkRectangle cursor_rect;
+ cairo_rectangle_int_t cursor_rect;
if (cursor == NULL)
return;
@@ -98,14 +98,14 @@ byzanz_recorder_invalidate_cursor (GdkRegion *region, XFixesCursorImage *cursor,
cursor_rect.width = cursor->width;
cursor_rect.height = cursor->height;
- gdk_region_union_with_rect (region, &cursor_rect);
+ cairo_region_union_rectangle (region, &cursor_rect);
}
-static GdkRegion *
+static cairo_region_t *
byzanz_layer_cursor_snapshot (ByzanzLayer *layer)
{
ByzanzLayerCursor *clayer = BYZANZ_LAYER_CURSOR (layer);
- GdkRegion *region, *area;
+ cairo_region_t *region, *area;
int x, y;
gdk_window_get_pointer (layer->recorder->window, &x, &y, NULL);
@@ -114,12 +114,12 @@ byzanz_layer_cursor_snapshot (ByzanzLayer *layer)
clayer->cursor_next == clayer->cursor)
return NULL;
- region = gdk_region_new ();
+ region = cairo_region_create ();
byzanz_recorder_invalidate_cursor (region, clayer->cursor, clayer->cursor_x, clayer->cursor_y);
byzanz_recorder_invalidate_cursor (region, clayer->cursor_next, x, y);
- area = gdk_region_rectangle (&layer->recorder->area);
- gdk_region_intersect (region, area);
- gdk_region_destroy (area);
+ area = cairo_region_create_rectangle (&layer->recorder->area);
+ cairo_region_intersect (region, area);
+ cairo_region_destroy (area);
clayer->cursor = clayer->cursor_next;
clayer->cursor_x = x;
@@ -168,9 +168,9 @@ byzanz_layer_cursor_finalize (GObject *object)
{
ByzanzLayerCursor *clayer = BYZANZ_LAYER_CURSOR (object);
GdkWindow *window = BYZANZ_LAYER (object)->recorder->window;
- Display *dpy = gdk_x11_drawable_get_xdisplay (window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (window));
- XFixesSelectCursorInput (dpy, gdk_x11_drawable_get_xid (window), 0);
+ XFixesSelectCursorInput (dpy, GDK_WINDOW_XID (window), 0);
g_hash_table_destroy (clayer->cursors);
@@ -186,9 +186,9 @@ byzanz_layer_cursor_constructed (GObject *object)
{
ByzanzLayerCursor *clayer = BYZANZ_LAYER_CURSOR (object);
GdkWindow *window = BYZANZ_LAYER (object)->recorder->window;
- Display *dpy = gdk_x11_drawable_get_xdisplay (window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (window));
- XFixesSelectCursorInput (dpy, gdk_x11_drawable_get_xid (window), XFixesDisplayCursorNotifyMask);
+ XFixesSelectCursorInput (dpy, GDK_WINDOW_XID (window), XFixesDisplayCursorNotifyMask);
byzanz_layer_cursor_read_cursor (clayer);
byzanz_layer_cursor_setup_poll (clayer);
diff --git a/src/byzanzlayerwindow.c b/src/byzanzlayerwindow.c
index f7d4188..c2d095b 100644
--- a/src/byzanzlayerwindow.c
+++ b/src/byzanzlayerwindow.c
@@ -36,14 +36,16 @@ byzanz_layer_window_event (ByzanzLayer * layer,
if (event->type == layer->recorder->damage_event_base + XDamageNotify &&
event->damage == wlayer->damage) {
- GdkRectangle rect;
+ cairo_rectangle_int_t rect;
rect.x = event->area.x;
rect.y = event->area.y;
rect.width = event->area.width;
rect.height = event->area.height;
- if (gdk_rectangle_intersect (&rect, &layer->recorder->area, &rect)) {
- gdk_region_union_with_rect (wlayer->invalid, &rect);
+ if (gdk_rectangle_intersect ((GdkRectangle*) &rect,
+ (GdkRectangle*) &layer->recorder->area,
+ (GdkRectangle*) &rect)) {
+ cairo_region_union_rectangle (wlayer->invalid, &rect);
byzanz_layer_invalidate (layer);
}
return TRUE;
@@ -53,38 +55,38 @@ byzanz_layer_window_event (ByzanzLayer * layer,
}
static XserverRegion
-byzanz_server_region_from_gdk (Display *dpy, GdkRegion *source)
+byzanz_server_region_from_gdk (Display *dpy, cairo_region_t *source)
{
XserverRegion dest;
XRectangle *dest_rects;
- GdkRectangle *source_rects;
+ cairo_rectangle_int_t source_rect;
int n_rectangles, i;
- gdk_region_get_rectangles (source, &source_rects, &n_rectangles);
+ n_rectangles = cairo_region_num_rectangles (source);
g_assert (n_rectangles);
dest_rects = g_new (XRectangle, n_rectangles);
for (i = 0; i < n_rectangles; i++) {
- dest_rects[i].x = source_rects[i].x;
- dest_rects[i].y = source_rects[i].y;
- dest_rects[i].width = source_rects[i].width;
- dest_rects[i].height = source_rects[i].height;
+ cairo_region_get_rectangle (source, i, &source_rect);
+ dest_rects[i].x = source_rect.x;
+ dest_rects[i].y = source_rect.y;
+ dest_rects[i].width = source_rect.width;
+ dest_rects[i].height = source_rect.height;
}
dest = XFixesCreateRegion (dpy, dest_rects, n_rectangles);
g_free (dest_rects);
- g_free (source_rects);
return dest;
}
-static GdkRegion *
+static cairo_region_t *
byzanz_layer_window_snapshot (ByzanzLayer *layer)
{
- Display *dpy = gdk_x11_drawable_get_xdisplay (layer->recorder->window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (layer->recorder->window));
ByzanzLayerWindow *wlayer = BYZANZ_LAYER_WINDOW (layer);
XserverRegion reg;
- GdkRegion *region;
+ cairo_region_t *region;
- if (gdk_region_empty (wlayer->invalid))
+ if (cairo_region_is_empty (wlayer->invalid))
return NULL;
reg = byzanz_server_region_from_gdk (dpy, wlayer->invalid);
@@ -92,7 +94,7 @@ byzanz_layer_window_snapshot (ByzanzLayer *layer)
XFixesDestroyRegion (dpy, reg);
region = wlayer->invalid;
- wlayer->invalid = gdk_region_new ();
+ wlayer->invalid = cairo_region_create ();
return region;
}
@@ -117,11 +119,11 @@ byzanz_layer_window_render (ByzanzLayer *layer,
static void
byzanz_layer_window_finalize (GObject *object)
{
- Display *dpy = gdk_x11_drawable_get_xdisplay (BYZANZ_LAYER (object)->recorder->window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (BYZANZ_LAYER (object)->recorder->window));
ByzanzLayerWindow *wlayer = BYZANZ_LAYER_WINDOW (object);
XDamageDestroy (dpy, wlayer->damage);
- gdk_region_destroy (wlayer->invalid);
+ cairo_region_destroy (wlayer->invalid);
G_OBJECT_CLASS (byzanz_layer_window_parent_class)->finalize (object);
}
@@ -131,11 +133,11 @@ byzanz_layer_window_constructed (GObject *object)
{
ByzanzLayer *layer = BYZANZ_LAYER (object);
GdkWindow *window = layer->recorder->window;
- Display *dpy = gdk_x11_drawable_get_xdisplay (window);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (window));
ByzanzLayerWindow *wlayer = BYZANZ_LAYER_WINDOW (object);
- wlayer->damage = XDamageCreate (dpy, gdk_x11_drawable_get_xid (window), XDamageReportDeltaRectangles);
- gdk_region_union_with_rect (wlayer->invalid, &layer->recorder->area);
+ wlayer->damage = XDamageCreate (dpy, gdk_x11_window_get_xid (window), XDamageReportDeltaRectangles);
+ cairo_region_union_rectangle (wlayer->invalid, &layer->recorder->area);
G_OBJECT_CLASS (byzanz_layer_window_parent_class)->constructed (object);
}
@@ -157,6 +159,6 @@ byzanz_layer_window_class_init (ByzanzLayerWindowClass *klass)
static void
byzanz_layer_window_init (ByzanzLayerWindow *wlayer)
{
- wlayer->invalid = gdk_region_new ();
+ wlayer->invalid = cairo_region_create ();
}
diff --git a/src/byzanzlayerwindow.h b/src/byzanzlayerwindow.h
index c93fa2d..70a7d2c 100644
--- a/src/byzanzlayerwindow.h
+++ b/src/byzanzlayerwindow.h
@@ -38,7 +38,7 @@ typedef struct _ByzanzLayerWindowClass ByzanzLayerWindowClass;
struct _ByzanzLayerWindow {
ByzanzLayer layer;
- GdkRegion * invalid; /* TRUE if we need to repaint */
+ cairo_region_t * invalid; /* TRUE if we need to repaint */
Damage damage; /* the Damage object */
};
diff --git a/src/byzanzrecorder.c b/src/byzanzrecorder.c
index 31675ec..25666ad 100644
--- a/src/byzanzrecorder.c
+++ b/src/byzanzrecorder.c
@@ -48,13 +48,13 @@ enum {
G_DEFINE_TYPE (ByzanzRecorder, byzanz_recorder, G_TYPE_OBJECT)
static guint signals[LAST_SIGNAL] = { 0, };
-static GdkRegion *
+static cairo_region_t *
byzanz_recorder_get_invalid_region (ByzanzRecorder *recorder)
{
- GdkRegion *invalid, *layer_invalid;
+ cairo_region_t *invalid, *layer_invalid;
GSequenceIter *iter;
- invalid = gdk_region_new ();
+ invalid = cairo_region_create ();
for (iter = g_sequence_get_begin_iter (recorder->layers);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter)) {
@@ -63,8 +63,8 @@ byzanz_recorder_get_invalid_region (ByzanzRecorder *recorder)
layer_invalid = klass->snapshot (layer);
if (layer_invalid) {
- gdk_region_union (invalid, layer_invalid);
- gdk_region_destroy (layer_invalid);
+ cairo_region_union (invalid, layer_invalid);
+ cairo_region_destroy (layer_invalid);
}
}
@@ -72,23 +72,32 @@ byzanz_recorder_get_invalid_region (ByzanzRecorder *recorder)
}
static cairo_surface_t *
-ensure_image_surface (cairo_surface_t *surface, const GdkRegion *region)
+ensure_image_surface (cairo_surface_t *surface, const cairo_region_t *region)
{
- GdkRectangle extents;
+ cairo_rectangle_int_t extents;
cairo_surface_t *image;
cairo_t *cr;
+ int i, num_rects;
if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
return surface;
- gdk_region_get_clipbox (region, &extents);
+ cairo_region_get_extents (region, &extents);
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, extents.width, extents.height);
cairo_surface_set_device_offset (image, -extents.x, -extents.y);
cr = cairo_create (image);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- gdk_cairo_region (cr, region);
+
+ num_rects = cairo_region_num_rectangles (region);
+ for (i = 0; i < num_rects; i++) {
+ cairo_rectangle_int_t rect;
+ cairo_region_get_rectangle (region, i, &rect);
+ cairo_rectangle (cr, rect.x, rect.y,
+ rect.width, rect.height);
+ }
+
cairo_fill (cr);
cairo_destroy (cr);
@@ -97,14 +106,15 @@ ensure_image_surface (cairo_surface_t *surface, const GdkRegion *region)
}
static cairo_surface_t *
-byzanz_recorder_create_snapshot (ByzanzRecorder *recorder, const GdkRegion *invalid)
+byzanz_recorder_create_snapshot (ByzanzRecorder *recorder, const cairo_region_t *invalid)
{
- GdkRectangle extents;
+ cairo_rectangle_int_t extents;
cairo_surface_t *surface;
cairo_t *cr;
GSequenceIter *iter;
+ int i, num_rects;
- gdk_region_get_clipbox (invalid, &extents);
+ cairo_region_get_extents (invalid, &extents);
cr = gdk_cairo_create (recorder->window);
surface = cairo_surface_create_similar (cairo_get_target (cr), CAIRO_CONTENT_COLOR,
extents.width, extents.height);
@@ -112,7 +122,15 @@ byzanz_recorder_create_snapshot (ByzanzRecorder *recorder, const GdkRegion *inva
cairo_surface_set_device_offset (surface, -extents.x, -extents.y);
cr = cairo_create (surface);
- gdk_cairo_region (cr, invalid);
+
+ num_rects = cairo_region_num_rectangles (invalid);
+ for (i = 0; i < num_rects; i++) {
+ cairo_rectangle_int_t rect;
+ cairo_region_get_rectangle (invalid, i, &rect);
+ cairo_rectangle (cr, rect.x, rect.y,
+ rect.width, rect.height);
+ }
+
cairo_clip (cr);
for (iter = g_sequence_get_begin_iter (recorder->layers);
@@ -157,7 +175,7 @@ static gboolean
byzanz_recorder_snapshot (ByzanzRecorder *recorder)
{
cairo_surface_t *surface;
- GdkRegion *invalid;
+ cairo_region_t *invalid;
GTimeVal tv;
if (!recorder->recording)
@@ -167,19 +185,19 @@ byzanz_recorder_snapshot (ByzanzRecorder *recorder)
return FALSE;
invalid = byzanz_recorder_get_invalid_region (recorder);
- if (gdk_region_empty (invalid)) {
- gdk_region_destroy (invalid);
+ if (cairo_region_is_empty (invalid)) {
+ cairo_region_destroy (invalid);
return FALSE;
}
surface = byzanz_recorder_create_snapshot (recorder, invalid);
g_get_current_time (&tv);
- gdk_region_offset (invalid, -recorder->area.x, -recorder->area.y);
+ cairo_region_translate (invalid, -recorder->area.x, -recorder->area.y);
g_signal_emit (recorder, signals[IMAGE], 0, surface, invalid, &tv);
cairo_surface_destroy (surface);
- gdk_region_destroy (invalid);
+ cairo_region_destroy (invalid);
recorder->next_image_source = gdk_threads_add_timeout_full (G_PRIORITY_HIGH_IDLE,
BYZANZ_RECORDER_FRAME_RATE_MS, byzanz_recorder_next_image, recorder, NULL);
@@ -254,7 +272,7 @@ byzanz_recorder_set_property (GObject *object, guint param_id, const GValue *val
byzanz_recorder_set_window (recorder, g_value_get_object (value));
break;
case PROP_AREA:
- recorder->area = *(GdkRectangle *) g_value_get_boxed (value);
+ recorder->area = *(cairo_rectangle_int_t *) g_value_get_boxed (value);
break;
case PROP_RECORDING:
byzanz_recorder_set_recording (recorder, g_value_get_boolean (value));
@@ -362,7 +380,7 @@ byzanz_recorder_init (ByzanzRecorder *recorder)
}
ByzanzRecorder *
-byzanz_recorder_new (GdkWindow *window, GdkRectangle *area)
+byzanz_recorder_new (GdkWindow *window, cairo_rectangle_int_t *area)
{
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
g_return_val_if_fail (area != NULL, NULL);
diff --git a/src/byzanzrecorder.h b/src/byzanzrecorder.h
index 1a4be56..b88ff32 100644
--- a/src/byzanzrecorder.h
+++ b/src/byzanzrecorder.h
@@ -39,7 +39,7 @@ struct _ByzanzRecorder {
GObject object;
GdkWindow * window; /* window we are recording from */
- GdkRectangle area; /* area of window that we record */
+ cairo_rectangle_int_t area; /* area of window that we record */
gboolean recording; /* wether we should be recording now */
int damage_event_base; /* base event for Damage extension */
@@ -55,16 +55,16 @@ struct _ByzanzRecorder {
struct _ByzanzRecorderClass {
GObjectClass object_class;
- void (* image) (ByzanzRecorder * recorder,
- cairo_surface_t * surface,
- const GdkRegion * region,
- const GTimeVal * tv);
+ void (* image) (ByzanzRecorder * recorder,
+ cairo_surface_t * surface,
+ const cairo_surface_t * region,
+ const GTimeVal * tv);
};
GType byzanz_recorder_get_type (void) G_GNUC_CONST;
-ByzanzRecorder * byzanz_recorder_new (GdkWindow * window,
- GdkRectangle * area);
+ByzanzRecorder * byzanz_recorder_new (GdkWindow * window,
+ cairo_rectangle_int_t * area);
void byzanz_recorder_set_recording (ByzanzRecorder * recorder,
gboolean recording);
diff --git a/src/byzanzselect.c b/src/byzanzselect.c
index abf0f25..c74b1ef 100644
--- a/src/byzanzselect.c
+++ b/src/byzanzselect.c
@@ -28,7 +28,7 @@
#include "screenshot-utils.h"
static void
-rectangle_sanitize (GdkRectangle *dest, const GdkRectangle *src)
+rectangle_sanitize (cairo_rectangle_int_t *dest, const cairo_rectangle_int_t *src)
{
*dest = *src;
if (dest->width < 0) {
@@ -48,7 +48,7 @@ struct _ByzanzSelectData {
/* results */
GdkWindow * result; /* window that was selected */
- GdkRectangle area; /* the area to select */
+ cairo_rectangle_int_t area; /* the area to select */
/* method data */
GtkWidget * window; /* window we created to do selecting or NULL */
@@ -91,7 +91,7 @@ byzanz_select_done (ByzanzSelectData *data, GdkWindow *window)
if (window) {
/* stupid hack to get around a session recording the selection window */
- gdk_display_sync (gdk_drawable_get_display (GDK_DRAWABLE (window)));
+ gdk_display_sync (gdk_window_get_display (window));
data->result = g_object_ref (window);
gdk_threads_add_timeout (1000, byzanz_select_really_done, data);
} else {
@@ -113,7 +113,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer datap)
static double dashes[] = { 1.0, 2.0 };
#endif
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_rectangle (cr, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_clip (cr);
@@ -140,11 +140,11 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer datap)
cairo_stroke (cr);
#endif
if (data->area.x >= 0 && data->area.width != 0 && data->area.height != 0) {
- GdkRectangle rect = data->area;
+ cairo_rectangle_int_t rect = data->area;
rectangle_sanitize (&rect, &data->area);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.5, 0.2);
cairo_set_dash (cr, NULL, 0, 0.0);
- gdk_cairo_rectangle (cr, &rect);
+ gdk_cairo_rectangle (cr, (GdkRectangle *) &rect);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.5, 0.5);
cairo_rectangle (cr, rect.x + 0.5, rect.y + 0.5, rect.width - 1, rect.height - 1);
@@ -199,7 +199,7 @@ motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, gpointer datap)
gtk_widget_queue_draw (widget);
#else
if (data->area.x >= 0) {
- GdkRectangle rect;
+ cairo_rectangle_int_t rect;
rectangle_sanitize (&rect, &data->area);
gtk_widget_queue_draw_area (widget, rect.x, rect.y, rect.width, rect.height);
}
@@ -207,7 +207,7 @@ motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, gpointer datap)
data->area.width = event->x - data->area.x;
data->area.height = event->y - data->area.y;
if (data->area.x >= 0) {
- GdkRectangle rect;
+ cairo_rectangle_int_t rect;
rectangle_sanitize (&rect, &data->area);
gtk_widget_queue_draw_area (widget, rect.x, rect.y, rect.width, rect.height);
}
@@ -218,7 +218,7 @@ motion_notify_cb (GtkWidget *widget, GdkEventMotion *event, gpointer datap)
static void
realize_cb (GtkWidget *widget, gpointer datap)
{
- GdkWindow *window = widget->window;
+ GdkWindow *window = gtk_widget_get_window (widget);
GdkCursor *cursor;
gdk_window_set_events (window, gdk_window_get_events (window) |
@@ -228,7 +228,7 @@ realize_cb (GtkWidget *widget, gpointer datap)
cursor = gdk_cursor_new (GDK_CROSSHAIR);
gdk_window_set_cursor (window, cursor);
gdk_cursor_unref (cursor);
- gdk_window_set_back_pixmap (window, NULL, FALSE);
+ gdk_window_set_background_pattern (window, NULL);
}
static void
@@ -247,21 +247,22 @@ active_cb (GtkWindow *window, GParamSpec *pspec, ByzanzSelectData *data)
static void
byzanz_select_area (ByzanzSelectData *data)
{
- GdkColormap *rgba;
+ GdkVisual *visual;
data->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
data->area.x = -1;
data->area.y = -1;
- rgba = gdk_screen_get_rgba_colormap (gdk_screen_get_default ());
- if (rgba && gdk_screen_is_composited (gdk_screen_get_default ())) {
- gtk_widget_set_colormap (data->window, rgba);
+ visual = gdk_screen_get_rgba_visual (gdk_screen_get_default ());
+ if (visual && gdk_screen_is_composited (gdk_screen_get_default ())) {
+ gtk_widget_set_visual (data->window, visual);
} else {
GdkWindow *root = gdk_get_default_root_window ();
cairo_t *cr;
cairo_surface_t *root_surface;
gint width, height;
- gdk_drawable_get_size (root, &width, &height);
+ width = gdk_window_get_width (root);
+ height = gdk_window_get_height (root);
cr = gdk_cairo_create (root);
root_surface = cairo_surface_reference (cairo_get_target (cr));
@@ -294,7 +295,8 @@ byzanz_select_screen (ByzanzSelectData *data)
GdkWindow *root;
root = gdk_get_default_root_window ();
- gdk_drawable_get_size (root, &data->area.width, &data->area.height);
+ data->area.width = gdk_window_get_width (root);
+ data->area.height = gdk_window_get_height (root);
byzanz_select_done (data, root);
}
@@ -312,12 +314,13 @@ select_window_button_pressed_cb (GtkWidget *widget, GdkEventButton *event, gpoin
w = screenshot_find_current_window (TRUE);
if (w != None)
- window = gdk_window_foreign_new (w);
+ window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), w);
else
window = gdk_get_default_root_window ();
gdk_window_get_root_origin (window, &data->area.x, &data->area.y);
- gdk_drawable_get_size (window, &data->area.width, &data->area.height);
+ data->area.width = gdk_window_get_width (window);
+ data->area.height = gdk_window_get_height (window);
g_object_unref (window);
window = gdk_get_default_root_window ();
@@ -338,7 +341,7 @@ byzanz_select_window (ByzanzSelectData *data)
g_signal_connect (data->window, "button-press-event",
G_CALLBACK (select_window_button_pressed_cb), data);
gtk_widget_show (data->window);
- gdk_pointer_grab (data->window->window, FALSE, GDK_BUTTON_PRESS_MASK, NULL, cursor, GDK_CURRENT_TIME);
+ gdk_pointer_grab (gtk_widget_get_window (data->window), FALSE, GDK_BUTTON_PRESS_MASK, NULL, cursor, GDK_CURRENT_TIME);
gdk_cursor_unref (cursor);
}
diff --git a/src/byzanzselect.h b/src/byzanzselect.h
index e7f04e2..188fe0e 100644
--- a/src/byzanzselect.h
+++ b/src/byzanzselect.h
@@ -30,7 +30,7 @@ const char * byzanz_select_method_get_icon_name (guint met
const char * byzanz_select_method_get_name (guint method);
int byzanz_select_method_lookup (const char * name);
-typedef void (* ByzanzSelectFunc) (GdkWindow *window, const GdkRectangle *area, gpointer data);
+typedef void (* ByzanzSelectFunc) (GdkWindow *window, const cairo_rectangle_int_t *area, gpointer data);
void byzanz_select_method_select (guint method,
ByzanzSelectFunc func,
gpointer data);
diff --git a/src/byzanzserialize.c b/src/byzanzserialize.c
index ad1232b..308a46a 100644
--- a/src/byzanzserialize.c
+++ b/src/byzanzserialize.c
@@ -106,22 +106,22 @@ byzanz_deserialize_header (GInputStream * stream,
}
gboolean
-byzanz_serialize (GOutputStream * stream,
- guint64 msecs,
- cairo_surface_t * surface,
- const GdkRegion * region,
- GCancellable * cancellable,
- GError ** error)
+byzanz_serialize (GOutputStream * stream,
+ guint64 msecs,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ GCancellable * cancellable,
+ GError ** error)
{
guint i, stride;
- GdkRectangle *rects, extents;
+ cairo_rectangle_int_t rect, extents;
guchar *data;
guint32 n;
int y, n_rects;
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE);
g_return_val_if_fail ((surface == NULL) == (region == NULL), FALSE);
- g_return_val_if_fail (region == NULL || !gdk_region_empty (region), FALSE);
+ g_return_val_if_fail (region == NULL || !cairo_region_is_empty (region), FALSE);
if (!g_output_stream_write_all (stream, &msecs, sizeof (guint64), NULL, cancellable, error))
return FALSE;
@@ -131,51 +131,48 @@ byzanz_serialize (GOutputStream * stream,
return g_output_stream_write_all (stream, &n, sizeof (guint32), NULL, cancellable, error);
}
- gdk_region_get_rectangles (region, &rects, &n_rects);
- n = n_rects;
+ n = n_rects = cairo_region_num_rectangles (region);
if (!g_output_stream_write_all (stream, &n, sizeof (guint32), NULL, cancellable, error))
- goto fail;
+ return FALSE;
for (i = 0; i < n; i++) {
- gint32 ints[4] = { rects[i].x, rects[i].y, rects[i].width, rects[i].height };
+ gint32 ints[4];
+ cairo_region_get_rectangle (region, i, &rect);
+ ints[0] = rect.x, ints[1] = rect.y, ints[2] = rect.width, ints[3] = rect.height;
g_assert (sizeof (ints) == 16);
if (!g_output_stream_write_all (stream, ints, sizeof (ints), NULL, cancellable, error))
- goto fail;
+ return FALSE;
}
stride = cairo_image_surface_get_stride (surface);
- gdk_region_get_clipbox (region, &extents);
+ cairo_region_get_extents (region, &extents);
for (i = 0; i < n; i++) {
+ cairo_region_get_rectangle (region, i, &rect);
data = cairo_image_surface_get_data (surface)
- + stride * (rects[i].y - extents.y)
- + sizeof (guint32) * (rects[i].x - extents.x);
- for (y = 0; y < rects[i].height; y++) {
+ + stride * (rect.y - extents.y)
+ + sizeof (guint32) * (rect.x - extents.x);
+ for (y = 0; y < rect.height; y++) {
if (!g_output_stream_write_all (G_OUTPUT_STREAM (stream), data,
- rects[i].width * sizeof (guint32), NULL, cancellable, error))
- goto fail;
+ rect.width * sizeof (guint32), NULL, cancellable, error))
+ return FALSE;
data += stride;
}
}
- g_free (rects);
return TRUE;
-
-fail:
- g_free (rects);
- return FALSE;
}
gboolean
byzanz_deserialize (GInputStream * stream,
guint64 * msecs_out,
cairo_surface_t ** surface_out,
- GdkRegion ** region_out,
+ cairo_region_t ** region_out,
GCancellable * cancellable,
GError ** error)
{
guint i, stride;
- GdkRectangle extents, *rects;
- GdkRegion *region;
+ cairo_rectangle_int_t extents, *rects;
+ cairo_region_t *region;
cairo_surface_t *surface;
guchar *data;
guint32 n;
@@ -197,8 +194,8 @@ byzanz_deserialize (GInputStream * stream,
return TRUE;
}
- region = gdk_region_new ();
- rects = g_new (GdkRectangle, n);
+ region = cairo_region_create ();
+ rects = g_new (cairo_rectangle_int_t, n);
surface = NULL;
for (i = 0; i < n; i++) {
gint ints[4];
@@ -209,10 +206,10 @@ byzanz_deserialize (GInputStream * stream,
rects[i].y = ints[1];
rects[i].width = ints[2];
rects[i].height = ints[3];
- gdk_region_union_with_rect (region, &rects[i]);
+ cairo_region_union_rectangle (region, &rects[i]);
}
- gdk_region_get_clipbox (region, &extents);
+ cairo_region_get_extents (region, &extents);
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, extents.width, extents.height);
cairo_surface_set_device_offset (surface, -extents.x, -extents.y);
stride = cairo_image_surface_get_stride (surface);
@@ -236,7 +233,7 @@ byzanz_deserialize (GInputStream * stream,
fail:
if (surface)
cairo_surface_destroy (surface);
- gdk_region_destroy (region);
+ cairo_region_destroy (region);
g_free (rects);
return FALSE;
}
diff --git a/src/byzanzserialize.h b/src/byzanzserialize.h
index 8ab5881..6f8f4bf 100644
--- a/src/byzanzserialize.h
+++ b/src/byzanzserialize.h
@@ -30,12 +30,12 @@ gboolean byzanz_serialize_header (GOutputStream *
guint height,
GCancellable * cancellable,
GError ** error);
-gboolean byzanz_serialize (GOutputStream * stream,
- guint64 msecs,
- cairo_surface_t * surface,
- const GdkRegion * region,
- GCancellable * cancellable,
- GError ** error);
+gboolean byzanz_serialize (GOutputStream * stream,
+ guint64 msecs,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ GCancellable * cancellable,
+ GError ** error);
gboolean byzanz_deserialize_header (GInputStream * stream,
guint * width,
@@ -45,7 +45,7 @@ gboolean byzanz_deserialize_header (GInputStream *
gboolean byzanz_deserialize (GInputStream * stream,
guint64 * msecs_out,
cairo_surface_t ** surface_out,
- GdkRegion ** region_out,
+ cairo_region_t ** region_out,
GCancellable * cancellable,
GError ** error);
diff --git a/src/byzanzsession.c b/src/byzanzsession.c
index df36c62..0cd7c67 100644
--- a/src/byzanzsession.c
+++ b/src/byzanzsession.c
@@ -105,7 +105,7 @@ byzanz_session_set_property (GObject *object, guint param_id, const GValue *valu
session->file = g_value_dup_object (value);
break;
case PROP_AREA:
- session->area = *(GdkRectangle *) g_value_get_boxed (value);
+ session->area = *(cairo_rectangle_int_t *) g_value_get_boxed (value);
break;
case PROP_WINDOW:
session->window = g_value_dup_object (value);
@@ -185,11 +185,11 @@ byzanz_session_elapsed (ByzanzSession *session, const GTimeVal *tv)
}
static void
-byzanz_session_recorder_image_cb (ByzanzRecorder * recorder,
- cairo_surface_t * surface,
- const GdkRegion * region,
- const GTimeVal * tv,
- ByzanzSession * session)
+byzanz_session_recorder_image_cb (ByzanzRecorder * recorder,
+ cairo_surface_t * surface,
+ const cairo_region_t * region,
+ const GTimeVal * tv,
+ ByzanzSession * session)
{
GOutputStream *stream;
GError *error = NULL;
@@ -328,7 +328,7 @@ byzanz_session_init (ByzanzSession *session)
**/
ByzanzSession *
byzanz_session_new (GFile *file, GType encoder_type,
- GdkWindow *window, const GdkRectangle *area, gboolean record_cursor,
+ GdkWindow *window, const cairo_rectangle_int_t *area, gboolean record_cursor,
gboolean record_audio)
{
g_return_val_if_fail (G_IS_FILE (file), NULL);
diff --git a/src/byzanzsession.h b/src/byzanzsession.h
index ed6c32d..7362da6 100644
--- a/src/byzanzsession.h
+++ b/src/byzanzsession.h
@@ -43,7 +43,7 @@ struct _ByzanzSession {
/*< private >*/
/* properties */
GFile * file; /* file we're saving to */
- GdkRectangle area; /* area of window to record */
+ cairo_rectangle_int_t area; /* area of window to record */
GdkWindow * window; /* window to record */
gboolean record_audio; /* TRUE to record audio */
GType encoder_type; /* type of encoder to use */
@@ -64,12 +64,12 @@ struct _ByzanzSessionClass {
GType byzanz_session_get_type (void) G_GNUC_CONST;
-ByzanzSession * byzanz_session_new (GFile * file,
- GType encoder_type,
- GdkWindow * window,
- const GdkRectangle * area,
- gboolean record_cursor,
- gboolean record_audio);
+ByzanzSession * byzanz_session_new (GFile * file,
+ GType encoder_type,
+ GdkWindow * window,
+ const cairo_rectangle_int_t * area,
+ gboolean record_cursor,
+ gboolean record_audio);
void byzanz_session_start (ByzanzSession * session);
void byzanz_session_stop (ByzanzSession * session);
void byzanz_session_abort (ByzanzSession * session);
diff --git a/src/paneltogglebutton.c b/src/paneltogglebutton.c
index 245f0d8..2a76e28 100644
--- a/src/paneltogglebutton.c
+++ b/src/paneltogglebutton.c
@@ -32,7 +32,7 @@ panel_toggle_button_size_request (GtkWidget *widget,
{
GtkWidget *child;
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child) {
gtk_widget_size_request (child, requisition);
@@ -42,53 +42,77 @@ panel_toggle_button_size_request (GtkWidget *widget,
}
static void
+panel_toggle_button_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ GtkRequisition requisition;
+
+ panel_toggle_button_size_request (widget, &requisition);
+
+ *minimal_width = *natural_width = requisition.width;
+}
+
+static void
+panel_toggle_button_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ GtkRequisition requisition;
+
+ panel_toggle_button_size_request (widget, &requisition);
+
+ *minimal_height = *natural_height = requisition.height;
+}
+
+static void
panel_toggle_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWidget *child;
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (GTK_BUTTON (widget)->event_window,
- widget->allocation.x, widget->allocation.y,
- widget->allocation.width, widget->allocation.height);
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (gtk_button_get_event_window (GTK_BUTTON(widget)),
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
if (child)
gtk_widget_size_allocate (child, allocation);
}
static gboolean
-panel_toggle_button_expose (GtkWidget *widget, GdkEventExpose *event)
+panel_toggle_button_draw (GtkWidget *widget, cairo_t *cr)
{
- if (GTK_WIDGET_DRAWABLE (widget)) {
- GtkWidget *child = GTK_BIN (widget)->child;
- GtkStateType state_type;
- GtkShadowType shadow_type;
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
+ GtkStateType state_type;
+ GtkShadowType shadow_type;
+ GtkAllocation allocation;
- state_type = GTK_WIDGET_STATE (widget);
+ state_type = gtk_widget_get_state (widget);
- /* FIXME: someone make this layout work nicely for all themes
- * Currently I'm trying to imitate the volume applet's widget */
- if (GTK_TOGGLE_BUTTON (widget)->inconsistent) {
- if (state_type == GTK_STATE_ACTIVE)
- state_type = GTK_STATE_NORMAL;
- shadow_type = GTK_SHADOW_ETCHED_IN;
- } else {
- shadow_type = GTK_BUTTON (widget)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- }
- if (GTK_BUTTON (widget)->depressed)
- state_type = GTK_STATE_SELECTED;
- /* FIXME: better detail? */
- gtk_paint_flat_box (widget->style, widget->window, state_type, shadow_type,
- &event->area, widget, "togglebutton", widget->allocation.x,
- widget->allocation.y, widget->allocation.width, widget->allocation.height);
-
- if (child)
- gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event);
+ /* FIXME: someone make this layout work nicely for all themes
+ * Currently I'm trying to imitate the volume applet's widget */
+ if (gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (widget))) {
+ if (state_type == GTK_STATE_ACTIVE)
+ state_type = GTK_STATE_NORMAL;
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ } else {
+ shadow_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
}
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ state_type = GTK_STATE_SELECTED;
+ /* FIXME: better detail? */
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_paint_flat_box (gtk_widget_get_style (widget), cr, state_type, shadow_type,
+ widget, "togglebutton", allocation.x,
+ allocation.y, allocation.width, allocation.height);
+
+ if (child)
+ gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
return FALSE;
}
@@ -118,9 +142,10 @@ panel_toggle_button_class_init (PanelToggleButtonClass *class)
parent_class = g_type_class_peek_parent (class);
- widget_class->size_request = panel_toggle_button_size_request;
+ widget_class->get_preferred_width = panel_toggle_button_get_preferred_width;
+ widget_class->get_preferred_height = panel_toggle_button_get_preferred_height;
widget_class->size_allocate = panel_toggle_button_size_allocate;
- widget_class->expose_event = panel_toggle_button_expose;
+ widget_class->draw = panel_toggle_button_draw;
widget_class->button_press_event = panel_toggle_button_button_press;
widget_class->button_release_event = panel_toggle_button_button_release;
}
diff --git a/src/paneltogglebutton.h b/src/paneltogglebutton.h
index fb5bdbd..35f85b4 100644
--- a/src/paneltogglebutton.h
+++ b/src/paneltogglebutton.h
@@ -22,7 +22,7 @@
#ifndef __PANEL_TOGGLE_BUTTON_H__
#define __PANEL_TOGGLE_BUTTON_H__
-#include <gtk/gtktogglebutton.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS
diff --git a/src/record.c b/src/record.c
index fa29397..e0871c8 100644
--- a/src/record.c
+++ b/src/record.c
@@ -30,7 +30,7 @@ static int delay = 1;
static gboolean cursor = FALSE;
static gboolean audio = FALSE;
static gboolean verbose = FALSE;
-static GdkRectangle area = { 0, 0, G_MAXINT / 2, G_MAXINT / 2 };
+static cairo_rectangle_int_t area = { 0, 0, G_MAXINT / 2, G_MAXINT / 2 };
static GOptionEntry entries[] =
{
@@ -105,12 +105,15 @@ start_recording (gpointer session)
}
static gboolean
-clamp_to_window (GdkRectangle *out, GdkWindow *window, GdkRectangle *in)
+clamp_to_window (cairo_rectangle_int_t *out, GdkWindow *window, cairo_rectangle_int_t *in)
{
- GdkRectangle window_area = { 0, };
+ cairo_rectangle_int_t window_area = { 0, };
- gdk_drawable_get_size (GDK_DRAWABLE (window), &window_area.width, &window_area.height);
- return gdk_rectangle_intersect (in, &window_area, in);
+ window_area.width = gdk_window_get_width (window);
+ window_area.height = gdk_window_get_height (window);
+ return gdk_rectangle_intersect ((GdkRectangle *) in,
+ (GdkRectangle *) &window_area,
+ (GdkRectangle *) in);
}
int
diff --git a/src/screenshot-utils.c b/src/screenshot-utils.c
index bd29061..5f02849 100644
--- a/src/screenshot-utils.c
+++ b/src/screenshot-utils.c
@@ -23,7 +23,7 @@ get_atom_property (Window xwindow,
gdk_error_trap_push ();
type = None;
- result = XGetWindowProperty (gdk_display,
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
xwindow,
atom,
0, G_MAXLONG,
@@ -56,7 +56,7 @@ find_toplevel_window (Window xid)
do
{
- if (XQueryTree (GDK_DISPLAY (), xid, &root,
+ if (XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xid, &root,
&parent, &children, &nchildren) == 0)
{
g_warning ("Couldn't find window manager window");
@@ -79,7 +79,8 @@ screenshot_window_is_desktop (Window xid)
if (xid == root_window)
return TRUE;
- if (gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE)))
+ if (gdk_x11_screen_supports_net_wm_hint (gdk_screen_get_default (),
+ gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE)))
{
gboolean retval;
Atom property;
@@ -106,7 +107,7 @@ screenshot_find_pointer_window (void)
root_window = GDK_ROOT_WINDOW ();
- XQueryPointer (GDK_DISPLAY (), root_window,
+ XQueryPointer (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), root_window,
&root_return, &child, &unused,
&unused, &unused, &unused, &mask);
@@ -128,7 +129,8 @@ look_for_hint_helper (Window xid,
Window root, parent, *children, window;
guint nchildren, i;
- if (XGetWindowProperty (GDK_DISPLAY (), xid, property, 0, 1,
+ if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ xid, property, 0, 1,
False, AnyPropertyType, &actual_type,
&actual_format, &nitems, &bytes_after,
(gpointer) &prop) == Success
@@ -144,7 +146,7 @@ look_for_hint_helper (Window xid,
if (depth < MAXIMUM_WM_REPARENTING_DEPTH)
{
- if (XQueryTree (GDK_DISPLAY (), xid, &root,
+ if (XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xid, &root,
&parent, &children, &nchildren) != 0)
{
window = None;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]