[gtk+] Add a tiled window state



commit cbe5a3a590d66b9bc1c3d152be593a6dced5475d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 26 01:05:25 2013 -0400

    Add a tiled window state
    
    This information is needed to draw client-side decorations
    properly in this state.
    https://bugzilla.gnome.org/show_bug.cgi?id=696001

 gdk/gdkevents.h          |    5 ++++-
 gdk/x11/gdkdisplay-x11.c |   19 +++++++++++++++++++
 gtk/gtkwindow.c          |   14 ++++++++++++--
 3 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 999b0d3..c0e911c 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -460,6 +460,8 @@ typedef enum
  * @GDK_WINDOW_STATE_ABOVE: the window is kept above other windows.
  * @GDK_WINDOW_STATE_BELOW: the window is kept below other windows.
  * @GDK_WINDOW_STATE_FOCUSED: the window is presented as focused (with active decorations).
+ * @GDK_WINDOW_TILED: the window is in a tiled state, see
+ *   gdk_window_get_tiled_edges() for more details. Since 3.10
  *
  * Specifies the state of a toplevel window.
  */
@@ -472,7 +474,8 @@ typedef enum
   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
   GDK_WINDOW_STATE_BELOW      = 1 << 6,
-  GDK_WINDOW_STATE_FOCUSED    = 1 << 7
+  GDK_WINDOW_STATE_FOCUSED    = 1 << 7,
+  GDK_WINDOW_STATE_TILED      = 1 << 8
 } GdkWindowState;
 
 /**
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index f354132..42ed153 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -247,6 +247,25 @@ do_net_wm_state_changes (GdkWindow *window)
                                      GDK_WINDOW_STATE_MAXIMIZED);
     }
 
+  /* FIXME: we rely on implementation details of mutter here:
+   * mutter only tiles horizontally, and sets maxvert when it does
+   * and if it tiles, it always affects all edges
+   */
+  if (old_state & GDK_WINDOW_STATE_TILED)
+    {
+      if (!toplevel->have_maxvert)
+        gdk_synthesize_window_state (window,
+                                     GDK_WINDOW_STATE_TILED,
+                                     0);
+    }
+  else
+    {
+      if (toplevel->have_maxvert)
+        gdk_synthesize_window_state (window,
+                                     0,
+                                     GDK_WINDOW_STATE_TILED);
+    }
+
   if (old_state & GDK_WINDOW_STATE_FOCUSED)
     {
       if (!toplevel->have_focused)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 1eb3deb..8ff0a21 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -209,6 +209,7 @@ struct _GtkWindowPrivate
   guint    client_decorated          : 1; /* Decorations drawn client-side */
   guint    custom_title              : 1; /* app-provided titlebar */
   guint    fullscreen                : 1;
+  guint    tiled                     : 1;
 
 };
 
@@ -6120,7 +6121,8 @@ get_decoration_size (GtkWidget *widget,
   if (!priv->client_decorated)
     return;
 
-  if (gtk_window_get_maximized (GTK_WINDOW (widget)))
+  if (gtk_window_get_maximized (GTK_WINDOW (widget)) ||
+      GTK_WINDOW (widget)->priv->tiled)
     return;
 
   state = gtk_widget_get_state_flags (widget);
@@ -6556,7 +6558,14 @@ gtk_window_state_event (GtkWidget           *widget,
         (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) ? 1 : 0;
     }
 
-  if (event->changed_mask & (GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_MAXIMIZED))
+  if (event->changed_mask & GDK_WINDOW_STATE_TILED)
+    {
+      priv->tiled =
+        (event->new_window_state & GDK_WINDOW_STATE_TILED) ? 1 : 0;
+    }
+
+
+  if (event->changed_mask & (GDK_WINDOW_STATE_FULLSCREEN | GDK_WINDOW_STATE_MAXIMIZED | 
GDK_WINDOW_STATE_TILED))
     {
       update_window_buttons (window);
       gtk_widget_queue_draw (GTK_WIDGET (window));
@@ -8891,6 +8900,7 @@ gtk_window_draw (GtkWidget *widget,
       if (priv->client_decorated &&
           priv->decorated &&
           !priv->fullscreen &&
+          !priv->tiled &&
           !gtk_window_get_maximized (GTK_WINDOW (widget)))
         {
           gtk_style_context_save (context);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]