* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
GdkEvent *event,
XEvent *xevent);
-#ifdef HAVE_X11R6
static void gdk_internal_connection_watch (Display *display,
XPointer arg,
gint fd,
gboolean opening,
XPointer *watch_data);
-#endif /* HAVE_X11R6 */
typedef struct _GdkEventTypeX11 GdkEventTypeX11;
"_NET_WM_WINDOW_TYPE_NORMAL",
"_NET_WM_USER_TIME",
"_NET_VIRTUAL_ROOTS",
- "GDK_SELECTION"
+ "GDK_SELECTION",
+ "_NET_WM_STATE_FOCUSED"
};
static char *gdk_sm_client_id;
}
else
{
- if (toplevel->have_sticky || toplevel->on_all_desktops)
+ if (toplevel->have_sticky && toplevel->on_all_desktops)
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_STICKY);
0,
GDK_WINDOW_STATE_MAXIMIZED);
}
+
+ if (old_state & GDK_WINDOW_STATE_FOCUSED)
+ {
+ if (!toplevel->have_focused)
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_FOCUSED,
+ 0);
+ }
+ else
+ {
+ if (toplevel->have_focused)
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_FOCUSED);
+ }
+
+ if (old_state & GDK_WINDOW_STATE_ICONIFIED)
+ {
+ if (!toplevel->have_hidden)
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_ICONIFIED,
+ 0);
+ }
+ else
+ {
+ if (toplevel->have_hidden)
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_ICONIFIED);
+ }
}
static void
if (type != None)
{
desktop = (gulong *)data;
- toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
+ toplevel->on_all_desktops = ((*desktop & 0xFFFFFFFF) == 0xFFFFFFFF);
XFree (desktop);
}
else
{
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
+ GdkScreen *screen = GDK_WINDOW_SCREEN (window);
Atom type;
gint format;
toplevel->have_maxvert = FALSE;
toplevel->have_maxhorz = FALSE;
toplevel->have_fullscreen = FALSE;
+ toplevel->have_focused = FALSE;
+ toplevel->have_hidden = FALSE;
type = None;
gdk_x11_display_error_trap_push (display);
Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
Atom maxhorz_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
+ Atom focused_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FOCUSED");
+ Atom hidden_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_HIDDEN");
atoms = (Atom *)data;
toplevel->have_maxhorz = TRUE;
else if (atoms[i] == fullscreen_atom)
toplevel->have_fullscreen = TRUE;
+ else if (atoms[i] == focused_atom)
+ toplevel->have_focused = TRUE;
+ else if (atoms[i] == hidden_atom)
+ toplevel->have_hidden = TRUE;
++i;
}
XFree (atoms);
}
+ if (!gdk_x11_screen_supports_net_wm_hint (screen,
+ gdk_atom_intern_static_string ("_NET_WM_STATE_FOCUSED")))
+ toplevel->have_focused = TRUE;
+
/* When have_sticky is turned on, we have to check the DESKTOP property
* as well.
*/
do_net_wm_state_changes (window);
}
-static GdkWindow *
-get_event_window (GdkEventTranslator *translator,
- XEvent *xevent)
+static Window
+get_event_xwindow (XEvent *xevent)
{
- GdkDisplay *display;
Window xwindow;
- display = (GdkDisplay *) translator;
-
switch (xevent->type)
{
case DestroyNotify:
case ConfigureNotify:
xwindow = xevent->xconfigure.window;
break;
+ case ReparentNotify:
+ xwindow = xevent->xreparent.window;
+ break;
+ case GravityNotify:
+ xwindow = xevent->xgravity.window;
+ break;
+ case CirculateNotify:
+ xwindow = xevent->xcirculate.window;
+ break;
default:
xwindow = xevent->xany.window;
}
- return gdk_x11_window_lookup_for_display (display, xwindow);
+ return xwindow;
}
static gboolean
GdkEvent *event,
XEvent *xevent)
{
+ Window xwindow;
GdkWindow *window;
+ gboolean is_substructure;
GdkWindowImplX11 *window_impl = NULL;
GdkScreen *screen = NULL;
GdkX11Screen *x11_screen = NULL;
GdkToplevelX11 *toplevel = NULL;
GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
gboolean return_val;
- Window xwindow = None;
- /* Find the GdkWindow that this event relates to.
- * Basically this means substructure events
- * are reported same as structure events
+ /* Find the GdkWindow that this event relates to. If that's
+ * not the same as the window that the event was sent to,
+ * we are getting an event from SubstructureNotifyMask.
+ * We ignore such events for internal operation, but we
+ * need to report them to the application because of
+ * GDK_SUBSTRUCTURE_MASK (which should be removed at next
+ * opportunity.) The most likely reason for getting these
+ * events is when we are used in the Metacity or Mutter
+ * window managers.
*/
- window = get_event_window (translator, xevent);
+ xwindow = get_event_xwindow (xevent);
+ is_substructure = xwindow != xevent->xany.window;
+ window = gdk_x11_window_lookup_for_display (display, xwindow);
if (window)
{
/* We may receive events such as NoExpose/GraphicsExpose
x11_screen = GDK_X11_SCREEN (screen);
toplevel = _gdk_x11_window_get_toplevel (window);
window_impl = GDK_WINDOW_IMPL_X11 (window->impl);
- xwindow = GDK_WINDOW_XID (window);
g_object_ref (window);
}
}
}
- if (xevent->type == DestroyNotify)
+ if (xevent->type == DestroyNotify && !is_substructure)
{
int i, n;
screen = gdk_display_get_screen (display, i);
x11_screen = GDK_X11_SCREEN (screen);
- if (x11_screen->wmspec_check_window == xwindow)
+ if (x11_screen->wmspec_check_window == xevent->xdestroywindow.window)
{
x11_screen->wmspec_check_window = None;
x11_screen->last_wmspec_check_time = 0;
g_message ("destroy notify:\twindow: %ld",
xevent->xdestroywindow.window));
- /* Ignore DestroyNotify from SubstructureNotifyMask */
- if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
+ if (!is_substructure)
{
event->any.type = GDK_DESTROY;
event->any.window = window;
event->any.type = GDK_UNMAP;
event->any.window = window;
- /* If we are shown (not withdrawn) and get an unmap, it means we
- * were iconified in the X sense. If we are withdrawn, and get
- * an unmap, it means we hid the window ourselves, so we
- * will have already flipped the iconified bit off.
- */
- if (window)
- {
- if (GDK_WINDOW_IS_MAPPED (window))
- gdk_synthesize_window_state (window,
- 0,
- GDK_WINDOW_STATE_ICONIFIED);
+ if (window && !is_substructure)
+ {
+ /* If the WM supports the _NET_WM_STATE_HIDDEN hint, we do not want to
+ * interpret UnmapNotify events as implying iconic state.
+ * http://bugzilla.gnome.org/show_bug.cgi?id=590726.
+ */
+ if (screen &&
+ !gdk_x11_screen_supports_net_wm_hint (screen,
+ gdk_atom_intern_static_string ("_NET_WM_STATE_HIDDEN")))
+ {
+ /* If we are shown (not withdrawn) and get an unmap, it means we were
+ * iconified in the X sense. If we are withdrawn, and get an unmap, it
+ * means we hid the window ourselves, so we will have already flipped
+ * the iconified bit off.
+ */
+ if (GDK_WINDOW_IS_MAPPED (window))
+ gdk_synthesize_window_state (window,
+ 0,
+ GDK_WINDOW_STATE_ICONIFIED);
+ }
+
+ if (window_impl->toplevel &&
+ window_impl->toplevel->frame_pending)
+ {
+ window_impl->toplevel->frame_pending = FALSE;
+ gdk_frame_clock_thaw (gdk_window_get_frame_clock (event->any.window));
+ }
+
+ if (toplevel)
+ gdk_window_freeze_toplevel_updates_libgtk_only (window);
_gdk_x11_window_grab_check_unmap (window, xevent->xany.serial);
}
event->any.type = GDK_MAP;
event->any.window = window;
- /* Unset iconified if it was set */
- if (window && (window->state & GDK_WINDOW_STATE_ICONIFIED))
- gdk_synthesize_window_state (window,
- GDK_WINDOW_STATE_ICONIFIED,
- 0);
+ if (window && !is_substructure)
+ {
+ /* Unset iconified if it was set */
+ if (window->state & GDK_WINDOW_STATE_ICONIFIED)
+ gdk_synthesize_window_state (window,
+ GDK_WINDOW_STATE_ICONIFIED,
+ 0);
+
+ if (toplevel)
+ gdk_window_thaw_toplevel_updates_libgtk_only (window);
+ }
break;
}
#ifdef HAVE_XSYNC
- if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
+ if (!is_substructure && toplevel && display_x11->use_sync && toplevel->pending_counter_value != 0)
{
- toplevel->current_counter_value = toplevel->pending_counter_value;
- XSyncIntToValue (&toplevel->pending_counter_value, 0);
+ toplevel->configure_counter_value = toplevel->pending_counter_value;
+ toplevel->pending_counter_value = 0;
}
#endif
event->configure.x = xevent->xconfigure.x;
event->configure.y = xevent->xconfigure.y;
}
- window->x = event->configure.x;
- window->y = event->configure.y;
- window->width = xevent->xconfigure.width;
- window->height = xevent->xconfigure.height;
+ if (!is_substructure)
+ {
+ window->x = event->configure.x;
+ window->y = event->configure.y;
+ window->width = xevent->xconfigure.width;
+ window->height = xevent->xconfigure.height;
- _gdk_window_update_size (window);
- _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
+ _gdk_window_update_size (window);
+ _gdk_x11_window_update_size (GDK_WINDOW_IMPL_X11 (window->impl));
- if (window->resize_count >= 1)
- {
- window->resize_count -= 1;
+ if (window->resize_count >= 1)
+ {
+ window->resize_count -= 1;
- if (window->resize_count == 0)
- _gdk_x11_moveresize_configure_done (display, window);
- }
+ if (window->resize_count == 0)
+ _gdk_x11_moveresize_configure_done (display, window);
+ }
+ }
}
break;
return return_val;
}
+static GdkFrameTimings *
+find_frame_timings (GdkFrameClock *clock,
+ guint64 serial)
+{
+ GdkFrameHistory *history = gdk_frame_clock_get_history (clock);
+ gint64 start_frame, end_frame, i;
+
+ start_frame = gdk_frame_history_get_start (history);
+ end_frame = gdk_frame_history_get_frame_counter (history);
+ for (i = end_frame; i >= start_frame; i--)
+ {
+ GdkFrameTimings *timings = gdk_frame_history_get_timings (history, i);
+
+ if (gdk_frame_timings_get_cookie (timings) == serial)
+ return timings;
+ }
+
+ return NULL;
+}
+
GdkFilterReturn
_gdk_wm_protocols_filter (GdkXEvent *xev,
GdkEvent *event,
display = GDK_WINDOW_DISPLAY (win);
+ /* This isn't actually WM_PROTOCOLS because that wouldn't leave enough space
+ * in the message for everything that gets stuffed in */
+ if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_FRAME_DRAWN"))
+ {
+ GdkWindowImplX11 *window_impl;
+ window_impl = GDK_WINDOW_IMPL_X11 (event->any.window->impl);
+ if (window_impl->toplevel)
+ {
+ guint32 d0 = xevent->xclient.data.l[0];
+ guint32 d1 = xevent->xclient.data.l[1];
+ guint32 d2 = xevent->xclient.data.l[2];
+ guint32 d3 = xevent->xclient.data.l[3];
+
+ guint64 serial = ((guint64)d0 << 32) | d1;
+
+ GdkFrameClock *clock = gdk_window_get_frame_clock (event->any.window);
+ GdkFrameTimings *timings = find_frame_timings (clock, serial);
+
+ if (timings)
+ gdk_frame_timings_set_drawn_time (timings, ((guint64)d2 << 32) | d3);
+
+ if (window_impl->toplevel->frame_pending)
+ {
+ window_impl->toplevel->frame_pending = FALSE;
+ gdk_frame_clock_thaw (clock);
+ }
+ }
+
+ return GDK_FILTER_REMOVE;
+ }
+
+ if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_FRAME_TIMINGS"))
+ {
+ GdkWindowImplX11 *window_impl;
+ window_impl = GDK_WINDOW_IMPL_X11 (event->any.window->impl);
+ if (window_impl->toplevel)
+ {
+ guint32 d0 = xevent->xclient.data.l[0];
+ guint32 d1 = xevent->xclient.data.l[1];
+ guint32 d2 = xevent->xclient.data.l[2];
+ guint32 d3 = xevent->xclient.data.l[3];
+
+ guint64 serial = ((guint64)d0 << 32) | d1;
+
+ GdkFrameClock *clock = gdk_window_get_frame_clock (event->any.window);
+ GdkFrameTimings *timings = find_frame_timings (clock, serial);
+
+ if (timings)
+ {
+ gint64 drawn_time = gdk_frame_timings_get_drawn_time (timings);
+ gint32 presentation_time_offset = (gint32)d2;
+ gint32 refresh_interval = d3;
+
+ if (drawn_time && presentation_time_offset)
+ gdk_frame_timings_set_presentation_time (timings,
+ drawn_time + presentation_time_offset);
+
+ if (refresh_interval)
+ gdk_frame_timings_set_refresh_interval (timings, refresh_interval);
+
+ gdk_frame_timings_set_complete (timings, TRUE);
+ }
+ }
+ }
+
if (xevent->xclient.message_type != gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"))
return GDK_FILTER_CONTINUE;
if (toplevel)
{
#ifdef HAVE_XSYNC
- XSyncIntsToValue (&toplevel->pending_counter_value,
- xevent->xclient.data.l[2],
- xevent->xclient.data.l[3]);
+ toplevel->pending_counter_value = xevent->xclient.data.l[2] + ((gint64)xevent->xclient.data.l[3] << 32);
#endif
}
return GDK_FILTER_REMOVE;
xdisplay = XOpenDisplay (display_name);
if (!xdisplay)
return NULL;
-
+
display = g_object_new (GDK_TYPE_X11_DISPLAY, NULL);
display_x11 = GDK_X11_DISPLAY (display);
display_x11->xdisplay = xdisplay;
-#ifdef HAVE_X11R6
/* Set up handlers for Xlib internal connections */
XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);
-#endif /* HAVE_X11R6 */
-
+
_gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
/* RandR must be initialized before we initialize the screens */
XSynchronize (display_x11->xdisplay, True);
class_hint = XAllocClassHint();
- class_hint->res_name = g_get_prgname ();
-
+ class_hint->res_name = (char *) g_get_prgname ();
class_hint->res_class = (char *)gdk_get_program_class ();
/* XmbSetWMProperties sets the RESOURCE_NAME environment variable
* from argv[0], so we just synthesize an argument array here.
*/
argc = 1;
- argv[0] = g_get_prgname ();
+ argv[0] = (char *) g_get_prgname ();
XmbSetWMProperties (display_x11->xdisplay,
display_x11->leader_window,
XkbSelectEventDetails (display_x11->xdisplay,
XkbUseCoreKbd, XkbStateNotify,
XkbAllStateComponentsMask,
- XkbGroupLockMask|XkbModifierLockMask);
+ XkbModifierStateMask|XkbGroupStateMask);
XkbSetDetectableAutoRepeat (display_x11->xdisplay,
True,
_gdk_x11_screen_setup (display_x11->screens[i]);
g_signal_emit_by_name (display, "opened");
- g_signal_emit_by_name (gdk_display_manager_get (), "display-opened", display);
return display;
}
-#ifdef HAVE_X11R6
/*
* XLib internal connection handling
*/
{
GdkInternalConnection *connection = (GdkInternalConnection *)data;
- GDK_THREADS_ENTER ();
+ gdk_threads_enter ();
XProcessInternalConnection ((Display*)connection->display, connection->fd);
- GDK_THREADS_LEAVE ();
+ gdk_threads_leave ();
return TRUE;
}
else
gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);
}
-#endif /* HAVE_X11R6 */
-static G_CONST_RETURN gchar *
+static const gchar *
gdk_x11_display_get_name (GdkDisplay *display)
{
return (gchar *) DisplayString (GDK_X11_DISPLAY (display)->xdisplay);
gpointer data,
gulong serial)
{
+ GdkPointerWindowInfo *pointer_info;
GdkDevice *device = data;
- _gdk_display_device_grab_update (display, device, NULL, serial);
+ pointer_info = _gdk_display_get_pointer_info (display, device);
+ _gdk_display_device_grab_update (display, device,
+ pointer_info->last_slave, serial);
}
#define XSERVER_TIME_IS_LATER(time1, time2) \
/**
* gdk_x11_display_grab:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Call XGrabServer() on @display.
* To ungrab the display again, use gdk_x11_display_ungrab().
/**
* gdk_x11_display_ungrab:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Ungrab @display after it has been grabbed with
* gdk_x11_display_grab().
_gdk_x11_cursor_display_finalize (GDK_DISPLAY (display_x11));
+ /* Empty the event queue */
+ _gdk_x11_display_free_translate_queue (GDK_DISPLAY (display_x11));
+
/* Atom Hashtable */
g_hash_table_destroy (display_x11->atom_from_virtual);
g_hash_table_destroy (display_x11->atom_to_virtual);
g_slist_free (display_x11->event_types);
/* input GdkDevice list */
- g_list_foreach (display_x11->input_devices, (GFunc) g_object_unref, NULL);
- g_list_free (display_x11->input_devices);
+ g_list_free_full (display_x11->input_devices, g_object_unref);
/* input GdkWindow list */
- g_list_foreach (display_x11->input_windows, (GFunc) g_free, NULL);
- g_list_free (display_x11->input_windows);
+ g_list_free_full (display_x11->input_windows, g_free);
/* Free all GdkScreens */
for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)
}
/**
- * gdk_x11_display_get_xdisplay: (skip)
- * @display: a #GdkDisplay
- * @returns: an X display.
+ * gdk_x11_display_get_xdisplay:
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Returns the X display of a #GdkDisplay.
*
+ * Returns: (transfer none): an X display
+ *
* Since: 2.2
*/
Display *
/**
* gdk_x11_display_broadcast_startup_message:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
* @message_type: startup notification message type ("new", "change",
* or "remove")
* @...: a list of key/value pairs (as strings), terminated by a
/**
* gdk_x11_display_get_user_time:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Returns the timestamp of the last user interaction on
* @display. The timestamp is taken from events caused
/**
* gdk_x11_display_get_startup_notification_id:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Gets the startup notification ID for a display.
*
*
* Since: 2.12
*/
-G_CONST_RETURN gchar *
+const gchar *
gdk_x11_display_get_startup_notification_id (GdkDisplay *display)
{
return GDK_X11_DISPLAY (display)->startup_notification_id;
/**
* gdk_x11_display_set_startup_notification_id:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
* @startup_id: the startup notification ID (must be valid utf8)
*
* Sets the startup notification ID for a display.
" (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
" (Note to programmers: normally, X errors are reported asynchronously;\n"
" that is, you will receive the error a while after causing it.\n"
- " To debug your program, run it with the --sync command line\n"
- " option to change this behavior. You can then get a meaningful\n"
+ " To debug your program, run it with the GDK_SYNCHRONIZE environment\n"
+ " variable to change this behavior. You can then get a meaningful\n"
" backtrace from your debugger if you break on the gdk_x_error() function.)",
g_get_prgname (),
buf,
/**
* gdk_x11_display_error_trap_push:
- * @display: a #GdkDisplay
+ * @display: (type GdkX11Display): a #GdkDisplay
*
* Begins a range of X requests on @display for which X error events
* will be ignored. Unignored errors (when no trap is pushed) will abort
/**
* gdk_x11_display_error_trap_pop:
- * @display: the display
+ * @display: (type GdkX11Display): the display
*
* Pops the error trap pushed by gdk_x11_display_error_trap_push().
* Will XSync() if necessary and will always block until
/**
* gdk_x11_display_error_trap_pop_ignored:
- * @display: the display
+ * @display: (type GdkX11Display): the display
*
* Pops the error trap pushed by gdk_x11_display_error_trap_push().
* Does not block to see if an error occurred; merely records the