[mutter/wip/cb2eb3: 47/55] ui: Scrap MetaFrames, move rest of frame management into MetaUi



commit 5053997021e4e9eb5dbb96fecd863b4d8adfe4e2
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri May 4 23:30:17 2012 -0300

    ui: Scrap MetaFrames, move rest of frame management into MetaUi
    
    Additionally, rename the code that houses MetaUIFrame to uiframe.[ch],
    and fix up some other places that depended on MetaFrames.

 src/Makefile.am                |    4 +-
 src/core/frame.c               |    4 +-
 src/core/window.c              |    2 +
 src/ui/menu.c                  |   22 ++--
 src/ui/menu.h                  |    8 +-
 src/ui/ui.c                    |  227 ++++++++++++++++++++++++++----
 src/ui/ui.h                    |    4 +
 src/ui/{frames.c => uiframe.c} |  302 +---------------------------------------
 src/ui/{frames.h => uiframe.h} |   52 +------
 9 files changed, 238 insertions(+), 387 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ea6794d..c0faa3a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -128,8 +128,8 @@ libmutter_la_SOURCES =                              \
        core/core.h                             \
        ui/ui.h                                 \
        inlinepixbufs.h                         \
-       ui/frames.c                             \
-       ui/frames.h                             \
+       ui/uiframe.c                            \
+       ui/uiframe.h                            \
        ui/menu.c                               \
        ui/menu.h                               \
        ui/metaaccellabel.c                     \
diff --git a/src/core/frame.c b/src/core/frame.c
index 84ace36..279d6fa 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -362,8 +362,8 @@ meta_frame_sync_to_window (MetaFrame *frame,
        */
       if (frame->window->display->grab_window ==
           frame->window)
-        meta_ui_repaint_frame (frame->window->screen->ui,
-                               frame->xwindow);
+        meta_ui_queue_frame_draw (frame->window->screen->ui,
+                                  frame->xwindow);
     }
 
   return need_resize;
diff --git a/src/core/window.c b/src/core/window.c
index 6f8b3b3..14e6650 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8327,6 +8327,8 @@ meta_window_show_menu (MetaWindow *window,
 
   menu =
     meta_ui_window_menu_new (window->screen->ui,
+                             window->display->xdisplay,
+                             window->screen->number,
                              window->xwindow,
                              ops,
                              insensitive,
diff --git a/src/ui/menu.c b/src/ui/menu.c
index 5372a8c..04cc8c0 100644
--- a/src/ui/menu.c
+++ b/src/ui/menu.c
@@ -137,7 +137,7 @@ menu_closed (GtkMenu *widget,
   
   menu = data;
 
-  meta_frames_notify_menu_hide (menu->frames);
+  meta_ui_notify_menu_hide (menu->ui);
   (* menu->func) (menu,
                   GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                   menu->client_xwindow,
@@ -157,7 +157,7 @@ activate_cb (GtkWidget *menuitem, gpointer data)
   
   md = data;
 
-  meta_frames_notify_menu_hide (md->menu->frames);
+  meta_ui_notify_menu_hide (md->menu->ui);
   (* md->menu->func) (md->menu,
                       GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                       md->menu->client_xwindow,
@@ -321,7 +321,9 @@ menu_item_new (MenuItem *menuitem, int workspace_id)
 }
 
 MetaWindowMenu*
-meta_window_menu_new   (MetaFrames         *frames,
+meta_window_menu_new   (MetaUI             *ui,
+                        Display            *display,
+                        gint                screen_no,
                         MetaMenuOp          ops,
                         MetaMenuOp          insensitive,
                         Window              client_xwindow,
@@ -332,6 +334,8 @@ meta_window_menu_new   (MetaFrames         *frames,
 {
   int i;
   MetaWindowMenu *menu;
+  GdkDisplay *gdkdisplay = gdk_x11_lookup_xdisplay (display);
+  GdkScreen *screen = gdk_display_get_screen (gdkdisplay, screen_no);
 
   /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */
   if (n_workspaces < 2)
@@ -341,7 +345,7 @@ meta_window_menu_new   (MetaFrames         *frames,
     ops &= ~(META_MENU_OP_WORKSPACES);
   
   menu = g_new (MetaWindowMenu, 1);
-  menu->frames = frames;
+  menu->ui = ui;
   menu->client_xwindow = client_xwindow;
   menu->func = func;
   menu->data = data;
@@ -350,8 +354,7 @@ meta_window_menu_new   (MetaFrames         *frames,
   
   menu->menu = gtk_menu_new ();
 
-  gtk_menu_set_screen (GTK_MENU (menu->menu),
-                       gtk_widget_get_screen (GTK_WIDGET (frames)));
+  gtk_menu_set_screen (GTK_MENU (menu->menu), screen);
 
   for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++)
     {
@@ -384,10 +387,7 @@ meta_window_menu_new   (MetaFrames         *frames,
             {
               if (ops & META_MENU_OP_WORKSPACES)
                 {
-                  Display *display;
                   Window xroot;
-                  GdkScreen *screen;
-                  GdkWindow *window;
                   GtkWidget *submenu;
                   int j;
 
@@ -400,10 +400,6 @@ meta_window_menu_new   (MetaFrames         *frames,
                   meta_verbose ("Creating %d-workspace menu current space %lu\n",
                       n_workspaces, active_workspace);
 
-                  window = gtk_widget_get_window (GTK_WIDGET (frames));
-                  display = GDK_WINDOW_XDISPLAY (window);
-
-                  screen = gdk_window_get_screen (window);
                   xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
 
                   submenu = gtk_menu_new ();
diff --git a/src/ui/menu.h b/src/ui/menu.h
index c6e8dde..59ae08d 100644
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
@@ -25,7 +25,7 @@
 #define META_MENU_H
 
 #include <gtk/gtk.h>
-#include "frames.h"
+#include "ui.h"
 
 /* Stock icons */
 #define METACITY_STOCK_DELETE   "metacity-delete"
@@ -34,7 +34,7 @@
 
 struct _MetaWindowMenu
 {
-  MetaFrames *frames;
+  MetaUI *ui;
   Window client_xwindow;
   GtkWidget *menu;
   MetaWindowMenuFunc func;
@@ -43,7 +43,9 @@ struct _MetaWindowMenu
   MetaMenuOp insensitive;
 };
 
-MetaWindowMenu* meta_window_menu_new      (MetaFrames         *frames,
+MetaWindowMenu* meta_window_menu_new      (MetaUI             *ui,
+                                           Display            *display,
+                                           gint                screen_no,
                                            MetaMenuOp          ops,
                                            MetaMenuOp          insensitive,
                                            Window              client_xwindow,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index e01ec04..168761b 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -25,7 +25,7 @@
 #include <config.h>
 #include <meta/prefs.h>
 #include "ui.h"
-#include "frames.h"
+#include "uiframe.h"
 #include <meta/util.h>
 #include "menu.h"
 #include "core.h"
@@ -47,7 +47,7 @@ struct _MetaUI
 {
   Display *xdisplay;
   Screen *xscreen;
-  MetaFrames *frames;
+  GHashTable *frames;
 
   /* For double-click tracking */
   guint button_click_number;
@@ -82,7 +82,7 @@ meta_ui_get_display (void)
   return GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 }
 
-/* We do some of our event handling in frames.c, which expects
+/* We do some of our event handling in uiframe.c, which expects
  * GDK events delivered by GTK+.  However, since the transition to
  * client side windows, we can't let GDK see button events, since the
  * client-side tracking of implicit and explicit grabs it does will
@@ -93,7 +93,7 @@ meta_ui_get_display (void)
  * through the normal GDK event handling.
  *
  * To reduce the amount of code, the only events fields filled out
- * below are the ones that frames.c uses. If frames.c is modified to
+ * below are the ones that uiframe.c uses. If uiframe.c is modified to
  * use more fields, more fields need to be filled out below.
  */
 
@@ -270,6 +270,60 @@ meta_ui_remove_event_func (Display       *xdisplay,
   ef = NULL;
 }
 
+
+static void
+queue_draw_func (gpointer key, gpointer value, gpointer data)
+{
+  gtk_widget_queue_draw (GTK_WIDGET (value));
+}
+
+static void
+button_layout_changed (MetaUI *ui)
+{
+  g_hash_table_foreach (ui->frames, queue_draw_func, NULL);
+}
+
+static void
+prefs_changed_callback (MetaPreference pref,
+                        void          *data)
+{
+  switch (pref)
+    {
+    case META_PREF_BUTTON_LAYOUT:
+      button_layout_changed ((MetaUI *) data);
+      break;
+    default:
+      break;
+    }
+}
+
+static gint
+unsigned_long_equal (gconstpointer v1,
+                     gconstpointer v2)
+{
+  return *((const gulong*) v1) == *((const gulong*) v2);
+}
+
+static guint
+unsigned_long_hash (gconstpointer v)
+{
+  gulong val = * (const gulong *) v;
+
+  /* I'm not sure this works so well. */
+#if GLIB_SIZEOF_LONG > 4
+  return (guint) (val ^ (val >> 32));
+#else
+  return val;
+#endif
+}
+
+static MetaUIFrame*
+meta_ui_lookup_window (MetaUI *ui,
+                       Window  xwindow)
+{
+  return g_hash_table_lookup (ui->frames, &xwindow);
+}
+
 MetaUI*
 meta_ui_new (Display *xdisplay,
              Screen  *screen)
@@ -284,7 +338,9 @@ meta_ui_new (Display *xdisplay,
   gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
   g_assert (gdisplay == gdk_display_get_default ());
 
-  ui->frames = meta_frames_new ();
+  ui->frames = g_hash_table_new_full (unsigned_long_hash, unsigned_long_equal,
+                                      NULL, (GDestroyNotify) gtk_widget_destroy);
+  meta_prefs_add_listener (prefs_changed_callback, ui);
 
   g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
 
@@ -296,7 +352,9 @@ meta_ui_free (MetaUI *ui)
 {
   GdkDisplay *gdisplay;
 
-  meta_frames_free (ui->frames);
+  g_assert (g_hash_table_size (ui->frames) == 0);
+  meta_prefs_remove_listener (prefs_changed_callback, ui);
+  g_hash_table_unref (ui->frames);
 
   gdisplay = gdk_x11_lookup_xdisplay (ui->xdisplay);
   g_object_set_data (G_OBJECT (gdisplay), "meta-ui", NULL);
@@ -306,11 +364,37 @@ meta_ui_free (MetaUI *ui)
 
 void
 meta_ui_get_frame_borders (MetaUI *ui,
-                           Window frame_xwindow,
+                           Window xwindow,
                            MetaFrameBorders *borders)
 {
-  meta_frames_get_borders (ui->frames, frame_xwindow,
-                           borders);
+  MetaFrameFlags flags;
+  MetaUIFrame *frame;
+  MetaFrameType type;
+  
+  frame = meta_ui_lookup_window (ui, xwindow);
+
+  if (frame == NULL)
+    meta_bug ("No such frame 0x%lx\n", xwindow);
+  
+  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+                 META_CORE_GET_FRAME_FLAGS, &flags,
+                 META_CORE_GET_FRAME_TYPE, &type,
+                 META_CORE_GET_END);
+
+  g_return_if_fail (type < META_FRAME_TYPE_LAST);
+
+  meta_uiframe_ensure_layout (frame);
+  
+  /* We can't get the full geometry, because that depends on
+   * the client window size and probably we're being called
+   * by the core move/resize code to decide on the client
+   * window size
+   */
+  meta_theme_get_frame_borders (frame->tv->theme,
+                                frame->tv->style_context,
+                                type,
+                                flags,
+                                borders);
 }
 
 void
@@ -318,7 +402,18 @@ meta_ui_render_background (MetaUI  *ui,
                            Window   xwindow,
                            cairo_t *cr)
 {
-  meta_frames_render_background (ui->frames, xwindow, cr);
+  MetaUIFrame *frame;
+  MetaFrameGeometry fgeom;
+  MetaFrameFlags flags;
+
+  frame = meta_ui_lookup_window (ui, xwindow);
+
+  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+                 META_CORE_GET_FRAME_FLAGS, &flags,
+                 META_CORE_GET_END);
+
+  meta_uiframe_calc_geometry (frame, &fgeom);
+  meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom, frame->layout);
 }
 
 Window
@@ -338,6 +433,7 @@ meta_ui_create_frame_window (MetaUI *ui,
   gint attributes_mask;
   GdkWindow *window;
   GdkVisual *visual;
+  MetaUIFrame *frame;
   
   /* Default depth/visual handles clients with weird visuals; they can
    * always be children of the root depth/visual obviously, but
@@ -387,28 +483,80 @@ meta_ui_create_frame_window (MetaUI *ui,
                    &attrs, attributes_mask);
 
   gdk_window_resize (window, width, height);
-  
-  meta_frames_manage_window (ui->frames, GDK_WINDOW_XID (window), window);
 
-  return GDK_WINDOW_XID (window);
+  frame = g_object_new (META_TYPE_UIFRAME,
+                        "type", GTK_WINDOW_POPUP,
+                        "app-paintable", TRUE,
+                        NULL);
+
+  /* This fakes out the widget so it won't actually
+   * get realized as a server-side window. */
+
+  /* XXX: the gtk_widget_set_parent_window call unsets is_toplevel,
+   * leading to the widget not being realized, which triggers all sorts
+   * of assertions. Company suggested the below hack until we have
+   * something better. */
+
+  /* gtk_widget_set_parent_window (GTK_WIDGET (frame), window); */
+  g_object_set_data (G_OBJECT (frame), "gtk-parent-window", g_object_ref (window));
+
+  gdk_window_set_user_data (window, frame);
+  gtk_widget_show (GTK_WIDGET (frame));
+
+  /* Don't set event mask here, it's in frame.c */
+  frame->window = g_object_ref (window);
+  frame->xwindow = GDK_WINDOW_XID (window);
+  frame->layout = NULL;
+  frame->title = NULL;
+  frame->shape_applied = FALSE;
+  frame->prelit_control = META_FRAME_CONTROL_NONE;
+
+  /* Don't set the window background yet; we need frame->xwindow to be
+   * registered with its MetaWindow, which happens after this function
+   * and meta_ui_create_frame_window() return to meta_window_ensure_frame().
+   */
+  meta_core_grab_buttons (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow);
+
+  g_hash_table_replace (ui->frames, &frame->xwindow, frame);
+
+  return frame->xwindow;
 }
 
 void
 meta_ui_destroy_frame_window (MetaUI *ui,
                              Window  xwindow)
 {
-  meta_frames_unmanage_window (ui->frames, xwindow);
+  MetaUIFrame *frame;
+
+  frame = g_hash_table_lookup (ui->frames, &xwindow);
+
+  if (frame)
+    {
+      /* restore the cursor */
+      meta_core_set_screen_cursor (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+                                   frame->xwindow,
+                                   META_CURSOR_DEFAULT);
+
+      gdk_window_set_user_data (frame->window, NULL);
+
+      g_hash_table_remove (ui->frames, &frame->xwindow);
+    }
+  else
+    meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
 }
 
 void
 meta_ui_move_resize_frame (MetaUI *ui,
-                          Window frame,
+                          Window xwindow,
                           int x,
                           int y,
                           int width,
                           int height)
 {
-  meta_frames_move_resize_frame (ui->frames, frame, x, y, width, height);
+  MetaUIFrame *frame = meta_ui_lookup_window (ui, xwindow);
+
+  gdk_window_move_resize (frame->window, x, y, width, height);
+  gtk_widget_set_size_request (GTK_WIDGET (frame), width, height);
 }
 
 void
@@ -443,21 +591,17 @@ void
 meta_ui_update_frame_style (MetaUI  *ui,
                             Window   xwindow)
 {
-  meta_frames_update_frame_style (ui->frames, xwindow);
-}
-
-void
-meta_ui_repaint_frame (MetaUI *ui,
-                       Window xwindow)
-{
-  meta_frames_repaint_frame (ui->frames, xwindow);
+  MetaUIFrame *frame = meta_ui_lookup_window (ui, xwindow);
+  meta_uiframe_attach_style (frame);
+  gtk_widget_queue_draw (GTK_WIDGET (frame));
 }
 
 void
 meta_ui_queue_frame_draw (MetaUI *ui,
                           Window xwindow)
 {
-  meta_frames_queue_draw (ui->frames, xwindow);
+  MetaUIFrame *frame = meta_ui_lookup_window (ui, xwindow);
+  gtk_widget_queue_draw (GTK_WIDGET (frame));
 }
 
 void
@@ -465,11 +609,14 @@ meta_ui_set_frame_title (MetaUI     *ui,
                          Window      xwindow,
                          const char *title)
 {
-  meta_frames_set_title (ui->frames, xwindow, title);
+  MetaUIFrame *frame = meta_ui_lookup_window (ui, xwindow);
+  meta_uiframe_set_title (frame, title);
 }
 
 MetaWindowMenu*
 meta_ui_window_menu_new  (MetaUI             *ui,
+                          Display            *display,
+                          gint                screen_no,
                           Window              client_xwindow,
                           MetaMenuOp          ops,
                           MetaMenuOp          insensitive,
@@ -478,7 +625,7 @@ meta_ui_window_menu_new  (MetaUI             *ui,
                           MetaWindowMenuFunc  func,
                           gpointer            data)
 {
-  return meta_window_menu_new (ui->frames,
+  return meta_window_menu_new (ui, display, screen_no,
                                ops, insensitive,
                                client_xwindow,
                                active_workspace,
@@ -962,3 +1109,29 @@ meta_ui_get_direction (void)
   return META_UI_DIRECTION_LTR;
 }
 
+void
+meta_ui_notify_menu_hide (MetaUI *ui)
+{
+  Display *display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+  if (meta_core_get_grab_op (display) ==
+      META_GRAB_OP_CLICKING_MENU)
+    {
+      Window grab_frame;
+
+      grab_frame = meta_core_get_grab_frame (display);
+
+      if (grab_frame != None)
+        {
+          MetaUIFrame *frame;
+          frame = meta_ui_lookup_window (ui, grab_frame);
+
+          if (frame)
+            {
+              /* XXX: will redo redraw_control with GTK+ widgets
+               * soon enough */
+              /* redraw_control (frame, META_FRAME_CONTROL_MENU); */
+              meta_core_end_grab_op (display, CurrentTime);
+            }
+        }
+    }
+}
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 00c8656..d9fc442 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -102,6 +102,8 @@ void meta_ui_repaint_frame (MetaUI *ui,
                             Window xwindow);
 
 MetaWindowMenu* meta_ui_window_menu_new   (MetaUI             *ui,
+                                           Display            *display,
+                                           gint                screen_no,
                                            Window              client_xwindow,
                                            MetaMenuOp          ops,
                                            MetaMenuOp          insensitive,
@@ -160,6 +162,8 @@ int      meta_ui_get_drag_threshold       (MetaUI *ui);
 
 MetaUIDirection meta_ui_get_direction (void);
 
+void meta_ui_notify_menu_hide (MetaUI *ui);
+
 #include "tabpopup.h"
 #include "tile-preview.h"
 
diff --git a/src/ui/frames.c b/src/ui/uiframe.c
similarity index 83%
rename from src/ui/frames.c
rename to src/ui/uiframe.c
index 39f57d7..5b8bd5b 100644
--- a/src/ui/frames.c
+++ b/src/ui/uiframe.c
@@ -27,7 +27,7 @@
 #include <math.h>
 #include <string.h>
 #include <meta/boxes.h>
-#include "frames.h"
+#include "uiframe.h"
 #include <meta/util.h>
 #include "core.h"
 #include "menu.h"
@@ -44,19 +44,6 @@
 static void meta_uiframe_update_prelit_control (MetaUIFrame     *frame,
                                                 MetaFrameControl control);
 
-static void meta_uiframe_attach_style (MetaUIFrame *frame);
-
-static void meta_uiframe_calc_geometry (MetaUIFrame         *frame,
-                                        MetaFrameGeometry *fgeom);
-
-static void meta_uiframe_ensure_layout (MetaUIFrame     *frame);
-
-static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames,
-                                               Window      xwindow);
-
-static void meta_frames_button_layout_changed (MetaFrames *frames);
-
-
 static GdkRectangle*    control_rect (MetaFrameControl   control,
                                       MetaFrameGeometry *fgeom);
 static MetaFrameControl get_control  (MetaUIFrame       *frame,
@@ -80,83 +67,18 @@ meta_uiframe_finalize (GObject *obj)
     g_free (frame->title);
 }
 
-static gint
-unsigned_long_equal (gconstpointer v1,
-                     gconstpointer v2)
-{
-  return *((const gulong*) v1) == *((const gulong*) v2);
-}
-
-static guint
-unsigned_long_hash (gconstpointer v)
-{
-  gulong val = * (const gulong *) v;
-
-  /* I'm not sure this works so well. */
-#if GLIB_SIZEOF_LONG > 4
-  return (guint) (val ^ (val >> 32));
-#else
-  return val;
-#endif
-}
-
-static void
-prefs_changed_callback (MetaPreference pref,
-                        void          *data)
-{
-  switch (pref)
-    {
-    case META_PREF_BUTTON_LAYOUT:
-      meta_frames_button_layout_changed ((MetaFrames *) data);
-      break;
-    default:
-      break;
-    }
-}
-
-MetaFrames*
-meta_frames_new ()
-{
-  MetaFrames *frames = g_slice_new (MetaFrames);
-  frames->frames = g_hash_table_new_full (unsigned_long_hash, unsigned_long_equal,
-                                          NULL, (GDestroyNotify) gtk_widget_destroy);
-  meta_prefs_add_listener (prefs_changed_callback, frames);
-  return frames;
-}
-
-void
-meta_frames_free (MetaFrames *frames)
-{
-  g_assert (g_hash_table_size (frames->frames) == 0);
-  meta_prefs_remove_listener (prefs_changed_callback, frames);
-  g_hash_table_unref (frames->frames);
-  g_slice_free (MetaFrames, frames);
-}
-
 static void
 meta_uiframe_init (MetaUIFrame *frame)
 {
 }
 
-static void
-queue_draw_func (gpointer key, gpointer value, gpointer data)
-{
-  gtk_widget_queue_draw (GTK_WIDGET (value));
-}
-
-static void
-meta_frames_button_layout_changed (MetaFrames *frames)
-{
-  g_hash_table_foreach (frames->frames, queue_draw_func, NULL);
-}
-
 /* In order to use a style with a window it has to be attached to that
  * window. Actually, the colormaps just have to match, but since GTK+
  * already takes care of making sure that its cheap to attach a style
  * to multiple windows with the same colormap, we can just go ahead
  * and attach separately for each window.
  */
-static void
+void
 meta_uiframe_attach_style (MetaUIFrame *frame)
 {
   char *variant = NULL;
@@ -170,7 +92,7 @@ meta_uiframe_attach_style (MetaUIFrame *frame)
                                       variant);
 }
 
-static void
+void
 meta_uiframe_ensure_layout (MetaUIFrame *frame)
 {
   MetaFrameFlags flags;
@@ -194,7 +116,7 @@ meta_uiframe_ensure_layout (MetaUIFrame *frame)
     }
 }
 
-static void
+void
 meta_uiframe_calc_geometry (MetaUIFrame       *frame,
                             MetaFrameGeometry *fgeom)
 {
@@ -223,141 +145,6 @@ meta_uiframe_calc_geometry (MetaUIFrame       *frame,
                             fgeom);
 }
 
-void
-meta_frames_manage_window (MetaFrames *frames,
-                           Window      xwindow,
-                           GdkWindow  *window)
-{
-  MetaUIFrame *frame;
-
-  g_assert (window);
-
-  frame = g_object_new (META_TYPE_UIFRAME,
-                        "type", GTK_WINDOW_POPUP,
-                        "app-paintable", TRUE,
-                        NULL);
-
-  /* This fakes out the widget so it won't actually
-   * get realized as a server-side window. */
-
-  /* XXX: the gtk_widget_set_parent_window call unsets is_toplevel,
-   * leading to the widget not being realized, which triggers all sorts
-   * of assertions. Company suggested the below hack until we have
-   * something better. */
-
-  /* gtk_widget_set_parent_window (GTK_WIDGET (frame), window); */
-  g_object_set_data (G_OBJECT (frame), "gtk-parent-window", g_object_ref (window));
-
-
-  gdk_window_set_user_data (window, frame);
-  gtk_widget_show (GTK_WIDGET (frame));
-
-  /* Don't set event mask here, it's in frame.c */
-  frame->window = g_object_ref (window);
-  frame->xwindow = xwindow;
-  frame->layout = NULL;
-  frame->title = NULL;
-  frame->shape_applied = FALSE;
-  frame->prelit_control = META_FRAME_CONTROL_NONE;
-
-  /* Don't set the window background yet; we need frame->xwindow to be
-   * registered with its MetaWindow, which happens after this function
-   * and meta_ui_create_frame_window() return to meta_window_ensure_frame().
-   */
-  
-  meta_core_grab_buttons (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow);
-
-  g_hash_table_replace (frames->frames, &frame->xwindow, frame);
-}
-
-void
-meta_frames_unmanage_window (MetaFrames *frames,
-                             Window      xwindow)
-{
-  MetaUIFrame *frame;
-
-  frame = g_hash_table_lookup (frames->frames, &xwindow);
-
-  if (frame)
-    {
-      /* restore the cursor */
-      meta_core_set_screen_cursor (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-                                   frame->xwindow,
-                                   META_CURSOR_DEFAULT);
-
-      gdk_window_set_user_data (frame->window, NULL);
-
-      g_hash_table_remove (frames->frames, &frame->xwindow);
-    }
-  else
-    meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
-}
-
-static MetaUIFrame*
-meta_frames_lookup_window (MetaFrames *frames,
-                           Window      xwindow)
-{
-  MetaUIFrame *frame;
-
-  frame = g_hash_table_lookup (frames->frames, &xwindow);
-
-  return frame;
-}
-
-void
-meta_frames_get_borders (MetaFrames *frames,
-                         Window xwindow,
-                         MetaFrameBorders *borders)
-{
-  MetaFrameFlags flags;
-  MetaUIFrame *frame;
-  MetaFrameType type;
-  
-  frame = meta_frames_lookup_window (frames, xwindow);
-
-  if (frame == NULL)
-    meta_bug ("No such frame 0x%lx\n", xwindow);
-  
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
-                 META_CORE_GET_FRAME_FLAGS, &flags,
-                 META_CORE_GET_FRAME_TYPE, &type,
-                 META_CORE_GET_END);
-
-  g_return_if_fail (type < META_FRAME_TYPE_LAST);
-
-  meta_uiframe_ensure_layout (frame);
-  
-  /* We can't get the full geometry, because that depends on
-   * the client window size and probably we're being called
-   * by the core move/resize code to decide on the client
-   * window size
-   */
-  meta_theme_get_frame_borders (frame->tv->theme,
-                                frame->tv->style_context,
-                                type,
-                                flags,
-                                borders);
-}
-
-void
-meta_frames_render_background (MetaFrames *frames,
-                               Window      xwindow,
-                               cairo_t    *cr)
-{
-  MetaUIFrame *frame;
-  MetaFrameGeometry fgeom;
-  MetaFrameFlags flags;
-
-  frame = meta_frames_lookup_window (frames, xwindow);
-
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
-                 META_CORE_GET_FRAME_FLAGS, &flags,
-                 META_CORE_GET_END);
-
-  meta_uiframe_calc_geometry (frame, &fgeom);
-  meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom, frame->layout);
-}
-
 /* The client rectangle surrounds client window; it subtracts both
  * the visible and invisible borders from the frame window's size.
  */
@@ -374,38 +161,9 @@ get_client_rect (MetaFrameGeometry     *fgeom,
 }
 
 void
-meta_frames_move_resize_frame (MetaFrames *frames,
-                               Window      xwindow,
-                               int         x,
-                               int         y,
-                               int         width,
-                               int         height)
+meta_uiframe_set_title (MetaUIFrame *frame,
+                        const char  *title)
 {
-  MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
-
-  gdk_window_move_resize (frame->window, x, y, width, height);
-  gtk_widget_set_size_request (GTK_WIDGET (frame), width, height);
-}
-
-void
-meta_frames_queue_draw (MetaFrames *frames,
-                        Window      xwindow)
-{
-  MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
-  gtk_widget_queue_draw (GTK_WIDGET (frame));
-}
-
-void
-meta_frames_set_title (MetaFrames *frames,
-                       Window      xwindow,
-                       const char *title)
-{
-  MetaUIFrame *frame;
-  
-  frame = meta_frames_lookup_window (frames, xwindow);
-
-  g_assert (frame);
-  
   g_free (frame->title);
   frame->title = g_strdup (title);
   
@@ -418,28 +176,6 @@ meta_frames_set_title (MetaFrames *frames,
   gtk_widget_queue_draw (GTK_WIDGET (frame));
 }
 
-void
-meta_frames_update_frame_style (MetaFrames *frames,
-                                Window      xwindow)
-{
-  MetaUIFrame *frame;
-  frame = meta_frames_lookup_window (frames, xwindow);
-  g_assert (frame);
-
-  meta_uiframe_attach_style (frame);
-  gtk_widget_queue_draw (GTK_WIDGET (frame));
-}
-
-void
-meta_frames_repaint_frame (MetaFrames *frames,
-                           Window      xwindow)
-{
-  MetaUIFrame *frame;
-  frame = meta_frames_lookup_window (frames, xwindow);
-  g_assert (frame);
-  gtk_widget_queue_draw (GTK_WIDGET (frame));
-}
-
 static void
 redraw_control (MetaUIFrame *frame,
                 MetaFrameControl control)
@@ -824,32 +560,6 @@ meta_uiframe_button_press_event (GtkWidget      *widget,
   return TRUE;
 }
 
-void
-meta_frames_notify_menu_hide (MetaFrames *frames)
-{
-  Display *display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-  if (meta_core_get_grab_op (display) ==
-      META_GRAB_OP_CLICKING_MENU)
-    {
-      Window grab_frame;
-
-      grab_frame = meta_core_get_grab_frame (display);
-
-      if (grab_frame != None)
-        {
-          MetaUIFrame *frame;
-
-          frame = meta_frames_lookup_window (frames, grab_frame);
-
-          if (frame)
-            {
-              redraw_control (frame, META_FRAME_CONTROL_MENU);
-              meta_core_end_grab_op (display, CurrentTime);
-            }
-        }
-    }
-}
-
 static gboolean
 meta_uiframe_button_release_event    (GtkWidget           *widget,
                                       GdkEventButton      *event)
diff --git a/src/ui/frames.h b/src/ui/uiframe.h
similarity index 64%
rename from src/ui/frames.h
rename to src/ui/uiframe.h
index 4427fe3..f10f1f3 100644
--- a/src/ui/frames.h
+++ b/src/ui/uiframe.h
@@ -21,8 +21,8 @@
  * 02111-1307, USA.
  */
 
-#ifndef META_FRAMES_H
-#define META_FRAMES_H
+#ifndef META_UIFRAME_H
+#define META_UIFRAME_H
 
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
@@ -87,52 +87,16 @@ struct _MetaUIFrameClass
   GtkWindowClass parent_class;
 };
 
-typedef struct _MetaFrames         MetaFrames;
-
-struct _MetaFrames
-{
-  GHashTable *frames;
-};
-
 GType        meta_uiframe_get_type (void) G_GNUC_CONST;
 
-MetaFrames *meta_frames_new ();
-void        meta_frames_free (MetaFrames *frames);
-
-void meta_frames_manage_window (MetaFrames *frames,
-                                Window      xwindow,
-                               GdkWindow  *window);
-void meta_frames_unmanage_window (MetaFrames *frames,
-                                  Window      xwindow);
-void meta_frames_set_title (MetaFrames *frames,
-                            Window      xwindow,
-                            const char *title);
-
-void meta_frames_update_frame_style (MetaFrames *frames,
-                                     Window      xwindow);
-
-void meta_frames_repaint_frame (MetaFrames *frames,
-                                Window      xwindow);
-
-void meta_frames_get_borders (MetaFrames *frames,
-                              Window xwindow,
-                              MetaFrameBorders *borders);
-
-void meta_frames_render_background (MetaFrames *frames,
-                                    Window      xwindow,
-                                    cairo_t    *cr);
+void meta_uiframe_set_title (MetaUIFrame *frame,
+                             const char  *title);
 
-void meta_frames_move_resize_frame (MetaFrames *frames,
-                                   Window      xwindow,
-                                   int         x,
-                                   int         y,
-                                   int         width,
-                                   int         height);
-void meta_frames_queue_draw (MetaFrames *frames,
-                             Window      xwindow);
+void meta_uiframe_attach_style (MetaUIFrame *frame);
 
-void meta_frames_notify_menu_hide (MetaFrames *frames);
+void meta_uiframe_ensure_layout (MetaUIFrame *frame);
 
-Window meta_frames_get_moving_frame (MetaFrames *frames);
+void meta_uiframe_calc_geometry (MetaUIFrame       *frame,
+                                 MetaFrameGeometry *fgeom);
 
 #endif


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