[mutter/wip/cb2eb3: 52/55] frames: Only realize the widget after it's been properly associated



commit 873da3405c4d18fdb7328c9e0fdf705ec19750db
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon May 7 20:20:51 2012 -0300

    frames: Only realize the widget after it's been properly associated
    
    This makes sure that we don't get into a situation from a GTK+ handler
    where we'll have an unassociated frame window.

 src/core/frame.c |   26 ++++++++++++++------------
 src/ui/ui.c      |    9 ++++++++-
 src/ui/ui.h      |    2 ++
 3 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/core/frame.c b/src/core/frame.c
index 279d6fa..1b6fb0f 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -113,9 +113,23 @@ meta_window_ensure_frame (MetaWindow *window)
   attrs.event_mask = EVENT_MASK;
   XChangeWindowAttributes (window->display->xdisplay,
                           frame->xwindow, CWEventMask, &attrs);
+  /* stick frame to the window */
+  window->frame = frame;
   
   meta_display_register_x_window (window->display, &frame->xwindow, window);
 
+  /* Now that frame->xwindow is registered with window, we can set its
+   * style and background.
+   */
+  meta_ui_update_frame_style (window->screen->ui, frame->xwindow);
+
+  meta_ui_realize_frame_window (window->screen->ui, frame->xwindow);
+
+  if (window->title)
+    meta_ui_set_frame_title (window->screen->ui,
+                             window->frame->xwindow,
+                             window->title);
+
   /* Reparent the client window; it may be destroyed,
    * thus the error trap. We'll get a destroy notify later
    * and free everything. Comment in FVWM source code says
@@ -149,18 +163,6 @@ meta_window_ensure_frame (MetaWindow *window)
   /* FIXME handle this error */
   meta_error_trap_pop (window->display);
   
-  /* stick frame to the window */
-  window->frame = frame;
-
-  /* Now that frame->xwindow is registered with window, we can set its
-   * style and background.
-   */
-  meta_ui_update_frame_style (window->screen->ui, frame->xwindow);
-  
-  if (window->title)
-    meta_ui_set_frame_title (window->screen->ui,
-                             window->frame->xwindow,
-                             window->title);
 
   /* Move keybindings to frame instead of window */
   meta_window_grab_keys (window);
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 84237b0..86416f0 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -499,7 +499,6 @@ meta_ui_create_frame_window (MetaUI *ui,
   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);
@@ -518,6 +517,14 @@ meta_ui_create_frame_window (MetaUI *ui,
 }
 
 void
+meta_ui_realize_frame_window (MetaUI  *ui,
+                            Window   xwindow)
+{
+  MetaUIFrame *frame = meta_ui_lookup_window (ui, xwindow);
+  gtk_widget_show (GTK_WIDGET (frame));
+}
+
+void
 meta_ui_destroy_frame_window (MetaUI *ui,
                              Window  xwindow)
 {
diff --git a/src/ui/ui.h b/src/ui/ui.h
index d9fc442..89b0ec5 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -69,6 +69,8 @@ Window meta_ui_create_frame_window (MetaUI *ui,
                                    gint height,
                                    gint screen_no,
                                     gulong *create_serial);
+void meta_ui_realize_frame_window (MetaUI *ui,
+                                  Window  xwindow);
 void meta_ui_destroy_frame_window (MetaUI *ui,
                                   Window  xwindow);
 void meta_ui_move_resize_frame (MetaUI *ui,


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