* 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"
"_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);
+ }
}
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;
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");
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;
++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.
*/
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
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);
}
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;
event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
- event->selection.requestor = xevent->xselectionrequest.requestor;
+ if (xevent->xselectionrequest.requestor != None)
+ event->selection.requestor = gdk_x11_window_foreign_new_for_display (display,
+ xevent->xselectionrequest.requestor);
+ else
+ event->selection.requestor = NULL;
event->selection.time = xevent->xselectionrequest.time;
break;
break;
case ClientMessage:
- {
- GList *tmp_list;
- GdkFilterReturn result = GDK_FILTER_CONTINUE;
- GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
-
- GDK_NOTE (EVENTS,
- g_message ("client message:\twindow: %ld",
- xevent->xclient.window));
-
- tmp_list = display_x11->client_filters;
- while (tmp_list)
- {
- GdkClientFilter *filter = tmp_list->data;
- tmp_list = tmp_list->next;
-
- if (filter->type == message_type)
- {
- result = (*filter->function) (xevent, event, filter->data);
- if (result != GDK_FILTER_CONTINUE)
- break;
- }
- }
-
- switch (result)
- {
- case GDK_FILTER_REMOVE:
- return_val = FALSE;
- break;
- case GDK_FILTER_TRANSLATE:
- return_val = TRUE;
- break;
- case GDK_FILTER_CONTINUE:
- /* Send unknown ClientMessage's on to Gtk for it to use */
- if (window == NULL)
- {
- return_val = FALSE;
- }
- else
- {
- event->client.type = GDK_CLIENT_EVENT;
- event->client.window = window;
- event->client.message_type = message_type;
- event->client.data_format = xevent->xclient.format;
- memcpy(&event->client.data, &xevent->xclient.data,
- sizeof(event->client.data));
- }
- break;
- }
- }
+ GDK_NOTE (EVENTS,
+ g_message ("client message:\twindow: %ld",
+ xevent->xclient.window));
+ /* Not currently handled */
+ return_val = FALSE;
break;
case MappingNotify:
GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
/* There is no way of knowing reliably whether we are viewable;
- * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
+ * so trap errors asynchronously around the XSetInputFocus call
*/
if (toplevel && win->accept_focus)
- _gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
- RevertToParent,
- xevent->xclient.data.l[1]);
+ {
+ gdk_x11_display_error_trap_push (display);
+ XSetInputFocus (GDK_DISPLAY_XDISPLAY (display),
+ toplevel->focus_window,
+ RevertToParent,
+ xevent->xclient.data.l[1]);
+ gdk_x11_display_error_trap_pop_ignored (display);
+ }
return GDK_FILTER_REMOVE;
}
XkbSelectEventDetails (display_x11->xdisplay,
XkbUseCoreKbd, XkbStateNotify,
XkbAllStateComponentsMask,
- XkbGroupLockMask|XkbModifierLockMask);
+ XkbModifierStateMask|XkbGroupStateMask);
XkbSetDetectableAutoRepeat (display_x11->xdisplay,
True,
}
#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);
/* Leader Window */
XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
- /* list of filters for client messages */
- g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
- g_list_free (display_x11->client_filters);
-
/* List of event window extraction functions */
g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
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.
return GDK_X11_DISPLAY (display)->input_devices;
}
-static gboolean
-gdk_x11_display_send_client_message (GdkDisplay *display,
- GdkEvent *event,
- GdkNativeWindow winid)
-{
- XEvent sev;
-
- g_return_val_if_fail(event != NULL, FALSE);
-
- /* Set up our event to send, with the exception of its target window */
- sev.xclient.type = ClientMessage;
- sev.xclient.display = GDK_DISPLAY_XDISPLAY (display);
- sev.xclient.format = event->client.data_format;
- sev.xclient.window = winid;
- memcpy(&sev.xclient.data, &event->client.data, sizeof (sev.xclient.data));
- sev.xclient.message_type = gdk_x11_atom_to_xatom_for_display (display, event->client.message_type);
-
- return _gdk_x11_display_send_xevent (display, winid, False, NoEventMask, &sev);
-}
-
-static void
-gdk_x11_display_add_client_message_filter (GdkDisplay *display,
- GdkAtom message_type,
- GdkFilterFunc func,
- gpointer data)
-{
- GdkClientFilter *filter;
- g_return_if_fail (GDK_IS_DISPLAY (display));
- filter = g_new (GdkClientFilter, 1);
-
- filter->type = message_type;
- filter->function = func;
- filter->data = data;
-
- GDK_X11_DISPLAY(display)->client_filters =
- g_list_append (GDK_X11_DISPLAY (display)->client_filters,
- filter);
-}
-
/**
* gdk_x11_register_standard_event_type:
* @display: a #GdkDisplay
" (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,
#else /* !G_ENABLE_DEBUG */
g_warning ("%s\n", msg);
- exit (1);
+ _exit (1);
#endif /* G_ENABLE_DEBUG */
}
}
/**
* 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
gdk_x11_display_error_trap_pop_internal (display, FALSE);
}
-extern GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
-extern GdkNativeWindow _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
- GdkNativeWindow xid,
- GdkDragProtocol *protocol,
- guint *version);
-
-
/**
* gdk_x11_set_sm_client_id:
* @sm_client_id: the client id assigned by the session manager when the
display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
display_class->supports_composite = gdk_x11_display_supports_composite;
display_class->list_devices = gdk_x11_display_list_devices;
- display_class->send_client_message = gdk_x11_display_send_client_message;
- display_class->add_client_message_filter = gdk_x11_display_add_client_message_filter;
display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
- display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;