summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormonsta <[email protected]>2019-07-30 11:50:34 +0300
committerraveit65 <[email protected]>2019-09-12 15:14:51 +0200
commit44c20584f3b64163126d7846beb61825efd02d64 (patch)
tree4f9a2b42891fff3d1f99bb70740b4e9a697940d8 /src
parentb2898238f715a67d6e560a10e5894a04ee3455c9 (diff)
downloadmarco-44c20584f3b64163126d7846beb61825efd02d64.tar.bz2
marco-44c20584f3b64163126d7846beb61825efd02d64.tar.xz
frames: apply modified hack from Mutter/Metacity
- this will be needed for proper window decoration color updates on theme change when theme variants fixes are applied - realize/unrealize functions are dropped instead of map/unmap ones, because we didn't change these during GTK+3 porting - MetaFrames now has GtkWindow as parent instead of GtkInvisible, otherwise the hack doesn't work (revert part of 96c7256d638b8c76c8abf786ba307e82a595dd67) adapted from: https://github.com/GNOME/metacity/commit/ba8500663457ad9f18ebfdf405162c2cb5caf88f
Diffstat (limited to 'src')
-rw-r--r--src/ui/frames.c39
-rw-r--r--src/ui/frames.h4
-rw-r--r--src/ui/ui.c9
3 files changed, 25 insertions, 27 deletions
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 74e97a30..52001c7d 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -42,7 +42,7 @@
#include <cairo-xlib.h>
-G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_INVISIBLE);
+G_DEFINE_TYPE (MetaFrames, meta_frames, GTK_TYPE_WINDOW);
#define DEFAULT_INNER_BUTTON_BORDER 3
@@ -51,8 +51,6 @@ static void meta_frames_init (MetaFrames *frames);
static void meta_frames_destroy (GtkWidget *object);
static void meta_frames_finalize (GObject *object);
static void meta_frames_style_updated (GtkWidget *widget);
-static void meta_frames_realize (GtkWidget *widget);
-static void meta_frames_unrealize (GtkWidget *widget);
static void meta_frames_update_prelit_control (MetaFrames *frames,
MetaUIFrame *frame,
@@ -131,8 +129,6 @@ meta_frames_class_init (MetaFramesClass *class)
gobject_class->finalize = meta_frames_finalize;
widget_class->destroy = meta_frames_destroy;
widget_class->style_updated = meta_frames_style_updated;
- widget_class->realize = meta_frames_realize;
- widget_class->unrealize = meta_frames_unrealize;
widget_class->draw = meta_frames_draw;
widget_class->destroy_event = meta_frames_destroy_event;
@@ -620,12 +616,25 @@ MetaFrames*
meta_frames_new (void)
{
GdkScreen *screen;
+ MetaFrames *frames;
screen = gdk_display_get_default_screen (gdk_display_get_default ());
- return g_object_new (META_TYPE_FRAMES,
- "screen", screen,
- NULL);
+ frames = g_object_new (META_TYPE_FRAMES,
+ "screen", screen,
+ "type", GTK_WINDOW_POPUP,
+ NULL);
+
+ /* Put the window at an arbitrary offscreen location; the one place
+ * it can't be is at -100x-100, since the meta_window_new() will
+ * mistake it for a window created via meta_create_offscreen_window()
+ * and ignore it, and we need this window to get frame-synchronization
+ * messages so that GTK+'s style change handling works.
+ */
+ gtk_window_move (GTK_WINDOW (frames), -200, -200);
+ gtk_window_resize (GTK_WINDOW (frames), 1, 1);
+
+ return frames;
}
/* In order to use a style with a window it has to be attached to that
@@ -734,20 +743,6 @@ meta_frames_unmanage_window (MetaFrames *frames,
meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
}
-static void
-meta_frames_realize (GtkWidget *widget)
-{
- if (GTK_WIDGET_CLASS (meta_frames_parent_class)->realize)
- GTK_WIDGET_CLASS (meta_frames_parent_class)->realize (widget);
-}
-
-static void
-meta_frames_unrealize (GtkWidget *widget)
-{
- if (GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize)
- GTK_WIDGET_CLASS (meta_frames_parent_class)->unrealize (widget);
-}
-
static MetaUIFrame*
meta_frames_lookup_window (MetaFrames *frames,
Window xwindow)
diff --git a/src/ui/frames.h b/src/ui/frames.h
index f1258783..ad86ee44 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -90,7 +90,7 @@ struct _MetaUIFrame
struct _MetaFrames
{
- GtkInvisible parent_instance;
+ GtkWindow parent_instance;
GHashTable *text_heights;
@@ -110,7 +110,7 @@ struct _MetaFrames
struct _MetaFramesClass
{
- GtkInvisibleClass parent_class;
+ GtkWindowClass parent_class;
};
GType meta_frames_get_type (void) G_GNUC_CONST;
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 0639757d..ed2c5772 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -271,9 +271,12 @@ meta_ui_new (Display *xdisplay,
g_assert (xdisplay == GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
ui->frames = meta_frames_new ();
- /* This does not actually show any widget. MetaFrames has been hacked so
- * that showing it doesn't actually do anything. But we need the flags
- * set for GTK to deliver events properly. */
+ /* GTK+ needs the frame-sync protocol to work in order to properly
+ * handle style changes. This means that the dummy widget we create
+ * to get the style for title bars actually needs to be mapped
+ * and fully tracked as a MetaWindow. Horrible, but mostly harmless -
+ * the window is a 1x1 overide redirect window positioned offscreen.
+ */
gtk_widget_show (GTK_WIDGET (ui->frames));
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);