summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/display.c82
-rw-r--r--src/ui/fixedtip.c15
-rw-r--r--src/ui/frames.c65
-rw-r--r--src/ui/frames.h13
-rw-r--r--src/ui/preview-widget.c168
-rw-r--r--src/ui/theme.c33
-rw-r--r--src/ui/theme.h8
-rw-r--r--src/ui/ui.c54
8 files changed, 332 insertions, 106 deletions
diff --git a/src/core/display.c b/src/core/display.c
index d950e7ea..2fdf6bfd 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1429,7 +1429,7 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
{
/* We're always using the default display */
GdkDisplay* gdk_display = gdk_display_get_default();
- GdkEvent gdk_event;
+ GdkEvent* gdk_event = NULL;
GdkWindow* gdk_window;
Window window;
@@ -1475,7 +1475,10 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
return FALSE;
}
- memset(&gdk_event, 0, sizeof(gdk_event));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDeviceManager *device_manager = gdk_display_get_device_manager (gdk_display);
+ GdkDevice *device = gdk_device_manager_get_client_pointer (device_manager);
+#endif
switch (xevent->type)
{
@@ -1502,13 +1505,12 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
ABS(xevent->xbutton.x - display->button_click_x) <= double_click_distance &&
ABS (xevent->xbutton.y - display->button_click_y) <= double_click_distance)
{
-
- gdk_event.button.type = GDK_2BUTTON_PRESS;
+ gdk_event = gdk_event_new(GDK_2BUTTON_PRESS);
display->button_click_number = 0;
}
else
{
- gdk_event.button.type = GDK_BUTTON_PRESS;
+ gdk_event = gdk_event_new(GDK_BUTTON_PRESS);
display->button_click_number = xevent->xbutton.button;
display->button_click_window = xevent->xbutton.window;
display->button_click_time = xevent->xbutton.time;
@@ -1518,40 +1520,80 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
}
else
{
- gdk_event.button.type = GDK_BUTTON_RELEASE;
+ gdk_event = gdk_event_new(GDK_BUTTON_RELEASE);
}
- gdk_event.button.window = gdk_window;
- gdk_event.button.button = xevent->xbutton.button;
- gdk_event.button.time = xevent->xbutton.time;
- gdk_event.button.x = xevent->xbutton.x;
- gdk_event.button.y = xevent->xbutton.y;
- gdk_event.button.x_root = xevent->xbutton.x_root;
- gdk_event.button.y_root = xevent->xbutton.y_root;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_event->button.window = g_object_ref(gdk_window);
+#else
+ gdk_event->button.window = gdk_window;
+#endif
+ gdk_event->button.send_event = 0;
+ gdk_event->button.axes = NULL;
+ gdk_event->button.state = 0;
+ gdk_event->button.device = NULL;
+ gdk_event->button.button = xevent->xbutton.button;
+ gdk_event->button.time = xevent->xbutton.time;
+ gdk_event->button.x = xevent->xbutton.x;
+ gdk_event->button.y = xevent->xbutton.y;
+ gdk_event->button.x_root = xevent->xbutton.x_root;
+ gdk_event->button.y_root = xevent->xbutton.y_root;
break;
case MotionNotify:
- gdk_event.motion.type = GDK_MOTION_NOTIFY;
- gdk_event.motion.window = gdk_window;
+ gdk_event = gdk_event_new(GDK_MOTION_NOTIFY);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_event->motion.window = g_object_ref(gdk_window);
+#else
+ gdk_event->motion.window = gdk_window;
+#endif
+ gdk_event->motion.send_event = FALSE;
+ gdk_event->motion.time = 0;
+ gdk_event->motion.x = 0;
+ gdk_event->motion.y = 0;
+ gdk_event->motion.axes = NULL;
+ gdk_event->motion.state = 0;
+ gdk_event->motion.is_hint = 0;
+ gdk_event->motion.device = NULL;
+ gdk_event->motion.x_root = 0;
+ gdk_event->motion.y_root = 0;
break;
case EnterNotify:
case LeaveNotify:
- gdk_event.crossing.type = xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
- gdk_event.crossing.window = gdk_window;
- gdk_event.crossing.x = xevent->xcrossing.x;
- gdk_event.crossing.y = xevent->xcrossing.y;
+ gdk_event = gdk_event_new(xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_event->crossing.window = g_object_ref(gdk_window);
+#else
+ gdk_event->crossing.window = gdk_window;
+#endif
+ gdk_event->crossing.send_event = 0;
+ gdk_event->crossing.subwindow = NULL;
+ gdk_event->crossing.time = 0;
+ gdk_event->crossing.x = xevent->xcrossing.x;
+ gdk_event->crossing.y = xevent->xcrossing.y;
+ gdk_event->crossing.x_root = 0;
+ gdk_event->crossing.y_root = 0;
+ gdk_event->crossing.mode = 0;
+ gdk_event->crossing.detail = 0;
+ gdk_event->crossing.focus = FALSE;
+ gdk_event->crossing.state = 0;
break;
default:
g_assert_not_reached();
break;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_event_set_device (gdk_event, device);
+#endif
/* If we've gotten here, we've filled in the gdk_event and should send it on */
- gtk_main_do_event(&gdk_event);
+ gtk_main_do_event(gdk_event);
+
+ gdk_event_free(gdk_event);
return TRUE;
}
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index 3d9aea06..b06c9708 100644
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
@@ -52,16 +52,19 @@ static int screen_bottom_edge = 0;
#if GTK_CHECK_VERSION(3, 0, 0)
-static gboolean
+static gint
draw_handler (GtkWidget *tooltips,
cairo_t *cr,
gpointer user_data)
{
- gtk_render_background (gtk_widget_get_style_context (tooltips),
- cr,
- 0, 0,
- gtk_widget_get_allocated_width (tooltips),
- gtk_widget_get_allocated_height (tooltips));
+ if (tooltips != NULL)
+ {
+ gtk_render_background (gtk_widget_get_style_context (tooltips),
+ cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (tooltips),
+ gtk_widget_get_allocated_height (tooltips));
+ }
return FALSE;
}
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 5c19bd4c..9d4fd68d 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -41,19 +41,12 @@
#if GTK_CHECK_VERSION(3, 0, 0)
#include <cairo-xlib.h>
- #define GtkObject GtkWidget
- #define GTK_OBJECT_CLASS GTK_WIDGET_CLASS
#define GdkRegion cairo_region_t
- #define GdkRegion cairo_region_t
- #define gdk_region_new cairo_region_create
- #define gdk_region_subtract cairo_region_subtract
#define gdk_region_destroy cairo_region_destroy
- #define gdk_region_union_with_rect cairo_region_union_rectangle
#define gdk_region_rectangle cairo_region_create_rectangle
#define gdk_region_offset cairo_region_translate
#define gdk_region_intersect cairo_region_intersect
- #define gdk_region_copy cairo_region_copy
- G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_WINDOW);
+ G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_INVISIBLE);
#define parent_class meta_frames_parent_class
#define GTK_WIDGET_REALIZED gtk_widget_get_realized
#endif
@@ -62,7 +55,11 @@
static void meta_frames_class_init (MetaFramesClass *klass);
static void meta_frames_init (MetaFrames *frames);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void meta_frames_destroy (GtkWidget *object);
+#else
static void meta_frames_destroy (GtkObject *object);
+#endif
static void meta_frames_finalize (GObject *object);
static void meta_frames_style_set (GtkWidget *widget,
GtkStyle *prev_style);
@@ -134,27 +131,7 @@ static void invalidate_all_caches (MetaFrames *frames);
static void invalidate_whole_window (MetaFrames *frames,
MetaUIFrame *frame);
-#if GTK_CHECK_VERSION(3, 0, 0)
-
-static GObject *
-meta_frames_constructor (GType gtype,
- guint n_properties,
- GObjectConstructParam *properties)
-{
- GObject *object;
- GObjectClass *gobject_class;
-
- gobject_class = G_OBJECT_CLASS (meta_frames_parent_class);
- object = gobject_class->constructor (gtype, n_properties, properties);
-
- g_object_set (object,
- "type", GTK_WINDOW_POPUP,
- NULL);
-
- return object;
-}
-
-#else
+#if !GTK_CHECK_VERSION(3, 0, 0)
static GtkWidgetClass *parent_class = NULL;
@@ -200,11 +177,15 @@ meta_frames_class_init (MetaFramesClass *class)
#endif
widget_class = (GtkWidgetClass*) class;
+#if !GTK_CHECK_VERSION (3, 0, 0)
parent_class = g_type_class_peek_parent (class);
+#endif
gobject_class->finalize = meta_frames_finalize;
#if !GTK_CHECK_VERSION(3, 0, 0)
object_class->destroy = meta_frames_destroy;
+ #else
+ widget_class->destroy = meta_frames_destroy;
#endif
widget_class->style_set = meta_frames_style_set;
@@ -295,8 +276,13 @@ listify_func (gpointer key, gpointer value, gpointer data)
*listp = g_slist_prepend (*listp, value);
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void
+meta_frames_destroy (GtkWidget *object)
+#else
static void
meta_frames_destroy (GtkObject *object)
+#endif
{
GSList *winlist;
GSList *tmp;
@@ -320,7 +306,11 @@ meta_frames_destroy (GtkObject *object)
}
g_slist_free (winlist);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GTK_WIDGET_CLASS (parent_class)->destroy (object);
+#else
GTK_OBJECT_CLASS (parent_class)->destroy (object);
+#endif
}
static void
@@ -663,16 +653,19 @@ meta_frames_attach_style (MetaFrames *frames,
MetaUIFrame *frame)
{
if (frame->style != NULL)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ g_object_unref (frame->style);
+#else
gtk_style_detach (frame->style);
+#endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ frame->style = g_object_ref (gtk_widget_get_style_context (GTK_WIDGET (frames)));
+#else
/* Weirdly, gtk_style_attach() steals a reference count from the style passed in */
- #if GTK_CHECK_VERSION(3, 0, 0)
- g_object_ref (gtk_widget_get_style (GTK_WIDGET (frames)));
- frame->style = gtk_style_attach (gtk_widget_get_style (GTK_WIDGET (frames)), frame->window);
- #else
g_object_ref (GTK_WIDGET (frames)->style);
frame->style = gtk_style_attach (GTK_WIDGET (frames)->style, frame->window);
- #endif
+#endif
}
void
@@ -2926,8 +2919,12 @@ meta_frames_set_window_background (MetaFrames *frames,
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_style_context_set_background (frame->style, frame->window);
+#else
gtk_style_set_background (frame->style,
frame->window, GTK_STATE_NORMAL);
+#endif
}
}
diff --git a/src/ui/frames.h b/src/ui/frames.h
index b1d178ad..8ada07ca 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -75,7 +75,11 @@ struct _MetaUIFrame
{
Window xwindow;
GdkWindow *window;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style;
+#else
GtkStyle *style;
+#endif
MetaFrameStyle *cache_style;
PangoLayout *layout;
int text_height;
@@ -89,7 +93,11 @@ struct _MetaUIFrame
struct _MetaFrames
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkInvisible parent_instance;
+#else
GtkWindow parent_instance;
+#endif
GHashTable *text_heights;
@@ -107,8 +115,11 @@ struct _MetaFrames
struct _MetaFramesClass
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkInvisibleClass parent_class;
+#else
GtkWindowClass parent_class;
-
+#endif
};
GType meta_frames_get_type (void) G_GNUC_CONST;
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index cb05c2f8..9e592cdc 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -37,10 +37,10 @@ static void meta_preview_get_preferred_width(GtkWidget *widget,
gint *minimal, gint *natural);
static void meta_preview_get_preferred_height(GtkWidget *widget,
gint *minimal, gint *natural);
-#endif
-
+#else
static void meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req);
+#endif
static void meta_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
#if GTK_CHECK_VERSION(3, 0, 0)
@@ -52,6 +52,8 @@ static gboolean meta_preview_expose (GtkWidget *widget,
#endif
static void meta_preview_finalize (GObject *object);
+#define NO_CHILD_WIDTH 80
+#define NO_CHILD_HEIGHT 20
#if GTK_CHECK_VERSION(3, 0, 0)
@@ -110,6 +112,10 @@ meta_preview_class_init (MetaPreviewClass *class)
widget_class->size_request = meta_preview_size_request;
#endif
widget_class->size_allocate = meta_preview_size_allocate;
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (class));
+#endif
}
static void
@@ -247,53 +253,118 @@ ensure_info (MetaPreview *preview)
}
#if GTK_CHECK_VERSION(3, 0, 0)
-static void meta_preview_get_preferred_width(GtkWidget *widget, gint *minimal, gint *natural)
+static void
+meta_preview_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
- GtkRequisition requisition;
- meta_preview_size_request (widget, &requisition);
- *minimal = *natural = requisition.width;
+ MetaPreview *preview;
+ int border_width;
+ GtkWidget *child;
+
+ preview = META_PREVIEW (widget);
+
+ ensure_info (preview);
+
+ *minimum = *natural = preview->left_width + preview->right_width;
+
+ child = gtk_bin_get_child (GTK_BIN (preview));
+ if (child && gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+
+ *minimum += child_min;
+ *natural += child_nat;
+ }
+ else
+ {
+ *minimum += NO_CHILD_WIDTH;
+ *natural += NO_CHILD_WIDTH;
+ }
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ *minimum += border_width * 2;
+ *natural += border_width * 2;
}
-static void meta_preview_get_preferred_height(GtkWidget *widget, gint *minimal, gint *natural)
+static void
+meta_preview_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
{
- GtkRequisition requisition;
- meta_preview_size_request (widget, &requisition);
- *minimal = *natural = requisition.height;
-}
+ MetaPreview *preview;
+ int border_width;
+ GtkWidget *child;
+
+ preview = META_PREVIEW (widget);
+ ensure_info (preview);
+
+ *minimum = *natural = preview->top_height + preview->bottom_height;
+
+ child = gtk_bin_get_child (GTK_BIN (preview));
+ if (child && gtk_widget_get_visible (child))
+ {
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+ *minimum += child_min;
+ *natural += child_nat;
+ }
+ else
+ {
+ *minimum += NO_CHILD_HEIGHT;
+ *natural += NO_CHILD_HEIGHT;
+ }
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ *minimum += border_width * 2;
+ *natural += border_width * 2;
+}
static gboolean
meta_preview_draw(GtkWidget *widget,
cairo_t *cr)
{
- MetaPreview *preview = META_PREVIEW (widget);
+ MetaPreview *preview;
GtkAllocation allocation;
+ int border_width;
+ int client_width;
+ int client_height;
+ MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
+ {
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL,
+ META_BUTTON_STATE_NORMAL
+ };
+
+ g_return_val_if_fail (META_IS_PREVIEW (widget), FALSE);
+ preview = META_PREVIEW (widget);
+
+ ensure_info (preview);
+
+ cairo_save (cr);
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
gtk_widget_get_allocation (widget, &allocation);
+ client_width = allocation.width - preview->left_width - preview->right_width - border_width * 2;
+ client_height = allocation.height - preview->top_height - preview->bottom_height - border_width * 2;
+ if (client_width < 0)
+ client_width = 1;
+ if (client_height < 0)
+ client_height = 1;
+
if (preview->theme)
{
- int client_width;
- int client_height;
- MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
- {
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL,
- META_BUTTON_STATE_NORMAL
- };
-
- ensure_info (preview);
- cairo_save (cr);
-
- client_width = allocation.width - preview->left_width - preview->right_width;
- client_height = allocation.height - preview->top_height - preview->bottom_height;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- if (client_width < 0)
- client_width = 1;
- if (client_height < 0)
- client_height = 1;
-
meta_theme_draw_frame (preview->theme,
widget,
cr,
@@ -306,11 +377,12 @@ meta_preview_draw(GtkWidget *widget,
button_states,
meta_preview_get_mini_icon (),
meta_preview_get_icon ());
-
- cairo_restore (cr);
}
- return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+ cairo_restore (cr);
+
+ /* draw child */
+ return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
}
#else
@@ -377,6 +449,7 @@ meta_preview_expose (GtkWidget *widget,
#endif
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req)
@@ -405,8 +478,6 @@ meta_preview_size_request (GtkWidget *widget,
}
else
{
-#define NO_CHILD_WIDTH 80
-#define NO_CHILD_HEIGHT 20
req->width += NO_CHILD_WIDTH;
req->height += NO_CHILD_HEIGHT;
}
@@ -415,6 +486,7 @@ meta_preview_size_request (GtkWidget *widget,
req->width += border_width * 2;
req->height += border_width * 2;
}
+#endif
static void
meta_preview_size_allocate (GtkWidget *widget,
@@ -422,16 +494,22 @@ meta_preview_size_allocate (GtkWidget *widget,
{
MetaPreview *preview;
int border_width;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkAllocation widget_allocation, child_allocation;
+#else
GtkAllocation child_allocation;
+#endif
GtkWidget *child;
preview = META_PREVIEW (widget);
ensure_info (preview);
- #if !GTK_CHECK_VERSION(3, 0, 0)
+#if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_set_allocation (widget, allocation);
+#else
widget->allocation = *allocation;
- #endif
+#endif
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -439,12 +517,20 @@ meta_preview_size_allocate (GtkWidget *widget,
if (child &&
gtk_widget_get_visible (child))
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ child_allocation.x = widget_allocation.x + border_width + preview->left_width;
+ child_allocation.y = widget_allocation.y + border_width + preview->top_height;
+
+ child_allocation.width = MAX (1, widget_allocation.width - border_width * 2 - preview->left_width - preview->right_width);
+ child_allocation.height = MAX (1, widget_allocation.height - border_width * 2 - preview->top_height - preview->bottom_height);
+#else
child_allocation.x = allocation->x + border_width + preview->left_width;
child_allocation.y = allocation->y + border_width + preview->top_height;
child_allocation.width = MAX (1, allocation->width - border_width * 2 - preview->left_width - preview->right_width);
child_allocation.height = MAX (1, allocation->height - border_width * 2 - preview->top_height - preview->bottom_height);
-
+#endif
gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), &child_allocation);
}
}
@@ -704,4 +790,4 @@ meta_preview_get_clip_region (MetaPreview *preview, gint new_window_width, gint
gdk_region_destroy (corners_xregion);
return window_xregion;
-} \ No newline at end of file
+}
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 4d430b7c..be948369 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3425,7 +3425,11 @@ state_flags_from_gtk_state (GtkStateType state)
*/
static void
meta_draw_op_draw_with_env (const MetaDrawOp *op,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
+ #else
GtkStyle *style_gtk,
+ #endif
GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
@@ -3990,7 +3994,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
break;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_restore (cr);
+ gtk_style_context_restore (style_gtk);
+#else
cairo_destroy (cr);
+#endif
}
void
@@ -4532,7 +4541,11 @@ button_rect (MetaButtonType type,
void
meta_frame_style_draw_with_style (MetaFrameStyle *style,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
+ #else
GtkStyle *style_gtk,
+ #endif
GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
@@ -4908,7 +4921,13 @@ meta_frame_style_draw (MetaFrameStyle *style,
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
- meta_frame_style_draw_with_style (style, gtk_widget_get_style (widget), widget,
+ meta_frame_style_draw_with_style (style,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_get_style_context (widget),
+ #else
+ gtk_widget_get_style (widget),
+ #endif
+ widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cr,
#else
@@ -5467,7 +5486,11 @@ meta_theme_get_title_scale (MetaTheme *theme,
void
meta_theme_draw_frame_with_style (MetaTheme *theme,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
+ #else
GtkStyle *style_gtk,
+ #endif
GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
@@ -5545,7 +5568,13 @@ meta_theme_draw_frame (MetaTheme *theme,
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
- meta_theme_draw_frame_with_style (theme, gtk_widget_get_style (widget), widget,
+ meta_theme_draw_frame_with_style (theme,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_get_style_context (widget),
+ #else
+ gtk_widget_get_style (widget),
+ #endif
+ widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cr,
#else
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 30cf7ade..cfa3bde4 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -990,7 +990,11 @@ void meta_frame_style_draw (MetaFrameStyle *style,
void meta_frame_style_draw_with_style (MetaFrameStyle *style,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
+ #else
GtkStyle *style_gtk,
+ #endif
GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
@@ -1085,7 +1089,11 @@ void meta_theme_draw_frame_by_name (MetaTheme *theme,
GdkPixbuf *icon);
void meta_theme_draw_frame_with_style (MetaTheme *theme,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext *style_gtk,
+ #else
GtkStyle *style_gtk,
+ #endif
GtkWidget *widget,
#if GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index c170adb8..02c88c1c 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -52,6 +52,16 @@ struct _MetaUI {
void meta_ui_init(int* argc, char*** argv)
{
+ /* As of 2.91.7, Gdk uses XI2 by default, which conflicts with the
+ * direct X calls we use - in particular, events caused by calls to
+ * XGrabPointer/XGrabKeyboard are no longer understood by GDK, while
+ * GDK will no longer generate the core XEvents we process.
+ * So at least for now, enforce the previous behavior.
+ */
+#if GTK_CHECK_VERSION(2, 91, 7)
+ gdk_disable_multidevice ();
+#endif
+
if (!gtk_init_check (argc, argv))
{
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
@@ -313,7 +323,14 @@ meta_ui_new (Display *xdisplay,
g_assert (xdisplay == GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ /* This does not actually show any widget. MetaFrames has been hacked so
+ * that showing it doesn't actually do anything. But we need the flags
+ * set for GTK to deliver events properly. */
+ gtk_widget_show (GTK_WIDGET (ui->frames));
+#else
gtk_widget_realize (GTK_WIDGET (ui->frames));
+#endif
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
@@ -901,7 +918,10 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
GdkWindow *window;
#if GTK_CHECK_VERSION (3, 0, 0)
- window = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xwindow);
+ GdkDisplay *display;
+
+ display = gdk_x11_lookup_xdisplay (xdisplay);
+ window = gdk_x11_window_lookup_for_display (display, xwindow);
#else
window = gdk_xid_table_lookup (xwindow);
#endif
@@ -967,6 +987,10 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
int *right_width)
{
int text_height;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *style = NULL;
+ PangoFontDescription *free_font_desc = NULL;
+#endif
PangoContext *context;
const PangoFontDescription *font_desc;
GtkStyle *default_style;
@@ -978,8 +1002,24 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
if (!font_desc)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
+ GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
+ GtkWidgetPath *widget_path;
+
+ style = gtk_style_context_new ();
+ gtk_style_context_set_screen (style, screen);
+ widget_path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
+ gtk_style_context_set_path (style, widget_path);
+ gtk_widget_path_free (widget_path);
+
+ gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
+ font_desc = (const PangoFontDescription *) free_font_desc;
+#else
default_style = gtk_widget_get_default_style ();
font_desc = default_style->font_desc;
+#endif
}
text_height = meta_pango_font_desc_get_text_height (font_desc, context);
@@ -988,11 +1028,21 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
type, text_height, flags,
top_height, bottom_height,
left_width, right_width);
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (free_font_desc)
+ pango_font_description_free (free_font_desc);
+#endif
}
else
{
*top_height = *bottom_height = *left_width = *right_width = 0;
}
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (style != NULL)
+ g_object_unref (style);
+#endif
}
void
@@ -1171,7 +1221,7 @@ meta_ui_window_is_widget (MetaUI *ui,
#if GTK_CHECK_VERSION (3, 0, 0)
GdkDisplay *display;
-
+ display = gdk_x11_lookup_xdisplay (ui->xdisplay);
window = gdk_x11_window_lookup_for_display (display, xwindow);
#else
window = gdk_xid_table_lookup (xwindow);