summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/core/constraints.c8
-rw-r--r--src/libmarco-private.pc.in2
-rw-r--r--src/tools/Makefile.am2
-rw-r--r--src/tools/marco-mag.c9
-rw-r--r--src/tools/marco-window-demo.c110
-rw-r--r--src/ui/draw-workspace.c38
-rw-r--r--src/ui/draw-workspace.h4
-rw-r--r--src/ui/fixedtip.c24
-rw-r--r--src/ui/frames.c269
-rw-r--r--src/ui/menu.c29
-rw-r--r--src/ui/metaaccellabel.c169
-rw-r--r--src/ui/preview-widget.c132
-rw-r--r--src/ui/preview-widget.h9
-rw-r--r--src/ui/resizepopup.c14
-rw-r--r--src/ui/tabpopup.c227
-rw-r--r--src/ui/theme.c341
-rw-r--r--src/ui/theme.h36
-rw-r--r--src/ui/themewidget.c129
-rw-r--r--src/ui/themewidget.h17
-rw-r--r--src/ui/ui.c40
-rw-r--r--src/wm-tester/Makefile.am4
-rw-r--r--src/wm-tester/main.c4
23 files changed, 1542 insertions, 77 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 93263611..e91cb338 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,7 +2,7 @@ lib_LTLIBRARIES = libmarco-private.la
SUBDIRS=wm-tester tools themes
-INCLUDES = \
+AM_CPPFLAGS = \
-I$(srcdir)/include \
-DMARCO_LIBEXECDIR=\"$(libexecdir)\" \
-DHOST_ALIAS=\"@HOST_ALIAS@\" \
diff --git a/src/core/constraints.c b/src/core/constraints.c
index a79f858a..1b2b70ab 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -429,9 +429,15 @@ setup_constraint_info (ConstraintInfo *info,
xinerama_info->number);
/* Workaround braindead legacy apps that don't know how to
- * fullscreen themselves properly.
+ * fullscreen themselves properly - don't get fooled by
+ * windows which hide their titlebar when maximized or which are
+ * client decorated; that's not the same as fullscreen, even
+ * if there are no struts making the workarea smaller than
+ * the monitor.
*/
+
if (meta_prefs_get_force_fullscreen() &&
+ window->decorated &&
meta_rectangle_equal (new, &xinerama_info->rect) &&
window->has_fullscreen_func &&
!window->fullscreen)
diff --git a/src/libmarco-private.pc.in b/src/libmarco-private.pc.in
index 8b0a5c83..f20b9eb2 100644
--- a/src/libmarco-private.pc.in
+++ b/src/libmarco-private.pc.in
@@ -6,7 +6,7 @@ libmate_serverdir=@libexecdir@
Name: libmarco-private
Description: Marco internals shared
-Requires: gtk+-2.0
+Requires: gtk+-@GTK_API_VERSION@
Version: @VERSION@
Libs: -L${libdir} -lmarco-private
Cflags: -I${includedir}/marco-1
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
index 031ef961..39df3390 100644
--- a/src/tools/Makefile.am
+++ b/src/tools/Makefile.am
@@ -3,7 +3,7 @@
icondir=$(pkgdatadir)/icons
icon_DATA=marco-window-demo.png
-INCLUDES=@MARCO_WINDOW_DEMO_CFLAGS@ @MARCO_MESSAGE_CFLAGS@ \
+AM_CPPFLAGS=@MARCO_WINDOW_DEMO_CFLAGS@ @MARCO_MESSAGE_CFLAGS@ \
-DMARCO_ICON_DIR=\"$(pkgdatadir)/icons\" \
-DMARCO_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\"
diff --git a/src/tools/marco-mag.c b/src/tools/marco-mag.c
index 4cb33183..5d6dff35 100644
--- a/src/tools/marco-mag.c
+++ b/src/tools/marco-mag.c
@@ -29,6 +29,10 @@
#include <stdlib.h>
#include <math.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #include <gdk/gdkkeysyms-compat.h>
+#endif
+
static GtkWidget *grab_widget = NULL;
static GtkWidget *display_window = NULL;
static int last_grab_x = 0;
@@ -52,10 +56,15 @@ get_pixbuf (void)
last_grab_width, last_grab_height);
#endif
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ screenshot = gdk_pixbuf_get_from_window(gdk_get_default_root_window(), last_grab_x, last_grab_y, last_grab_width, last_grab_height);
+ #else
screenshot = gdk_pixbuf_get_from_drawable (NULL, gdk_get_default_root_window (),
NULL,
last_grab_x, last_grab_y, 0, 0,
last_grab_width, last_grab_height);
+ #endif
if (screenshot == NULL)
{
diff --git a/src/tools/marco-window-demo.c b/src/tools/marco-window-demo.c
index 37a5dd4e..5a7afa6f 100644
--- a/src/tools/marco-window-demo.c
+++ b/src/tools/marco-window-demo.c
@@ -24,6 +24,10 @@
#include <X11/Xatom.h>
#include <unistd.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #define GDK_WINDOW_XWINDOW(w) GDK_WINDOW_XID(w)
+#endif
+
static GtkWidget* do_appwindow (void);
static gboolean aspect_on;
@@ -647,6 +651,25 @@ dock_cb (gpointer callback_data,
}
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static void top_dock_cb()
+ { make_dock(DOCK_TOP); }
+
+static void bottom_dock_cb()
+ { make_dock(DOCK_BOTTOM); }
+
+static void left_dock_cb()
+ { make_dock(DOCK_LEFT); }
+
+static void right_dock_cb()
+ { make_dock(DOCK_RIGHT); }
+
+static void all_dock_cb()
+ { dock_cb(NULL, DOCK_ALL, NULL); }
+
+#endif
+
static void
desktop_cb (gpointer callback_data,
guint callback_action,
@@ -676,6 +699,62 @@ desktop_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gchar ui_definition[] =
+"<ui>\
+ <menubar name=\"MainMenuBar\">\
+ <menu name=\"WindowsMenu\">\
+ <menuitem name=\"Dialog\" action=\"DialogAction\" />\
+ <menuitem name=\"ModalDialog\" action=\"ModalDialogAction\" />\
+ <menuitem name=\"ParentlessDialog\" action=\"ParentlessDialogAction\" />\
+ <menuitem name=\"Utility\" action=\"UtilityAction\" />\
+ <menuitem name=\"Splashscreen\" action=\"SplashscreenAction\" />\
+ <menuitem name=\"TopDock\" action=\"TopDockAction\" />\
+ <menuitem name=\"BottomDock\" action=\"BottomDockAction\" />\
+ <menuitem name=\"LeftDock\" action=\"LeftDockAction\" />\
+ <menuitem name=\"RightDock\" action=\"RightDockAction\" />\
+ <menuitem name=\"AllDocks\" action=\"AllDocksAction\" />\
+ <menuitem name=\"Desktop\" action=\"DesktopAction\" />\
+ <menuitem name=\"Menu\" action=\"MenuAction\" />\
+ <menuitem name=\"Toolbar\" action=\"ToolbarAction\" />\
+ <menuitem name=\"OverrideRedirect\" action=\"OverrideRedirectAction\" />\
+ <menuitem name=\"BorderOnly\" action=\"BorderOnlyAction\" />\
+ </menu>\
+ </menubar>\
+</ui>";
+
+static GtkActionEntry entries[] =
+{
+ /*
+ struct GtkActionEntry {
+ const gchar *name;
+ const gchar *stock_id;
+ const gchar *label;
+ const gchar *accelerator;
+ const gchar *tooltip;
+ GCallback callback;
+ }; */
+
+ {"DialogAction" , NULL , "_Dialog" , "<control>d" , NULL , G_CALLBACK(dialog_cb)} ,
+ {"ModalDialogAction" , NULL , "_Modal dialog" , NULL , NULL , G_CALLBACK(modal_dialog_cb)} ,
+ {"ParentlessDialogAction" , NULL , "_Parentless dialog" , NULL , NULL , G_CALLBACK(no_parent_dialog_cb)} ,
+ {"UtilityAction" , NULL , "_Utility" , "<control>u" , NULL , G_CALLBACK(utility_cb)} ,
+ {"SplashscreenAction" , NULL , "_Splashscreen" , "<control>s" , NULL , G_CALLBACK(splashscreen_cb)} ,
+ {"TopDockAction" , NULL , "_Top dock" , NULL , NULL , G_CALLBACK(top_dock_cb)} ,
+ {"BottomDockAction" , NULL , "_Bottom dock" , NULL , NULL , G_CALLBACK(bottom_dock_cb)} ,
+ {"LeftDockAction" , NULL , "_Left dock" , NULL , NULL , G_CALLBACK(left_dock_cb)} ,
+ {"RightDockAction" , NULL , "_Right dock" , NULL , NULL , G_CALLBACK(right_dock_cb)} ,
+ {"AllDocksAction" , NULL , "_All docks" , NULL , NULL , G_CALLBACK(all_dock_cb)} ,
+ {"DesktopAction" , NULL , "Des_ktop" , NULL , NULL , G_CALLBACK(desktop_cb)} ,
+ {"MenuAction" , NULL , "Me_nu" , NULL , NULL , G_CALLBACK(menu_cb)} ,
+ {"ToolbarAction" , NULL , "Tool_bar" , NULL , NULL , G_CALLBACK(toolbar_cb)} ,
+ {"OverrideRedirectAction" , NULL , "Override Redirect" , NULL , NULL , G_CALLBACK(override_redirect_cb)} ,
+ {"BorderOnly" , NULL , "Border Only" , NULL , NULL , G_CALLBACK(border_only_cb)} ,
+};
+
+#else
+
static GtkItemFactoryEntry menu_items[] =
{
{ "/_Windows", NULL, NULL, 0, "<Branch>" },
@@ -697,6 +776,8 @@ static GtkItemFactoryEntry menu_items[] =
{ "/Windows/Border Only", NULL, border_only_cb, 0, NULL }
};
+#endif
+
static void
sleep_cb (GtkWidget *button,
gpointer data)
@@ -823,8 +904,14 @@ do_appwindow (void)
GtkWidget *contents;
GtkWidget *sw;
GtkTextBuffer *buffer;
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ #else
GtkAccelGroup *accel_group;
GtkItemFactory *item_factory;
+ #endif
/* Create the toplevel window
@@ -843,6 +930,26 @@ do_appwindow (void)
table = gtk_table_new (1, 4, FALSE);
gtk_container_add (GTK_CONTAINER (window), table);
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+
+ action_group = gtk_action_group_new("ActionGroups");
+ gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), NULL);
+
+ ui_manager = gtk_ui_manager_new();
+ gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
+ gtk_ui_manager_add_ui_from_string(ui_manager, ui_definition, -1, NULL);
+
+ gtk_table_attach (GTK_TABLE (table),
+ gtk_ui_manager_get_widget (ui_manager, "/MainMenuBar"),
+ /* X direction */ /* Y direction */
+ 0, 1, 0, 1,
+ GTK_EXPAND | GTK_FILL, 0,
+ 0, 0);
+
+ gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui_manager));
+
+ #else
/* Create the menubar
*/
@@ -873,6 +980,9 @@ do_appwindow (void)
GTK_EXPAND | GTK_FILL, 0,
0, 0);
+
+ #endif
+
/* Create document
*/
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index 4008dc7c..2a6e7675 100644
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
@@ -67,12 +67,19 @@ get_window_rect (const WnckWindowDisplayInfo *win,
static void
draw_window (GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
+ #endif
const WnckWindowDisplayInfo *win,
const GdkRectangle *winrect,
GtkStateType state)
{
+ #if !GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr;
+ #endif
+
GdkPixbuf *icon;
int icon_x, icon_y, icon_w, icon_h;
gboolean is_active;
@@ -80,8 +87,13 @@ draw_window (GtkWidget *widget,
GtkStyle *style;
is_active = win->is_active;
-
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save(cr);
+ #else
cr = gdk_cairo_create (drawable);
+ #endif
+
cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
cairo_clip (cr);
@@ -159,12 +171,20 @@ draw_window (GtkWidget *widget,
MAX (0, winrect->width - 1), MAX (0, winrect->height - 1));
cairo_stroke (cr);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_restore(cr);
+ #else
cairo_destroy (cr);
+ #endif
}
void
wnck_draw_workspace (GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
+ #endif
int x,
int y,
int width,
@@ -179,7 +199,9 @@ wnck_draw_workspace (GtkWidget *widget,
int i;
GdkRectangle workspace_rect;
GtkStateType state;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
cairo_t *cr;
+ #endif
workspace_rect.x = x;
workspace_rect.y = y;
@@ -193,7 +215,11 @@ wnck_draw_workspace (GtkWidget *widget,
else
state = GTK_STATE_NORMAL;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save(cr);
+ #else
cr = gdk_cairo_create (drawable);
+ #endif
if (workspace_background)
{
@@ -207,7 +233,9 @@ wnck_draw_workspace (GtkWidget *widget,
cairo_fill (cr);
}
+ #if !GTK_CHECK_VERSION(3, 0, 0)
cairo_destroy (cr);
+ #endif
i = 0;
while (i < n_windows)
@@ -219,11 +247,19 @@ wnck_draw_workspace (GtkWidget *widget,
screen_height, &workspace_rect, &winrect);
draw_window (widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
drawable,
+ #endif
win,
&winrect,
state);
++i;
}
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save(cr);
+ #endif
}
diff --git a/src/ui/draw-workspace.h b/src/ui/draw-workspace.h
index 5186d053..b1dabae3 100644
--- a/src/ui/draw-workspace.h
+++ b/src/ui/draw-workspace.h
@@ -46,7 +46,11 @@ typedef struct
} WnckWindowDisplayInfo;
void wnck_draw_workspace (GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
+ #endif
int x,
int y,
int width,
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index 707c461f..3d9aea06 100644
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
@@ -50,6 +50,24 @@ static int screen_right_edge = 0;
*/
static int screen_bottom_edge = 0;
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+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));
+
+ return FALSE;
+}
+
+#else
+
static gint
expose_handler (GtkTooltips *tooltips)
{
@@ -60,6 +78,7 @@ expose_handler (GtkTooltips *tooltips)
return FALSE;
}
+#endif
void
meta_fixed_tip_show (Display *xdisplay, int screen_number,
@@ -93,8 +112,13 @@ meta_fixed_tip_show (Display *xdisplay, int screen_number,
gtk_widget_set_name (tip, "gtk-tooltips");
gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ g_signal_connect (tip, "draw",
+ G_CALLBACK (draw_handler), NULL);
+ #else
g_signal_connect_swapped (tip, "expose_event",
G_CALLBACK (expose_handler), NULL);
+ #endif
label = gtk_label_new (NULL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 09bfcb61..82bca2ab 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -39,6 +39,25 @@
#include <X11/extensions/shape.h>
#endif
+#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);
+ #define parent_class meta_frames_parent_class
+ #define GTK_WIDGET_REALIZED gtk_widget_get_realized
+#endif
+
#define DEFAULT_INNER_BUTTON_BORDER 3
static void meta_frames_class_init (MetaFramesClass *klass);
@@ -61,8 +80,13 @@ static gboolean meta_frames_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event);
static gboolean meta_frames_destroy_event (GtkWidget *widget,
GdkEventAny *event);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean meta_frames_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gboolean meta_frames_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+#endif
static gboolean meta_frames_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static gboolean meta_frames_leave_notify_event (GtkWidget *widget,
@@ -73,10 +97,14 @@ static void meta_frames_attach_style (MetaFrames *frames,
static void meta_frames_paint_to_drawable (MetaFrames *frames,
MetaUIFrame *frame,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr);
+ #else
GdkDrawable *drawable,
GdkRegion *region,
int x_offset,
int y_offset);
+ #endif
static void meta_frames_set_window_background (MetaFrames *frames,
MetaUIFrame *frame);
@@ -106,6 +134,28 @@ 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
+
static GtkWidgetClass *parent_class = NULL;
GType
@@ -133,28 +183,40 @@ meta_frames_get_type (void)
return frames_type;
}
+#endif
+
static void
meta_frames_class_init (MetaFramesClass *class)
{
GObjectClass *gobject_class;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
GtkObjectClass *object_class;
+ #endif
GtkWidgetClass *widget_class;
gobject_class = G_OBJECT_CLASS (class);
+ #if !GTK_CHECK_VERSION(3, 0, 0)
object_class = (GtkObjectClass*) class;
+ #endif
widget_class = (GtkWidgetClass*) class;
parent_class = g_type_class_peek_parent (class);
gobject_class->finalize = meta_frames_finalize;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
object_class->destroy = meta_frames_destroy;
+ #endif
widget_class->style_set = meta_frames_style_set;
widget_class->realize = meta_frames_realize;
widget_class->unrealize = meta_frames_unrealize;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = meta_frames_draw;
+ #else
widget_class->expose_event = meta_frames_expose_event;
+ #endif
widget_class->destroy_event = meta_frames_destroy_event;
widget_class->button_press_event = meta_frames_button_press_event;
widget_class->button_release_event = meta_frames_button_release_event;
@@ -203,7 +265,9 @@ prefs_changed_callback (MetaPreference pref,
static void
meta_frames_init (MetaFrames *frames)
{
+ #if !GTK_CHECK_VERSION(3, 0, 0)
GTK_WINDOW (frames)->type = GTK_WINDOW_POPUP;
+ #endif
frames->text_heights = g_hash_table_new (NULL, NULL);
@@ -283,8 +347,13 @@ meta_frames_finalize (GObject *object)
typedef struct
{
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_rectangle_int_t rect;
+ cairo_surface_t *pixmap;
+ #else
MetaRectangle rect;
GdkPixmap *pixmap;
+ #endif
} CachedFramePiece;
typedef struct
@@ -321,7 +390,11 @@ invalidate_cache (MetaFrames *frames,
for (i = 0; i < 4; i++)
if (pixels->piece[i].pixmap)
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_surface_destroy (pixels->piece[i].pixmap);
+ #else
g_object_unref (pixels->piece[i].pixmap);
+ #endif
g_free (pixels);
g_hash_table_remove (frames->cache, frame);
@@ -460,7 +533,7 @@ meta_frames_ensure_layout (MetaFrames *frames,
MetaFrameType type;
MetaFrameStyle *style;
- g_return_if_fail (GTK_WIDGET_REALIZED (frames));
+ g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET(frames)));
widget = GTK_WIDGET (frames);
@@ -593,8 +666,12 @@ meta_frames_attach_style (MetaFrames *frames,
gtk_style_detach (frame->style);
/* 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)));
+ #else
g_object_ref (GTK_WIDGET (frames)->style);
frame->style = gtk_style_attach (GTK_WIDGET (frames)->style, frame->window);
+ #endif
}
void
@@ -2113,6 +2190,7 @@ setup_bg_cr (cairo_t *cr, GdkWindow *window, int x_offset, int y_offset)
}
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void
clear_backing (GdkPixmap *pixmap,
GdkWindow *window,
@@ -2135,32 +2213,65 @@ clear_backing (GdkPixmap *pixmap,
cairo_destroy (cr);
}
+#endif
/* Returns a pixmap with a piece of the windows frame painted on it.
*/
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static cairo_surface_t *
+generate_pixmap (MetaFrames *frames,
+ MetaUIFrame *frame,
+ cairo_rectangle_int_t *rect)
+{
+ cairo_surface_t *result;
+ cairo_t *cr;
+
+ /* do not create a pixmap for nonexisting areas */
+ if (rect->width <= 0 || rect->height <= 0)
+ return NULL;
+
+ result = gdk_window_create_similar_surface (frame->window,
+ CAIRO_CONTENT_COLOR,
+ rect->width, rect->height);
+
+ cr = cairo_create (result);
+ cairo_translate (cr, -rect->x, -rect->y);
+
+ setup_bg_cr (cr, frame->window, 0, 0);
+ cairo_paint (cr);
+
+ meta_frames_paint_to_drawable (frames, frame, cr);
+
+ cairo_destroy (cr);
+
+ return result;
+}
+
+#else
static GdkPixmap *
generate_pixmap (MetaFrames *frames,
MetaUIFrame *frame,
- MetaRectangle rect)
+ MetaRectangle *rect)
{
GdkRectangle rectangle;
GdkRegion *region;
GdkPixmap *result;
/* do not create a pixmap for nonexisting areas */
- if (rect.width <= 0 || rect.height <= 0)
+ if (rect->width <= 0 || rect->height <= 0)
return NULL;
- rectangle.x = rect.x;
- rectangle.y = rect.y;
- rectangle.width = rect.width;
- rectangle.height = rect.height;
+ rectangle.x = rect->x;
+ rectangle.y = rect->y;
+ rectangle.width = rect->width;
+ rectangle.height = rect->height;
result = gdk_pixmap_new (frame->window,
- rect.width, rect.height, -1);
+ rect->width, rect->height, -1);
- clear_backing (result, frame->window, rect.x, rect.y);
+ clear_backing (result, frame->window, rect->x, rect->y);
region = gdk_region_rectangle (&rectangle);
@@ -2172,6 +2283,8 @@ generate_pixmap (MetaFrames *frames,
return result;
}
+#endif
+
static void
populate_cache (MetaFrames *frames,
@@ -2237,7 +2350,7 @@ populate_cache (MetaFrames *frames,
{
CachedFramePiece *piece = &pixels->piece[i];
if (!piece->pixmap)
- piece->pixmap = generate_pixmap (frames, frame, piece->rect);
+ piece->pixmap = generate_pixmap (frames, frame, &piece->rect);
}
if (frames->invalidate_cache_timeout_id)
@@ -2279,6 +2392,8 @@ clip_to_screen (GdkRegion *region, MetaUIFrame *frame)
gdk_region_offset (region, - frame_area.x, - frame_area.y);
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
+
static void
subtract_from_region (GdkRegion *region, GdkDrawable *drawable,
gint x, gint y)
@@ -2301,6 +2416,38 @@ subtract_from_region (GdkRegion *region, GdkDrawable *drawable,
gdk_region_destroy (reg_rect);
}
+#endif
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static void
+cached_pixels_draw (CachedPixels *pixels,
+ cairo_t *cr,
+ cairo_region_t *region)
+{
+ cairo_region_t *region_piece;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ CachedFramePiece *piece;
+ piece = &pixels->piece[i];
+
+ if (piece->pixmap)
+ {
+ cairo_set_source_surface (cr, piece->pixmap,
+ piece->rect.x, piece->rect.y);
+ cairo_paint (cr);
+
+ region_piece = cairo_region_create_rectangle (&piece->rect);
+ cairo_region_subtract (region, region_piece);
+ cairo_region_destroy (region_piece);
+ }
+ }
+}
+
+#else
+
static void
cached_pixels_draw (CachedPixels *pixels,
GdkWindow *window,
@@ -2329,6 +2476,79 @@ cached_pixels_draw (CachedPixels *pixels,
cairo_destroy (cr);
}
+#endif
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+meta_frames_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaUIFrame *frame;
+ MetaFrames *frames;
+ CachedPixels *pixels;
+ cairo_region_t *region;
+ cairo_rectangle_int_t clip;
+ int i, n_areas;
+ cairo_surface_t *target;
+
+ frames = META_FRAMES (widget);
+ target = cairo_get_target (cr);
+ gdk_cairo_get_clip_rectangle (cr, &clip);
+
+ g_assert (cairo_surface_get_type (target) == CAIRO_SURFACE_TYPE_XLIB);
+ frame = meta_frames_lookup_window (frames, cairo_xlib_surface_get_drawable (target));
+ if (frame == NULL)
+ return FALSE;
+
+ if (frames->expose_delay_count > 0)
+ {
+ /* Redraw this entire frame later */
+ frame->expose_delayed = TRUE;
+ return TRUE;
+ }
+
+ populate_cache (frames, frame);
+
+ region = cairo_region_create_rectangle (&clip);
+
+ pixels = get_cache (frames, frame);
+
+ cached_pixels_draw (pixels, cr, region);
+
+ clip_to_screen (region, frame);
+ subtract_client_area (region, frame);
+
+ n_areas = cairo_region_num_rectangles (region);
+
+ for (i = 0; i < n_areas; i++)
+ {
+ cairo_rectangle_int_t area;
+
+ cairo_region_get_rectangle (region, i, &area);
+
+ cairo_save (cr);
+
+ cairo_rectangle (cr, area.x, area.y, area.width, area.height);
+ cairo_clip (cr);
+
+ cairo_push_group (cr);
+
+ meta_frames_paint_to_drawable (frames, frame, cr);
+
+ cairo_pop_group_to_source (cr);
+ cairo_paint (cr);
+
+ cairo_restore (cr);
+ }
+
+ cairo_region_destroy (region);
+
+ return TRUE;
+}
+
+#else
+
static gboolean
meta_frames_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -2367,6 +2587,8 @@ meta_frames_expose_event (GtkWidget *widget,
return TRUE;
}
+#endif
+
/* How far off the screen edge the window decorations should
* be drawn. Used only in meta_frames_paint_to_drawable, below.
*/
@@ -2375,10 +2597,14 @@ meta_frames_expose_event (GtkWidget *widget,
static void
meta_frames_paint_to_drawable (MetaFrames *frames,
MetaUIFrame *frame,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr)
+ #else
GdkDrawable *drawable,
GdkRegion *region,
int x_offset,
int y_offset)
+ #endif
{
GtkWidget *widget;
MetaFrameFlags flags;
@@ -2504,6 +2730,23 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
meta_prefs_get_button_layout (&button_layout);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+
+ meta_theme_draw_frame_with_style (meta_theme_get_current (),
+ frame->style,
+ widget,
+ cr,
+ type,
+ flags,
+ w, h,
+ frame->layout,
+ frame->text_height,
+ &button_layout,
+ button_states,
+ mini_icon, icon);
+
+ #else
+
if (G_LIKELY (GDK_IS_WINDOW (drawable)))
{
/* A window; happens about 2/3 of the time */
@@ -2605,6 +2848,8 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
mini_icon, icon);
}
+ #endif
+
}
static void
@@ -2640,7 +2885,11 @@ meta_frames_set_window_background (MetaFrames *frames,
/* Set A in ARGB to window_background_alpha, if we have ARGB */
visual = gtk_widget_get_visual (GTK_WIDGET (frames));
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ if (gdk_visual_get_depth(visual) == 32) /* we have ARGB */
+ #else
if (visual->depth == 32) /* we have ARGB */
+ #endif
{
color.pixel = (color.pixel & 0xffffff) &
style->window_background_alpha << 24;
diff --git a/src/ui/menu.c b/src/ui/menu.c
index d98a33d3..2b6dfe83 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -390,10 +390,19 @@ meta_window_menu_new (MetaFrames *frames,
meta_verbose ("Creating %d-workspace menu current space %lu\n",
n_workspaces, active_workspace);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(frames));
+
+ display = GDK_WINDOW_XDISPLAY (window);
+
+ screen = gdk_window_get_screen (window);
+ xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
+ #else
display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
+ #endif
submenu = gtk_menu_new ();
@@ -435,12 +444,20 @@ meta_window_menu_new (MetaFrames *frames,
"workspace",
GINT_TO_POINTER (j));
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ g_signal_connect_data (G_OBJECT (submi),
+ "activate",
+ G_CALLBACK (activate_cb),
+ md,
+ (GClosureNotify) g_free, 0);
+ #else
gtk_signal_connect_full (GTK_OBJECT (submi),
"activate",
G_CALLBACK (activate_cb),
NULL,
md,
g_free, FALSE, FALSE);
+ #endif
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi);
@@ -463,12 +480,20 @@ meta_window_menu_new (MetaFrames *frames,
md->menu = menu;
md->op = menuitem.op;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ g_signal_connect_data (G_OBJECT (mi),
+ "activate",
+ G_CALLBACK (activate_cb),
+ md,
+ (GClosureNotify) g_free, 0);
+ #else
gtk_signal_connect_full (GTK_OBJECT (mi),
"activate",
G_CALLBACK (activate_cb),
NULL,
md,
g_free, FALSE, FALSE);
+ #endif
}
if (mi)
@@ -496,7 +521,11 @@ void meta_window_menu_popup(MetaWindowMenu* menu, int root_x, int root_y, int bu
gtk_menu_popup(GTK_MENU (menu->menu), NULL, NULL, popup_position_func, pt, button, timestamp);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ if (!gtk_widget_get_visible (menu->menu))
+ #else
if (!GTK_MENU_SHELL(menu->menu)->have_xgrab)
+ #endif
{
meta_warning("GtkMenu failed to grab the pointer\n");
}
diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c
index 88262d0f..829b8a75 100644
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
@@ -37,21 +37,44 @@
#include <string.h>
#include "util.h"
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #define parent_class meta_accel_label_parent_class
+ #define GtkObject GtkWidget
+ #define GTK_OBJECT_CLASS GTK_WIDGET_CLASS
+#endif
+
static void meta_accel_label_class_init (MetaAccelLabelClass *klass);
static void meta_accel_label_init (MetaAccelLabel *accel_label);
static void meta_accel_label_destroy (GtkObject *object);
static void meta_accel_label_finalize (GObject *object);
+static void meta_accel_label_update (MetaAccelLabel *accel_label);
+static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void meta_accel_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void meta_accel_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static gboolean meta_accel_label_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static void meta_accel_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gboolean meta_accel_label_expose_event (GtkWidget *widget,
GdkEventExpose *event);
-static void meta_accel_label_update (MetaAccelLabel *accel_label);
-static int meta_accel_label_get_accel_width (MetaAccelLabel *accel_label);
+static GtkLabelClass *parent_class = NULL;
+#endif
-static GtkLabelClass *parent_class = NULL;
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+G_DEFINE_TYPE (MetaAccelLabel, meta_accel_label, GTK_TYPE_LABEL);
+
+#else
GType
meta_accel_label_get_type (void)
@@ -78,9 +101,24 @@ meta_accel_label_get_type (void)
return accel_label_type;
}
+#endif
+
static void
meta_accel_label_class_init (MetaAccelLabelClass *class)
{
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+ gobject_class->finalize = meta_accel_label_finalize;
+
+ widget_class->destroy = meta_accel_label_destroy;
+
+ widget_class->get_preferred_width = meta_accel_label_get_preferred_width;
+ widget_class->get_preferred_height = meta_accel_label_get_preferred_height;
+ widget_class->draw = meta_accel_label_draw;
+ #else
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
@@ -93,6 +131,7 @@ meta_accel_label_class_init (MetaAccelLabelClass *class)
widget_class->size_request = meta_accel_label_size_request;
widget_class->expose_event = meta_accel_label_expose_event;
+ #endif
class->signal_quote1 = g_strdup ("<:");
class->signal_quote2 = g_strdup (":>");
@@ -236,6 +275,34 @@ meta_accel_label_get_accel_width (MetaAccelLabel *accel_label)
(accel_label->accel_string_width ? accel_label->accel_padding : 0));
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static void
+meta_accel_label_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ MetaAccelLabel *accel_label = META_ACCEL_LABEL (widget);
+ PangoLayout *layout;
+ gint width;
+
+ GTK_WIDGET_CLASS (meta_accel_label_parent_class)->get_preferred_width (widget, minimum, natural);
+
+ layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ accel_label->accel_string_width = width;
+
+ g_object_unref (G_OBJECT (layout));
+}
+
+static void
+meta_accel_label_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GTK_WIDGET_CLASS (meta_accel_label_parent_class)->get_preferred_height (widget, minimum, natural);
+}
+#else
+
static void
meta_accel_label_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -254,6 +321,100 @@ meta_accel_label_size_request (GtkWidget *widget,
g_object_unref (G_OBJECT (layout));
}
+#endif
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+meta_accel_label_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaAccelLabel *accel_label = META_ACCEL_LABEL (widget);
+ GtkMisc *misc = GTK_MISC (accel_label);
+ GtkTextDirection direction;
+ int ac_width;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
+
+ direction = gtk_widget_get_direction (widget);
+ ac_width = meta_accel_label_get_accel_width (accel_label);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_preferred_size (widget,
+ &requisition, NULL);
+
+ if (allocation.width >= requisition.width + ac_width)
+ {
+ GtkStyleContext *style;
+ PangoLayout *label_layout;
+ PangoLayout *accel_layout;
+ GtkLabel *label = GTK_LABEL (widget);
+ gint x, y, xpad, ypad;
+ gfloat xalign, yalign;
+
+ label_layout = gtk_label_get_layout (GTK_LABEL (accel_label));
+ gtk_misc_get_alignment (misc, &xalign, &yalign);
+
+ cairo_save (cr);
+
+ /* XXX: Mad hack: We modify the label's width so it renders
+ * properly in its draw function that we chain to. */
+ if (direction == GTK_TEXT_DIR_RTL)
+ cairo_translate (cr, ac_width, 0);
+ if (gtk_label_get_ellipsize (label))
+ pango_layout_set_width (label_layout,
+ pango_layout_get_width (label_layout)
+ - ac_width * PANGO_SCALE);
+
+ allocation.width -= ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
+ if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw)
+ GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw (widget,
+ cr);
+ allocation.width += ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
+ if (gtk_label_get_ellipsize (label))
+ pango_layout_set_width (label_layout,
+ pango_layout_get_width (label_layout)
+ + ac_width * PANGO_SCALE);
+
+ cairo_restore (cr);
+
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+
+ if (direction == GTK_TEXT_DIR_RTL)
+ x = xpad;
+ else
+ x = gtk_widget_get_allocated_width (widget) - xpad - ac_width;
+
+ gtk_label_get_layout_offsets (GTK_LABEL (accel_label), NULL, &y);
+
+ accel_layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
+
+ y = (allocation.height - (requisition.height - ypad * 2)) * yalign + 1.5;
+
+ style = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style,
+ gtk_widget_get_state_flags (widget));
+ gtk_render_layout (gtk_widget_get_style_context (widget),
+ cr,
+ x, y,
+ accel_layout);
+ gtk_style_context_restore (style);
+
+ g_object_unref (accel_layout);
+ }
+ else
+ {
+ if (GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw)
+ GTK_WIDGET_CLASS (meta_accel_label_parent_class)->draw (widget, cr);
+ }
+
+ return FALSE;
+}
+
+#else
+
static gboolean
meta_accel_label_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -327,6 +488,8 @@ meta_accel_label_expose_event (GtkWidget *widget,
return FALSE;
}
+#endif
+
static void
meta_accel_label_update (MetaAccelLabel *accel_label)
{
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 0163c7f5..cb05c2f8 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -30,16 +30,39 @@
static void meta_preview_class_init (MetaPreviewClass *klass);
static void meta_preview_init (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_height(GtkWidget *widget,
+ gint *minimal, gint *natural);
+#endif
+
static void meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req);
static void meta_preview_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean meta_preview_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gboolean meta_preview_expose (GtkWidget *widget,
GdkEventExpose *event);
+#endif
static void meta_preview_finalize (GObject *object);
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
+#define parent_class meta_preview_parent_class
+
+#else
+
static GtkWidgetClass *parent_class;
+
GType
meta_preview_get_type (void)
{
@@ -49,12 +72,12 @@ meta_preview_get_type (void)
{
static const GtkTypeInfo preview_info =
{
- "MetaPreview",
- sizeof (MetaPreview),
- sizeof (MetaPreviewClass),
- (GtkClassInitFunc) meta_preview_class_init,
- (GtkObjectInitFunc) meta_preview_init,
- /* reserved_1 */ NULL,
+ "MetaPreview",
+ sizeof (MetaPreview),
+ sizeof (MetaPreviewClass),
+ (GtkClassInitFunc) meta_preview_class_init,
+ (GtkObjectInitFunc) meta_preview_init,
+ /* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
@@ -65,6 +88,8 @@ meta_preview_get_type (void)
return preview_type;
}
+#endif
+
static void
meta_preview_class_init (MetaPreviewClass *class)
{
@@ -76,8 +101,14 @@ meta_preview_class_init (MetaPreviewClass *class)
gobject_class->finalize = meta_preview_finalize;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = meta_preview_draw;
+ widget_class->get_preferred_width = meta_preview_get_preferred_width;
+ widget_class->get_preferred_height = meta_preview_get_preferred_height;
+ #else
widget_class->expose_event = meta_preview_expose;
widget_class->size_request = meta_preview_size_request;
+ #endif
widget_class->size_allocate = meta_preview_size_allocate;
}
@@ -125,7 +156,11 @@ meta_preview_new (void)
{
MetaPreview *preview;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ preview = g_object_new (META_TYPE_PREVIEW, NULL);
+ #else
preview = gtk_type_new (META_TYPE_PREVIEW);
+ #endif
return GTK_WIDGET (preview);
}
@@ -210,6 +245,75 @@ ensure_info (MetaPreview *preview)
}
}
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static void meta_preview_get_preferred_width(GtkWidget *widget, gint *minimal, gint *natural)
+{
+ GtkRequisition requisition;
+ meta_preview_size_request (widget, &requisition);
+ *minimal = *natural = requisition.width;
+}
+
+static void meta_preview_get_preferred_height(GtkWidget *widget, gint *minimal, gint *natural)
+{
+ GtkRequisition requisition;
+ meta_preview_size_request (widget, &requisition);
+ *minimal = *natural = requisition.height;
+}
+
+
+static gboolean
+meta_preview_draw(GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaPreview *preview = META_PREVIEW (widget);
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ 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;
+
+ if (client_width < 0)
+ client_width = 1;
+ if (client_height < 0)
+ client_height = 1;
+
+ meta_theme_draw_frame (preview->theme,
+ widget,
+ cr,
+ preview->type,
+ preview->flags,
+ client_width, client_height,
+ preview->layout,
+ preview->text_height,
+ &preview->button_layout,
+ button_states,
+ meta_preview_get_mini_icon (),
+ meta_preview_get_icon ());
+
+ cairo_restore (cr);
+ }
+
+ return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
+}
+
+#else
static gboolean
meta_preview_expose (GtkWidget *widget,
@@ -271,6 +375,8 @@ meta_preview_expose (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
+#endif
+
static void
meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req)
@@ -323,7 +429,9 @@ meta_preview_size_allocate (GtkWidget *widget,
ensure_info (preview);
+ #if !GTK_CHECK_VERSION(3, 0, 0)
widget->allocation = *allocation;
+ #endif
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -331,11 +439,11 @@ meta_preview_size_allocate (GtkWidget *widget,
if (child &&
gtk_widget_get_visible (child))
{
- child_allocation.x = widget->allocation.x + border_width + preview->left_width;
- child_allocation.y = widget->allocation.y + border_width + preview->top_height;
+ 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, 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);
+ 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);
gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), &child_allocation);
}
@@ -596,6 +704,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/preview-widget.h b/src/ui/preview-widget.h
index e11a0b81..c19da7cc 100644
--- a/src/ui/preview-widget.h
+++ b/src/ui/preview-widget.h
@@ -24,6 +24,15 @@
#include "theme.h"
#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #include <cairo/cairo.h>
+ #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
+#endif
+
#ifndef META_PREVIEW_WIDGET_H
#define META_PREVIEW_WIDGET_H
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index f740f236..06b8c5af 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -27,6 +27,10 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #define GTK_WIDGET_REALIZED gtk_widget_get_realized
+#endif
+
struct _MetaResizePopup
{
GtkWidget *size_window;
@@ -126,9 +130,15 @@ update_size_window (MetaResizePopup *popup)
if (GTK_WIDGET_REALIZED (popup->size_window))
{
/* using move_resize to avoid jumpiness */
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_window_move_resize (gtk_widget_get_window(GTK_WIDGET(popup->size_window)),
+ x, y,
+ width, height);
+ #else
gdk_window_move_resize (popup->size_window->window,
x, y,
width, height);
+ #endif
}
else
{
@@ -146,7 +156,11 @@ sync_showing (MetaResizePopup *popup)
gtk_widget_show (popup->size_window);
if (popup->size_window && GTK_WIDGET_REALIZED (popup->size_window))
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gdk_window_raise (gtk_widget_get_window(GTK_WIDGET(popup->size_window)));
+ #else
gdk_window_raise (popup->size_window->window);
+ #endif
}
else
{
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index 71319f16..6cee30cd 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -36,6 +36,14 @@
#include <gtk/gtk.h>
#include <math.h>
+#if GTK_CHECK_VERSION(3, 0, 0)
+ #define GTK_WIDGET_VISIBLE gtk_widget_get_visible
+ #define GdkRegion cairo_region_t
+ #define gdk_region_subtract cairo_region_subtract
+ #define gdk_region_destroy cairo_region_destroy
+ #define gdk_region_rectangle cairo_region_create_rectangle
+#endif
+
#define OUTSIDE_SELECT_RECT 2
#define INSIDE_SELECT_RECT 2
@@ -458,6 +466,7 @@ display_entry (MetaTabPopup *popup,
GdkRectangle rect;
GdkRegion *region;
GdkRegion *inner_region;
+ GdkWindow *window;
if (popup->current_selected_entry)
@@ -478,26 +487,33 @@ display_entry (MetaTabPopup *popup,
if (popup->outline)
{
/* Do stuff behind gtk's back */
- gdk_window_hide (popup->outline_window->window);
+ gdk_window_hide (gtk_widget_get_window(popup->outline_window));
meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
rect = te->rect;
rect.x = 0;
rect.y = 0;
- gdk_window_move_resize (popup->outline_window->window,
+ window = gtk_widget_get_window(GTK_WIDGET(popup->outline_window));
+
+ gdk_window_move_resize (window,
te->rect.x, te->rect.y,
te->rect.width, te->rect.height);
- gdk_window_set_background (popup->outline_window->window,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
+ gdk_window_set_background_rgba (window, &black);
+ #else
+ gdk_window_set_background (window,
&popup->outline_window->style->black);
+ #endif
region = gdk_region_rectangle (&rect);
inner_region = gdk_region_rectangle (&te->inner_rect);
gdk_region_subtract (region, inner_region);
gdk_region_destroy (inner_region);
- gdk_window_shape_combine_region (popup->outline_window->window,
+ gdk_window_shape_combine_region (window,
region,
0, 0);
@@ -508,8 +524,12 @@ display_entry (MetaTabPopup *popup,
* we manually set the window as mapped and then manually map it
* with gdk functions.
*/
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_set_mapped (popup->outline_window, TRUE);
+ #else
GTK_WIDGET_SET_FLAGS (popup->outline_window, GTK_MAPPED);
- gdk_window_show_unraised (popup->outline_window->window);
+ #endif
+ gdk_window_show_unraised (window);
}
/* Must be before we handle an expose for the outline window */
@@ -645,8 +665,13 @@ unselect_image (GtkWidget *widget)
}
static void meta_select_image_class_init (MetaSelectImageClass *klass);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean meta_select_image_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gboolean meta_select_image_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+#endif
static GtkImageClass *parent_class;
@@ -684,10 +709,70 @@ meta_select_image_class_init (MetaSelectImageClass *klass)
parent_class = g_type_class_peek (gtk_image_get_type ());
widget_class = GTK_WIDGET_CLASS (klass);
-
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = meta_select_image_draw;
+ #else
widget_class->expose_event = meta_select_image_expose_event;
+ #endif
+}
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+meta_select_image_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (META_SELECT_IMAGE (widget)->selected)
+ {
+ GtkMisc *misc;
+ GtkRequisition requisition;
+ GtkStyleContext *context;
+ GdkRGBA color;
+ int x, y, w, h;
+ gint xpad, ypad;
+ gfloat xalign, yalign;
+
+ misc = GTK_MISC (widget);
+
+ gtk_widget_get_requisition (widget, &requisition);
+ gtk_misc_get_alignment (misc, &xalign, &yalign);
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+
+ x = (allocation.width - (requisition.width - xpad * 2)) * xalign + 0.5;
+ y = (allocation.height - (requisition.height - ypad * 2)) * yalign + 0.5;
+
+ x -= INSIDE_SELECT_RECT + 1;
+ y -= INSIDE_SELECT_RECT + 1;
+
+ w = requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
+ h = requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_set_state (context,
+ gtk_widget_get_state_flags (widget));
+
+ gtk_style_context_lookup_color (context, "color", &color);
+
+ cairo_set_line_width (cr, 2.0);
+ cairo_set_source_rgb (cr, color.red, color.green, color.blue);
+
+ cairo_rectangle (cr, x, y, w + 1, h + 1);
+ cairo_stroke (cr);
+
+ cairo_set_line_width (cr, 1.0);
+ }
+
+ return GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
}
+#else
+
static gboolean
meta_select_image_expose_event (GtkWidget *widget,
GdkEventExpose *event)
@@ -699,15 +784,18 @@ meta_select_image_expose_event (GtkWidget *widget,
GtkStyle *style;
GtkStateType state;
cairo_t *cr;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(widget, &allocation);
misc = GTK_MISC (widget);
- x = (widget->allocation.x * (1.0 - misc->xalign) +
- (widget->allocation.x + widget->allocation.width
+ x = (allocation.x * (1.0 - misc->xalign) +
+ (allocation.x + allocation.width
- (widget->requisition.width - misc->xpad * 2)) *
misc->xalign) + 0.5;
- y = (widget->allocation.y * (1.0 - misc->yalign) +
- (widget->allocation.y + widget->allocation.height
+ y = (allocation.y * (1.0 - misc->yalign) +
+ (allocation.y + allocation.height
- (widget->requisition.height - misc->ypad * 2)) *
misc->yalign) + 0.5;
@@ -719,7 +807,7 @@ meta_select_image_expose_event (GtkWidget *widget,
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window(widget));
cairo_set_line_width (cr, 2.0);
gdk_cairo_set_source_color (cr, &style->fg[state]);
@@ -746,6 +834,8 @@ meta_select_image_expose_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
+#endif
+
#define META_TYPE_SELECT_WORKSPACE (meta_select_workspace_get_type ())
#define META_SELECT_WORKSPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_SELECT_WORKSPACE, MetaSelectWorkspace))
@@ -807,8 +897,13 @@ unselect_workspace (GtkWidget *widget)
static void meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean meta_select_workspace_draw (GtkWidget *widget,
+ cairo_t *cr);
+#else
static gboolean meta_select_workspace_expose_event (GtkWidget *widget,
GdkEventExpose *event);
+#endif
GType
meta_select_workspace_get_type (void)
@@ -846,7 +941,11 @@ meta_select_workspace_class_init (MetaSelectWorkspaceClass *klass)
widget_class = GTK_WIDGET_CLASS (klass);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = meta_select_workspace_draw;
+ #else
widget_class->expose_event = meta_select_workspace_expose_event;
+ #endif
}
/**
@@ -882,6 +981,96 @@ meta_convert_meta_to_wnck (MetaWindow *window, MetaScreen *screen)
return wnck_window;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+meta_select_workspace_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaWorkspace *workspace;
+ WnckWindowDisplayInfo *windows;
+ GtkAllocation allocation;
+ int i, n_windows;
+ GList *tmp, *list;
+
+ workspace = META_SELECT_WORKSPACE (widget)->workspace;
+
+ list = meta_stack_list_windows (workspace->screen->stack, workspace);
+ n_windows = g_list_length (list);
+ windows = g_new (WnckWindowDisplayInfo, n_windows);
+
+ tmp = list;
+ i = 0;
+ while (tmp != NULL)
+ {
+ MetaWindow *window;
+ gboolean ignoreable_sticky;
+
+ window = tmp->data;
+
+ ignoreable_sticky = window->on_all_workspaces &&
+ workspace != workspace->screen->active_workspace;
+
+ if (window->skip_pager ||
+ !meta_window_showing_on_its_workspace (window) ||
+ window->unmaps_pending ||
+ ignoreable_sticky)
+ {
+ --n_windows;
+ }
+ else
+ {
+ windows[i] = meta_convert_meta_to_wnck (window, workspace->screen);
+ i++;
+ }
+ tmp = tmp->next;
+ }
+
+ g_list_free (list);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ wnck_draw_workspace (widget,
+ cr,
+ SELECT_OUTLINE_WIDTH,
+ SELECT_OUTLINE_WIDTH,
+ allocation.width - SELECT_OUTLINE_WIDTH * 2,
+ allocation.height - SELECT_OUTLINE_WIDTH * 2,
+ workspace->screen->rect.width,
+ workspace->screen->rect.height,
+ NULL,
+ (workspace->screen->active_workspace == workspace),
+ windows,
+ n_windows);
+
+ g_free (windows);
+
+ if (META_SELECT_WORKSPACE (widget)->selected)
+ {
+ GtkStyleContext *context;
+ GdkRGBA color;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_set_state (context,
+ gtk_widget_get_state_flags (widget));
+
+ gtk_style_context_lookup_color (context, "color", &color);
+
+ cairo_set_line_width (cr, SELECT_OUTLINE_WIDTH);
+ cairo_set_source_rgb (cr, color.red, color.green, color.blue);
+
+ cairo_rectangle (cr,
+ SELECT_OUTLINE_WIDTH / 2.0, SELECT_OUTLINE_WIDTH / 2.0,
+ allocation.width - SELECT_OUTLINE_WIDTH,
+ allocation.height - SELECT_OUTLINE_WIDTH);
+ cairo_stroke (cr);
+ }
+
+ return TRUE;
+}
+
+#else
static gboolean
meta_select_workspace_expose_event (GtkWidget *widget,
@@ -893,6 +1082,9 @@ meta_select_workspace_expose_event (GtkWidget *widget,
cairo_t *cr;
int i, n_windows;
GList *tmp, *list;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation(widget, &allocation);
workspace = META_SELECT_WORKSPACE (widget)->workspace;
@@ -930,11 +1122,11 @@ meta_select_workspace_expose_event (GtkWidget *widget,
g_list_free (list);
wnck_draw_workspace (widget,
- widget->window,
+ gtk_widget_get_window(widget),
SELECT_OUTLINE_WIDTH,
SELECT_OUTLINE_WIDTH,
- widget->allocation.width - SELECT_OUTLINE_WIDTH * 2,
- widget->allocation.height - SELECT_OUTLINE_WIDTH * 2,
+ allocation.width - SELECT_OUTLINE_WIDTH * 2,
+ allocation.height - SELECT_OUTLINE_WIDTH * 2,
workspace->screen->rect.width,
workspace->screen->rect.height,
NULL,
@@ -947,7 +1139,7 @@ meta_select_workspace_expose_event (GtkWidget *widget,
if (META_SELECT_WORKSPACE (widget)->selected)
{
style = gtk_widget_get_style (widget);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window(widget));
gdk_cairo_set_source_color (cr,
&style->fg[gtk_widget_get_state (widget)]);
@@ -955,8 +1147,8 @@ meta_select_workspace_expose_event (GtkWidget *widget,
cairo_rectangle (cr,
SELECT_OUTLINE_WIDTH / 2.0, SELECT_OUTLINE_WIDTH / 2.0,
- widget->allocation.width - SELECT_OUTLINE_WIDTH,
- widget->allocation.height - SELECT_OUTLINE_WIDTH);
+ allocation.width - SELECT_OUTLINE_WIDTH,
+ allocation.height - SELECT_OUTLINE_WIDTH);
cairo_stroke (cr);
cairo_destroy (cr);
@@ -965,3 +1157,4 @@ meta_select_workspace_expose_event (GtkWidget *widget,
return TRUE;
}
+#endif \ No newline at end of file
diff --git a/src/ui/theme.c b/src/ui/theme.c
index d5efce8e..655c63f3 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3402,25 +3402,36 @@ static void
meta_draw_op_draw_with_env (const MetaDrawOp *op,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle rect,
MetaPositionExprEnv *env)
{
GdkColor color;
- cairo_t *cr;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save(cr);
+ gtk_style_context_save(style_gtk);
+ #else
+ cairo_t *cr;
cr = gdk_cairo_create (drawable);
+ #endif
cairo_set_line_width (cr, 1.0);
+ #if !GTK_CHECK_VERSION(3, 0, 0)
if (clip)
{
gdk_cairo_rectangle (cr, clip);
cairo_clip (cr);
}
-
+ #endif
+
switch (op->type)
{
case META_DRAW_LINE:
@@ -3686,6 +3697,34 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.gtk_arrow.width, env);
rheight = parse_size_unchecked (op->data.gtk_arrow.height, env);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+
+ double size = MAX(rwidth, rheight), angle = 0;
+
+ switch (op->data.gtk_arrow.arrow)
+ {
+ case GTK_ARROW_UP:
+ angle = 0;
+ break;
+ case GTK_ARROW_RIGHT:
+ angle = M_PI / 2;
+ break;
+ case GTK_ARROW_DOWN:
+ angle = M_PI;
+ break;
+ case GTK_ARROW_LEFT:
+ angle = 3 * M_PI / 2;
+ break;
+ case GTK_ARROW_NONE:
+ return;
+ }
+
+ gtk_style_context_set_state (style_gtk,
+ state_flags_from_gtk_state (op->data.gtk_arrow.state));
+ gtk_render_arrow (style_gtk, cr, angle, rx, ry, size);
+
+ #else
+
gtk_paint_arrow (style_gtk,
drawable,
op->data.gtk_arrow.state,
@@ -3696,6 +3735,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
op->data.gtk_arrow.arrow,
op->data.gtk_arrow.filled,
rx, ry, rwidth, rheight);
+ #endif
}
break;
@@ -3708,6 +3748,12 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.gtk_box.width, env);
rheight = parse_size_unchecked (op->data.gtk_box.height, env);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_style_context_set_state (style_gtk,
+ state_flags_from_gtk_state (op->data.gtk_box.state));
+ gtk_render_background (style_gtk, cr, rx, ry, rwidth, rheight);
+ gtk_render_frame (style_gtk, cr, rx, ry, rwidth, rheight);
+ #else
gtk_paint_box (style_gtk,
drawable,
op->data.gtk_box.state,
@@ -3716,6 +3762,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
widget,
"marco",
rx, ry, rwidth, rheight);
+ #endif
}
break;
@@ -3727,6 +3774,11 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
ry1 = parse_y_position_unchecked (op->data.gtk_vline.y1, env);
ry2 = parse_y_position_unchecked (op->data.gtk_vline.y2, env);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_style_context_set_state (style_gtk,
+ state_flags_from_gtk_state (op->data.gtk_vline.state));
+ gtk_render_line (style_gtk, cr, rx, ry1, rx, ry2);
+ #else
gtk_paint_vline (style_gtk,
drawable,
op->data.gtk_vline.state,
@@ -3734,6 +3786,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
widget,
"marco",
ry1, ry2, rx);
+ #endif
}
break;
@@ -3787,8 +3840,13 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
d_rect.height = parse_size_unchecked (op->data.op_list.height, env);
meta_draw_op_list_draw_with_style (op->data.op_list.op_list,
- style_gtk, widget, drawable, clip, info,
- d_rect);
+ style_gtk, widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, clip,
+ #endif
+ info, d_rect);
}
break;
@@ -3796,7 +3854,9 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
{
int rx, ry, rwidth, rheight;
int tile_xoffset, tile_yoffset;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
GdkRectangle new_clip;
+ #endif
MetaRectangle tile;
rx = parse_x_position_unchecked (op->data.tile.x, env);
@@ -3804,6 +3864,41 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
rwidth = parse_size_unchecked (op->data.tile.width, env);
rheight = parse_size_unchecked (op->data.tile.height, env);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save (cr);
+
+ cairo_rectangle (cr, rx, ry, rwidth, rheight);
+ cairo_clip (cr);
+
+ tile_xoffset = parse_x_position_unchecked (op->data.tile.tile_xoffset, env);
+ tile_yoffset = parse_y_position_unchecked (op->data.tile.tile_yoffset, env);
+ /* tile offset should not include x/y */
+ tile_xoffset -= rect.x;
+ tile_yoffset -= rect.y;
+
+ tile.width = parse_size_unchecked (op->data.tile.tile_width, env);
+ tile.height = parse_size_unchecked (op->data.tile.tile_height, env);
+
+ tile.x = rx - tile_xoffset;
+
+ while (tile.x < (rx + rwidth))
+ {
+ tile.y = ry - tile_yoffset;
+ while (tile.y < (ry + rheight))
+ {
+ meta_draw_op_list_draw_with_style (op->data.tile.op_list,
+ style_gtk, widget, cr, info,
+ tile);
+
+ tile.y += tile.height;
+ }
+
+ tile.x += tile.width;
+ }
+ cairo_restore (cr);
+
+ #else
+
new_clip.x = rx;
new_clip.y = ry;
new_clip.width = rwidth;
@@ -3838,6 +3933,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
tile.x += tile.width;
}
}
+ #endif
}
break;
}
@@ -3849,18 +3945,29 @@ void
meta_draw_op_draw_with_style (const MetaDrawOp *op,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle logical_region)
{
MetaPositionExprEnv env;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
+ #endif
fill_env (&env, info, logical_region);
- meta_draw_op_draw_with_env (op, style_gtk, widget, drawable, clip,
+ meta_draw_op_draw_with_env (op, style_gtk, widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, clip,
+ #endif
info, logical_region,
&env);
@@ -3869,13 +3976,22 @@ meta_draw_op_draw_with_style (const MetaDrawOp *op,
void
meta_draw_op_draw (const MetaDrawOp *op,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle logical_region)
{
meta_draw_op_draw_with_style (op, gtk_widget_get_style (widget), widget,
- drawable, clip, info, logical_region);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, clip,
+ #endif
+ info, logical_region);
}
MetaDrawOpList*
@@ -3929,17 +4045,27 @@ void
meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle rect)
{
+ /* BOOKMARK */
+
int i;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
GdkRectangle active_clip;
GdkRectangle orig_clip;
+ #endif
MetaPositionExprEnv env;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
+ #endif
if (op_list->n_ops == 0)
return;
@@ -3957,6 +4083,10 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
* evaluated), we make an array of those, and then fold
* adjacent items when possible.
*/
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save(cr);
+ #else
if (clip)
{
orig_clip = *clip;
@@ -3970,11 +4100,36 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
}
active_clip = orig_clip;
+ #endif
for (i = 0; i < op_list->n_ops; i++)
{
MetaDrawOp *op = op_list->ops[i];
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ if (op->type == META_DRAW_CLIP)
+ {
+ cairo_restore (cr);
+
+ cairo_rectangle (cr,
+ parse_x_position_unchecked (op->data.clip.x, &env),
+ parse_y_position_unchecked (op->data.clip.y, &env),
+ parse_size_unchecked (op->data.clip.width, &env),
+ parse_size_unchecked (op->data.clip.height, &env));
+ cairo_clip (cr);
+
+ cairo_save (cr);
+ }
+ else if (gdk_cairo_get_clip_rectangle (cr, NULL))
+ {
+ meta_draw_op_draw_with_env (op,
+ style_gtk, widget, cr, info,
+ rect,
+ &env);
+ }
+
+ #else
+
if (op->type == META_DRAW_CLIP)
{
active_clip.x = parse_x_position_unchecked (op->data.clip.x, &env);
@@ -3992,20 +4147,34 @@ meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
rect,
&env);
}
+ #endif
}
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_restore(cr);
+ #endif
}
void
meta_draw_op_list_draw (const MetaDrawOpList *op_list,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle rect)
{
meta_draw_op_list_draw_with_style (op_list, gtk_widget_get_style (widget), widget,
- drawable, clip, info, rect);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, clip,
+ #endif
+ info, rect);
}
void
@@ -4313,10 +4482,14 @@ void
meta_frame_style_draw_with_style (MetaFrameStyle *style,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
int x_offset,
int y_offset,
const GdkRectangle *clip,
+ #endif
const MetaFrameGeometry *fgeom,
int client_width,
int client_height,
@@ -4326,6 +4499,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
GdkPixbuf *mini_icon,
GdkPixbuf *icon)
{
+ /* BOOKMARK */
int i, j;
GdkRectangle titlebar_rect;
GdkRectangle left_titlebar_edge;
@@ -4336,7 +4510,9 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
PangoRectangle extents;
MetaDrawInfo draw_info;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
g_return_if_fail (style_gtk->colormap == gdk_drawable_get_colormap (drawable));
+ #endif
titlebar_rect.x = 0;
titlebar_rect.y = 0;
@@ -4394,7 +4570,9 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
while (i < META_FRAME_PIECE_LAST)
{
GdkRectangle rect;
+ #if !GTK_CHECK_VERSION(3, 0, 0)
GdkRectangle combined_clip;
+ #endif
switch ((MetaFramePiece) i)
{
@@ -4461,6 +4639,43 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
break;
}
+ #if GTK_CHECK_VERSION(3, 0, 0)
+
+ cairo_save (cr);
+
+ gdk_cairo_rectangle (cr, &rect);
+ cairo_clip (cr);
+
+ if (gdk_cairo_get_clip_rectangle (cr, NULL))
+ {
+ MetaDrawOpList *op_list;
+ MetaFrameStyle *parent;
+
+ parent = style;
+ op_list = NULL;
+ while (parent && op_list == NULL)
+ {
+ op_list = parent->pieces[i];
+ parent = parent->parent;
+ }
+
+ if (op_list)
+ {
+ MetaRectangle m_rect;
+ m_rect = meta_rect (rect.x, rect.y, rect.width, rect.height);
+ meta_draw_op_list_draw_with_style (op_list,
+ style_gtk,
+ widget,
+ cr,
+ &draw_info,
+ m_rect);
+ }
+ }
+
+ cairo_restore (cr);
+
+ #else
+
rect.x += x_offset;
rect.y += y_offset;
@@ -4498,8 +4713,70 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
}
}
+ #endif
+
/* Draw buttons just before overlay */
+ #if GTK_CHECK_VERSION(3, 0, 0)
+
+ if ((i + 1) == META_FRAME_PIECE_OVERLAY)
+ {
+ MetaDrawOpList *op_list;
+ int middle_bg_offset;
+
+ middle_bg_offset = 0;
+ 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);
+
+ if (op_list)
+ {
+ cairo_save (cr);
+ gdk_cairo_rectangle (cr, &rect);
+ cairo_clip (cr);
+
+ if (gdk_cairo_get_clip_rectangle (cr, NULL))
+ {
+ MetaRectangle m_rect;
+
+ m_rect = meta_rect (rect.x, rect.y,
+ rect.width, rect.height);
+
+ meta_draw_op_list_draw_with_style (op_list,
+ style_gtk,
+ widget,
+ cr,
+ &draw_info,
+ m_rect);
+ }
+
+ cairo_restore (cr);
+ }
+
+ /* MIDDLE_BACKGROUND type may get drawn more than once */
+ if ((j == META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND ||
+ j == META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND) &&
+ middle_bg_offset < MAX_MIDDLE_BACKGROUNDS)
+ {
+ ++middle_bg_offset;
+ }
+ else
+ {
+ middle_bg_offset = 0;
+ ++j;
+ }
+ }
+ }
+
+ #else
+
if ((i + 1) == META_FRAME_PIECE_OVERLAY)
{
int middle_bg_offset;
@@ -4556,6 +4833,8 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
}
}
+ #endif
+
++i;
}
}
@@ -4563,10 +4842,14 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
void
meta_frame_style_draw (MetaFrameStyle *style,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
int x_offset,
int y_offset,
const GdkRectangle *clip,
+ #endif
const MetaFrameGeometry *fgeom,
int client_width,
int client_height,
@@ -4577,8 +4860,12 @@ meta_frame_style_draw (MetaFrameStyle *style,
GdkPixbuf *icon)
{
meta_frame_style_draw_with_style (style, gtk_widget_get_style (widget), widget,
- drawable, x_offset, y_offset,
- clip, fgeom, client_width, client_height,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, x_offset, y_offset, clip,
+ #endif
+ fgeom, client_width, client_height,
title_layout, text_height,
button_states, mini_icon, icon);
}
@@ -5133,10 +5420,14 @@ void
meta_theme_draw_frame_with_style (MetaTheme *theme,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
MetaFrameType type,
MetaFrameFlags flags,
int client_width,
@@ -5170,9 +5461,11 @@ meta_theme_draw_frame_with_style (MetaTheme *theme,
meta_frame_style_draw_with_style (style,
style_gtk,
widget,
- drawable,
- x_offset, y_offset,
- clip,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, x_offset, y_offset, clip,
+ #endif
&fgeom,
client_width, client_height,
title_layout,
@@ -5184,10 +5477,14 @@ meta_theme_draw_frame_with_style (MetaTheme *theme,
void
meta_theme_draw_frame (MetaTheme *theme,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
MetaFrameType type,
MetaFrameFlags flags,
int client_width,
@@ -5200,8 +5497,12 @@ meta_theme_draw_frame (MetaTheme *theme,
GdkPixbuf *icon)
{
meta_theme_draw_frame_with_style (theme, gtk_widget_get_style (widget), widget,
- drawable, clip, x_offset, y_offset, type,flags,
- client_width, client_height,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, clip, x_offset, y_offset,
+ #endif
+ type, flags, client_width, client_height,
title_layout, text_height,
button_layout, button_states,
mini_icon, icon);
@@ -5210,10 +5511,14 @@ meta_theme_draw_frame (MetaTheme *theme,
void
meta_theme_draw_frame_by_name (MetaTheme *theme,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
const gchar *style_name,
MetaFrameFlags flags,
int client_width,
@@ -5244,9 +5549,11 @@ meta_theme_draw_frame_by_name (MetaTheme *theme,
meta_frame_style_draw (style,
widget,
- drawable,
- x_offset, y_offset,
- clip,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cr,
+ #else
+ drawable, x_offset, y_offset, clip,
+ #endif
&fgeom,
client_width, client_height,
title_layout,
diff --git a/src/ui/theme.h b/src/ui/theme.h
index f7214e9b..30cf7ade 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -897,8 +897,12 @@ MetaDrawOp* meta_draw_op_new (MetaDrawType type);
void meta_draw_op_free (MetaDrawOp *op);
void meta_draw_op_draw (const MetaDrawOp *op,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
/* logical region being drawn */
MetaRectangle logical_region);
@@ -906,8 +910,12 @@ void meta_draw_op_draw (const MetaDrawOp *op,
void meta_draw_op_draw_with_style (const MetaDrawOp *op,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
/* logical region being drawn */
MetaRectangle logical_region);
@@ -917,15 +925,23 @@ void meta_draw_op_list_ref (MetaDrawOpList *op_list);
void meta_draw_op_list_unref (MetaDrawOpList *op_list);
void meta_draw_op_list_draw (const MetaDrawOpList *op_list,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle rect);
void meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
+ #endif
const MetaDrawInfo *info,
MetaRectangle rect);
void meta_draw_op_list_append (MetaDrawOpList *op_list,
@@ -955,10 +971,14 @@ void meta_frame_style_unref (MetaFrameStyle *style);
void meta_frame_style_draw (MetaFrameStyle *style,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
int x_offset,
int y_offset,
const GdkRectangle *clip,
+ #endif
const MetaFrameGeometry *fgeom,
int client_width,
int client_height,
@@ -972,10 +992,14 @@ void meta_frame_style_draw (MetaFrameStyle *style,
void meta_frame_style_draw_with_style (MetaFrameStyle *style,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
int x_offset,
int y_offset,
const GdkRectangle *clip,
+ #endif
const MetaFrameGeometry *fgeom,
int client_width,
int client_height,
@@ -1020,10 +1044,14 @@ double meta_theme_get_title_scale (MetaTheme *theme,
void meta_theme_draw_frame (MetaTheme *theme,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
MetaFrameType type,
MetaFrameFlags flags,
int client_width,
@@ -1037,10 +1065,14 @@ void meta_theme_draw_frame (MetaTheme *theme,
void meta_theme_draw_frame_by_name (MetaTheme *theme,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
const gchar *style_name,
MetaFrameFlags flags,
int client_width,
@@ -1055,10 +1087,14 @@ void meta_theme_draw_frame_by_name (MetaTheme *theme,
void meta_theme_draw_frame_with_style (MetaTheme *theme,
GtkStyle *style_gtk,
GtkWidget *widget,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_t *cr,
+ #else
GdkDrawable *drawable,
const GdkRectangle *clip,
int x_offset,
int y_offset,
+ #endif
MetaFrameType type,
MetaFrameFlags flags,
int client_width,
diff --git a/src/ui/themewidget.c b/src/ui/themewidget.c
index 3489618a..938248bd 100644
--- a/src/ui/themewidget.c
+++ b/src/ui/themewidget.c
@@ -34,11 +34,28 @@ static void meta_area_class_init (MetaAreaClass *klass);
static void meta_area_init (MetaArea *area);
static void meta_area_size_request (GtkWidget *widget,
GtkRequisition *req);
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean meta_area_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void meta_area_get_preferred_height (GtkWidget *widget,
+ gint *minimal,
+ gint *natural);
+static void meta_area_get_preferred_width (GtkWidget *widget,
+ gint *minimal,
+ gint *natural);
+#else
static gint meta_area_expose (GtkWidget *widget,
GdkEventExpose *event);
+#endif
static void meta_area_finalize (GObject *object);
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+G_DEFINE_TYPE (MetaArea, meta_area, GTK_TYPE_MISC);
+
+#else
+
static GtkMiscClass *parent_class;
GType
@@ -66,35 +83,49 @@ meta_area_get_type (void)
return area_type;
}
+#endif
+
static void
meta_area_class_init (MetaAreaClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- GtkObjectClass UNUSED_VARIABLE *object_class;
GtkWidgetClass *widget_class;
- object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = g_type_class_peek (gtk_misc_get_type ());
gobject_class->finalize = meta_area_finalize;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->draw = meta_area_draw;
+ widget_class->get_preferred_width = meta_area_get_preferred_width;
+ widget_class->get_preferred_height = meta_area_get_preferred_height;
+ #else
widget_class->expose_event = meta_area_expose;
widget_class->size_request = meta_area_size_request;
+ #endif
}
static void
meta_area_init (MetaArea *area)
{
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ gtk_widget_set_has_window (GTK_WIDGET(area), FALSE);
+ #else
GTK_WIDGET_SET_FLAGS (area, GTK_NO_WINDOW);
+ #endif
}
GtkWidget*
meta_area_new (void)
{
MetaArea *area;
-
+
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ area = g_object_new (META_TYPE_AREA, NULL);
+ #else
area = gtk_type_new (META_TYPE_AREA);
+ #endif
return GTK_WIDGET (area);
}
@@ -112,6 +143,60 @@ meta_area_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static gboolean
+meta_area_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ MetaArea *area;
+ GtkMisc *misc;
+ gint x, y;
+ gfloat xalign, yalign;
+ gint xpad, ypad;
+ GtkAllocation allocation;
+ GtkRequisition req;
+
+ g_return_val_if_fail (META_IS_AREA (widget), FALSE);
+
+ if (gtk_widget_is_drawable (widget))
+ {
+ area = META_AREA (widget);
+ misc = GTK_MISC (widget);
+
+ gtk_widget_get_allocation(widget, &allocation);
+ gtk_widget_get_requisition(widget, &req);
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ gtk_misc_get_alignment(misc, &xalign, &yalign);
+ else
+ {
+ gtk_misc_get_alignment(misc, &xalign, &yalign);
+ xalign = 1.0 - xalign;
+ }
+
+ gtk_misc_get_padding(misc, &xpad, &ypad);
+
+
+ x = floor (allocation.x + xpad
+ + ((allocation.width - req.width) * xalign)
+ + 0.5);
+ y = floor (allocation.y + ypad
+ + ((allocation.height - req.height) * yalign)
+ + 0.5);
+
+ if (area->draw_func)
+ {
+ (* area->draw_func) (area, cr,
+ area->user_data);
+ }
+ }
+
+ return FALSE;
+}
+
+#else
+
static gint
meta_area_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -151,6 +236,8 @@ meta_area_expose (GtkWidget *widget,
return FALSE;
}
+#endif
+
static void
meta_area_size_request (GtkWidget *widget,
GtkRequisition *req)
@@ -169,10 +256,42 @@ meta_area_size_request (GtkWidget *widget,
}
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+
+static void
+meta_area_get_preferred_width (GtkWidget *widget,
+ gint *minimal,
+ gint *natural)
+{
+ GtkRequisition requisition;
+
+ meta_area_size_request (widget, &requisition);
+
+ *minimal = *natural = requisition.width;
+}
+
+static void
+meta_area_get_preferred_height (GtkWidget *widget,
+ gint *minimal,
+ gint *natural)
+{
+ GtkRequisition requisition;
+
+ meta_area_size_request (widget, &requisition);
+
+ *minimal = *natural = requisition.height;
+}
+
+#endif
+
void
meta_area_setup (MetaArea *area,
MetaAreaSizeFunc size_func,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ MetaAreaDrawFunc draw_func,
+ #else
MetaAreaExposeFunc expose_func,
+ #endif
void *user_data,
GDestroyNotify dnotify)
{
@@ -180,7 +299,11 @@ meta_area_setup (MetaArea *area,
(* area->dnotify) (area->user_data);
area->size_func = size_func;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ area->draw_func = draw_func;
+ #else
area->expose_func = expose_func;
+ #endif
area->user_data = user_data;
area->dnotify = dnotify;
diff --git a/src/ui/themewidget.h b/src/ui/themewidget.h
index 79f10e65..940b44fc 100644
--- a/src/ui/themewidget.h
+++ b/src/ui/themewidget.h
@@ -42,19 +42,30 @@ typedef void (* MetaAreaSizeFunc) (MetaArea *area,
int *width,
int *height,
void *user_data);
-
+#if GTK_CHECK_VERSION(3, 0, 0)
+typedef void (* MetaAreaDrawFunc) (MetaArea *area,
+ cairo_t *cr,
+ void *user_data);
+#else
typedef void (* MetaAreaExposeFunc) (MetaArea *area,
GdkEventExpose *event,
int x_offset,
int y_offset,
void *user_data);
+#endif
+
+#define parent_class meta_area_parent_class
struct _MetaArea
{
GtkMisc misc;
MetaAreaSizeFunc size_func;
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ MetaAreaDrawFunc draw_func;
+ #else
MetaAreaExposeFunc expose_func;
+ #endif
void *user_data;
GDestroyNotify dnotify;
};
@@ -70,7 +81,11 @@ GtkWidget* meta_area_new (void);
void meta_area_setup (MetaArea *area,
MetaAreaSizeFunc size_func,
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ MetaAreaDrawFunc draw_func,
+ #else
MetaAreaExposeFunc expose_func,
+ #endif
void *user_data,
GDestroyNotify dnotify);
diff --git a/src/ui/ui.c b/src/ui/ui.c
index e58035bf..42d3dc57 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -304,7 +304,9 @@ meta_ui_create_frame_window (MetaUI *ui,
gint attributes_mask;
GdkWindow *window;
GdkVisual *visual;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *cmap = gdk_screen_get_default_colormap (screen);
+#endif
/* Default depth/visual handles clients with weird visuals; they can
* always be children of the root depth/visual obviously, but
@@ -317,7 +319,9 @@ meta_ui_create_frame_window (MetaUI *ui,
{
visual = gdk_x11_screen_lookup_visual (screen,
XVisualIDFromVisual (xvisual));
+#if !GTK_CHECK_VERSION (3, 0, 0)
cmap = gdk_colormap_new (visual, FALSE);
+#endif
}
attrs.title = NULL;
@@ -333,7 +337,9 @@ meta_ui_create_frame_window (MetaUI *ui,
attrs.y = y;
attrs.wclass = GDK_INPUT_OUTPUT;
attrs.visual = visual;
+#if !GTK_CHECK_VERSION (3, 0, 0)
attrs.colormap = cmap;
+#endif
attrs.window_type = GDK_WINDOW_CHILD;
attrs.cursor = NULL;
attrs.wmclass_name = NULL;
@@ -343,7 +349,11 @@ meta_ui_create_frame_window (MetaUI *ui,
attrs.width = width;
attrs.height = height;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+#else
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+#endif
window =
gdk_window_new (gdk_screen_get_root_window(screen),
@@ -580,6 +590,7 @@ meta_image_window_set (MetaImageWindow *iw,
gdk_window_clear (iw->window->window);
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static GdkColormap*
get_cmap (GdkPixmap *pixmap)
{
@@ -616,6 +627,7 @@ get_cmap (GdkPixmap *pixmap)
return cmap;
}
+#endif
GdkPixbuf*
meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
@@ -629,7 +641,9 @@ meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
{
GdkDrawable *drawable;
GdkPixbuf *retval;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *cmap;
+#endif
retval = NULL;
@@ -640,7 +654,9 @@ meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
else
drawable = gdk_window_foreign_new (xwindow);
+#if !GTK_CHECK_VERSION (3, 0, 0)
cmap = get_cmap (drawable);
+#endif
retval = gdk_pixbuf_get_from_drawable (dest,
drawable,
@@ -649,8 +665,10 @@ meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
dest_x, dest_y,
width, height);
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (cmap)
g_object_unref (G_OBJECT (cmap));
+#endif
g_object_unref (G_OBJECT (drawable));
return retval;
@@ -668,10 +686,14 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
{
GdkDrawable *drawable;
GdkPixbuf *retval;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *cmap;
+#endif
retval = NULL;
+#if !GTK_CHECK_VERSION (3, 0, 0)
cmap = NULL;
+#endif
drawable = gdk_xid_table_lookup (xpixmap);
@@ -691,8 +713,10 @@ meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
dest_x, dest_y,
width, height);
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (cmap)
g_object_unref (G_OBJECT (cmap));
+#endif
if (drawable)
g_object_unref (G_OBJECT (drawable));
@@ -1083,7 +1107,9 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
GdkPixmap* gpmap;
GdkScreen* screen;
GdkPixbuf* pixbuf;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap* cmap;
+#endif
int width;
int height;
int depth;
@@ -1091,15 +1117,16 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
gpmap = gdk_pixmap_foreign_new(pmap);
screen = gdk_drawable_get_screen(gpmap);
- #if GTK_CHECK_VERSION(3, 0, 0)
- width = gdk_window_get_width(GDK_WINDOW(gpmap));
- height = gdk_window_get_height(GDK_WINDOW(gpmap));
- #else
- gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
- #endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ width = gdk_window_get_width(GDK_WINDOW(gpmap));
+ height = gdk_window_get_height(GDK_WINDOW(gpmap));
+#else
+ gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
+#endif
depth = gdk_drawable_get_depth(GDK_DRAWABLE(gpmap));
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (depth <= 24)
{
cmap = gdk_screen_get_system_colormap(screen);
@@ -1108,6 +1135,7 @@ GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
{
cmap = gdk_screen_get_rgba_colormap(screen);
}
+#endif
pixbuf = gdk_pixbuf_get_from_drawable(NULL, gpmap, cmap, 0, 0, 0, 0, width, height);
diff --git a/src/wm-tester/Makefile.am b/src/wm-tester/Makefile.am
index 3d35c741..e719bdb6 100644
--- a/src/wm-tester/Makefile.am
+++ b/src/wm-tester/Makefile.am
@@ -1,5 +1,5 @@
-INCLUDES=@MARCO_CFLAGS@
+AM_CPPFLAGS=@MARCO_CFLAGS@
wm_tester_SOURCES= \
main.c
@@ -22,4 +22,4 @@ wm_tester_LDADD= @MARCO_LIBS@
test_gravity_LDADD= @MARCO_LIBS@
test_resizing_LDADD= @MARCO_LIBS@
test_size_hints_LDADD= @MARCO_LIBS@
-focus_window_LDADD= @MARCO_LIBS@ \ No newline at end of file
+focus_window_LDADD= @MARCO_LIBS@
diff --git a/src/wm-tester/main.c b/src/wm-tester/main.c
index 50bb85fc..48a23a06 100644
--- a/src/wm-tester/main.c
+++ b/src/wm-tester/main.c
@@ -120,6 +120,10 @@ evil_timeout (gpointer data)
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ #if GTK_CHECK_VERSION(3, 0, 0)
+ #define gtk_widget_set_uposition gtk_window_move
+ #endif
+
gtk_widget_set_uposition (w,
g_random_int_range (0,
gdk_screen_width ()),