Apply patch from Gregory Merchan to avoid using CurrentTime when setting

2003-11-24  Havoc Pennington  <hp@redhat.com>

	* Apply patch from Gregory Merchan to avoid using CurrentTime when
	setting input focus. Bug #108881
This commit is contained in:
Havoc Pennington 2003-11-24 17:47:48 +00:00 committed by Havoc Pennington
parent 927a6def1b
commit feefcdd892
6 changed files with 85 additions and 59 deletions

View File

@ -1,3 +1,8 @@
2003-11-24 Havoc Pennington <hp@redhat.com>
* Apply patch from Gregory Merchan to avoid using CurrentTime when
setting input focus. Bug #108881
2003-11-23 Havoc Pennington <hp@redhat.com> 2003-11-23 Havoc Pennington <hp@redhat.com>
* src/compositor.c: move xcompmgr code in here (minus drop * src/compositor.c: move xcompmgr code in here (minus drop

View File

@ -123,9 +123,10 @@ meta_compositor_new (MetaDisplay *display)
{ {
compositor->composite_event_base = 0; compositor->composite_event_base = 0;
compositor->composite_error_base = 0; compositor->composite_error_base = 0;
meta_verbose ("XCompositeQueryExtension() returned FALSE\n");
} }
meta_verbose ("Composite extension event base %d error base %d", meta_verbose ("Composite extension event base %d error base %d\n",
compositor->composite_event_base, compositor->composite_event_base,
compositor->composite_error_base); compositor->composite_error_base);
@ -137,7 +138,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->damage_error_base = 0; compositor->damage_error_base = 0;
} }
meta_verbose ("Damage extension event base %d error base %d", meta_verbose ("Damage extension event base %d error base %d\n",
compositor->damage_event_base, compositor->damage_event_base,
compositor->damage_error_base); compositor->damage_error_base);
@ -149,7 +150,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->fixes_error_base = 0; compositor->fixes_error_base = 0;
} }
meta_verbose ("Fixes extension event base %d error base %d", meta_verbose ("Fixes extension event base %d error base %d\n",
compositor->fixes_event_base, compositor->fixes_event_base,
compositor->fixes_error_base); compositor->fixes_error_base);
@ -161,7 +162,7 @@ meta_compositor_new (MetaDisplay *display)
compositor->render_error_base = 0; compositor->render_error_base = 0;
} }
meta_verbose ("Render extension event base %d error base %d", meta_verbose ("Render extension event base %d error base %d\n",
compositor->render_event_base, compositor->render_event_base,
compositor->render_error_base); compositor->render_error_base);
@ -209,6 +210,7 @@ meta_compositor_unref (MetaCompositor *compositor)
*/ */
remove_repair_idle (compositor); remove_repair_idle (compositor);
if (compositor->window_hash)
g_hash_table_destroy (compositor->window_hash); g_hash_table_destroy (compositor->window_hash);
g_free (compositor); g_free (compositor);
@ -599,8 +601,6 @@ meta_compositor_add_window (MetaCompositor *compositor,
XRenderPictFormat *format; XRenderPictFormat *format;
XRenderPictureAttributes pa; XRenderPictureAttributes pa;
g_print ("compositor adding window 0x%lx\n", xwindow);
if (!compositor->enabled) if (!compositor->enabled)
return; /* no extension */ return; /* no extension */
@ -669,8 +669,6 @@ meta_compositor_remove_window (MetaCompositor *compositor,
MetaCompositorWindow *cwindow; MetaCompositorWindow *cwindow;
MetaScreen *screen; MetaScreen *screen;
g_print ("compositor removing window 0x%lx\n", xwindow);
if (!compositor->enabled) if (!compositor->enabled)
return; /* no extension */ return; /* no extension */
@ -716,6 +714,14 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
g_assert (screen->root_picture == None); g_assert (screen->root_picture == None);
/* FIXME add flag for whether we're composite-managing each
* screen and detect failure here
*/
XCompositeRedirectSubwindows (screen->display->xdisplay,
screen->xroot,
CompositeRedirectManual);
g_print ("Subwindows redirected\n");
pa.subwindow_mode = IncludeInferiors; pa.subwindow_mode = IncludeInferiors;
screen->root_picture = screen->root_picture =

View File

@ -187,6 +187,7 @@ meta_display_open (const char *name)
GSList *screens; GSList *screens;
GSList *tmp; GSList *tmp;
int i; int i;
Time timestamp;
/* Remember to edit code that assigns each atom to display struct /* Remember to edit code that assigns each atom to display struct
* when adding an atom name here. * when adding an atom name here.
*/ */
@ -532,6 +533,41 @@ meta_display_open (const char *name)
meta_verbose ("Not compiled with Shape support\n"); meta_verbose ("Not compiled with Shape support\n");
#endif /* !HAVE_SHAPE */ #endif /* !HAVE_SHAPE */
/* Create the leader window here. Set its properties and
* use the timestamp from one of the PropertyNotify events
* that will follow.
*/
{
XSetWindowAttributes attrs;
gulong data[1];
XEvent event;
attrs.event_mask = PropertyChangeMask;
attrs.override_redirect = True;
display->leader_window = meta_create_offscreen_window (display->xdisplay,
DefaultRootWindow (display->xdisplay));
set_utf8_string_hint (display,
display->leader_window,
display->atom_net_wm_name,
"Metacity");
data[0] = display->leader_window;
XChangeProperty (display->xdisplay,
display->leader_window,
display->atom_net_supporting_wm_check,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
XWindowEvent (display->xdisplay,
display->leader_window,
PropertyChangeMask,
&event);
timestamp = event.xproperty.time;
}
display->compositor = meta_compositor_new (display); display->compositor = meta_compositor_new (display);
screens = NULL; screens = NULL;
@ -541,7 +577,7 @@ meta_display_open (const char *name)
{ {
MetaScreen *screen; MetaScreen *screen;
screen = meta_screen_new (display, i); screen = meta_screen_new (display, i, timestamp);
if (screen) if (screen)
screens = g_slist_prepend (screens, screen); screens = g_slist_prepend (screens, screen);
@ -559,25 +595,6 @@ meta_display_open (const char *name)
return FALSE; return FALSE;
} }
/* display->leader_window was created as a side effect of
* initializing the screens
*/
set_utf8_string_hint (display,
display->leader_window,
display->atom_net_wm_name,
"Metacity");
{
gulong data[1];
data[0] = display->leader_window;
XChangeProperty (display->xdisplay,
display->leader_window,
display->atom_net_supporting_wm_check,
XA_WINDOW,
32, PropModeReplace, (guchar*) data, 1);
}
meta_display_grab (display); meta_display_grab (display);
/* Now manage all existing windows */ /* Now manage all existing windows */
@ -603,9 +620,11 @@ meta_display_open (const char *name)
if (focus == None || focus == PointerRoot) if (focus == None || focus == PointerRoot)
focus = display->no_focus_window; focus = display->no_focus_window;
/* FIXME CurrentTime evil */ /* Use the same timestamp that was passed to meta_screen_new(),
* as it is the most recent timestamp.
*/
XSetInputFocus (display->xdisplay, focus, RevertToPointerRoot, XSetInputFocus (display->xdisplay, focus, RevertToPointerRoot,
CurrentTime); timestamp);
meta_error_trap_pop (display, FALSE); meta_error_trap_pop (display, FALSE);
} }
@ -1616,14 +1635,28 @@ event_callback (XEvent *event,
if (event->type == FocusIn && if (event->type == FocusIn &&
event->xfocus.detail == NotifyDetailNone) event->xfocus.detail == NotifyDetailNone)
{ {
XEvent property_event;
/* FIXME _() gettextify on HEAD */ /* FIXME _() gettextify on HEAD */
meta_warning ("Working around an application which called XSetInputFocus (None) or with RevertToNone instead of RevertToPointerRoot, this is a minor bug in some application. If you can figure out which application causes this please report it as a bug against that application.\n"); meta_warning ("Working around an application which called XSetInputFocus (None) or with RevertToNone instead of RevertToPointerRoot, this is a minor bug in some application. If you can figure out which application causes this please report it as a bug against that application.\n");
/* Fix the problem */ /* Fix the problem */
/* Using the property XA_PRIMARY because it's safe;
* nothing would use it as a property. The type
* doesn't matter.
*/
XChangeProperty (display->xdisplay,
display->leader_window,
XA_PRIMARY, XA_STRING, 8,
PropModeAppend, NULL, 0);
XWindowEvent (display->xdisplay,
display->leader_window,
PropertyChangeMask,
&property_event);
XSetInputFocus (display->xdisplay, XSetInputFocus (display->xdisplay,
display->no_focus_window, display->no_focus_window,
RevertToPointerRoot, RevertToPointerRoot,
CurrentTime); /* CurrentTime FIXME */ property_event.xproperty.time);
} }
} }
break; break;

View File

@ -376,7 +376,8 @@ reload_xinerama_infos (MetaScreen *screen)
MetaScreen* MetaScreen*
meta_screen_new (MetaDisplay *display, meta_screen_new (MetaDisplay *display,
int number) int number,
Time timestamp)
{ {
MetaScreen *screen; MetaScreen *screen;
Window xroot; Window xroot;
@ -442,24 +443,7 @@ meta_screen_new (MetaDisplay *display,
new_wm_sn_owner = meta_create_offscreen_window (xdisplay, xroot); new_wm_sn_owner = meta_create_offscreen_window (xdisplay, xroot);
{ manager_timestamp = timestamp;
/* Generate a timestamp */
XSetWindowAttributes attrs;
XEvent event;
attrs.event_mask = PropertyChangeMask;
XChangeWindowAttributes (xdisplay, new_wm_sn_owner, CWEventMask, &attrs);
XChangeProperty (xdisplay,
new_wm_sn_owner, XA_WM_CLASS, XA_STRING, 8,
PropModeAppend, NULL, 0);
XWindowEvent (xdisplay, new_wm_sn_owner, PropertyChangeMask, &event);
attrs.event_mask = NoEventMask;
XChangeWindowAttributes (display->xdisplay,
new_wm_sn_owner, CWEventMask, &attrs);
manager_timestamp = event.xproperty.time;
}
XSetSelectionOwner (xdisplay, wm_sn_atom, new_wm_sn_owner, XSetSelectionOwner (xdisplay, wm_sn_atom, new_wm_sn_owner,
manager_timestamp); manager_timestamp);
@ -561,6 +545,7 @@ meta_screen_new (MetaDisplay *display,
screen->compositor_windows = NULL; screen->compositor_windows = NULL;
screen->damage_region = None; screen->damage_region = None;
screen->root_picture = None;
{ {
XGCValues gc_values; XGCValues gc_values;
@ -583,10 +568,6 @@ meta_screen_new (MetaDisplay *display,
meta_screen_set_cursor (screen, META_CURSOR_DEFAULT); meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
if (display->leader_window == None)
display->leader_window = meta_create_offscreen_window (display->xdisplay,
screen->xroot);
if (display->no_focus_window == None) if (display->no_focus_window == None)
{ {
display->no_focus_window = meta_create_offscreen_window (display->xdisplay, display->no_focus_window = meta_create_offscreen_window (display->xdisplay,

View File

@ -121,7 +121,8 @@ struct _MetaScreen
}; };
MetaScreen* meta_screen_new (MetaDisplay *display, MetaScreen* meta_screen_new (MetaDisplay *display,
int number); int number,
Time timestamp);
void meta_screen_free (MetaScreen *screen); void meta_screen_free (MetaScreen *screen);
void meta_screen_manage_all_windows (MetaScreen *screen); void meta_screen_manage_all_windows (MetaScreen *screen);
MetaScreen* meta_screen_for_x_screen (Screen *xscreen); MetaScreen* meta_screen_for_x_screen (Screen *xscreen);

View File

@ -3126,7 +3126,7 @@ meta_window_focus (MetaWindow *window,
XSetInputFocus (window->display->xdisplay, XSetInputFocus (window->display->xdisplay,
window->frame->xwindow, window->frame->xwindow,
RevertToPointerRoot, RevertToPointerRoot,
CurrentTime); timestamp);
window->display->expected_focus_window = window; window->display->expected_focus_window = window;
} }
} }