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.
This commit is contained in:
Jasper St. Pierre 2012-05-07 20:20:51 -03:00
parent 8a062b39ab
commit 873da3405c
3 changed files with 24 additions and 13 deletions

View File

@ -113,9 +113,23 @@ meta_window_ensure_frame (MetaWindow *window)
attrs.event_mask = EVENT_MASK; attrs.event_mask = EVENT_MASK;
XChangeWindowAttributes (window->display->xdisplay, XChangeWindowAttributes (window->display->xdisplay,
frame->xwindow, CWEventMask, &attrs); frame->xwindow, CWEventMask, &attrs);
/* stick frame to the window */
window->frame = frame;
meta_display_register_x_window (window->display, &frame->xwindow, window); 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, /* Reparent the client window; it may be destroyed,
* thus the error trap. We'll get a destroy notify later * thus the error trap. We'll get a destroy notify later
* and free everything. Comment in FVWM source code says * and free everything. Comment in FVWM source code says
@ -149,18 +163,6 @@ meta_window_ensure_frame (MetaWindow *window)
/* FIXME handle this error */ /* FIXME handle this error */
meta_error_trap_pop (window->display); 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 */ /* Move keybindings to frame instead of window */
meta_window_grab_keys (window); meta_window_grab_keys (window);

View File

@ -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)); g_object_set_data (G_OBJECT (frame), "gtk-parent-window", g_object_ref (window));
gdk_window_set_user_data (window, frame); gdk_window_set_user_data (window, frame);
gtk_widget_show (GTK_WIDGET (frame));
/* Don't set event mask here, it's in frame.c */ /* Don't set event mask here, it's in frame.c */
frame->window = g_object_ref (window); frame->window = g_object_ref (window);
@ -517,6 +516,14 @@ meta_ui_create_frame_window (MetaUI *ui,
return frame->xwindow; return frame->xwindow;
} }
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 void
meta_ui_destroy_frame_window (MetaUI *ui, meta_ui_destroy_frame_window (MetaUI *ui,
Window xwindow) Window xwindow)

View File

@ -69,6 +69,8 @@ Window meta_ui_create_frame_window (MetaUI *ui,
gint height, gint height,
gint screen_no, gint screen_no,
gulong *create_serial); gulong *create_serial);
void meta_ui_realize_frame_window (MetaUI *ui,
Window xwindow);
void meta_ui_destroy_frame_window (MetaUI *ui, void meta_ui_destroy_frame_window (MetaUI *ui,
Window xwindow); Window xwindow);
void meta_ui_move_resize_frame (MetaUI *ui, void meta_ui_move_resize_frame (MetaUI *ui,