summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac11
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/POTFILES.skip2
-rw-r--r--src/50-marco-global-key.xml.in3
-rw-r--r--src/compositor/compositor-private.h3
-rw-r--r--src/compositor/compositor-xrender.c259
-rw-r--r--src/compositor/compositor.c4
-rw-r--r--src/core/display-private.h5
-rw-r--r--src/core/display.c40
-rw-r--r--src/core/edge-resistance.c18
-rw-r--r--src/core/keybindings.c8
-rw-r--r--src/core/place.c52
-rw-r--r--src/core/prefs.c16
-rw-r--r--src/core/screen-private.h3
-rw-r--r--src/core/window-private.h3
-rw-r--r--src/core/window.c25
-rw-r--r--src/core/workspace.c18
-rw-r--r--src/core/workspace.h3
-rw-r--r--src/core/xprops.c40
-rw-r--r--src/include/all-keybindings.h3
-rw-r--r--src/include/common.h10
-rw-r--r--src/include/display.h3
-rw-r--r--src/include/prefs.h5
-rw-r--r--src/include/ui.h17
-rw-r--r--src/org.mate.marco.gschema.xml15
-rw-r--r--src/tools/marco-window-demo.c344
-rw-r--r--src/ui/draw-workspace.c11
-rw-r--r--src/ui/fixedtip.c2
-rw-r--r--src/ui/frames.c32
-rw-r--r--src/ui/menu.c29
-rw-r--r--src/ui/metaaccellabel.c43
-rw-r--r--src/ui/preview-widget.c19
-rw-r--r--src/ui/tabpopup.c52
-rw-r--r--src/ui/theme-viewer.c138
-rw-r--r--src/ui/theme.c129
-rw-r--r--src/ui/theme.h10
-rw-r--r--src/ui/tile-preview.c25
-rw-r--r--src/ui/ui.c193
-rw-r--r--src/wm-tester/main.c8
39 files changed, 797 insertions, 805 deletions
diff --git a/configure.ac b/configure.ac
index 7a31f56a..a637fbd3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,11 +22,9 @@ GETTEXT_PACKAGE=marco
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Name of default gettext domain])
-IT_PROG_INTLTOOL([0.34.90])
+IT_PROG_INTLTOOL([0.50.1])
AC_PROG_CC
-AC_ISC_POSIX
AC_HEADER_STDC
-AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
#### Integer sizes
@@ -124,7 +122,6 @@ case "$with_gtk" in
3.0) GTK_API_VERSION=3.0
GTK_MIN_VERSION=2.90.0
CANBERRA_GTK=libcanberra-gtk3
- MATE_DESKTOP_VERSION=1.9.3
;;
esac
AM_CONDITIONAL([HAVE_GTK2], [test "x$with_gtk" = "x2.0"])
@@ -134,10 +131,6 @@ GIO_MIN_VERSION=2.25.10
MARCO_PC_MODULES="gtk+-$GTK_API_VERSION >= $GTK_MIN_VERSION gio-2.0 >= $GIO_MIN_VERSION pango >= 1.2.0 $CANBERRA_GTK"
AC_SUBST(GTK_API_VERSION)
-if test x$GTK_API_VERSION = x3.0; then
- MARCO_PC_MODULES="$MARCO_PC_MODULES mate-desktop-2.0 >= $MATE_DESKTOP_VERSION"
-fi
-
GLIB_GSETTINGS
AC_ARG_ENABLE(verbose-mode,
@@ -231,7 +224,7 @@ fi
## or the render-specific check later
have_xrender=no
-XCOMPOSITE_VERSION=0.2
+XCOMPOSITE_VERSION=0.3
if test x$enable_compositor = xyes; then
have_xcomposite=yes
elif test x$enable_compositor = xauto; then
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e503cb17..5c585ccb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
src/50-marco-desktop-key.xml.in
src/50-marco-global-key.xml.in
src/50-marco-window-key.xml.in
+[type: gettext/gsettings]src/org.mate.marco.gschema.xml
src/core/bell.c
src/core/core.c
src/core/delete.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 7ebf145b..e69de29b 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,2 +0,0 @@
-src/marco.schemas.in
-
diff --git a/src/50-marco-global-key.xml.in b/src/50-marco-global-key.xml.in
index 81a8db85..84276a86 100644
--- a/src/50-marco-global-key.xml.in
+++ b/src/50-marco-global-key.xml.in
@@ -127,5 +127,8 @@
schema="org.mate.Marco.general"
comparison="gt" />
+ <KeyListEntry name="switch-to-workspace-prev"
+ _description="Switch to previously selected workspace" />
+
</KeyListEntries>
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 93f3e05b..61e7ffb0 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -50,6 +50,9 @@ struct _MetaCompositor
MetaScreen *screen,
MetaWindow *window);
+ void (*free_window) (MetaCompositor *compositor,
+ MetaWindow *window);
+
void (*maximize_window) (MetaCompositor *compositor,
MetaWindow *window);
void (*unmaximize_window) (MetaCompositor *compositor,
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index 7d31f303..c1218ebc 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -50,39 +50,8 @@
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/Xrender.h>
-#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2
-#define HAVE_NAME_WINDOW_PIXMAP 1
-#endif
-
-#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 3
-#define HAVE_COW 1
-#else
-/* Don't have a cow man...HAAHAAHAA */
-#endif
-
#define USE_IDLE_REPAINT 1
-#ifdef HAVE_COMPOSITE_EXTENSIONS
-static inline gboolean
-composite_at_least_version (MetaDisplay *display,
- int maj, int min)
-{
- static int major = -1;
- static int minor = -1;
-
- if (major == -1)
- meta_display_get_compositor_version (display, &major, &minor);
-
- return (major > maj || (major == maj && minor >= min));
-}
-
-#define have_name_window_pixmap(display) \
- composite_at_least_version (display, 0, 2)
-#define have_cow(display) \
- composite_at_least_version (display, 0, 3)
-
-#endif
-
typedef enum _MetaCompWindowType
{
META_COMP_WINDOW_NORMAL,
@@ -180,7 +149,6 @@ typedef struct _MetaCompWindow
Window id;
XWindowAttributes attrs;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
Pixmap back_pixmap;
/* When the window is shaded back_pixmap will be replaced with the pixmap
@@ -188,7 +156,6 @@ typedef struct _MetaCompWindow
so that we can still see what the window looked like when it is needed
for the _get_window_pixmap function */
Pixmap shaded_back_pixmap;
-#endif
int mode;
@@ -1062,21 +1029,21 @@ get_window_picture (MetaCompWindow *cw)
XRenderPictureAttributes pa;
XRenderPictFormat *format;
Drawable draw;
+ int error_code;
draw = cw->id;
meta_error_trap_push (display);
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (display))
- {
- if (cw->back_pixmap == None)
- cw->back_pixmap = XCompositeNameWindowPixmap (xdisplay, cw->id);
+ if (cw->back_pixmap == None)
+ cw->back_pixmap = XCompositeNameWindowPixmap (xdisplay, cw->id);
- if (cw->back_pixmap != None)
- draw = cw->back_pixmap;
- }
-#endif
+ error_code = meta_error_trap_pop_with_return (display, FALSE);
+ if (error_code != 0)
+ cw->back_pixmap = None;
+
+ if (cw->back_pixmap != None)
+ draw = cw->back_pixmap;
format = get_window_format (cw);
if (format)
@@ -1085,13 +1052,13 @@ get_window_picture (MetaCompWindow *cw)
pa.subwindow_mode = IncludeInferiors;
+ meta_error_trap_push (display);
pict = XRenderCreatePicture (xdisplay, draw, format, CPSubwindowMode, &pa);
meta_error_trap_pop (display, FALSE);
return pict;
}
- meta_error_trap_pop (display, FALSE);
return None;
}
@@ -1231,22 +1198,10 @@ paint_windows (MetaScreen *screen,
{
int x, y, wid, hei;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (display))
- {
- x = cw->attrs.x;
- y = cw->attrs.y;
- wid = cw->attrs.width + cw->attrs.border_width * 2;
- hei = cw->attrs.height + cw->attrs.border_width * 2;
- }
- else
-#endif
- {
- x = cw->attrs.x + cw->attrs.border_width;
- y = cw->attrs.y + cw->attrs.border_width;
- wid = cw->attrs.width;
- hei = cw->attrs.height;
- }
+ x = cw->attrs.x;
+ y = cw->attrs.y;
+ wid = cw->attrs.width + cw->attrs.border_width * 2;
+ hei = cw->attrs.height + cw->attrs.border_width * 2;
XFixesSetPictureClipRegion (xdisplay, root_buffer,
0, 0, paint_region);
@@ -1322,22 +1277,11 @@ paint_windows (MetaScreen *screen,
if (cw->mode == WINDOW_ARGB)
{
int x, y, wid, hei;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (display))
- {
- x = cw->attrs.x;
- y = cw->attrs.y;
- wid = cw->attrs.width + cw->attrs.border_width * 2;
- hei = cw->attrs.height + cw->attrs.border_width * 2;
- }
- else
-#endif
- {
- x = cw->attrs.x + cw->attrs.border_width;
- y = cw->attrs.y + cw->attrs.border_width;
- wid = cw->attrs.width;
- hei = cw->attrs.height;
- }
+
+ x = cw->attrs.x;
+ y = cw->attrs.y;
+ wid = cw->attrs.width + cw->attrs.border_width * 2;
+ hei = cw->attrs.height + cw->attrs.border_width * 2;
XRenderComposite (xdisplay, PictOpOver, cw->picture,
cw->alpha_pict, root_buffer, 0, 0, 0, 0,
@@ -1553,24 +1497,38 @@ free_win (MetaCompWindow *cw,
MetaDisplay *display = meta_screen_get_display (cw->screen);
Display *xdisplay = meta_display_get_xdisplay (display);
MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen);
+ XRectangle r;
+ XserverRegion region;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (display))
+ /*
+ * If we are deleting a window with a compositor shadow,
+ * trigger a repaint of the area it was covering.
+ * This fixes an issue where the shadow beneath a
+ * (GTK3) tooltip was not being erased after the tooltip
+ * disappeared.
+ */
+ if (cw->shadow) {
+ r.x = cw->attrs.x + cw->shadow_dx;
+ r.y = cw->attrs.y + cw->shadow_dy;
+ r.width = cw->attrs.width + cw->shadow_width;
+ r.height = cw->attrs.height + cw->shadow_height;
+ region = XFixesCreateRegion (xdisplay, &r, 1);
+ add_damage(cw->screen, region);
+ }
+
+
+ /* See comment in map_win */
+ if (cw->back_pixmap && destroy)
{
- /* See comment in map_win */
- if (cw->back_pixmap && destroy)
- {
- XFreePixmap (xdisplay, cw->back_pixmap);
- cw->back_pixmap = None;
- }
+ XFreePixmap (xdisplay, cw->back_pixmap);
+ cw->back_pixmap = None;
+ }
- if (cw->shaded_back_pixmap && destroy)
- {
- XFreePixmap (xdisplay, cw->shaded_back_pixmap);
- cw->shaded_back_pixmap = None;
- }
+ if (cw->shaded_back_pixmap && destroy)
+ {
+ XFreePixmap (xdisplay, cw->shaded_back_pixmap);
+ cw->shaded_back_pixmap = None;
}
-#endif
if (cw->picture)
{
@@ -1644,7 +1602,6 @@ map_win (MetaDisplay *display,
if (cw == NULL)
return;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
/* The reason we deallocate this here and not in unmap
is so that we will still have a valid pixmap for
whenever the window is unmapped */
@@ -1659,7 +1616,6 @@ map_win (MetaDisplay *display,
XFreePixmap (xdisplay, cw->shaded_back_pixmap);
cw->shaded_back_pixmap = None;
}
-#endif
cw->attrs.map_state = IsViewable;
cw->damaged = FALSE;
@@ -1853,11 +1809,8 @@ add_win (MetaScreen *screen,
XSelectInput (xdisplay, xwindow, event_mask);
-
-#ifdef HAVE_NAME_WINDOW_PIXMAP
cw->back_pixmap = None;
cw->shaded_back_pixmap = None;
-#endif
cw->damaged = FALSE;
cw->shaped = is_shaped (display, xwindow);
@@ -2039,32 +1992,28 @@ resize_win (MetaCompWindow *cw,
if (cw->attrs.width != width || cw->attrs.height != height)
{
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (display))
+ if (cw->shaded_back_pixmap)
+ {
+ XFreePixmap (xdisplay, cw->shaded_back_pixmap);
+ cw->shaded_back_pixmap = None;
+ }
+
+ if (cw->back_pixmap)
{
- if (cw->shaded_back_pixmap)
+ /* If the window is shaded, we store the old backing pixmap
+ so we can return a proper image of the window */
+ if (cw->window && meta_window_is_shaded (cw->window))
{
- XFreePixmap (xdisplay, cw->shaded_back_pixmap);
- cw->shaded_back_pixmap = None;
+ cw->shaded_back_pixmap = cw->back_pixmap;
+ cw->back_pixmap = None;
}
-
- if (cw->back_pixmap)
+ else
{
- /* If the window is shaded, we store the old backing pixmap
- so we can return a proper image of the window */
- if (cw->window && meta_window_is_shaded (cw->window))
- {
- cw->shaded_back_pixmap = cw->back_pixmap;
- cw->back_pixmap = None;
- }
- else
- {
- XFreePixmap (xdisplay, cw->back_pixmap);
- cw->back_pixmap = None;
- }
+ XFreePixmap (xdisplay, cw->back_pixmap);
+ cw->back_pixmap = None;
}
}
-#endif
+
if (cw->picture)
{
XRenderFreePicture (xdisplay, cw->picture);
@@ -2501,29 +2450,22 @@ show_overlay_window (MetaScreen *screen,
{
MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion region;
-#ifdef HAVE_COW
- if (have_cow (display))
- {
- XserverRegion region;
-
- region = XFixesCreateRegion (xdisplay, NULL, 0);
+ region = XFixesCreateRegion (xdisplay, NULL, 0);
- XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, 0);
- XFixesSetWindowShapeRegion (xdisplay, cow, ShapeInput, 0, 0, region);
+ XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, 0);
+ XFixesSetWindowShapeRegion (xdisplay, cow, ShapeInput, 0, 0, region);
- XFixesDestroyRegion (xdisplay, region);
+ XFixesDestroyRegion (xdisplay, region);
- damage_screen (screen);
- }
-#endif
+ damage_screen (screen);
}
static void
hide_overlay_window (MetaScreen *screen,
Window cow)
{
-#ifdef HAVE_COW
MetaDisplay *display = meta_screen_get_display (screen);
Display *xdisplay = meta_display_get_xdisplay (display);
XserverRegion region;
@@ -2531,7 +2473,6 @@ hide_overlay_window (MetaScreen *screen,
region = XFixesCreateRegion (xdisplay, NULL, 0);
XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, region);
XFixesDestroyRegion (xdisplay, region);
-#endif
}
static Window
@@ -2543,17 +2484,8 @@ get_output_window (MetaScreen *screen)
xroot = meta_screen_get_xroot (screen);
-#ifdef HAVE_COW
- if (have_cow (display))
- {
- output = XCompositeGetOverlayWindow (xdisplay, xroot);
- XSelectInput (xdisplay, output, ExposureMask);
- }
- else
-#endif
- {
- output = xroot;
- }
+ output = XCompositeGetOverlayWindow (xdisplay, xroot);
+ XSelectInput (xdisplay, output, ExposureMask);
return output;
}
@@ -2690,9 +2622,7 @@ xrender_unmanage_screen (MetaCompositor *compositor,
CompositeRedirectManual);
meta_screen_unset_cm_selection (screen);
-#ifdef HAVE_COW
XCompositeReleaseOverlayWindow (xdisplay, info->output);
-#endif
g_free (info);
@@ -2751,23 +2681,38 @@ xrender_end_move (MetaCompositor *compositor,
#ifdef HAVE_COMPOSITE_EXTENSIONS
#endif
}
+#endif /* 0 */
static void
xrender_free_window (MetaCompositor *compositor,
MetaWindow *window)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
- /* FIXME: When an undecorated window is hidden this is called,
- but the window does not get readded if it is subsequentally shown again
- See http://bugzilla.gnome.org/show_bug.cgi?id=504876
-
- I don't *think* theres any need for this call anyway, leaving it out
- does not seem to cause any side effects so far, but I should check with
- someone who understands more. */
- /* destroy_win (compositor->display, window->xwindow, FALSE); */
+ MetaCompositorXRender *xrc;
+ MetaFrame *frame;
+ Window xwindow;
+
+ xrc = (MetaCompositorXRender *) compositor;
+ frame = meta_window_get_frame (window);
+ xwindow = None;
+
+ if (frame)
+ {
+ xwindow = meta_frame_get_xwindow (frame);
+ }
+ else
+ {
+ /* FIXME: When an undecorated window is hidden this is called, but the
+ * window does not get readded if it is subsequentally shown again. See:
+ * http://bugzilla.gnome.org/show_bug.cgi?id=504876
+ */
+ /* xwindow = meta_window_get_xwindow (window); */
+ }
+
+ if (xwindow != None)
+ destroy_win (xrc->display, xwindow, FALSE);
#endif
}
-#endif /* 0 */
static void
xrender_process_event (MetaCompositor *compositor,
@@ -2858,17 +2803,10 @@ xrender_get_window_pixmap (MetaCompositor *compositor,
if (cw == NULL)
return None;
-#ifdef HAVE_NAME_WINDOW_PIXMAP
- if (have_name_window_pixmap (meta_window_get_display (window)))
- {
- if (meta_window_is_shaded (window))
- return cw->shaded_back_pixmap;
- else
- return cw->back_pixmap;
- }
+ if (meta_window_is_shaded (window))
+ return cw->shaded_back_pixmap;
else
-#endif
- return None;
+ return cw->back_pixmap;
#endif
}
@@ -3056,6 +2994,7 @@ static MetaCompositor comp_info = {
xrender_process_event,
xrender_get_window_pixmap,
xrender_set_active_window,
+ xrender_free_window,
xrender_maximize_window,
xrender_unmaximize_window,
};
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index d23fe3f7..f7a28261 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -156,6 +156,10 @@ void meta_compositor_end_move (MetaCompositor *compositor,
void meta_compositor_free_window (MetaCompositor *compositor,
MetaWindow *window)
{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor && compositor->free_window)
+ compositor->free_window (compositor, window);
+#endif
}
void
diff --git a/src/core/display-private.h b/src/core/display-private.h
index dc270a96..069e0ccf 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -276,8 +276,6 @@ struct _MetaDisplay {
#ifdef HAVE_COMPOSITE_EXTENSIONS
int composite_event_base;
int composite_error_base;
- int composite_major_version;
- int composite_minor_version;
int damage_event_base;
int damage_error_base;
int xfixes_event_base;
@@ -420,8 +418,7 @@ void meta_display_ungrab_focus_window_button (MetaDisplay *display,
MetaWindow *window);
/* Next two functions are defined in edge-resistance.c */
-void meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display);
-void meta_display_cleanup_edges (MetaDisplay *display);
+void meta_display_cleanup_edges (MetaDisplay *display);
/* make a request to ensure the event serial has changed */
void meta_display_increment_event_serial (MetaDisplay *display);
diff --git a/src/core/display.c b/src/core/display.c
index 6a4831fb..caa76247 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -558,6 +558,9 @@ meta_display_open (void)
#ifdef HAVE_COMPOSITE_EXTENSIONS
{
+ int composite_major_version = 0;
+ int composite_minor_version = 0;
+
the_display->have_composite = FALSE;
the_display->composite_error_base = 0;
@@ -572,18 +575,16 @@ meta_display_open (void)
}
else
{
- the_display->composite_major_version = 0;
- the_display->composite_minor_version = 0;
if (XCompositeQueryVersion (the_display->xdisplay,
- &the_display->composite_major_version,
- &the_display->composite_minor_version))
+ &composite_major_version,
+ &composite_minor_version))
{
the_display->have_composite = TRUE;
}
else
{
- the_display->composite_major_version = 0;
- the_display->composite_minor_version = 0;
+ composite_major_version = 0;
+ composite_minor_version = 0;
}
}
@@ -591,8 +592,8 @@ meta_display_open (void)
"extn ver %d %d\n",
the_display->composite_error_base,
the_display->composite_event_base,
- the_display->composite_major_version,
- the_display->composite_minor_version);
+ composite_major_version,
+ composite_minor_version);
the_display->have_damage = FALSE;
@@ -3662,18 +3663,6 @@ meta_display_begin_grab_op (MetaDisplay *display,
g_assert (display->grab_window != NULL || display->grab_screen != NULL);
g_assert (display->grab_op != META_GRAB_OP_NONE);
- /* If this is a move or resize, cache the window edges for
- * resistance/snapping
- */
- if (meta_grab_op_is_resizing (display->grab_op) ||
- meta_grab_op_is_moving (display->grab_op))
- {
- meta_topic (META_DEBUG_WINDOW_OPS,
- "Computing edges to resist-movement or snap-to for %s.\n",
- window->desc);
- meta_display_compute_resistance_and_snapping_edges (display);
- }
-
/* Save the old stacking */
if (GRAB_OP_IS_WINDOW_SWITCH (display->grab_op))
{
@@ -5401,17 +5390,6 @@ meta_display_remove_autoraise_callback (MetaDisplay *display)
}
}
-#ifdef HAVE_COMPOSITE_EXTENSIONS
-void
-meta_display_get_compositor_version (MetaDisplay *display,
- int *major,
- int *minor)
-{
- *major = display->composite_major_version;
- *minor = display->composite_minor_version;
-}
-#endif
-
Display *
meta_display_get_xdisplay (MetaDisplay *display)
{
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index 51e77d54..aa4fcb6a 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -63,6 +63,8 @@ struct MetaEdgeResistanceData
ResistanceDataForAnEdge bottom_data;
};
+static void compute_resistance_and_snapping_edges (MetaDisplay *display);
+
/* !WARNING!: this function can return invalid indices (namely, either -1 or
* edges->len); this is by design, but you need to remember this.
*/
@@ -550,7 +552,9 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
gboolean modified;
int new_left, new_right, new_top, new_bottom;
- g_assert (display->grab_edge_resistance_data != NULL);
+ if (display->grab_edge_resistance_data == NULL)
+ compute_resistance_and_snapping_edges (display);
+
edge_data = display->grab_edge_resistance_data;
if (auto_snap)
@@ -671,7 +675,8 @@ meta_display_cleanup_edges (MetaDisplay *display)
MetaEdgeResistanceData *edge_data = display->grab_edge_resistance_data;
GHashTable *edges_to_be_freed;
- g_assert (edge_data != NULL);
+ if (edge_data == NULL) /* Not currently cached */
+ return;
/* We first need to clean out any window edges */
edges_to_be_freed = g_hash_table_new_full (g_direct_hash, g_direct_equal,
@@ -938,8 +943,8 @@ initialize_grab_edge_resistance_data (MetaDisplay *display)
edge_data->bottom_data.keyboard_buildup = 0;
}
-void
-meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
+static void
+compute_resistance_and_snapping_edges (MetaDisplay *display)
{
GList *stacked_windows;
GList *cur_window_iter;
@@ -952,6 +957,11 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
*/
GSList *rem_windows, *rem_win_stacking;
+ g_assert (display->grab_window != NULL);
+ meta_topic (META_DEBUG_WINDOW_OPS,
+ "Computing edges to resist-movement or snap-to for %s.\n",
+ display->grab_window->desc);
+
/*
* 1st: Get the list of relevant windows, from bottom to top
*/
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 9e602a91..068199b8 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2288,6 +2288,14 @@ handle_switch_to_workspace (MetaDisplay *display,
{
gint which = binding->handler->data;
MetaWorkspace *workspace;
+
+ if (which == META_MOTION_PREV)
+ {
+ workspace = screen->prev_workspace;
+ if (workspace)
+ meta_workspace_activate (workspace, event->xkey.time);
+ return;
+ }
if (which < 0)
{
diff --git a/src/core/place.c b/src/core/place.c
index 99cedd14..bcfafe42 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -87,6 +87,47 @@ northwestcmp (gconstpointer a, gconstpointer b)
return 0;
}
+static gboolean
+place_by_pointer(MetaWindow *window,
+ MetaFrameGeometry *fgeom,
+ MetaPlacementMode placement_mode,
+ int *new_x,
+ int *new_y)
+{
+ int window_width, window_height;
+ Window root_return, child_return;
+ int root_x_return, root_y_return;
+ int win_x_return, win_y_return;
+ unsigned int mask_return;
+
+ XQueryPointer (window->display->xdisplay,
+ window->screen->xroot,
+ &root_return,
+ &child_return,
+ &root_x_return,
+ &root_y_return,
+ &win_x_return,
+ &win_y_return,
+ &mask_return);
+
+ window_width = window->frame ? window->frame->rect.width : window->rect.width;
+ window_height = window->frame ? window->frame->rect.height : window->rect.height;
+
+ if (fgeom) {
+ *new_x = root_x_return + fgeom->left_width - window_width / 2;
+ *new_y = root_y_return + fgeom->top_height - window_height / 2;
+ }
+ else {
+ *new_x = root_x_return - window_width / 2;
+ *new_y = root_y_return - window_height / 2;
+ }
+
+ if (placement_mode == META_PLACEMENT_MODE_MANUAL)
+ window->move_after_placement = TRUE;
+
+ return TRUE;
+}
+
static void
find_next_cascade (MetaWindow *window,
MetaFrameGeometry *fgeom,
@@ -663,6 +704,7 @@ meta_window_place (MetaWindow *window,
{
GList *windows;
const MetaXineramaScreenInfo *xi;
+ MetaPlacementMode placement_mode;
/* frame member variables should NEVER be used in here, only
* MetaFrameGeometry. But remember fgeom == NULL
@@ -853,6 +895,16 @@ meta_window_place (MetaWindow *window,
x = xi->rect.x;
y = xi->rect.y;
+ /* Placement based on pointer position */
+ placement_mode = meta_prefs_get_placement_mode();
+
+ if (placement_mode == META_PLACEMENT_MODE_POINTER ||
+ placement_mode == META_PLACEMENT_MODE_MANUAL)
+ {
+ if (place_by_pointer (window, fgeom, placement_mode, &x, &y))
+ goto done_check_denied_focus;
+ }
+
if (find_first_fit (window, fgeom, windows,
xi->number,
x, y, &x, &y))
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 8fa28b83..2f3e9392 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -168,6 +168,8 @@ static void init_window_bindings (void);
static void init_commands (void);
static void init_workspace_names (void);
+static MetaPlacementMode placement_mode = META_PLACEMENT_MODE_AUTOMATIC;
+
typedef struct
{
MetaPrefsChangedFunc func;
@@ -317,6 +319,11 @@ static MetaEnumPreference preferences_enum[] =
META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
(gint *) &action_right_click_titlebar,
},
+ { "placement-mode",
+ KEY_GENERAL_SCHEMA,
+ META_PREF_PLACEMENT_MODE,
+ (gint *) &placement_mode,
+ },
{ NULL, NULL, 0, NULL },
};
@@ -1556,6 +1563,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_SIDE_BY_SIDE_TILING:
return "SIDE_BY_SIDE_TILING";
+
+ case META_PREF_PLACEMENT_MODE:
+ return "PLACEMENT_MODE";
}
return "(unknown)";
@@ -2241,6 +2251,12 @@ meta_prefs_get_force_fullscreen (void)
return force_fullscreen;
}
+MetaPlacementMode
+meta_prefs_get_placement_mode (void)
+{
+ return placement_mode;
+}
+
void
meta_prefs_set_force_compositing_manager (gboolean whether)
{
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index ee014ff2..c1552ab0 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -85,6 +85,9 @@ struct _MetaScreen
MetaWorkspace *active_workspace;
+ /* Previous active workspace */
+ MetaWorkspace *prev_workspace;
+
/* This window holds the focus when we don't want to focus
* any actual clients
*/
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 20e619cb..0b3cf594 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -139,6 +139,9 @@ struct _MetaWindow
guint maximize_vertically_after_placement : 1;
guint minimize_after_placement : 1;
+ /* Whether to move after placement */
+ guint move_after_placement : 1;
+
/* The current or requested tile mode. If maximized_vertically is true,
* this is the current mode. If not, it is the mode which will be
* requested after the window grab is released */
diff --git a/src/core/window.c b/src/core/window.c
index 9b2ad926..30ebfa85 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -461,6 +461,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
window->maximize_horizontally_after_placement = FALSE;
window->maximize_vertically_after_placement = FALSE;
window->minimize_after_placement = FALSE;
+ window->move_after_placement = FALSE;
window->fullscreen = FALSE;
window->fullscreen_after_placement = FALSE;
window->fullscreen_monitors[0] = -1;
@@ -2346,6 +2347,13 @@ meta_window_show (MetaWindow *window)
if (takes_focus_on_map)
{
meta_window_focus (window, timestamp);
+
+ if (window->move_after_placement)
+ {
+ meta_window_begin_grab_op(window, META_GRAB_OP_KEYBOARD_MOVING,
+ FALSE, timestamp);
+ window->move_after_placement = FALSE;
+ }
}
else
{
@@ -5181,8 +5189,7 @@ meta_window_client_message (MetaWindow *window,
{
meta_verbose ("WM_CHANGE_STATE client message, state: %ld\n",
event->xclient.data.l[0]);
- if (event->xclient.data.l[0] == IconicState &&
- window->has_minimize_func)
+ if (event->xclient.data.l[0] == IconicState)
meta_window_minimize (window);
return TRUE;
@@ -5586,6 +5593,8 @@ static gboolean
process_property_notify (MetaWindow *window,
XPropertyEvent *event)
{
+ Window xid = window->xwindow;
+
if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
{
char *property_name = XGetAtomName (window->display->xdisplay,
@@ -5596,7 +5605,13 @@ process_property_notify (MetaWindow *window,
XFree (property_name);
}
- meta_window_reload_property (window, event->atom, FALSE);
+ if (event->atom == window->display->atom__NET_WM_USER_TIME &&
+ window->user_time_window)
+ {
+ xid = window->user_time_window;
+ }
+
+ meta_window_reload_property_from_xwindow (window, xid, event->atom, FALSE);
return TRUE;
}
@@ -6722,8 +6737,8 @@ meta_window_show_menu (MetaWindow *window,
if (!window->has_maximize_func)
insensitive |= META_MENU_OP_UNMAXIMIZE | META_MENU_OP_MAXIMIZE;
- /*if (!window->has_minimize_func)
- insensitive |= META_MENU_OP_MINIMIZE;*/
+ if (!window->has_minimize_func)
+ insensitive |= META_MENU_OP_MINIMIZE;
/*if (!window->has_close_func)
insensitive |= META_MENU_OP_DELETE;*/
diff --git a/src/core/workspace.c b/src/core/workspace.c
index b85ab53c..e2a397a0 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -382,9 +382,16 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
if (workspace->screen->active_workspace)
workspace_switch_sound(workspace->screen->active_workspace, workspace);
+ /* Free any cached pointers to the workspaces's edges from
+ * a current resize or move operation */
+ meta_display_cleanup_edges (workspace->screen->display);
+
/* Note that old can be NULL; e.g. when starting up */
old = workspace->screen->active_workspace;
+ /* Save old workspace, to be able to switch back. */
+ workspace->screen->prev_workspace = old;
+
workspace->screen->active_workspace = workspace;
set_active_space_hint (workspace->screen);
@@ -542,6 +549,11 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace)
"Invalidating work area for workspace %d\n",
meta_workspace_index (workspace));
+ /* If we are in the middle of a resize or move operation, we
+ * might have cached pointers to the workspace's edges */
+ if (workspace == workspace->screen->active_workspace)
+ meta_display_cleanup_edges (workspace->screen->display);
+
g_free (workspace->work_area_xinerama);
workspace->work_area_xinerama = NULL;
@@ -798,6 +810,8 @@ meta_motion_direction_to_string (MetaMotionDirection direction)
return "Left";
case META_MOTION_RIGHT:
return "Right";
+ case META_MOTION_PREV:
+ return "Previous";
}
return "Unknown";
@@ -838,6 +852,8 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
case META_MOTION_DOWN:
layout.current_row += 1;
break;
+ case META_MOTION_PREV:
+ break;
}
/* LEFT */
@@ -914,6 +930,8 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
if (wrap == META_WRAP_TOROIDAL)
layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0;
break;
+ case META_MOTION_PREV:
+ break;
}
i = layout.grid[layout.current_row * layout.cols + layout.current_col];
diff --git a/src/core/workspace.h b/src/core/workspace.h
index 40942e1a..4b52f96e 100644
--- a/src/core/workspace.h
+++ b/src/core/workspace.h
@@ -43,7 +43,8 @@ typedef enum
META_MOTION_UP = -1,
META_MOTION_DOWN = -2,
META_MOTION_LEFT = -3,
- META_MOTION_RIGHT = -4
+ META_MOTION_RIGHT = -4,
+ META_MOTION_PREV = -5
} MetaMotionDirection;
struct _MetaWorkspace
diff --git a/src/core/xprops.c b/src/core/xprops.c
index f9b4578a..a54e2185 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -264,6 +264,16 @@ cardinal_list_from_results (GetPropertyResults *results,
*n_cardinals_p = results->n_items;
results->prop = NULL;
+#if GLIB_SIZEOF_LONG == 8
+ /* Xlib sign-extends format=32 items, but we want them unsigned */
+ {
+ int i;
+
+ for (i = 0; i < *n_cardinals_p; i++)
+ (*cardinals_p)[i] = (*cardinals_p)[i] & 0xffffffff;
+ }
+#endif
+
return TRUE;
}
@@ -608,6 +618,10 @@ cardinal_with_atom_type_from_results (GetPropertyResults *results,
return FALSE;
*cardinal_p = *(gulong*) results->prop;
+#if GLIB_SIZEOF_LONG == 8
+ /* Xlib sign-extends format=32 items, but we want them unsigned */
+ *cardinal_p &= 0xffffffff;
+#endif
XFree (results->prop);
results->prop = NULL;
@@ -632,6 +646,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay *display,
return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
}
+static char *
+text_property_to_utf8 (Display *xdisplay,
+ const XTextProperty *prop)
+{
+ char *ret = NULL;
+ char **local_list = NULL;
+ int count = 0;
+ int res;
+
+ res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
+ if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
+ goto out;
+
+ if (count == 0)
+ goto out;
+
+ ret = g_strdup (local_list[0]);
+
+ out:
+ meta_XFree (local_list);
+ return ret;
+}
+
static gboolean
text_property_from_results (GetPropertyResults *results,
char **utf8_str_p)
@@ -646,8 +683,7 @@ text_property_from_results (GetPropertyResults *results,
tp.format = results->format;
tp.nitems = results->n_items;
- *utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
- &tp);
+ *utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
if (tp.value != NULL)
XFree (tp.value);
diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h
index a14777e9..a26720a1 100644
--- a/src/include/all-keybindings.h
+++ b/src/include/all-keybindings.h
@@ -277,5 +277,8 @@ keybind (move-to-side-w, handle_move_to_side_w, 0,
keybind (move-to-center, handle_move_to_center, 0,
BINDING_PER_WINDOW)
+keybind (switch-to-workspace-prev, handle_switch_to_workspace,
+ META_MOTION_PREV, 0)
+
/* eof all-keybindings.h */
diff --git a/src/include/common.h b/src/include/common.h
index 69755e24..74137967 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -312,4 +312,14 @@ struct _MetaButtonLayout
(ycoord) >= (rect).y && \
(ycoord) < ((rect).y + (rect).height))
+/*
+ * Placement mode
+ */
+typedef enum
+{
+ META_PLACEMENT_MODE_AUTOMATIC,
+ META_PLACEMENT_MODE_POINTER,
+ META_PLACEMENT_MODE_MANUAL
+} MetaPlacementMode;
+
#endif
diff --git a/src/include/display.h b/src/include/display.h
index a8dc49eb..5b0e5642 100644
--- a/src/include/display.h
+++ b/src/include/display.h
@@ -29,9 +29,6 @@
#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
-void meta_display_get_compositor_version (MetaDisplay *display,
- int *major,
- int *minor);
Display *meta_display_get_xdisplay (MetaDisplay *display);
MetaCompositor *meta_display_get_compositor (MetaDisplay *display);
GSList *meta_display_get_screens (MetaDisplay *display);
diff --git a/src/include/prefs.h b/src/include/prefs.h
index d804207c..a2fbbf55 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -64,7 +64,8 @@ typedef enum
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
META_PREF_CENTER_NEW_WINDOWS,
META_PREF_SIDE_BY_SIDE_TILING,
- META_PREF_FORCE_FULLSCREEN
+ META_PREF_FORCE_FULLSCREEN,
+ META_PREF_PLACEMENT_MODE
} MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@@ -112,6 +113,8 @@ MetaActionTitlebar meta_prefs_get_action_double_click_titlebar (void);
MetaActionTitlebar meta_prefs_get_action_middle_click_titlebar (void);
MetaActionTitlebar meta_prefs_get_action_right_click_titlebar (void);
+MetaPlacementMode meta_prefs_get_placement_mode (void);
+
void meta_prefs_set_num_workspaces (int n_workspaces);
const char* meta_prefs_get_workspace_name (int i);
diff --git a/src/include/ui.h b/src/include/ui.h
index e7ce90aa..70987d33 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -134,20 +134,6 @@ 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,
- int max_height);
-void meta_image_window_free (MetaImageWindow *iw);
-void meta_image_window_set_showing (MetaImageWindow *iw,
- gboolean showing);
-void meta_image_window_set (MetaImageWindow *iw,
- GdkPixbuf *pixbuf,
- int x,
- int y);
-#endif
-
GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
Pixmap xpixmap,
int src_x,
@@ -170,9 +156,6 @@ GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
Window xwindow);
-char* meta_text_property_to_utf8 (Display *xdisplay,
- const XTextProperty *prop);
-
void meta_ui_set_current_theme (const char *name,
gboolean force_reload);
gboolean meta_ui_have_a_theme (void);
diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml
index 30b37e50..0e24ab19 100644
--- a/src/org.mate.marco.gschema.xml
+++ b/src/org.mate.marco.gschema.xml
@@ -30,6 +30,11 @@
<value nick="menu" value="7"/>
<value nick="last" value="8"/>
</enum>
+ <enum id="org.mate.Marco.placement_type">
+ <value value="0" nick="automatic"/>
+ <value value="1" nick="pointer"/>
+ <value value="2" nick="manual"/>
+ </enum>
<schema id="org.mate.Marco" path="/org/mate/marco/">
<child name="general" schema="org.mate.Marco.general"/>
@@ -171,6 +176,11 @@
<summary>Whether to enable side-by-side tiling</summary>
<description>If enabled, dropping windows on screen edges maximizes them vertically and resizes them horizontally to cover half of the available area. Drag-dropping to the top maximizes the window.</description>
</key>
+ <key name="placement-mode" enum="org.mate.Marco.placement_type">
+ <default>'automatic'</default>
+ <summary>Window placement mode</summary>
+ <description>The window placement mode indicates how new windows are positioned. "automatic" means the system chooses a location automatically based on the space available on the desktop, or by a simple cascade if there is no space; "pointer" means that new windows are placed according to the mouse pointer position; "manual" means that the user must manually place the new window with the mouse or keyboard.</description>
+ </key>
</schema>
<schema id="org.mate.Marco.workspace-names" path="/org/mate/marco/workspace-names/">
@@ -497,6 +507,11 @@
<summary>Switch to workspace below the current workspace</summary>
<description>The format looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;". If you set the option to the special string "disabled", then there will be no keybinding for this action.</description>
</key>
+ <key name="switch-to-workspace-prev" type="s">
+ <default>'disabled'</default>
+ <summary>Switch to previously selected workspace</summary>
+ <description>The format looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;". If you set the option to the special string "disabled", then there will be no keybinding for this action.</description>
+ </key>
<key name="switch-group" type="s">
<default>'disabled'</default>
<summary>Move between windows of an application, using a popup window</summary>
diff --git a/src/tools/marco-window-demo.c b/src/tools/marco-window-demo.c
index 1585b385..edff5f71 100644
--- a/src/tools/marco-window-demo.c
+++ b/src/tools/marco-window-demo.c
@@ -74,19 +74,22 @@ static void
on_realize_set_struts (GtkWindow *window,
gpointer data)
{
+ GtkWidget *widget;
int left;
int right;
int top;
int bottom;
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
+ widget = GTK_WIDGET (window);
+
+ g_return_if_fail (gtk_widget_get_realized (widget));
left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-left"));
right = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-right"));
top = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-top"));
bottom = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window), "meta-strut-bottom"));
- set_gdk_window_struts (gtk_widget_get_window (GTK_WIDGET (window)),
+ set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@@ -97,6 +100,10 @@ set_gtk_window_struts (GtkWidget *window,
int top,
int bottom)
{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_object_set_data (G_OBJECT (window), "meta-strut-left",
GINT_TO_POINTER (left));
g_object_set_data (G_OBJECT (window), "meta-strut-right",
@@ -115,8 +122,8 @@ set_gtk_window_struts (GtkWidget *window,
G_CALLBACK (on_realize_set_struts),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_struts (gtk_widget_get_window (GTK_WIDGET (window)),
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_struts (gtk_widget_get_window (widget),
left, right, top, bottom);
}
@@ -157,6 +164,10 @@ static void
set_gtk_window_type (GtkWindow *window,
const char *type)
{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_object_set_data (G_OBJECT (window), "meta-window-type", (char*) type);
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
@@ -168,8 +179,8 @@ set_gtk_window_type (GtkWindow *window,
G_CALLBACK (on_realize_set_type),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_type (gtk_widget_get_window (GTK_WIDGET (window)),
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_type (gtk_widget_get_window (widget),
type);
}
@@ -183,14 +194,22 @@ static void
on_realize_set_border_only (GtkWindow *window,
gpointer data)
{
- g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
- set_gdk_window_border_only (gtk_widget_get_window (GTK_WIDGET (window)));
+ g_return_if_fail (gtk_widget_get_realized (widget));
+
+ set_gdk_window_border_only (gtk_widget_get_window (widget));
}
static void
set_gtk_window_border_only (GtkWindow *window)
{
+GtkWidget *widget;
+
+ widget = GTK_WIDGET (window);
+
g_signal_handlers_disconnect_by_func (G_OBJECT (window),
on_realize_set_border_only,
NULL);
@@ -200,8 +219,8 @@ set_gtk_window_border_only (GtkWindow *window)
G_CALLBACK (on_realize_set_border_only),
NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (window)))
- set_gdk_window_border_only (gtk_widget_get_window (GTK_WIDGET (window)));
+ if (gtk_widget_get_realized (widget))
+ set_gdk_window_border_only (gtk_widget_get_window (widget));
}
int
@@ -307,9 +326,8 @@ dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
make_dialog (GTK_WIDGET (callback_data), 1);
@@ -322,9 +340,8 @@ modal_dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-modal_dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+modal_dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *dialog;
@@ -349,9 +366,8 @@ no_parent_dialog_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-no_parent_dialog_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+no_parent_dialog_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
make_dialog (NULL, 1);
@@ -364,9 +380,8 @@ utility_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-utility_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+utility_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -405,9 +420,8 @@ toolbar_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-toolbar_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+toolbar_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -437,9 +451,8 @@ menu_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-menu_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+menu_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -469,9 +482,8 @@ override_redirect_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-override_redirect_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+override_redirect_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -498,9 +510,8 @@ border_only_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-border_only_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+border_only_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -575,9 +586,8 @@ splashscreen_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-splashscreen_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+splashscreen_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -691,15 +701,14 @@ dock_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-dock_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+dock_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
-#if GTK_CHECK_VERSION (3, 0, 0)
guint callback_action;
const gchar *name;
+#if GTK_CHECK_VERSION (3, 0, 0)
g_object_get (G_OBJECT (action), "name", &name, NULL);
if (!g_strcmp0 (name, "top-dock"))
@@ -714,6 +723,21 @@ dock_cb (gpointer callback_data,
callback_action = DOCK_ALL;
else
return;
+#else
+ name = gtk_action_get_name (action);
+
+ if (!g_strcmp0 (name, "Top dock"))
+ callback_action = DOCK_TOP;
+ else if (!g_strcmp0 (name, "Bottom dock"))
+ callback_action = DOCK_BOTTOM;
+ else if (!g_strcmp0 (name, "Left dock"))
+ callback_action = DOCK_LEFT;
+ else if (!g_strcmp0 (name, "Right dock"))
+ callback_action = DOCK_RIGHT;
+ else if (!g_strcmp0 (name, "All docks"))
+ callback_action = DOCK_ALL;
+ else
+ return;
#endif
if (callback_action == DOCK_ALL)
{
@@ -735,9 +759,8 @@ desktop_cb (GSimpleAction *action,
gpointer callback_data)
#else
static void
-desktop_cb (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget)
+desktop_cb (GtkAction *action,
+ gpointer callback_data)
#endif
{
GtkWidget *window;
@@ -777,30 +800,6 @@ desktop_cb (gpointer callback_data,
gtk_widget_show_all (window);
}
-#if !GTK_CHECK_VERSION(3, 0, 0)
-static GtkItemFactoryEntry menu_items[] =
-{
- { "/_Windows", NULL, NULL, 0, "<Branch>" },
- { "/Windows/tearoff", NULL, NULL, 0, "<Tearoff>" },
- { "/Windows/_Dialog", "<control>d", dialog_cb, 0, NULL },
- { "/Windows/_Modal dialog", NULL, modal_dialog_cb, 0, NULL },
- { "/Windows/_Parentless dialog", NULL, no_parent_dialog_cb, 0, NULL },
- { "/Windows/_Utility", "<control>u", utility_cb, 0, NULL },
- { "/Windows/_Splashscreen", "<control>s", splashscreen_cb, 0, NULL },
- { "/Windows/_Top dock", NULL, dock_cb, DOCK_TOP, NULL },
- { "/Windows/_Bottom dock", NULL, dock_cb, DOCK_BOTTOM, NULL },
- { "/Windows/_Left dock", NULL, dock_cb, DOCK_LEFT, NULL },
- { "/Windows/_Right dock", NULL, dock_cb, DOCK_RIGHT, NULL },
- { "/Windows/_All docks", NULL, dock_cb, DOCK_ALL, NULL },
- { "/Windows/Des_ktop", NULL, desktop_cb, 0, NULL },
- { "/Windows/Me_nu", NULL, menu_cb, 0, NULL },
- { "/Windows/Tool_bar", NULL, toolbar_cb, 0, NULL },
- { "/Windows/Override Redirect", NULL, override_redirect_cb, 0, NULL },
- { "/Windows/Border Only", NULL, border_only_cb, 0, NULL }
-};
-
-#endif
-
#if GTK_CHECK_VERSION (3, 0, 0)
static void
sleep_cb (GSimpleAction *action,
@@ -808,7 +807,7 @@ sleep_cb (GSimpleAction *action,
gpointer data)
#else
static void
-sleep_cb (GtkWidget *button,
+sleep_cb (GtkAction *action,
gpointer data)
#endif
{
@@ -822,12 +821,13 @@ toggle_aspect_ratio (GSimpleAction *action,
gpointer data)
#else
static void
-toggle_aspect_ratio (GtkWidget *button,
+toggle_aspect_ratio (GtkAction *action,
gpointer data)
#endif
{
GtkWidget *window;
GdkGeometry geom;
+ GtkWidget *widget = GTK_WIDGET (data);
if (aspect_on)
{
@@ -842,11 +842,7 @@ toggle_aspect_ratio (GtkWidget *button,
aspect_on = !aspect_on;
-#if GTK_CHECK_VERSION(3, 0, 0)
- window = gtk_widget_get_ancestor (GTK_WIDGET(data), GTK_TYPE_WINDOW);
-#else
- window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
-#endif
+ window = gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW);
if (window)
gtk_window_set_geometry_hints (GTK_WINDOW (window),
GTK_WIDGET (data),
@@ -867,11 +863,7 @@ toggle_decorated_cb (GtkWidget *button,
#endif
{
GtkWidget *window;
-#if GTK_CHECK_VERSION (3, 0, 0)
window = gtk_widget_get_ancestor (data, GTK_TYPE_WINDOW);
-#else
- window = gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW);
-#endif
if (window)
gtk_window_set_decorated (GTK_WINDOW (window),
!gtk_window_get_decorated (GTK_WINDOW (window)));
@@ -1088,6 +1080,90 @@ create_toolbar (void)
return toolbar;
}
+#else
+static const gchar *menu_item_string =
+ "<ui>\n"
+ "<menubar>\n"
+ "<menu name='Windows' action='Windows'>\n"
+ "<menuitem name='Dialog' action='Dialog'/>\n"
+ "<menuitem name='Modal dialog' action='Modal dialog'/>\n"
+ "<menuitem name='Parentless dialog' action='Parentless dialog'/>\n"
+ "<menuitem name='Utility' action='Utility'/>\n"
+ "<menuitem name='Splashscreen' action='Splashscreen'/>\n"
+ "<menuitem name='Top dock' action='Top dock'/>\n"
+ "<menuitem name='Bottom dock' action='Bottom dock'/>\n"
+ "<menuitem name='Left dock' action='Left dock'/>\n"
+ "<menuitem name='Right dock' action='Right dock'/>\n"
+ "<menuitem name='All docks' action='All docks'/>\n"
+ "<menuitem name='Desktop' action='Desktop'/>\n"
+ "<menuitem name='Menu' action='Menu'/>\n"
+ "<menuitem name='Toolbar' action='Toolbar'/>\n"
+ "<menuitem name='Override Redirect' action='Override Redirect'/>\n"
+ "<menuitem name='Border Only' action='Border Only'/>\n"
+ "</menu>\n"
+ "</menubar>\n"
+ "<toolbar>\n"
+ "<toolitem name='New' action='New'/>\n"
+ "<toolitem name='Lock' action='Lock'/>\n"
+ "<toolitem name='Decorations' action='Decorations'/>\n"
+ "<toolitem name='Ratio' action='Ratio'/>\n"
+ "<toolitem name='Quit' action='Quit'/>\n"
+ "</toolbar>\n"
+ "</ui>\n";
+
+static const GtkActionEntry menu_items[] =
+{
+ { "Windows", NULL, "_Windows", NULL,
+ NULL, NULL },
+ { "Dialog", NULL, "_Dialog", "<control>d",
+ NULL, G_CALLBACK (dialog_cb) },
+ { "Modal dialog", NULL, "_Modal dialog", NULL,
+ NULL, G_CALLBACK (modal_dialog_cb) },
+ { "Parentless dialog", NULL, "_Parentless dialog", NULL,
+ NULL, G_CALLBACK (no_parent_dialog_cb) },
+ { "Utility", NULL, "_Utility", "<control>u",
+ NULL, G_CALLBACK (utility_cb) },
+ { "Splashscreen", NULL, "_Splashscreen", "<control>s",
+ NULL, G_CALLBACK (splashscreen_cb) },
+ { "Top dock", NULL, "_Top dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Bottom dock", NULL, "_Bottom dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Left dock", NULL, "_Left dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Right dock", NULL, "_Right dock", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "All docks", NULL, "_All docks", NULL,
+ NULL, G_CALLBACK (dock_cb) },
+ { "Desktop", NULL, "Des_ktop", NULL,
+ NULL, G_CALLBACK (desktop_cb) },
+ { "Menu", NULL, "Me_nu", NULL,
+ NULL, G_CALLBACK (menu_cb) },
+ { "Toolbar", NULL, "Tool_bar", NULL,
+ NULL, G_CALLBACK (toolbar_cb) },
+ { "Override Redirect", NULL, "Override Redirect", NULL,
+ NULL, G_CALLBACK (override_redirect_cb) },
+ { "Border Only", NULL, "Border Only", NULL,
+ NULL, G_CALLBACK (border_only_cb) }
+};
+
+static const GtkActionEntry tool_items[] =
+{
+ { "New", GTK_STOCK_NEW, NULL, NULL,
+ "Open another one of these windows", G_CALLBACK (do_appwindow) },
+ { "Lock", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that"
+ " locks up the demo", G_CALLBACK (sleep_cb) },
+ { "Decorations", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that "
+ "toggles window decorations", G_CALLBACK (toggle_decorated_cb) },
+ { "Quit", GTK_STOCK_QUIT, NULL, NULL,
+ "This is a demo button with "
+ " a 'quit' icon", G_CALLBACK (clicked_toolbar_cb) },
+ { "Ratio", GTK_STOCK_OPEN, NULL, NULL,
+ "This is a demo button that locks the aspect ratio "
+ "using a hint", G_CALLBACK (toggle_aspect_ratio) }
+};
#endif
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -1103,27 +1179,20 @@ do_appwindow (void)
GtkWidget *window;
#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *grid;
+ GtkWidget *toolbar;
+ GSimpleActionGroup *action_group;
+ GtkBuilder *builder;
#else
GtkWidget *table;
-#endif
- GtkWidget *toolbar;
-#if !GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *handlebox;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
#endif
GtkWidget *statusbar;
GtkWidget *contents;
GtkWidget *sw;
GtkTextBuffer *buffer;
- #if GTK_CHECK_VERSION(3, 0, 0)
- GSimpleActionGroup *action_group;
- GtkBuilder *builder;
- #else
- GtkAccelGroup *accel_group;
- GtkItemFactory *item_factory;
- #endif
-
-
/* Create the toplevel window
*/
@@ -1179,27 +1248,27 @@ do_appwindow (void)
/* Create the menubar
*/
- accel_group = gtk_accel_group_new ();
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
- g_object_unref (accel_group);
+ contents = gtk_text_view_new ();
+
+ action_group = gtk_action_group_new ("mainmenu");
+ gtk_action_group_add_actions (action_group,
+ menu_items,
+ G_N_ELEMENTS (menu_items),
+ window);
+ gtk_action_group_add_actions (action_group,
+ tool_items,
+ G_N_ELEMENTS (tool_items),
+ window);
- item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
+ ui_manager = gtk_ui_manager_new ();
- /* Set up item factory to go away with the window */
- g_object_ref (item_factory);
- g_object_ref_sink (item_factory);
- g_object_unref (item_factory);
- g_object_set_data_full (G_OBJECT (window),
- "<main>",
- item_factory,
- (GDestroyNotify) g_object_unref);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
/* create menu items */
- gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
- menu_items, window);
+ gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL);
gtk_table_attach (GTK_TABLE (table),
- gtk_item_factory_get_widget (item_factory, "<main>"),
+ gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"),
/* X direction */ /* Y direction */
0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, 0,
@@ -1237,7 +1306,6 @@ do_appwindow (void)
gtk_window_set_default_size (GTK_WINDOW (window),
200, 200);
- contents = gtk_text_view_new ();
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
PANGO_WRAP_WORD);
@@ -1247,68 +1315,11 @@ do_appwindow (void)
#if !GTK_CHECK_VERSION (3, 0, 0)
/* Create the toolbar
*/
- toolbar = gtk_toolbar_new ();
-
- GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
- gtk_tool_item_set_tooltip_text(newButton,
- "Open another one of these windows");
- g_signal_connect(G_OBJECT(newButton),
- "clicked",
- G_CALLBACK(do_appwindow),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- newButton,
- -1); /*-1 means append to end of toolbar*/
-
-
- GtkToolItem *lockButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(lockButton,
- "This is a demo button that locks up the demo");
- g_signal_connect(G_OBJECT(lockButton),
- "clicked",
- G_CALLBACK(sleep_cb),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- lockButton,
- -1); /*-1 means append to end of toolbar*/
-
-
- GtkToolItem *decoButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(decoButton,
- "This is a demo button that toggles window decorations");
- g_signal_connect(G_OBJECT(decoButton),
- "clicked",
- G_CALLBACK(toggle_decorated_cb),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- decoButton,
- -1); /*-1 means append to end of toolbar*/
-
- GtkToolItem *lockRatioButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(lockRatioButton,
- "This is a demo button that locks the aspect ratio using a hint");
- g_signal_connect(G_OBJECT(lockRatioButton),
- "clicked",
- G_CALLBACK(toggle_aspect_ratio),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- lockRatioButton,
- -1); /*-1 means append to end of toolbar*/
-
- GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
- gtk_tool_item_set_tooltip_text(quitButton,
- "This is a demo button with a 'quit' icon");
- g_signal_connect(G_OBJECT(quitButton),
- "clicked",
- G_CALLBACK(clicked_toolbar_cb),
- window);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- quitButton,
- -1); /*-1 means append to end of toolbar*/
handlebox = gtk_handle_box_new ();
- gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
+ gtk_container_add (GTK_CONTAINER (handlebox),
+ gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar"));
gtk_table_attach (GTK_TABLE (table),
handlebox,
@@ -1362,6 +1373,7 @@ do_appwindow (void)
g_object_unref (action_group);
g_object_unref (builder);
#else
+ g_object_unref (ui_manager);
return window;
#endif
}
diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c
index a40579db..4feb25c9 100644
--- a/src/ui/draw-workspace.c
+++ b/src/ui/draw-workspace.c
@@ -26,12 +26,7 @@
*/
#include "draw-workspace.h"
-
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate-desktop/mate-desktop-utils.h>
-#endif
-
+#include "theme.h"
static void
get_window_rect (const WnckWindowDisplayInfo *win,
@@ -110,7 +105,7 @@ draw_window (GtkWidget *widget,
#if GTK_CHECK_VERSION (3, 0, 0)
style = gtk_widget_get_style_context (widget);
if (is_active)
- mate_desktop_gtk_style_get_light_color (style, state, &color);
+ meta_gtk_style_get_light_color (style, state, &color);
else
gtk_style_context_get_background_color (style, state, &color);
gdk_cairo_set_source_rgba (cr, &color);
@@ -268,7 +263,7 @@ wnck_draw_workspace (GtkWidget *widget,
#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color;
- mate_desktop_gtk_style_get_dark_color (style,state, &color);
+ meta_gtk_style_get_dark_color (style,state, &color);
gdk_cairo_set_source_rgba (cr, &color);
#else
gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->dark[state]);
diff --git a/src/ui/fixedtip.c b/src/ui/fixedtip.c
index fc1be2af..7037eab3 100644
--- a/src/ui/fixedtip.c
+++ b/src/ui/fixedtip.c
@@ -72,7 +72,7 @@ draw_handler (GtkWidget *tooltips,
#else
static gint
-expose_handler (GtkTooltips *tooltips)
+expose_handler (GtkTooltip *tooltips)
{
gtk_paint_flat_box (gtk_widget_get_style (tip), gtk_widget_get_window (tip),
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 099c5052..99260936 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -161,6 +161,24 @@ meta_frames_get_type (void)
#endif
+static GObject *
+meta_frames_constructor (GType gtype,
+ guint n_properties,
+ GObjectConstructParam *properties)
+{
+ GObject *object;
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (parent_class);
+ object = gobject_class->constructor (gtype, n_properties, properties);
+
+ g_object_set (object,
+ "type", GTK_WINDOW_POPUP,
+ NULL);
+
+ return object;
+}
+
static void
meta_frames_class_init (MetaFramesClass *class)
{
@@ -180,6 +198,7 @@ meta_frames_class_init (MetaFramesClass *class)
parent_class = g_type_class_peek_parent (class);
#endif
+ gobject_class->constructor = meta_frames_constructor;
gobject_class->finalize = meta_frames_finalize;
#if !GTK_CHECK_VERSION(3, 0, 0)
object_class->destroy = meta_frames_destroy;
@@ -245,10 +264,6 @@ 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);
frames->frames = g_hash_table_new (unsigned_long_hash, unsigned_long_equal);
@@ -565,6 +580,8 @@ meta_frames_ensure_layout (MetaFrames *frames,
pango_layout_set_auto_dir (frame->layout, FALSE);
+ pango_layout_set_single_paragraph_mode (frame->layout, TRUE);
+
font_desc = meta_gtk_widget_get_font_desc (widget, scale,
meta_prefs_get_titlebar_font ());
@@ -662,8 +679,9 @@ meta_frames_attach_style (MetaFrames *frames,
frame->style = g_object_ref (gtk_widget_get_style_context (GTK_WIDGET (frames)));
#else
/* Weirdly, gtk_style_attach() steals a reference count from the style passed in */
- g_object_ref (GTK_WIDGET (frames)->style);
- frame->style = gtk_style_attach (GTK_WIDGET (frames)->style, frame->window);
+ g_object_ref (gtk_widget_get_style (GTK_WIDGET (frames)));
+ frame->style = gtk_style_attach (gtk_widget_get_style (GTK_WIDGET (frames)),
+ frame->window);
#endif
}
@@ -2324,7 +2342,7 @@ clip_to_screen (GdkRegion *region, MetaUIFrame *frame)
META_CORE_GET_FRAME_Y, &frame_area.y,
META_CORE_GET_FRAME_WIDTH, &frame_area.width,
META_CORE_GET_FRAME_HEIGHT, &frame_area.height,
- META_CORE_GET_SCREEN_WIDTH, &screen_area.height,
+ META_CORE_GET_SCREEN_WIDTH, &screen_area.width,
META_CORE_GET_SCREEN_HEIGHT, &screen_area.height,
META_CORE_GET_END);
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 1dfc7140..407ef986 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -381,6 +381,7 @@ meta_window_menu_new (MetaFrames *frames,
Display *display;
Window xroot;
GdkScreen *screen;
+ GdkWindow *window;
GtkWidget *submenu;
int j;
@@ -393,7 +394,7 @@ meta_window_menu_new (MetaFrames *frames,
meta_verbose ("Creating %d-workspace menu current space %lu\n",
n_workspaces, active_workspace);
- GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (frames));
+ window = gtk_widget_get_window (GTK_WIDGET (frames));
display = GDK_WINDOW_XDISPLAY (window);
@@ -440,20 +441,11 @@ 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);
@@ -476,20 +468,11 @@ 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)
@@ -518,14 +501,8 @@ 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");
- }
+ meta_warning("GtkMenu failed to grab the pointer\n");
}
void meta_window_menu_free(MetaWindowMenu* menu)
diff --git a/src/ui/metaaccellabel.c b/src/ui/metaaccellabel.c
index 3ef870bc..da040ee8 100644
--- a/src/ui/metaaccellabel.c
+++ b/src/ui/metaaccellabel.c
@@ -423,52 +423,61 @@ meta_accel_label_expose_event (GtkWidget *widget,
GtkMisc *misc = GTK_MISC (accel_label);
PangoLayout *layout;
- if (GTK_WIDGET_DRAWABLE (accel_label))
+ if (gtk_widget_is_drawable (GTK_WIDGET (accel_label)))
{
int ac_width;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_requisition (widget, &requisition);
ac_width = meta_accel_label_get_accel_width (accel_label);
- if (widget->allocation.width >= widget->requisition.width + ac_width)
+ if (allocation.width >= requisition.width + ac_width)
{
GtkTextDirection direction = gtk_widget_get_direction (widget);
- gint x;
- gint y;
+ gfloat xalign, yalign;
+ gint x, y;
+ gint xpad, ypad;
+
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+ gtk_misc_get_alignment (misc, &xalign, &yalign);
if (direction == GTK_TEXT_DIR_RTL)
{
- widget->allocation.x += ac_width;
+ allocation.x += ac_width;
}
- widget->allocation.width -= ac_width;
+ allocation.width -= ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
if (GTK_WIDGET_CLASS (parent_class)->expose_event)
GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
if (direction == GTK_TEXT_DIR_RTL)
{
- widget->allocation.x -= ac_width;
+ allocation.x -= ac_width;
}
- widget->allocation.width += ac_width;
+ allocation.width += ac_width;
+ gtk_widget_set_allocation (widget, &allocation);
if (direction == GTK_TEXT_DIR_RTL)
{
- x = widget->allocation.x + misc->xpad;
+ x = allocation.x + allocation.width - xpad - ac_width;
}
else
{
- x = widget->allocation.x + widget->allocation.width - misc->xpad - ac_width;
+ x = allocation.x + allocation.width - xpad - ac_width;
}
- y = (widget->allocation.y * (1.0 - misc->yalign) +
- (widget->allocation.y + widget->allocation.height -
- (widget->requisition.height - misc->ypad * 2)) *
- misc->yalign) + 1.5;
+ y = (allocation.y * (1.0 - yalign) +
+ (allocation.y + allocation.height -
+ (requisition.height - ypad * 2)) * yalign) + 1.5;
layout = gtk_widget_create_pango_layout (widget, accel_label->accel_string);
- gtk_paint_layout (widget->style,
- widget->window,
- GTK_WIDGET_STATE (widget),
+ gtk_paint_layout (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget),
FALSE,
&event->area,
widget,
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index da8593d4..9138c6f5 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -103,19 +103,17 @@ meta_preview_class_init (MetaPreviewClass *class)
gobject_class->finalize = meta_preview_finalize;
- #if GTK_CHECK_VERSION(3, 0, 0)
+#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;
-#if GTK_CHECK_VERSION(3, 0, 0)
gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (class));
+#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;
}
static void
@@ -162,11 +160,7 @@ 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);
}
@@ -447,9 +441,6 @@ meta_preview_expose (GtkWidget *widget,
return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
}
-#endif
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
static void
meta_preview_size_request (GtkWidget *widget,
GtkRequisition *req)
diff --git a/src/ui/tabpopup.c b/src/ui/tabpopup.c
index dfbdf1a4..12fb4250 100644
--- a/src/ui/tabpopup.c
+++ b/src/ui/tabpopup.c
@@ -535,16 +535,16 @@ display_entry (MetaTabPopup *popup,
if (popup->outline)
{
+ window = gtk_widget_get_window (popup->outline_window);
+
/* Do stuff behind gtk's back */
- gdk_window_hide (gtk_widget_get_window(popup->outline_window));
+ gdk_window_hide (window);
meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
rect = te->rect;
rect.x = 0;
rect.y = 0;
- 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);
@@ -554,7 +554,7 @@ display_entry (MetaTabPopup *popup,
gdk_window_set_background_rgba (window, &black);
#else
gdk_window_set_background (window,
- &popup->outline_window->style->black);
+ &gtk_widget_get_style (popup->outline_window)->black);
#endif
region = gdk_region_rectangle (&rect);
@@ -828,35 +828,41 @@ meta_select_image_expose_event (GtkWidget *widget,
{
if (META_SELECT_IMAGE (widget)->selected)
{
- int x, y, w, h;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
GtkMisc *misc;
GtkStyle *style;
GtkStateType state;
+ GdkWindow *window;
+ int x, y, w, h;
+ int xpad, ypad;
+ float xalign, yalign;
cairo_t *cr;
- GtkAllocation allocation;
-
- gtk_widget_get_allocation(widget, &allocation);
misc = GTK_MISC (widget);
- x = (allocation.x * (1.0 - misc->xalign) +
+ gtk_widget_get_allocation(widget, &allocation);
+ gtk_widget_get_requisition (widget, &requisition);
+ gtk_misc_get_padding (misc, &xpad, &ypad);
+ gtk_misc_get_alignment (misc, &xalign, &yalign);
+
+ x = (allocation.x * (1.0 - xalign) +
(allocation.x + allocation.width
- - (widget->requisition.width - misc->xpad * 2)) *
- misc->xalign) + 0.5;
- y = (allocation.y * (1.0 - misc->yalign) +
+ - (requisition.width - xpad * 2)) * xalign) + 0.5;
+ y = (allocation.y * (1.0 - yalign) +
(allocation.y + allocation.height
- - (widget->requisition.height - misc->ypad * 2)) *
- misc->yalign) + 0.5;
+ - (requisition.height - ypad * 2)) * yalign) + 0.5;
x -= INSIDE_SELECT_RECT + 1;
y -= INSIDE_SELECT_RECT + 1;
- w = widget->requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
- h = widget->requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
+ w = requisition.width - OUTSIDE_SELECT_RECT * 2 - 1;
+ h = requisition.height - OUTSIDE_SELECT_RECT * 2 - 1;
+ window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
- cr = gdk_cairo_create (gtk_widget_get_window(widget));
+ cr = gdk_cairo_create (window);
cairo_set_line_width (cr, 2.0);
gdk_cairo_set_source_color (cr, &style->fg[state]);
@@ -1127,13 +1133,12 @@ meta_select_workspace_expose_event (GtkWidget *widget,
{
MetaWorkspace *workspace;
WnckWindowDisplayInfo *windows;
+ GtkAllocation allocation;
GtkStyle *style;
+ GdkWindow *window;
cairo_t *cr;
int i, n_windows;
GList *tmp, *list;
- GtkAllocation allocation;
-
- gtk_widget_get_allocation(widget, &allocation);
workspace = META_SELECT_WORKSPACE (widget)->workspace;
@@ -1170,8 +1175,11 @@ meta_select_workspace_expose_event (GtkWidget *widget,
g_list_free (list);
+ window = gtk_widget_get_window (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
wnck_draw_workspace (widget,
- gtk_widget_get_window(widget),
+ window,
SELECT_OUTLINE_WIDTH,
SELECT_OUTLINE_WIDTH,
allocation.width - SELECT_OUTLINE_WIDTH * 2,
@@ -1188,7 +1196,7 @@ meta_select_workspace_expose_event (GtkWidget *widget,
if (META_SELECT_WORKSPACE (widget)->selected)
{
style = gtk_widget_get_style (widget);
- cr = gdk_cairo_create (gtk_widget_get_window(widget));
+ cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr,
&style->fg[gtk_widget_get_state (widget)]);
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index 0a5e4eb2..a9ef8103 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -76,92 +76,99 @@ static void run_position_expression_timings (void);
static void run_theme_benchmark (void);
-static GtkItemFactoryEntry menu_items[] =
+static const gchar *menu_item_string =
+ "<ui>\n"
+ "<menubar>\n"
+ "<menu name='Windows' action='Windows'>\n"
+ "<menuitem name='Dialog' action='Dialog'/>\n"
+ "<menuitem name='Modal dialog' action='Modal dialog'/>\n"
+ "<menuitem name='Utility' action='Utility'/>\n"
+ "<menuitem name='Splashscreen' action='Splashscreen'/>\n"
+ "<menuitem name='Top dock' action='Top dock'/>\n"
+ "<menuitem name='Bottom dock' action='Bottom dock'/>\n"
+ "<menuitem name='Left dock' action='Left dock'/>\n"
+ "<menuitem name='Right dock' action='Right dock'/>\n"
+ "<menuitem name='Desktop' action='Desktop'/>\n"
+ "</menu>\n"
+ "</menubar>\n"
+ "<toolbar>\n"
+ "<separator/>\n"
+ "<toolitem name='New' action='New'/>\n"
+ "<toolitem name='Open' action='Open'/>\n"
+ "<toolitem name='Quit' action='Quit'/>\n"
+ "<separator/>\n"
+ "</toolbar>\n"
+ "</ui>\n";
+
+static GtkActionEntry menu_items[] =
{
- { N_("/_Windows"), NULL, NULL, 0, "<Branch>" },
- { N_("/Windows/tearoff"), NULL, NULL, 0, "<Tearoff>" },
- { N_("/Windows/_Dialog"), "<control>d", NULL, 0, NULL },
- { N_("/Windows/_Modal dialog"), NULL, NULL, 0, NULL },
- { N_("/Windows/_Utility"), "<control>u", NULL, 0, NULL },
- { N_("/Windows/_Splashscreen"), "<control>s", NULL, 0, NULL },
- { N_("/Windows/_Top dock"), NULL, NULL, 0, NULL },
- { N_("/Windows/_Bottom dock"), NULL, NULL, 0, NULL },
- { N_("/Windows/_Left dock"), NULL, NULL, 0, NULL },
- { N_("/Windows/_Right dock"), NULL, NULL, 0, NULL },
- { N_("/Windows/_All docks"), NULL, NULL, 0, NULL },
- { N_("/Windows/Des_ktop"), NULL, NULL, 0, NULL }
+ { "Windows", NULL, N_("_Windows"), NULL, NULL, NULL },
+ { "Dialog", NULL, N_("_Dialog"), "<control>d", NULL, NULL },
+ { "Modal dialog", NULL, N_("_Modal dialog"), NULL, NULL, NULL },
+ { "Utility", NULL, N_("_Utility"), "<control>u", NULL, NULL },
+ { "Splashscreen", NULL, N_("_Splashscreen"), "<control>s", NULL, NULL },
+ { "Top dock", NULL, N_("_Top dock"), NULL, NULL, NULL },
+ { "Bottom dock", NULL, N_("_Bottom dock"), NULL, NULL, NULL },
+ { "Left dock", NULL, N_("_Left dock"), NULL, NULL, NULL },
+ { "Right dock", NULL, N_("_Right dock"), NULL, NULL, NULL },
+ { "All docks", NULL, N_("_All docks"), NULL, NULL, NULL },
+ { "Desktop", NULL, N_("Des_ktop"), NULL, NULL, NULL }
+};
+
+static GtkActionEntry tool_items[] =
+{
+ { "New", GTK_STOCK_NEW, NULL, NULL,
+ N_("Open another one of these windows"), NULL },
+ { "Open", GTK_STOCK_OPEN, NULL, NULL,
+ N_("This is a demo button with an 'open' icon"), NULL },
+ { "Quit", GTK_STOCK_QUIT, NULL, NULL,
+ N_("This is a demo button with a 'quit' icon"), NULL }
};
static GtkWidget *
normal_contents (void)
{
GtkWidget *table;
- GtkWidget *toolbar;
GtkWidget *handlebox;
GtkWidget *statusbar;
GtkWidget *contents;
GtkWidget *sw;
- GtkItemFactory *item_factory;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
table = gtk_table_new (1, 4, FALSE);
/* Create the menubar
*/
- item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL);
+ action_group = gtk_action_group_new ("mainmenu");
+ gtk_action_group_add_actions (action_group,
+ menu_items,
+ G_N_ELEMENTS (menu_items),
+ NULL);
+ gtk_action_group_add_actions (action_group,
+ tool_items,
+ G_N_ELEMENTS (tool_items),
+ NULL);
- gtk_item_factory_set_translate_func(item_factory,
- (GtkTranslateFunc)gettext, NULL, NULL);
+ ui_manager = gtk_ui_manager_new ();
- /* Set up item factory to go away */
- g_object_ref (item_factory);
- g_object_ref_sink (item_factory);
- g_object_unref (item_factory);
- g_object_set_data_full (G_OBJECT (table),
- "<main>",
- item_factory,
- (GDestroyNotify) g_object_unref);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
/* create menu items */
- gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
- menu_items, NULL);
+ gtk_ui_manager_add_ui_from_string (ui_manager, menu_item_string, -1, NULL);
gtk_table_attach (GTK_TABLE (table),
- gtk_item_factory_get_widget (item_factory, "<main>"),
+ gtk_ui_manager_get_widget (ui_manager, "/ui/menubar"),
/* X direction */ /* Y direction */
0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, 0,
0, 0);
- /* Create the toolbar
- */
- toolbar = gtk_toolbar_new ();
-
- GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
- gtk_tool_item_set_tooltip_text(newButton,
- "Open another one of these windows");
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- newButton,
- -1); /*-1 means append to end of toolbar*/
-
- GtkToolItem *openButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
- gtk_tool_item_set_tooltip_text(openButton,
- "This is a demo button with an \'open\' icon");
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- openButton,
- -1); /*-1 means append to end of toolbar*/
-
- GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
- gtk_tool_item_set_tooltip_text(quitButton,
- "This is a demo button with a \'quit\' icon");
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
- quitButton,
- -1); /*-1 means append to end of toolbar*/
-
-
handlebox = gtk_handle_box_new ();
- gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
+ gtk_container_add (GTK_CONTAINER (handlebox),
+ gtk_ui_manager_get_widget (ui_manager, "/ui/toolbar"));
gtk_table_attach (GTK_TABLE (table),
handlebox,
@@ -208,6 +215,8 @@ normal_contents (void)
gtk_widget_show_all (table);
+ g_object_unref (ui_manager);
+
return table;
}
@@ -778,6 +787,7 @@ main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *collection;
+ GtkStyle *style;
GError *err;
clock_t start, end;
GtkWidget *notebook;
@@ -852,26 +862,28 @@ main (int argc, char **argv)
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_realize (window);
- g_assert (window->style);
- g_assert (window->style->font_desc);
+ style = gtk_widget_get_style (window);
+
+ g_assert (style);
+ g_assert (style->font_desc);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (window), notebook);
collection = preview_collection (FONT_SIZE_NORMAL,
- window->style->font_desc);
+ style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Normal Title Font")));
collection = preview_collection (FONT_SIZE_SMALL,
- window->style->font_desc);
+ style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Small Title Font")));
collection = preview_collection (FONT_SIZE_LARGE,
- window->style->font_desc);
+ style->font_desc);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
collection,
gtk_label_new (_("Large Title Font")));
@@ -922,7 +934,7 @@ get_flags (GtkWidget *widget)
static int
get_text_height (GtkWidget *widget)
{
- return meta_pango_font_desc_get_text_height (widget->style->font_desc,
+ return meta_pango_font_desc_get_text_height (gtk_widget_get_style (widget)->font_desc,
gtk_widget_get_pango_context (widget));
}
@@ -1003,7 +1015,7 @@ run_theme_benchmark (void)
/* Creating the pixmap in the loop is right, since
* GDK does the same with its double buffering.
*/
- pixmap = gdk_pixmap_new (widget->window,
+ pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
client_width + left_width + right_width,
client_height + top_height + bottom_height,
-1);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index a7dc8d08..c9f2ab47 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -64,11 +64,6 @@
#include <math.h>
#if GTK_CHECK_VERSION (3, 0, 0)
-#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate-desktop/mate-desktop-utils.h>
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
#define GDK_COLOR_RGBA(color) \
((guint32) (0xff | \
((int)((color).red * 255) << 24) | \
@@ -1312,7 +1307,6 @@ meta_color_spec_new_from_string (const char *str,
spec = meta_color_spec_new (META_COLOR_SPEC_GTK);
spec->data.gtk.state = state;
spec->data.gtk.component = component;
- g_assert (spec->data.gtk.state < N_GTK_STATES);
g_assert (spec->data.gtk.component < META_GTK_COLOR_LAST);
}
else if (str[0] == 'b' && str[1] == 'l' && str[2] == 'e' && str[3] == 'n' &&
@@ -1488,6 +1482,72 @@ meta_color_spec_new_gtk (MetaGtkColorComponent component,
#if GTK_CHECK_VERSION (3, 0, 0)
static void
+get_background_color_real (GtkStyleContext *context,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GdkRGBA *c;
+
+ g_return_if_fail (color != NULL);
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+
+ gtk_style_context_get (context,
+ state,
+ "background-color", &c,
+ NULL);
+
+ *color = *c;
+ gdk_rgba_free (c);
+}
+
+static void
+get_background_color (GtkStyleContext *context,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ GdkRGBA empty = { 0.0, 0.0, 0.0, 0.0 };
+ GdkRGBA rgba;
+
+ get_background_color_real (context, state, &rgba);
+
+ if (gdk_rgba_equal (&rgba, &empty))
+ {
+ GtkWidget *toplevel;
+ GtkStyleContext *tmp;
+
+ toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ tmp = gtk_widget_get_style_context (toplevel);
+
+ get_background_color_real (tmp, state, &rgba);
+
+ gtk_widget_destroy (toplevel);
+ }
+
+ *color = rgba;
+}
+
+/* Based on set_color() in gtkstyle.c */
+#define LIGHTNESS_MULT 1.3
+#define DARKNESS_MULT 0.7
+void
+meta_gtk_style_get_light_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ get_background_color (style, state, color);
+ gtk_style_shade (color, color, LIGHTNESS_MULT);
+}
+
+void
+meta_gtk_style_get_dark_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color)
+{
+ get_background_color (style, state, color);
+ gtk_style_shade (color, color, DARKNESS_MULT);
+}
+
+static void
meta_set_color_from_style (GdkRGBA *color,
GtkStyleContext *context,
GtkStateFlags state,
@@ -1499,7 +1559,7 @@ meta_set_color_from_style (GdkRGBA *color,
{
case META_GTK_COLOR_BG:
case META_GTK_COLOR_BASE:
- gtk_style_context_get_background_color (context, state, color);
+ get_background_color (context, state, color);
break;
case META_GTK_COLOR_FG:
case META_GTK_COLOR_TEXT:
@@ -1514,18 +1574,18 @@ meta_set_color_from_style (GdkRGBA *color,
color->blue = (color->blue + other.blue) / 2;
break;
case META_GTK_COLOR_MID:
- mate_desktop_gtk_style_get_light_color (context, state, color);
- mate_desktop_gtk_style_get_dark_color (context, state, &other);
+ meta_gtk_style_get_light_color (context, state, color);
+ meta_gtk_style_get_dark_color (context, state, &other);
color->red = (color->red + other.red) / 2;
color->green = (color->green + other.green) / 2;
color->blue = (color->blue + other.blue) / 2;
break;
case META_GTK_COLOR_LIGHT:
- mate_desktop_gtk_style_get_light_color (context, state, color);
+ meta_gtk_style_get_light_color (context, state, color);
break;
case META_GTK_COLOR_DARK:
- mate_desktop_gtk_style_get_dark_color (context, state, color);
+ meta_gtk_style_get_dark_color (context, state, color);
break;
case META_GTK_COLOR_LAST:
g_assert_not_reached ();
@@ -3698,44 +3758,31 @@ meta_draw_op_draw_with_env (const MetaDrawOp *op,
y2 = y1;
/* This is one of the cases where we are matching the exact
- * pixel aligned rectangle produced by X.
+ * pixel aligned rectangle produced by X; for zero-width lines
+ * the generic algorithm produces the right result so we don't
+ * need to handle them here.
*/
- if (y1 == y2 || x1 == x2)
+ if ((y1 == y2 || x1 == x2) && op->data.line.width != 0)
{
- double offset = (op->data.line.width == 0 ||
- op->data.line.width % 2) ? .5 : 0;
- /* X includes end points for lines of width 0 */
- double line_extend = op->data.line.width == 0 ? 1. : 0.;
+ double offset = op->data.line.width % 2 ? .5 : 0;
if (y1 == y2)
{
- if (x2 < x1)
- {
- x1 ^= x2;
- x2 ^= x1;
- x1 ^= x2;
- }
cairo_move_to (cr, x1, y1 + offset);
- cairo_line_to (cr, x2 + line_extend, y2 + offset);
+ cairo_line_to (cr, x2, y2 + offset);
}
else
{
- if (y2 < y1)
- {
- y1 ^= y2;
- y2 ^= y1;
- y1 ^= y2;
- }
cairo_move_to (cr, x1 + offset, y1);
- cairo_line_to (cr, x2 + offset, y2 + line_extend);
+ cairo_line_to (cr, x2 + offset, y2);
}
}
else
{
- if (op->data.line.width <= 0)
- {
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
- }
+ /* zero-width lines include both end-points in X, unlike wide lines */
+ if (op->data.line.width == 0)
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
+
cairo_move_to (cr, x1 + .5, y1 + .5);
cairo_line_to (cr, x2 + .5, y2 + .5);
}
@@ -4745,10 +4792,10 @@ meta_frame_style_validate (MetaFrameStyle *style,
}
static void
-button_rect (MetaButtonType type,
- const MetaFrameGeometry *fgeom,
- int middle_background_offset,
- GdkRectangle *rect)
+get_button_rect (MetaButtonType type,
+ const MetaFrameGeometry *fgeom,
+ int middle_background_offset,
+ GdkRectangle *rect)
{
switch (type)
{
@@ -5068,7 +5115,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
{
MetaButtonState button_state;
- button_rect (j, fgeom, middle_bg_offset, &rect);
+ get_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);
@@ -5123,7 +5170,7 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
{
MetaButtonState button_state;
- button_rect (j, fgeom, middle_bg_offset, &rect);
+ get_button_rect (j, fgeom, middle_bg_offset, &rect);
rect.x += x_offset;
rect.y += y_offset;
diff --git a/src/ui/theme.h b/src/ui/theme.h
index 66996d89..ea3ec196 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -694,8 +694,6 @@ typedef enum
META_FRAME_PIECE_LAST
} MetaFramePiece;
-#define N_GTK_STATES 5
-
/**
* How to draw a frame in a particular state (say, a focussed, non-maximised,
* resizable frame). This corresponds closely to the <frame_style> tag
@@ -1271,6 +1269,14 @@ GtkArrowType meta_gtk_arrow_from_string (const char *s
const char* meta_gtk_arrow_to_string (GtkArrowType arrow);
MetaImageFillType meta_image_fill_type_from_string (const char *str);
const char* meta_image_fill_type_to_string (MetaImageFillType fill_type);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void meta_gtk_style_get_light_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color);
+void meta_gtk_style_get_dark_color (GtkStyleContext *style,
+ GtkStateFlags state,
+ GdkRGBA *color);
+#endif
guint meta_theme_earliest_version_with_button (MetaButtonType type);
diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c
index c938317b..e14ffe25 100644
--- a/src/ui/tile-preview.c
+++ b/src/ui/tile-preview.c
@@ -62,24 +62,16 @@ meta_tile_preview_expose (GtkWidget *widget,
{
MetaTilePreview *preview = user_data;
#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkWindow *window;
- cairo_t *cr;
-
- window = gtk_widget_get_window (widget);
- cr = gdk_cairo_create (window);
+ cairo_t *cr = gdk_cairo_create (event->window);
#endif
cairo_set_line_width (cr, 1.0);
if (preview->has_alpha)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
- GdkRGBA preview_color = *preview->preview_color;
-#endif
-
/* Fill the preview area with a transparent color */
#if GTK_CHECK_VERSION (3, 0, 0)
- gdk_cairo_set_source_rgba (cr, &preview_color);
+ gdk_cairo_set_source_rgba (cr, preview->preview_color);
#else
cairo_set_source_rgba (cr,
(double)preview->preview_color->red / 0xFFFF,
@@ -93,7 +85,7 @@ meta_tile_preview_expose (GtkWidget *widget,
/* Use the opaque color for the border */
#if GTK_CHECK_VERSION (3, 0, 0)
- gdk_cairo_set_source_rgba (cr, &preview_color);
+ gdk_cairo_set_source_rgba (cr, preview->preview_color);
#else
gdk_cairo_set_source_color (cr, preview->preview_color);
#endif
@@ -121,6 +113,13 @@ meta_tile_preview_expose (GtkWidget *widget,
0.5, 0.5,
preview->tile_rect.width - 1,
preview->tile_rect.height - 1);
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (preview->has_alpha) {
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgba (cr, preview->preview_color->red, preview->preview_color->green, preview->preview_color->blue, 1.0);
+ }
+#endif
cairo_stroke (cr);
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -265,11 +264,7 @@ meta_tile_preview_show (MetaTilePreview *preview,
return; /* nothing to do */
window = gtk_widget_get_window (preview->preview_window);
-#if GTK_CHECK_VERSION (3, 0, 0)
meta_core_lower_beneath_focus_window (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-#else
- meta_core_lower_beneath_focus_window (gdk_display,
-#endif
GDK_WINDOW_XID (window),
gtk_get_current_event_time ());
diff --git a/src/ui/ui.c b/src/ui/ui.c
index bbef9395..76ef72fa 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -58,7 +58,7 @@ void meta_ui_init(int* argc, char*** argv)
* GDK will no longer generate the core XEvents we process.
* So at least for now, enforce the previous behavior.
*/
-#if GTK_CHECK_VERSION(2, 91, 7)
+#if GTK_CHECK_VERSION(3, 0, 0)
gdk_disable_multidevice ();
#endif
@@ -125,11 +125,7 @@ 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;
@@ -584,109 +580,6 @@ meta_ui_window_menu_free (MetaWindowMenu *menu)
}
#if !GTK_CHECK_VERSION (3, 0, 0)
-struct _MetaImageWindow
-{
- GtkWidget *window;
- GdkPixmap *pixmap;
-};
-
-MetaImageWindow*
-meta_image_window_new (Display *xdisplay,
- int screen_number,
- int max_width,
- int max_height)
-{
- MetaImageWindow *iw;
- GdkDisplay *gdisplay;
- GdkScreen *gscreen;
-
- iw = g_new (MetaImageWindow, 1);
- iw->window = gtk_window_new (GTK_WINDOW_POPUP);
-
- gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
- gscreen = gdk_display_get_screen (gdisplay, screen_number);
-
- gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
-
- gtk_widget_realize (iw->window);
- iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
- max_width, max_height,
- -1);
-
- gtk_widget_set_size_request (iw->window, 1, 1);
- gtk_widget_set_double_buffered (iw->window, FALSE);
- gtk_widget_set_app_paintable (iw->window, TRUE);
-
- return iw;
-}
-
-void
-meta_image_window_free (MetaImageWindow *iw)
-{
- gtk_widget_destroy (iw->window);
- g_object_unref (G_OBJECT (iw->pixmap));
- g_free (iw);
-}
-
-void
-meta_image_window_set_showing (MetaImageWindow *iw,
- gboolean showing)
-{
- if (showing)
- gtk_widget_show_all (iw->window);
- else
- {
- gtk_widget_hide (iw->window);
- meta_core_increment_event_serial (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
- }
-}
-
-void
-meta_image_window_set (MetaImageWindow *iw,
- GdkPixbuf *pixbuf,
- 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,
- 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 (gtk_widget_get_window (iw->window),
- iw->pixmap,
- FALSE);
-
- 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 (gtk_widget_get_window (iw->window));
-}
-#endif
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
static GdkColormap*
get_cmap (GdkPixmap *pixmap)
{
@@ -714,7 +607,7 @@ get_cmap (GdkPixmap *pixmap)
/* Be sure we aren't going to blow up due to visual mismatch */
if (cmap &&
- (gdk_colormap_get_visual (cmap)->depth !=
+ (gdk_visual_get_depth (gdk_colormap_get_visual (cmap)) !=
gdk_drawable_get_depth (pixmap)))
{
cmap = NULL;
@@ -791,14 +684,10 @@ 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_x11_window_lookup_for_display (gdk_display_get_default (), xpixmap);
@@ -818,10 +707,8 @@ 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));
@@ -841,6 +728,20 @@ meta_ui_pop_delay_exposes (MetaUI *ui)
meta_frames_pop_delay_exposes (ui->frames);
}
+static GdkPixbuf *
+load_default_window_icon (int size)
+{
+ GtkIconTheme *theme = gtk_icon_theme_get_default ();
+ const char *icon_name;
+
+ if (gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME))
+ icon_name = META_DEFAULT_ICON_NAME;
+ else
+ icon_name = "image-missing";
+
+ return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL);
+}
+
GdkPixbuf*
meta_ui_get_default_window_icon (MetaUI *ui)
{
@@ -848,26 +749,7 @@ meta_ui_get_default_window_icon (MetaUI *ui)
if (default_icon == NULL)
{
- GtkIconTheme *theme;
- gboolean icon_exists;
-
- theme = gtk_icon_theme_get_default ();
-
- icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
-
- if (icon_exists)
- default_icon = gtk_icon_theme_load_icon (theme,
- META_DEFAULT_ICON_NAME,
- META_ICON_WIDTH,
- 0,
- NULL);
- else
- default_icon = gtk_icon_theme_load_icon (theme,
- "image-missing",
- META_ICON_WIDTH,
- 0,
- NULL);
-
+ default_icon = load_default_window_icon (META_ICON_WIDTH);
g_assert (default_icon);
}
@@ -931,38 +813,6 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
return FALSE;
}
-char*
-meta_text_property_to_utf8 (Display *xdisplay,
- const XTextProperty *prop)
-{
- GdkDisplay *display;
- char **list;
- int count;
- char *retval;
-
- list = NULL;
-
- 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);
-
- if (count == 0)
- retval = NULL;
- else
- {
- retval = list[0];
- list[0] = g_strdup (""); /* something to free */
- }
-
- g_strfreev (list);
-
- return retval;
-}
-
void
meta_ui_theme_get_frame_borders (MetaUI *ui,
MetaFrameType type,
@@ -1253,9 +1103,7 @@ 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;
@@ -1263,16 +1111,10 @@ 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
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);
@@ -1281,7 +1123,6 @@ 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/main.c b/src/wm-tester/main.c
index d757270d..ae6db421 100644
--- a/src/wm-tester/main.c
+++ b/src/wm-tester/main.c
@@ -120,19 +120,11 @@ evil_timeout (gpointer data)
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_window_move (GTK_WINDOW (w),
g_random_int_range (0,
gdk_screen_width ()),
g_random_int_range (0,
gdk_screen_height ()));
-#else
- gtk_widget_set_uposition (w,
- g_random_int_range (0,
- gdk_screen_width ()),
- g_random_int_range (0,
- gdk_screen_height ()));
-#endif
parent = NULL;