GTK 1.2 plug/socket clients still broken, don't know why.

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

        GTK 1.2 plug/socket clients still broken, don't know why.

	* src/screen.c (meta_screen_new): select focus change on root
	window, for debugging

	* src/display.c (event_callback): when unfocusing, use
	no_focus_window to hold the focus

	* src/display.h (struct _MetaDisplay): have a no_focus_window to
	hold the focus when we don't want to have anything focused.
	Then we can avoid confusing focusing-the-frame stuff.

	* src/window.c (meta_window_notify_focus): improve some debug spew
	(meta_window_notify_focus): add hack from WindowMaker to ignore
	focus in events with detail > NotifyNonlinearVirtual
This commit is contained in:
Havoc Pennington 2002-01-06 03:15:49 +00:00 committed by Havoc Pennington
parent 029004f289
commit 3d1d70b727
6 changed files with 124 additions and 21 deletions

View File

@ -1,3 +1,21 @@
2002-01-05 Havoc Pennington <hp@pobox.com>
GTK 1.2 plug/socket clients still broken, don't know why.
* src/screen.c (meta_screen_new): select focus change on root
window, for debugging
* src/display.c (event_callback): when unfocusing, use
no_focus_window to hold the focus
* src/display.h (struct _MetaDisplay): have a no_focus_window to
hold the focus when we don't want to have anything focused.
Then we can avoid confusing focusing-the-frame stuff.
* src/window.c (meta_window_notify_focus): improve some debug spew
(meta_window_notify_focus): add hack from WindowMaker to ignore
focus in events with detail > NotifyNonlinearVirtual
2002-01-04 Havoc Pennington <hp@pobox.com> 2002-01-04 Havoc Pennington <hp@pobox.com>
* src/display.c (event_callback): don't lower docks when a grab * src/display.c (event_callback): don't lower docks when a grab

View File

@ -235,6 +235,7 @@ meta_display_open (const char *name)
* created in screen_new * created in screen_new
*/ */
display->leader_window = None; display->leader_window = None;
display->no_focus_window = None;
screens = NULL; screens = NULL;
#if 0 #if 0
@ -863,7 +864,7 @@ event_callback (XEvent *event,
meta_verbose ("Unsetting focus from %s due to LeaveNotify\n", meta_verbose ("Unsetting focus from %s due to LeaveNotify\n",
window->desc); window->desc);
XSetInputFocus (display->xdisplay, XSetInputFocus (display->xdisplay,
PointerRoot, display->no_focus_window,
RevertToPointerRoot, RevertToPointerRoot,
event->xcrossing.time); event->xcrossing.time);
} }
@ -882,7 +883,34 @@ event_callback (XEvent *event,
case FocusIn: case FocusIn:
case FocusOut: case FocusOut:
if (window) if (window)
meta_window_notify_focus (window, event); {
meta_window_notify_focus (window, event);
}
else if (event->xany.window == display->no_focus_window)
{
meta_topic (META_DEBUG_FOCUS,
"Focus %s event received on no_focus_window 0x%lx "
"mode %s detail %s\n",
event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" :
"???",
event->xany.window,
meta_focus_mode_to_string (event->xfocus.mode),
meta_focus_detail_to_string (event->xfocus.mode));
}
else if (meta_display_screen_for_root (display,
event->xany.window) != NULL)
{
meta_topic (META_DEBUG_FOCUS,
"Focus %s event received on root window 0x%lx "
"mode %s detail %s\n",
event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" :
"???",
event->xany.window,
meta_focus_mode_to_string (event->xfocus.mode),
meta_focus_detail_to_string (event->xfocus.mode));
}
break; break;
case KeymapNotify: case KeymapNotify:
break; break;
@ -1203,19 +1231,20 @@ event_get_time (MetaDisplay *display,
} }
} }
const char*
static const char* meta_focus_detail_to_string (int d)
focus_detail (int d)
{ {
const char *detail = "???"; const char *detail = "???";
switch (d) switch (d)
{ {
/* We are an ancestor in the A<->B focus change relationship */
case NotifyAncestor: case NotifyAncestor:
detail = "NotifyAncestor"; detail = "NotifyAncestor";
break; break;
case NotifyDetailNone: case NotifyDetailNone:
detail = "NotifyDetailNone"; detail = "NotifyDetailNone";
break; break;
/* We are a descendant in the A<->B focus change relationship */
case NotifyInferior: case NotifyInferior:
detail = "NotifyInferior"; detail = "NotifyInferior";
break; break;
@ -1239,8 +1268,8 @@ focus_detail (int d)
return detail; return detail;
} }
static const char* const char*
focus_mode (int m) meta_focus_mode_to_string (int m)
{ {
const char *mode = "???"; const char *mode = "???";
switch (m) switch (m)
@ -1254,6 +1283,14 @@ focus_mode (int m)
case NotifyUngrab: case NotifyUngrab:
mode = "NotifyUngrab"; mode = "NotifyUngrab";
break; break;
/* not sure any X implementations are missing this, but
* it seems to be absent from some docs.
*/
#ifdef NotifyWhileGrabbed
case NotifyWhileGrabbed:
mode = "NotifyWhileGrabbed";
break;
#endif
} }
return mode; return mode;
@ -1325,14 +1362,14 @@ meta_spew_event (MetaDisplay *display,
case FocusIn: case FocusIn:
name = "FocusIn"; name = "FocusIn";
extra = g_strdup_printf ("detail: %s mode: %s\n", extra = g_strdup_printf ("detail: %s mode: %s\n",
focus_detail (event->xfocus.detail), meta_focus_detail_to_string (event->xfocus.detail),
focus_mode (event->xfocus.mode)); meta_focus_mode_to_string (event->xfocus.mode));
break; break;
case FocusOut: case FocusOut:
name = "FocusOut"; name = "FocusOut";
extra = g_strdup_printf ("detail: %s mode: %s\n", extra = g_strdup_printf ("detail: %s mode: %s\n",
focus_detail (event->xfocus.detail), meta_focus_detail_to_string (event->xfocus.detail),
focus_mode (event->xfocus.mode)); meta_focus_mode_to_string (event->xfocus.mode));
break; break;
case KeymapNotify: case KeymapNotify:
name = "KeymapNotify"; name = "KeymapNotify";

View File

@ -124,6 +124,11 @@ struct _MetaDisplay
GSList *error_traps; GSList *error_traps;
int server_grab_count; int server_grab_count;
/* This window holds the focus when we don't want to focus
* any actual clients
*/
Window no_focus_window;
/* for double click */ /* for double click */
int double_click_time; int double_click_time;
Time last_button_time; Time last_button_time;
@ -215,4 +220,8 @@ void meta_display_unshow_desktop (MetaDisplay *display);
guint32 meta_display_get_current_time (MetaDisplay *display); guint32 meta_display_get_current_time (MetaDisplay *display);
/* utility goo */
const char* meta_focus_mode_to_string (int m);
const char* meta_focus_detail_to_string (int d);
#endif #endif

View File

@ -1033,7 +1033,7 @@ meta_frames_button_press_event (GtkWidget *widget,
meta_core_user_raise (gdk_display, meta_core_user_raise (gdk_display,
frame->xwindow); frame->xwindow);
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focusing frame 0x%lx due to button 1 press\n", "Focusing window with frame 0x%lx due to button 1 press\n",
frame->xwindow); frame->xwindow);
meta_core_user_focus (gdk_display, meta_core_user_focus (gdk_display,
frame->xwindow, frame->xwindow,

View File

@ -183,7 +183,8 @@ meta_screen_new (MetaDisplay *display,
SubstructureRedirectMask | SubstructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
ColormapChangeMask | PropertyChangeMask | ColormapChangeMask | PropertyChangeMask |
LeaveWindowMask | EnterWindowMask | LeaveWindowMask | EnterWindowMask |
ButtonPressMask | ButtonReleaseMask); ButtonPressMask | ButtonReleaseMask |
FocusChangeMask);
if (meta_error_trap_pop (display) != Success) if (meta_error_trap_pop (display) != Success)
{ {
meta_warning (_("Screen %d on display '%s' already has a window manager\n"), meta_warning (_("Screen %d on display '%s' already has a window manager\n"),
@ -211,6 +212,16 @@ meta_screen_new (MetaDisplay *display,
screen->xroot, screen->xroot,
-100, -100, 1, 1, 0, 0, 0); -100, -100, 1, 1, 0, 0, 0);
if (display->no_focus_window == None)
{
display->no_focus_window = XCreateSimpleWindow (display->xdisplay,
screen->xroot,
-100, -100, 1, 1, 0, 0, 0);
XSelectInput (display->xdisplay, display->no_focus_window,
FocusChangeMask);
XMapWindow (display->xdisplay, display->no_focus_window);
}
set_wm_icon_size_hint (screen); set_wm_icon_size_hint (screen);
set_supported_hint (screen); set_supported_hint (screen);

View File

@ -128,6 +128,13 @@ meta_window_new (MetaDisplay *display, Window xwindow,
meta_verbose ("Attempting to manage 0x%lx\n", xwindow); meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
if (xwindow == display->no_focus_window)
{
meta_verbose ("Not managing no_focus_window 0x%lx\n",
xwindow);
return NULL;
}
/* Grab server */ /* Grab server */
meta_display_grab (display); meta_display_grab (display);
@ -2042,8 +2049,9 @@ meta_window_focus (MetaWindow *window,
if (window->display->grab_window && if (window->display->grab_window &&
window->display->grab_window->all_keys_grabbed) window->display->grab_window->all_keys_grabbed)
{ {
meta_verbose ("Current focus window %s has global keygrab, not focusing window %s after all\n", meta_topic (META_DEBUG_FOCUS,
window->display->grab_window->desc, window->desc); "Current focus window %s has global keygrab, not focusing window %s after all\n",
window->display->grab_window->desc, window->desc);
return; return;
} }
@ -2061,7 +2069,8 @@ meta_window_focus (MetaWindow *window,
{ {
if (window->frame) if (window->frame)
{ {
meta_verbose ("Focusing frame of %s\n", window->desc); meta_topic (META_DEBUG_FOCUS,
"Focusing frame of %s\n", window->desc);
XSetInputFocus (window->display->xdisplay, XSetInputFocus (window->display->xdisplay,
window->frame->xwindow, window->frame->xwindow,
RevertToPointerRoot, RevertToPointerRoot,
@ -2074,6 +2083,9 @@ meta_window_focus (MetaWindow *window,
if (window->input) if (window->input)
{ {
meta_topic (META_DEBUG_FOCUS,
"Calling XSetInputFocus() on client window %s since input = true\n",
window->desc);
XSetInputFocus (window->display->xdisplay, XSetInputFocus (window->display->xdisplay,
window->xwindow, window->xwindow,
RevertToPointerRoot, RevertToPointerRoot,
@ -2082,6 +2094,9 @@ meta_window_focus (MetaWindow *window,
if (window->take_focus) if (window->take_focus)
{ {
meta_topic (META_DEBUG_FOCUS,
"Sending WM_TAKE_FOCUS to %s since take_focus = true\n",
window->desc);
meta_window_send_icccm_message (window, meta_window_send_icccm_message (window,
window->display->atom_wm_take_focus, window->display->atom_wm_take_focus,
timestamp); timestamp);
@ -2653,16 +2668,29 @@ meta_window_notify_focus (MetaWindow *window,
* user expects once a keybinding is used. * user expects once a keybinding is used.
*/ */
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focus %s event received\n", "Focus %s event received on %s 0x%lx (%s) "
"mode %s detail %s\n",
event->type == FocusIn ? "in" : event->type == FocusIn ? "in" :
event->type == FocusOut ? "out" : event->type == FocusOut ? "out" :
event->type == UnmapNotify ? "unmap" : event->type == UnmapNotify ? "unmap" :
"???"); "???",
window->desc, event->xany.window,
event->xany.window == window->xwindow ?
"client window" :
(window->frame && event->xany.window == window->frame->xwindow) ?
"frame window" :
"unknown window",
event->type != UnmapNotify ?
meta_focus_mode_to_string (event->xfocus.mode) : "n/a",
event->type != UnmapNotify ?
meta_focus_detail_to_string (event->xfocus.mode) : "n/a");
if ((event->type == FocusIn || if ((event->type == FocusIn ||
event->type == FocusOut) && event->type == FocusOut) &&
(event->xfocus.mode == NotifyGrab || (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab)) event->xfocus.mode == NotifyUngrab ||
/* From WindowMaker */
event->xfocus.detail > NotifyNonlinearVirtual))
{ {
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Ignoring focus event generated by a grab\n"); "Ignoring focus event generated by a grab\n");