Fix hiding newly added windows with live_hidden_windows

When we add a window and it gets hidden as the first thing, we need
to show not just the frame window, but also the window itself.
Otherwise when the window subsequently becomes visible, it will
just be an empty frame.

Add helper functions to reduce current code duplication and avoid
adding more.

http://bugzilla.gnome.org/show_bug.cgi?id=586309
This commit is contained in:
Owen W. Taylor 2009-06-18 16:35:31 -04:00
parent f26d503694
commit c012105b90

View File

@ -2307,6 +2307,75 @@ window_would_be_covered (const MetaWindow *newbie)
return FALSE; /* none found */ return FALSE; /* none found */
} }
static gboolean
map_frame (MetaWindow *window)
{
if (window->frame && !window->frame->mapped)
{
meta_topic (META_DEBUG_WINDOW_STATE,
"Frame actually needs map\n");
window->frame->mapped = TRUE;
meta_ui_map_frame (window->screen->ui, window->frame->xwindow);
return TRUE;
}
else
return FALSE;
}
static gboolean
unmap_frame (MetaWindow *window)
{
if (window->frame && window->frame->mapped)
{
meta_topic (META_DEBUG_WINDOW_STATE, "Frame actually needs unmap\n");
window->frame->mapped = FALSE;
meta_ui_unmap_frame (window->screen->ui, window->frame->xwindow);
return TRUE;
}
else
return FALSE;
}
static gboolean
map_client_window (MetaWindow *window)
{
if (!window->mapped)
{
meta_topic (META_DEBUG_WINDOW_STATE,
"%s actually needs map\n", window->desc);
window->mapped = TRUE;
meta_error_trap_push (window->display);
XMapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE);
return TRUE;
}
else
return FALSE;
}
static gboolean
unmap_client_window (MetaWindow *window,
const char *reason)
{
if (window->mapped)
{
meta_topic (META_DEBUG_WINDOW_STATE,
"%s actually needs unmap%s\n",
window->desc, reason);
meta_topic (META_DEBUG_WINDOW_STATE,
"Incrementing unmaps_pending on %s%s\n",
window->desc, reason);
window->mapped = FALSE;
window->unmaps_pending += 1;
meta_error_trap_push (window->display);
XUnmapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE);
return TRUE;
}
else
return FALSE;
}
/* XXX META_EFFECT_*_MAP */ /* XXX META_EFFECT_*_MAP */
void void
meta_window_show (MetaWindow *window) meta_window_show (MetaWindow *window)
@ -2456,30 +2525,12 @@ meta_window_show (MetaWindow *window)
/* Shaded means the frame is mapped but the window is not */ /* Shaded means the frame is mapped but the window is not */
if (window->frame && !window->frame->mapped) if (map_frame (window))
{
meta_topic (META_DEBUG_WINDOW_STATE,
"Frame actually needs map\n");
window->frame->mapped = TRUE;
meta_ui_map_frame (window->screen->ui, window->frame->xwindow);
did_show = TRUE; did_show = TRUE;
}
if (window->shaded) if (window->shaded)
{ {
if (window->mapped) unmap_client_window (window, " (shading)");
{
meta_topic (META_DEBUG_WINDOW_STATE,
"%s actually needs unmap (shaded)\n", window->desc);
meta_topic (META_DEBUG_WINDOW_STATE,
"Incrementing unmaps_pending on %s for shade\n",
window->desc);
window->mapped = FALSE;
window->unmaps_pending += 1;
meta_error_trap_push (window->display);
XUnmapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE);
}
if (!window->iconic) if (!window->iconic)
{ {
@ -2489,16 +2540,8 @@ meta_window_show (MetaWindow *window)
} }
else else
{ {
if (!window->mapped) if (map_client_window (window))
{
meta_topic (META_DEBUG_WINDOW_STATE,
"%s actually needs map\n", window->desc);
window->mapped = TRUE;
meta_error_trap_push (window->display);
XMapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE);
did_show = TRUE; did_show = TRUE;
}
if (meta_prefs_get_live_hidden_windows ()) if (meta_prefs_get_live_hidden_windows ())
{ {
@ -2607,20 +2650,11 @@ meta_window_hide (MetaWindow *window)
if (window->hidden) if (window->hidden)
return; return;
if (!window->mapped) /* If this is the first time that we've calculating the showing
{ * state of the window, the frame and client window might not
Window top_level_window; * yet be mapped, so we need to map them now */
meta_topic (META_DEBUG_WINDOW_STATE, map_frame (window);
"%s actually needs map\n", window->desc); map_client_window (window);
window->mapped = TRUE;
meta_error_trap_push (window->display);
if (window->frame)
top_level_window = window->frame->xwindow;
else
top_level_window = window->xwindow;
XMapWindow (window->display->xdisplay, top_level_window);
meta_error_trap_pop (window->display, FALSE);
}
meta_stack_freeze (window->screen->stack); meta_stack_freeze (window->screen->stack);
window->hidden = TRUE; window->hidden = TRUE;
@ -2641,29 +2675,14 @@ meta_window_hide (MetaWindow *window)
meta_compositor_unmap_window (window->display->compositor, meta_compositor_unmap_window (window->display->compositor,
window); window);
if (window->frame && window->frame->mapped) /* Unmapping the frame is enough to make the window disappear,
{ * but we need to hide the window itself so the client knows
meta_topic (META_DEBUG_WINDOW_STATE, "Frame actually needs unmap\n"); * it has been hidden */
window->frame->mapped = FALSE; if (unmap_frame (window))
meta_ui_unmap_frame (window->screen->ui, window->frame->xwindow);
did_hide = TRUE; did_hide = TRUE;
} if (unmap_client_window (window, " (hiding)"))
if (window->mapped)
{
meta_topic (META_DEBUG_WINDOW_STATE,
"%s actually needs unmap\n", window->desc);
meta_topic (META_DEBUG_WINDOW_STATE,
"Incrementing unmaps_pending on %s for hide\n",
window->desc);
window->mapped = FALSE;
window->unmaps_pending += 1;
meta_error_trap_push (window->display);
XUnmapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display, FALSE);
did_hide = TRUE; did_hide = TRUE;
} }
}
if (!window->iconic) if (!window->iconic)
{ {