only bump unmaps_pending if the window was mapped

2002-01-10  Havoc Pennington  <hp@pobox.com>

	* src/frame.c (meta_window_destroy_frame): only bump
	unmaps_pending if the window was mapped
	(meta_window_ensure_frame): ditto

	* src/keybindings.c: change arrow key bindings to use Ctrl+Alt not
	just Alt, and add debug mode key bindings

	* src/stack.c (meta_stack_get_default_focus_window): don't choose
	a default focus window with unmaps pending, since we probably just
	unmapped it.

	* src/display.c (event_callback): move notify_focus on UnmapNotify
	after the window_free check, so we can move focus to another
	window when we unmanage

	* src/window.c (meta_window_hide): invalidate work areas when
	hiding a window with struts
	(meta_window_free): invalidate work areas when unmanaging a window
	with struts
This commit is contained in:
Havoc Pennington 2002-01-11 03:31:14 +00:00 committed by Havoc Pennington
parent b2bbb306f4
commit 229589616f
6 changed files with 105 additions and 21 deletions

View File

@ -1,3 +1,25 @@
2002-01-10 Havoc Pennington <hp@pobox.com>
* src/frame.c (meta_window_destroy_frame): only bump
unmaps_pending if the window was mapped
(meta_window_ensure_frame): ditto
* src/keybindings.c: change arrow key bindings to use Ctrl+Alt not
just Alt, and add debug mode key bindings
* src/stack.c (meta_stack_get_default_focus_window): don't choose
a default focus window with unmaps pending, since we probably just
unmapped it.
* src/display.c (event_callback): move notify_focus on UnmapNotify
after the window_free check, so we can move focus to another
window when we unmanage
* src/window.c (meta_window_hide): invalidate work areas when
hiding a window with struts
(meta_window_free): invalidate work areas when unmanaging a window
with struts
2002-01-09 Havoc Pennington <hp@pobox.com>
* src/window.c, src/window.h: store strut information,

View File

@ -952,11 +952,7 @@ event_callback (XEvent *event,
case UnmapNotify:
if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window == window)
meta_display_end_grab_op (display, CurrentTime);
/* Unfocus on UnmapNotify */
if (window)
meta_window_notify_focus (window, event);
meta_display_end_grab_op (display, CurrentTime);
if (!frame_was_receiver && window)
{
@ -966,6 +962,7 @@ event_callback (XEvent *event,
window->desc);
window->withdrawn = TRUE;
meta_window_free (window); /* Unmanage withdrawn window */
window = NULL;
}
else
{
@ -974,6 +971,13 @@ event_callback (XEvent *event,
window->unmaps_pending);
}
}
/* Unfocus on UnmapNotify, do this after the possible
* window_free above so that window_free can see if window->has_focus
* and move focus to another window
*/
if (window)
meta_window_notify_focus (window, event);
break;
case MapNotify:
break;

View File

@ -100,10 +100,14 @@ meta_window_ensure_frame (MetaWindow *window)
* a grab.
*/
meta_error_trap_push (window->display);
window->mapped = FALSE; /* the reparent will unmap the window,
* we don't want to take that as a withdraw
*/
window->unmaps_pending += 1;
if (window->mapped)
{
window->mapped = FALSE; /* the reparent will unmap the window,
* we don't want to take that as a withdraw
*/
meta_verbose ("Incrementing unmaps_pending on %s for reparent\n", window->desc);
window->unmaps_pending += 1;
}
/* window was reparented to this position */
window->rect.x = 0;
window->rect.y = 0;
@ -148,11 +152,15 @@ meta_window_destroy_frame (MetaWindow *window)
* thus the error trap.
*/
meta_error_trap_push (window->display);
window->mapped = FALSE; /* Keep track of unmapping it, so we
* can identify a withdraw initiated
* by the client.
*/
window->unmaps_pending += 1;
if (window->mapped)
{
window->mapped = FALSE; /* Keep track of unmapping it, so we
* can identify a withdraw initiated
* by the client.
*/
meta_verbose ("Incrementing unmaps_pending on %s for reparent back to root\n", window->desc);
window->unmaps_pending += 1;
}
XReparentWindow (window->display->xdisplay,
window->xwindow,
window->screen->xroot,

View File

@ -71,7 +71,14 @@ static void handle_toggle_desktop (MetaDisplay *display,
XEvent *event,
gpointer data);
/* debug */
static void handle_spew_mark (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data);
static gboolean process_keyboard_move_grab (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
@ -114,13 +121,18 @@ static MetaKeyBinding screen_bindings[] = {
{ XK_ISO_Left_Tab, ShiftMask | Mod1Mask, KeyPress, handle_tab_backward, NULL, 0 },
{ XK_Tab, ShiftMask | Mod1Mask, KeyPress, handle_tab_backward, NULL, 0 },
{ XK_Escape, Mod1Mask, KeyPress, handle_focus_previous, NULL, 0 },
{ XK_Left, Mod1Mask, KeyPress, handle_workspace_left, NULL, 0 },
{ XK_Right, Mod1Mask, KeyPress, handle_workspace_right, NULL, 0 },
{ XK_Left, Mod1Mask | ControlMask, KeyPress, handle_workspace_left, NULL, 0 },
{ XK_Right, Mod1Mask | ControlMask, KeyPress, handle_workspace_right, NULL, 0 },
/* I don't like this binding, but haven't picked the right one yet */
{ XK_d, Mod1Mask | ControlMask, KeyPress, handle_toggle_desktop, NULL, 0 },
{ None, 0, 0, NULL, NULL, 0 }
};
static MetaKeyBinding debug_bindings[] = {
{ XK_m, Mod1Mask | ControlMask | ShiftMask, KeyPress, handle_spew_mark, NULL, 0 },
{ None, 0, 0, NULL, NULL, 0 }
};
static MetaKeyBinding window_bindings[] = {
{ XK_space, Mod1Mask, KeyPress, handle_activate_menu, NULL, 0 },
{ XK_Tab, Mod1Mask, KeyPress, handle_tab_forward, NULL, 0 },
@ -151,6 +163,7 @@ meta_display_init_keys (MetaDisplay *display)
{
init_bindings (display, screen_bindings);
init_bindings (display, window_bindings);
init_bindings (display, debug_bindings);
}
/* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */
@ -287,12 +300,16 @@ void
meta_screen_grab_keys (MetaScreen *screen)
{
grab_keys (screen_bindings, screen->display, screen->xroot);
if (meta_is_debugging ())
grab_keys (debug_bindings, screen->display, screen->xroot);
}
void
meta_screen_ungrab_keys (MetaScreen *screen)
{
ungrab_keys (screen_bindings, screen->display, screen->xroot);
if (meta_is_debugging ())
ungrab_keys (debug_bindings, screen->display, screen->xroot);
}
void
@ -538,6 +555,8 @@ meta_display_process_key_event (MetaDisplay *display,
{
/* Do the normal keybindings */
process_event (screen_bindings, display, NULL, event, keysym);
if (meta_is_debugging ())
process_event (debug_bindings, display, NULL, event, keysym);
if (window)
process_event (window_bindings, display, window, event, keysym);
@ -1085,3 +1104,14 @@ handle_focus_previous (MetaDisplay *display,
meta_window_focus (window, event->xkey.time);
}
}
static void
handle_spew_mark (MetaDisplay *display,
MetaWindow *window,
XEvent *event,
gpointer data)
{
meta_verbose ("-- MARK MARK MARK MARK --\n");
}

View File

@ -901,6 +901,7 @@ meta_stack_get_default_focus_window (MetaStack *stack,
if (window &&
window != not_this_one &&
(window->unmaps_pending == 0) &&
(workspace == NULL ||
meta_window_visible_on_workspace (window, workspace)))
{

View File

@ -698,6 +698,9 @@ meta_window_free (MetaWindow *window)
"Unmanaging window %s which doesn't currently have focus\n",
window->desc);
}
if (window->has_struts)
invalidate_work_areas (window);
if (window->display->grab_window == window)
meta_display_end_grab_op (window->display,
@ -1085,7 +1088,9 @@ meta_window_show (MetaWindow *window)
{
if (window->mapped)
{
meta_verbose ("%s actually needs unmap\n", window->desc);
meta_verbose ("%s actually needs unmap (shaded)\n", window->desc);
meta_verbose ("Incrementing unmaps_pending on %s for shade\n",
window->desc);
window->mapped = FALSE;
window->unmaps_pending += 1;
meta_error_trap_push (window->display);
@ -1148,23 +1153,31 @@ meta_window_show (MetaWindow *window)
void
meta_window_hide (MetaWindow *window)
{
gboolean did_hide;
meta_verbose ("Hiding window %s\n", window->desc);
did_hide = FALSE;
if (window->frame && window->frame->mapped)
{
meta_verbose ("Frame actually needs unmap\n");
window->frame->mapped = FALSE;
meta_ui_unmap_frame (window->screen->ui, window->frame->xwindow);
did_hide = TRUE;
}
if (window->mapped)
{
meta_verbose ("%s actually needs unmap\n", window->desc);
meta_verbose ("Incrementing unmaps_pending on %s for hide\n",
window->desc);
window->mapped = FALSE;
window->unmaps_pending += 1;
meta_error_trap_push (window->display);
meta_error_trap_push (window->display);
XUnmapWindow (window->display->xdisplay, window->xwindow);
meta_error_trap_pop (window->display);
did_hide = TRUE;
}
if (!window->iconic)
@ -1172,6 +1185,12 @@ meta_window_hide (MetaWindow *window)
window->iconic = TRUE;
set_wm_state (window, IconicState);
}
if (did_hide)
{
if (window->has_struts)
invalidate_work_areas (window);
}
}
void
@ -2787,7 +2806,7 @@ meta_window_notify_focus (MetaWindow *window,
window->display->prev_focus_window = window->display->focus_window;
}
meta_topic (META_DEBUG_FOCUS,
"New focus window %s\n", window->desc);
"* Focus --> %s\n", window->desc);
window->display->focus_window = window;
window->has_focus = TRUE;
if (window->frame)
@ -2816,7 +2835,7 @@ meta_window_notify_focus (MetaWindow *window,
window->display->prev_focus_window = window;
meta_topic (META_DEBUG_FOCUS,
"Clearing focus window (was %s)\n", window->desc);
"* Focus --> NULL (was %s)\n", window->desc);
window->display->focus_window = NULL;
window->has_focus = FALSE;