summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/display.c4
-rw-r--r--src/core/errors.c37
-rw-r--r--src/core/screen.c13
-rw-r--r--src/include/ui.h16
-rw-r--r--src/ui/frames.c29
-rw-r--r--src/ui/testgradient.c127
-rw-r--r--src/ui/theme.c30
-rw-r--r--src/ui/ui.c184
8 files changed, 373 insertions, 67 deletions
diff --git a/src/core/display.c b/src/core/display.c
index 584ca098..d950e7ea 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1454,7 +1454,11 @@ static gboolean maybe_send_event_to_gtk(MetaDisplay* display, XEvent* xevent)
return FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window = gdk_x11_window_lookup_for_display(gdk_display, window);
+#else
gdk_window = gdk_window_lookup_for_display(gdk_display, window);
+#endif
if (gdk_window == NULL)
{
diff --git a/src/core/errors.c b/src/core/errors.c
index c603ccfd..fc89e096 100644
--- a/src/core/errors.c
+++ b/src/core/errors.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <stdlib.h>
#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#ifdef __GNUC__
#define UNUSED_VARIABLE __attribute__ ((unused))
@@ -35,17 +36,51 @@
#define UNUSED_VARIABLE
#endif
+#if !GTK_CHECK_VERSION (3, 0, 0)
static int x_error_handler (Display *display,
XErrorEvent *error);
static int x_io_error_handler (Display *display);
+#endif
void
meta_errors_init (void)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
XSetErrorHandler (x_error_handler);
XSetIOErrorHandler (x_io_error_handler);
+#endif
+}
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+
+void
+meta_error_trap_push (MetaDisplay *display)
+{
+ gdk_error_trap_push ();
+}
+
+void
+meta_error_trap_pop (MetaDisplay *display,
+ gboolean last_request_was_roundtrip)
+{
+ gdk_error_trap_pop_ignored ();
}
+void
+meta_error_trap_push_with_return (MetaDisplay *display)
+{
+ gdk_error_trap_push ();
+}
+
+int
+meta_error_trap_pop_with_return (MetaDisplay *display,
+ gboolean last_request_was_roundtrip)
+{
+ return gdk_error_trap_pop ();
+}
+
+#else
+
typedef struct ForeignDisplay ForeignDisplay;
struct ForeignDisplay
@@ -292,3 +327,5 @@ x_io_error_handler (Display *xdisplay)
return 0;
}
+
+#endif
diff --git a/src/core/screen.c b/src/core/screen.c
index eefe58f2..f52f382c 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1206,6 +1206,7 @@ meta_screen_update_cursor (MetaScreen *screen)
XFreeCursor (screen->display->xdisplay, xcursor);
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
#define MAX_PREVIEW_SIZE 150.0
static GdkPixbuf *
@@ -1248,7 +1249,8 @@ get_window_pixbuf (MetaWindow *window,
g_object_unref (pixbuf);
return scaled;
}
-
+#endif
+
void
meta_screen_ensure_tab_popup (MetaScreen *screen,
MetaTabList list_type,
@@ -1281,14 +1283,17 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
{
MetaWindow *window;
MetaRectangle r;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf *win_pixbuf = NULL;
int width = 0, height = 0;
+#endif
window = tmp->data;
entries[i].key = (MetaTabEntryKey) window->xwindow;
entries[i].title = window->title;
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Only get the pixbuf if the user does NOT have
compositing-fast-alt-tab-set to true
in GSettings. There is an obvious lag when the pixbuf is
@@ -1321,7 +1326,11 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
t_width - icon_width, t_height - icon_height,
1.0, 1.0, GDK_INTERP_BILINEAR, 255);
}
-
+#else
+ /* at the moment, thumbnails are disabled for GTK3 */
+ entries[i].icon = g_object_ref (window->icon);
+#endif
+
entries[i].blank = FALSE;
entries[i].hidden = !meta_window_showing_on_its_workspace (window);
entries[i].demands_attention = window->wm_state_demands_attention;
diff --git a/src/include/ui.h b/src/include/ui.h
index 23525193..2301f4c7 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -29,6 +29,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <glib.h>
+#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
/* This is between GTK_PRIORITY_RESIZE (+10) and GDK_PRIORITY_REDRAW (+20) */
@@ -133,7 +134,7 @@ void meta_ui_window_menu_popup (MetaWindowMenu *menu,
guint32 timestamp);
void meta_ui_window_menu_free (MetaWindowMenu *menu);
-
+#if !GTK_CHECK_VERSION (3, 0, 0)
MetaImageWindow* meta_image_window_new (Display *xdisplay,
int screen_number,
int max_width,
@@ -145,16 +146,7 @@ void meta_image_window_set (MetaImageWindow *iw,
GdkPixbuf *pixbuf,
int x,
int y);
-
-/* FIXME these lack a display arg */
-GdkPixbuf* meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
- Window xwindow,
- int src_x,
- int src_y,
- int dest_x,
- int dest_y,
- int width,
- int height);
+#endif
GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
Pixmap xpixmap,
@@ -202,7 +194,9 @@ int meta_ui_get_drag_threshold (MetaUI *ui);
MetaUIDirection meta_ui_get_direction (void);
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf *meta_ui_get_pixbuf_from_pixmap (Pixmap pmap);
+#endif
#include "tabpopup.h"
#include "tile-preview.h"
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 82bca2ab..5c19bd4c 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -667,7 +667,8 @@ meta_frames_attach_style (MetaFrames *frames,
/* Weirdly, gtk_style_attach() steals a reference count from the style passed in */
#if GTK_CHECK_VERSION(3, 0, 0)
- frame->style = g_object_ref (gtk_widget_get_style_context (GTK_WIDGET (frames)));
+ 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);
@@ -2480,6 +2481,32 @@ cached_pixels_draw (CachedPixels *pixels,
#if GTK_CHECK_VERSION(3, 0, 0)
+static void
+subtract_client_area (cairo_region_t *region, MetaUIFrame *frame)
+{
+ GdkRectangle area;
+ MetaFrameFlags flags;
+ MetaFrameType type;
+ cairo_region_t *tmp_region;
+ Display *display;
+
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+ meta_core_get (display, frame->xwindow,
+ META_CORE_GET_FRAME_FLAGS, &flags,
+ META_CORE_GET_FRAME_TYPE, &type,
+ META_CORE_GET_CLIENT_WIDTH, &area.width,
+ META_CORE_GET_CLIENT_HEIGHT, &area.height,
+ META_CORE_GET_END);
+ meta_theme_get_frame_borders (meta_theme_get_current (),
+ type, frame->text_height, flags,
+ &area.x, NULL, &area.y, NULL);
+
+ tmp_region = cairo_region_create_rectangle (&area);
+ cairo_region_subtract (region, tmp_region);
+ cairo_region_destroy (tmp_region);
+}
+
static gboolean
meta_frames_draw (GtkWidget *widget,
cairo_t *cr)
diff --git a/src/ui/testgradient.c b/src/ui/testgradient.c
index 0de2510c..18a9de41 100644
--- a/src/ui/testgradient.c
+++ b/src/ui/testgradient.c
@@ -29,19 +29,28 @@
#define UNUSED_VARIABLE
#endif
-typedef void (* RenderGradientFunc) (GdkDrawable *drawable,
+typedef void (* RenderGradientFunc) (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width,
int height);
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+draw_checkerboard (cairo_t *cr,
+#else
draw_checkerboard (GdkDrawable *drawable,
+#endif
int width,
int height)
{
gint i, j, xcount, ycount;
GdkColor color1, color2;
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
+#endif
#define CHECK_SIZE 10
#define SPACING 2
@@ -54,7 +63,9 @@ draw_checkerboard (GdkDrawable *drawable,
color2.green = 50000;
color2.blue = 50000;
+#if !GTK_CHECK_VERSION (3, 0, 0)
cr = gdk_cairo_create (drawable);
+#endif
xcount = 0;
i = SPACING;
@@ -83,12 +94,17 @@ draw_checkerboard (GdkDrawable *drawable,
i += CHECK_SIZE + SPACING;
++xcount;
}
-
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
}
static void
-render_simple (GdkDrawable *drawable,
+render_simple (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height,
MetaGradientType type,
@@ -120,8 +136,12 @@ render_simple (GdkDrawable *drawable,
meta_gradient_add_alpha (pixbuf,
alphas, G_N_ELEMENTS (alphas),
META_GRADIENT_HORIZONTAL);
-
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ draw_checkerboard (cr , width, height);
+#else
draw_checkerboard (drawable, width, height);
+#endif
}
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
@@ -132,39 +152,70 @@ render_simple (GdkDrawable *drawable,
}
static void
-render_vertical_func (GdkDrawable *drawable,
+render_vertical_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_simple (cr, width, height, META_GRADIENT_VERTICAL, FALSE);
+#else
render_simple (drawable, cr, width, height, META_GRADIENT_VERTICAL, FALSE);
+#endif
}
static void
-render_horizontal_func (GdkDrawable *drawable,
+render_horizontal_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_simple (cr, width, height, META_GRADIENT_HORIZONTAL, FALSE);
+#else
render_simple (drawable, cr, width, height, META_GRADIENT_HORIZONTAL, FALSE);
+#endif
}
static void
-render_diagonal_func (GdkDrawable *drawable,
+render_diagonal_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_simple (cr, width, height, META_GRADIENT_DIAGONAL, FALSE);
+#else
render_simple (drawable, cr, width, height, META_GRADIENT_DIAGONAL, FALSE);
+#endif
}
static void
-render_diagonal_alpha_func (GdkDrawable *drawable,
+render_diagonal_alpha_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_simple (cr, width, height, META_GRADIENT_DIAGONAL, TRUE);
+#else
render_simple (drawable, cr, width, height, META_GRADIENT_DIAGONAL, TRUE);
+#endif
}
static void
-render_multi (GdkDrawable *drawable,
+render_multi (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height,
MetaGradientType type)
@@ -192,31 +243,55 @@ render_multi (GdkDrawable *drawable,
}
static void
-render_vertical_multi_func (GdkDrawable *drawable,
+render_vertical_multi_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_multi (cr, width, height, META_GRADIENT_VERTICAL);
+#else
render_multi (drawable, cr, width, height, META_GRADIENT_VERTICAL);
+#endif
}
static void
-render_horizontal_multi_func (GdkDrawable *drawable,
+render_horizontal_multi_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_multi (cr, width, height, META_GRADIENT_HORIZONTAL);
+#else
render_multi (drawable, cr, width, height, META_GRADIENT_HORIZONTAL);
+#endif
}
static void
-render_diagonal_multi_func (GdkDrawable *drawable,
+render_diagonal_multi_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ render_multi (cr, width, height, META_GRADIENT_DIAGONAL);
+#else
render_multi (drawable, cr, width, height, META_GRADIENT_DIAGONAL);
+#endif
}
static void
-render_interwoven_func (GdkDrawable *drawable,
+render_interwoven_func (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GdkDrawable *drawable,
+#endif
cairo_t *cr,
int width, int height)
{
@@ -241,31 +316,50 @@ render_interwoven_func (GdkDrawable *drawable,
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+draw_callback (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
+#else
expose_callback (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
+#endif
{
RenderGradientFunc func = data;
GdkWindow *window;
GtkAllocation allocation;
GtkStyle *style;
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
+#endif
style = gtk_widget_get_style (widget);
gtk_widget_get_allocation (widget, &allocation);
window = gtk_widget_get_window (widget);
+#if !GTK_CHECK_VERSION (3, 0, 0)
cr = gdk_cairo_create (window);
+#endif
gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]);
- (* func) (window,
+ (* func) (
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ window,
+#endif
cr,
allocation.width,
allocation.height);
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ return FALSE;
+#else
return TRUE;
+#endif
}
static GtkWidget*
@@ -286,8 +380,13 @@ create_gradient_window (const char *title,
gtk_window_set_default_size (GTK_WINDOW (window), 175, 175);
g_signal_connect (G_OBJECT (drawing_area),
+#if GTK_CHECK_VERSION (3, 0, 0)
+ "draw",
+ G_CALLBACK (draw_callback),
+#else
"expose_event",
G_CALLBACK (expose_callback),
+#endif
func);
gtk_container_add (GTK_CONTAINER (window), drawing_area);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 655c63f3..589c68e5 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3387,6 +3387,31 @@ fill_env (MetaPositionExprEnv *env,
env->theme = meta_current_theme;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static GtkStateFlags
+state_flags_from_gtk_state (GtkStateType state)
+{
+ switch (state)
+ {
+ case GTK_STATE_NORMAL:
+ return 0;
+ case GTK_STATE_PRELIGHT:
+ return GTK_STATE_FLAG_PRELIGHT;
+ case GTK_STATE_ACTIVE:
+ return GTK_STATE_FLAG_ACTIVE;
+ case GTK_STATE_SELECTED:
+ return GTK_STATE_FLAG_SELECTED;
+ case GTK_STATE_INSENSITIVE:
+ return GTK_STATE_FLAG_INSENSITIVE;
+ case GTK_STATE_INCONSISTENT:
+ return GTK_STATE_FLAG_INCONSISTENT;
+ case GTK_STATE_FOCUSED:
+ return GTK_STATE_FLAG_FOCUSED;
+ }
+ return 0;
+}
+#endif
+
/* This code was originally rendering anti-aliased using X primitives, and
* now has been switched to draw anti-aliased using cairo. In general, the
* closest correspondence between X rendering and cairo rendering is given
@@ -4728,13 +4753,10 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
j = 0;
while (j < META_BUTTON_TYPE_LAST)
{
- MetaButtonState button_state;
button_rect (j, fgeom, middle_bg_offset, &rect);
-
- button_state = map_button_state (j, fgeom, middle_bg_offset, button_states);
- op_list = get_button (style, j, button_state);
+ op_list = get_button (style, j, button_states[j]);
if (op_list)
{
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 42d3dc57..c170adb8 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -31,6 +31,10 @@
#include <string.h>
#include <stdlib.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <cairo-xlib.h>
+#endif
+
static void meta_ui_accelerator_parse(const char* accel, guint* keysym, guint* keycode, GdkModifierType* keymask);
struct _MetaUI {
@@ -79,7 +83,12 @@ maybe_redirect_mouse_event (XEvent *xevent)
{
GdkDisplay *gdisplay;
MetaUI *ui;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDeviceManager *gmanager;
+ GdkEvent *gevent;
+#else
GdkEvent gevent;
+#endif
GdkWindow *gdk_window;
Window window;
@@ -105,7 +114,11 @@ maybe_redirect_mouse_event (XEvent *xevent)
if (!ui)
return FALSE;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
+#else
gdk_window = gdk_window_lookup_for_display (gdisplay, window);
+#endif
if (gdk_window == NULL)
return FALSE;
@@ -116,7 +129,9 @@ maybe_redirect_mouse_event (XEvent *xevent)
if (gdk_display_pointer_is_grabbed (gdisplay))
return FALSE;
+#if !GTK_CHECK_VERSION (3, 0, 0)
memset (&gevent, 0, sizeof (gevent));
+#endif
switch (xevent->type)
{
@@ -139,13 +154,21 @@ maybe_redirect_mouse_event (XEvent *xevent)
ABS (xevent->xbutton.x - ui->button_click_x) <= double_click_distance &&
ABS (xevent->xbutton.y - ui->button_click_y) <= double_click_distance)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent = gdk_event_new (GDK_2BUTTON_PRESS);
+#else
gevent.button.type = GDK_2BUTTON_PRESS;
+#endif
ui->button_click_number = 0;
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent = gdk_event_new (GDK_BUTTON_PRESS);
+#else
gevent.button.type = GDK_BUTTON_PRESS;
+#endif
ui->button_click_number = xevent->xbutton.button;
ui->button_click_window = xevent->xbutton.window;
ui->button_click_time = xevent->xbutton.time;
@@ -155,9 +178,22 @@ maybe_redirect_mouse_event (XEvent *xevent)
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent = gdk_event_new (GDK_BUTTON_RELEASE);
+#else
gevent.button.type = GDK_BUTTON_RELEASE;
+#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent->button.window = g_object_ref (gdk_window);
+ gevent->button.button = xevent->xbutton.button;
+ gevent->button.time = xevent->xbutton.time;
+ gevent->button.x = xevent->xbutton.x;
+ gevent->button.y = xevent->xbutton.y;
+ gevent->button.x_root = xevent->xbutton.x_root;
+ gevent->button.y_root = xevent->xbutton.y_root;
+#else
gevent.button.window = gdk_window;
gevent.button.button = xevent->xbutton.button;
gevent.button.time = xevent->xbutton.time;
@@ -165,18 +201,32 @@ maybe_redirect_mouse_event (XEvent *xevent)
gevent.button.y = xevent->xbutton.y;
gevent.button.x_root = xevent->xbutton.x_root;
gevent.button.y_root = xevent->xbutton.y_root;
+#endif
break;
case MotionNotify:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent = gdk_event_new (GDK_MOTION_NOTIFY);
+ gevent->motion.type = GDK_MOTION_NOTIFY;
+ gevent->motion.window = g_object_ref (gdk_window);
+#else
gevent.motion.type = GDK_MOTION_NOTIFY;
gevent.motion.window = gdk_window;
+#endif
break;
case EnterNotify:
case LeaveNotify:
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gevent = gdk_event_new (xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
+ gevent->crossing.window = g_object_ref (gdk_window);
+ gevent->crossing.x = xevent->xcrossing.x;
+ gevent->crossing.y = xevent->xcrossing.y;
+#else
gevent.crossing.type = xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
gevent.crossing.window = gdk_window;
gevent.crossing.x = xevent->xcrossing.x;
gevent.crossing.y = xevent->xcrossing.y;
+#endif
break;
default:
g_assert_not_reached ();
@@ -184,7 +234,13 @@ maybe_redirect_mouse_event (XEvent *xevent)
}
/* If we've gotten here, we've filled in the gdk_event and should send it on */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gmanager = gdk_display_get_device_manager (gdisplay);
+ gdk_event_set_device (gevent, gdk_device_manager_get_client_pointer (gmanager)); gtk_main_do_event (gevent);
+ gdk_event_free (gevent);
+#else
gtk_main_do_event (&gevent);
+#endif
return TRUE;
}
@@ -390,7 +446,13 @@ meta_ui_map_frame (MetaUI *ui,
{
GdkWindow *window;
+#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);
+#endif
if (window)
gdk_window_show_unraised (window);
@@ -402,7 +464,13 @@ meta_ui_unmap_frame (MetaUI *ui,
{
GdkWindow *window;
+#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);
+#endif
if (window)
gdk_window_hide (window);
@@ -494,6 +562,7 @@ meta_ui_window_menu_free (MetaWindowMenu *menu)
meta_window_menu_free (menu);
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
struct _MetaImageWindow
{
GtkWidget *window;
@@ -519,7 +588,7 @@ meta_image_window_new (Display *xdisplay,
gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
gtk_widget_realize (iw->window);
- iw->pixmap = gdk_pixmap_new (iw->window->window,
+ iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
max_width, max_height,
-1);
@@ -557,38 +626,44 @@ meta_image_window_set (MetaImageWindow *iw,
int x,
int y)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr;
+#endif
/* We use a back pixmap to avoid having to handle exposes, because
* it's really too slow for large clients being minimized, etc.
* and this way flicker is genuinely zero.
*/
+#if !GTK_CHECK_VERSION (3, 0, 0)
gdk_draw_pixbuf (iw->pixmap,
- iw->window->style->black_gc,
- pixbuf,
+ gtk_widget_get_style (iw->window)->black_gc,
+ pixbuf,
0, 0,
0, 0,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
GDK_RGB_DITHER_NORMAL,
0, 0);
+#else
cr = gdk_cairo_create (iw->pixmap);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
+#endif
- gdk_window_set_back_pixmap (iw->window->window,
+ gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window),
iw->pixmap,
FALSE);
- gdk_window_move_resize (iw->window->window,
+ gdk_window_move_resize (gtk_widget_get_window (iw->window),
x, y,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
- gdk_window_clear (iw->window->window);
+ gdk_window_clear (gtk_widget_get_window (iw->window));
}
+#endif
#if !GTK_CHECK_VERSION (3, 0, 0)
static GdkColormap*
@@ -629,9 +704,10 @@ get_cmap (GdkPixmap *pixmap)
}
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf*
-meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
- Window xwindow,
+meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
+ Pixmap xpixmap,
int src_x,
int src_y,
int dest_x,
@@ -639,41 +715,49 @@ meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
int width,
int height)
{
- GdkDrawable *drawable;
+ cairo_surface_t *surface;
+ Display *display;
+ Window root_return;
+ int x_ret, y_ret;
+ unsigned int w_ret, h_ret, bw_ret, depth_ret;
+ XWindowAttributes attrs;
GdkPixbuf *retval;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkColormap *cmap;
-#endif
- retval = NULL;
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- drawable = gdk_xid_table_lookup (xwindow);
+ if (!XGetGeometry (display, xpixmap, &root_return,
+ &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
+ return NULL;
- if (drawable)
- g_object_ref (G_OBJECT (drawable));
+ if (depth_ret == 1)
+ {
+ surface = cairo_xlib_surface_create_for_bitmap (display,
+ xpixmap,
+ GDK_SCREEN_XSCREEN (gdk_screen_get_default ()),
+ w_ret,
+ h_ret);
+ }
else
- drawable = gdk_window_foreign_new (xwindow);
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cmap = get_cmap (drawable);
-#endif
+ {
+ if (!XGetWindowAttributes (display, root_return, &attrs))
+ return NULL;
- retval = gdk_pixbuf_get_from_drawable (dest,
- drawable,
- cmap,
- src_x, src_y,
- dest_x, dest_y,
- width, height);
+ surface = cairo_xlib_surface_create (display,
+ xpixmap,
+ attrs.visual,
+ w_ret, h_ret);
+ }
-#if !GTK_CHECK_VERSION (3, 0, 0)
- if (cmap)
- g_object_unref (G_OBJECT (cmap));
-#endif
- g_object_unref (G_OBJECT (drawable));
+ retval = gdk_pixbuf_get_from_surface (surface,
+ src_x,
+ src_y,
+ width,
+ height);
+ cairo_surface_destroy (surface);
return retval;
}
-
+#else
GdkPixbuf*
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
Pixmap xpixmap,
@@ -695,7 +779,11 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
cmap = NULL;
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ drawable = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xpixmap);
+#else
drawable = gdk_xid_table_lookup (xpixmap);
+#endif
if (drawable)
g_object_ref (G_OBJECT (drawable));
@@ -722,6 +810,7 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
return retval;
}
+#endif
void
meta_ui_push_delay_exposes (MetaUI *ui)
@@ -811,7 +900,11 @@ 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);
+#else
window = gdk_xid_table_lookup (xwindow);
+#endif
/* we shouldn't cause focus if we're an override redirect
* toplevel which is not foreign
@@ -826,17 +919,30 @@ char*
meta_text_property_to_utf8 (Display *xdisplay,
const XTextProperty *prop)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDisplay *display;
+#endif
char **list;
int count;
char *retval;
list = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ display = gdk_x11_lookup_xdisplay (xdisplay);
+ count = gdk_text_property_to_utf8_list_for_display (display,
+ gdk_x11_xatom_to_atom_for_display (display, prop->encoding),
+ prop->format,
+ prop->value,
+ prop->nitems,
+ &list);
+#else
count = gdk_text_property_to_utf8_list (gdk_x11_xatom_to_atom (prop->encoding),
prop->format,
prop->value,
prop->nitems,
&list);
+#endif
if (count == 0)
retval = NULL;
@@ -933,7 +1039,7 @@ meta_ui_parse_accelerator (const char *accel,
*keycode = 0;
*mask = 0;
- if (strcmp (accel, "disabled") == 0)
+ if (!accel[0] || strcmp (accel, "disabled") == 0)
return TRUE;
meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
@@ -1020,7 +1126,7 @@ meta_ui_parse_modifier (const char *accel,
*mask = 0;
- if (accel == NULL || strcmp (accel, "disabled") == 0)
+ if (accel == NULL || !accel[0] || strcmp (accel, "disabled") == 0)
return TRUE;
meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
@@ -1063,7 +1169,13 @@ meta_ui_window_is_widget (MetaUI *ui,
{
GdkWindow *window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDisplay *display;
+
+ window = gdk_x11_window_lookup_for_display (display, xwindow);
+#else
window = gdk_xid_table_lookup (xwindow);
+#endif
if (window)
{
@@ -1102,6 +1214,7 @@ MetaUIDirection meta_ui_get_direction(void)
return META_UI_DIRECTION_LTR;
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
{
GdkPixmap* gpmap;
@@ -1143,3 +1256,4 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
return pixbuf;
}
+#endif