Compare commits
12 Commits
3.28.2
...
wip/ui-on-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5bc7ae4095 | ||
![]() |
1a78515606 | ||
![]() |
4122257bce | ||
![]() |
29f6e3bda5 | ||
![]() |
bbcbf5820f | ||
![]() |
ee7c58984a | ||
![]() |
03e5bbf59f | ||
![]() |
cc6becb163 | ||
![]() |
e3b855a583 | ||
![]() |
5d8dd0653e | ||
![]() |
abe94827f5 | ||
![]() |
72b88c929e |
@@ -491,7 +491,7 @@ redirect_windows (MetaScreen *screen)
|
|||||||
*/
|
*/
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
||||||
XSync (xdisplay, FALSE);
|
XSync (xdisplay, FALSE);
|
||||||
|
|
||||||
|
@@ -92,6 +92,7 @@ struct _MetaDisplay
|
|||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
|
||||||
int clutter_event_filter;
|
int clutter_event_filter;
|
||||||
|
GSource *x11_event_source;
|
||||||
|
|
||||||
Window leader_window;
|
Window leader_window;
|
||||||
Window timestamp_pinging_window;
|
Window timestamp_pinging_window;
|
||||||
@@ -147,13 +148,10 @@ struct _MetaDisplay
|
|||||||
guint focused_by_us : 1;
|
guint focused_by_us : 1;
|
||||||
|
|
||||||
/*< private-ish >*/
|
/*< private-ish >*/
|
||||||
guint error_trap_synced_at_last_pop : 1;
|
|
||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
GHashTable *xids;
|
GHashTable *xids;
|
||||||
GHashTable *wayland_windows;
|
GHashTable *wayland_windows;
|
||||||
int error_traps;
|
|
||||||
int (* error_trap_handler) (Display *display,
|
|
||||||
XErrorEvent *error);
|
|
||||||
int server_grab_count;
|
int server_grab_count;
|
||||||
|
|
||||||
/* serials of leave/unmap events that may
|
/* serials of leave/unmap events that may
|
||||||
@@ -256,6 +254,8 @@ struct _MetaDisplay
|
|||||||
/* Closing down the display */
|
/* Closing down the display */
|
||||||
int closing;
|
int closing;
|
||||||
|
|
||||||
|
GSList *error_traps;
|
||||||
|
|
||||||
/* Managed by group.c */
|
/* Managed by group.c */
|
||||||
GHashTable *groups_by_leader;
|
GHashTable *groups_by_leader;
|
||||||
|
|
||||||
|
@@ -446,7 +446,7 @@ meta_display_open (void)
|
|||||||
|
|
||||||
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
||||||
|
|
||||||
xdisplay = meta_ui_get_display ();
|
xdisplay = XOpenDisplay (NULL);
|
||||||
|
|
||||||
if (xdisplay == NULL)
|
if (xdisplay == NULL)
|
||||||
{
|
{
|
||||||
@@ -472,9 +472,6 @@ meta_display_open (void)
|
|||||||
*/
|
*/
|
||||||
the_display->name = g_strdup (XDisplayName (NULL));
|
the_display->name = g_strdup (XDisplayName (NULL));
|
||||||
the_display->xdisplay = xdisplay;
|
the_display->xdisplay = xdisplay;
|
||||||
the_display->error_trap_synced_at_last_pop = TRUE;
|
|
||||||
the_display->error_traps = 0;
|
|
||||||
the_display->error_trap_handler = NULL;
|
|
||||||
the_display->server_grab_count = 0;
|
the_display->server_grab_count = 0;
|
||||||
the_display->display_opening = TRUE;
|
the_display->display_opening = TRUE;
|
||||||
|
|
||||||
@@ -835,7 +832,7 @@ meta_display_open (void)
|
|||||||
* now it always manages exactly one screen as specified by the DISPLAY
|
* now it always manages exactly one screen as specified by the DISPLAY
|
||||||
* environment variable.
|
* environment variable.
|
||||||
*/
|
*/
|
||||||
i = meta_ui_get_screen_number ();
|
i = DefaultScreen (the_display->xdisplay);
|
||||||
screen = meta_screen_new (the_display, i, timestamp);
|
screen = meta_screen_new (the_display, i, timestamp);
|
||||||
|
|
||||||
if (!screen)
|
if (!screen)
|
||||||
@@ -1016,9 +1013,6 @@ meta_display_close (MetaDisplay *display,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display->error_traps > 0)
|
|
||||||
meta_bug ("Display closed with error traps pending\n");
|
|
||||||
|
|
||||||
display->closing += 1;
|
display->closing += 1;
|
||||||
|
|
||||||
meta_prefs_remove_listener (prefs_changed_callback, display);
|
meta_prefs_remove_listener (prefs_changed_callback, display);
|
||||||
@@ -2212,7 +2206,7 @@ meta_change_button_grab (MetaDisplay *display,
|
|||||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||||
|
|
||||||
if (meta_is_debugging ())
|
if (meta_is_debugging ())
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
/* GrabModeSync means freeze until XAllowEvents */
|
/* GrabModeSync means freeze until XAllowEvents */
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2001 Havoc Pennington, error trapping inspired by GDK
|
* Copyright (C) 2014 Red Hat
|
||||||
* code copyrighted by the GTK team.
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
@@ -15,7 +14,9 @@
|
|||||||
* General Public License for more details.
|
* General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,42 +28,250 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <meta/errors.h>
|
#include <meta/errors.h>
|
||||||
#include "display-private.h"
|
#include "display-private.h"
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gdk/gdk.h>
|
|
||||||
|
|
||||||
/* In GTK+-3.0, the error trapping code was significantly rewritten. The new code
|
/* This is a copy-paste of the error handling code in GDK, modified
|
||||||
* has some neat features (like knowing automatically if a sync is needed or not
|
* so that it works with mutter's internal structures, since we don't
|
||||||
* and handling errors asynchronously when the error code isn't needed immediately),
|
* have a GDK display open. */
|
||||||
* but it's basically incompatible with the hacks we played with GTK+-2.0 to
|
|
||||||
* use a custom error handler along with gdk_error_trap_push().
|
/* compare X sequence numbers handling wraparound */
|
||||||
*
|
#define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
|
||||||
* Since the main point of our custom error trap was to get the error logged
|
|
||||||
* to the right place, with GTK+-3.0 we simply omit our own error handler and
|
typedef struct _GdkErrorTrap GdkErrorTrap;
|
||||||
* use the GTK+ handling straight-up.
|
|
||||||
* (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.)
|
struct _GdkErrorTrap
|
||||||
|
{
|
||||||
|
/* Next sequence when trap was pushed, i.e. first sequence to
|
||||||
|
* ignore
|
||||||
*/
|
*/
|
||||||
|
gulong start_sequence;
|
||||||
|
|
||||||
|
/* Next sequence when trap was popped, i.e. first sequence
|
||||||
|
* to not ignore. 0 if trap is still active.
|
||||||
|
*/
|
||||||
|
gulong end_sequence;
|
||||||
|
|
||||||
|
/* Most recent error code within the sequence */
|
||||||
|
int error_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* delivers an error event from the error handler in gdkmain-x11.c */
|
||||||
|
static void
|
||||||
|
meta_display_error_event (MetaDisplay *display,
|
||||||
|
XErrorEvent *error)
|
||||||
|
{
|
||||||
|
GSList *tmp_list;
|
||||||
|
gboolean ignore;
|
||||||
|
|
||||||
|
ignore = FALSE;
|
||||||
|
for (tmp_list = display->error_traps;
|
||||||
|
tmp_list != NULL;
|
||||||
|
tmp_list = tmp_list->next)
|
||||||
|
{
|
||||||
|
GdkErrorTrap *trap;
|
||||||
|
|
||||||
|
trap = tmp_list->data;
|
||||||
|
|
||||||
|
if (SEQUENCE_COMPARE (trap->start_sequence, <=, error->serial) &&
|
||||||
|
(trap->end_sequence == 0 ||
|
||||||
|
SEQUENCE_COMPARE (trap->end_sequence, >, error->serial)))
|
||||||
|
{
|
||||||
|
ignore = TRUE;
|
||||||
|
trap->error_code = error->error_code;
|
||||||
|
break; /* only innermost trap gets the error code */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ignore)
|
||||||
|
{
|
||||||
|
gchar buf[64];
|
||||||
|
gchar *msg;
|
||||||
|
|
||||||
|
XGetErrorText (display->xdisplay, error->error_code, buf, 63);
|
||||||
|
|
||||||
|
msg =
|
||||||
|
g_strdup_printf ("mutter received an X Window System error: %s\n"
|
||||||
|
" (Details: serial %ld error_code %d request_code %d minor_code %d)\n",
|
||||||
|
buf,
|
||||||
|
error->serial,
|
||||||
|
error->error_code,
|
||||||
|
error->request_code,
|
||||||
|
error->minor_code);
|
||||||
|
|
||||||
|
g_error ("%s", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
gdk_x_error (Display *xdisplay,
|
||||||
|
XErrorEvent *error)
|
||||||
|
{
|
||||||
|
MetaDisplay *display = meta_display_for_x_display (xdisplay);
|
||||||
|
meta_display_error_event (display, error);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non-GDK previous error handler */
|
||||||
|
typedef int (*GdkXErrorHandler) (Display *, XErrorEvent *);
|
||||||
|
static GdkXErrorHandler _gdk_old_error_handler;
|
||||||
|
/* number of times we've pushed the GDK error handler */
|
||||||
|
static int _gdk_error_handler_push_count = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gdk_x11_error_handler_push (void)
|
||||||
|
{
|
||||||
|
GdkXErrorHandler previous;
|
||||||
|
|
||||||
|
previous = XSetErrorHandler (gdk_x_error);
|
||||||
|
|
||||||
|
if (_gdk_error_handler_push_count > 0)
|
||||||
|
{
|
||||||
|
if (previous != gdk_x_error)
|
||||||
|
g_warning ("XSetErrorHandler() called with a GDK error trap pushed. Don't do that.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gdk_old_error_handler = previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gdk_error_handler_push_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gdk_x11_error_handler_pop (void)
|
||||||
|
{
|
||||||
|
g_return_if_fail (_gdk_error_handler_push_count > 0);
|
||||||
|
|
||||||
|
_gdk_error_handler_push_count -= 1;
|
||||||
|
|
||||||
|
if (_gdk_error_handler_push_count == 0)
|
||||||
|
{
|
||||||
|
XSetErrorHandler (_gdk_old_error_handler);
|
||||||
|
_gdk_old_error_handler = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_outdated_error_traps (MetaDisplay *display)
|
||||||
|
{
|
||||||
|
GSList *tmp_list;
|
||||||
|
gulong processed_sequence;
|
||||||
|
|
||||||
|
processed_sequence = XLastKnownRequestProcessed (display->xdisplay);
|
||||||
|
|
||||||
|
tmp_list = display->error_traps;
|
||||||
|
while (tmp_list != NULL)
|
||||||
|
{
|
||||||
|
GdkErrorTrap *trap = tmp_list->data;
|
||||||
|
|
||||||
|
if (trap->end_sequence != 0 &&
|
||||||
|
SEQUENCE_COMPARE (trap->end_sequence, <=, processed_sequence))
|
||||||
|
{
|
||||||
|
GSList *free_me = tmp_list;
|
||||||
|
|
||||||
|
tmp_list = tmp_list->next;
|
||||||
|
display->error_traps = g_slist_delete_link (display->error_traps, free_me);
|
||||||
|
g_slice_free (GdkErrorTrap, trap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp_list = tmp_list->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_error_trap_push (MetaDisplay *display)
|
meta_error_trap_push (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
gdk_error_trap_push ();
|
GdkErrorTrap *trap;
|
||||||
|
|
||||||
|
delete_outdated_error_traps (display);
|
||||||
|
|
||||||
|
/* set up the Xlib callback to tell us about errors */
|
||||||
|
_gdk_x11_error_handler_push ();
|
||||||
|
|
||||||
|
trap = g_slice_new0 (GdkErrorTrap);
|
||||||
|
|
||||||
|
trap->start_sequence = XNextRequest (display->xdisplay);
|
||||||
|
trap->error_code = Success;
|
||||||
|
|
||||||
|
display->error_traps =
|
||||||
|
g_slist_prepend (display->error_traps, trap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
meta_error_trap_pop_internal (MetaDisplay *display,
|
||||||
|
gboolean need_code)
|
||||||
|
{
|
||||||
|
GdkErrorTrap *trap;
|
||||||
|
GSList *tmp_list;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
g_return_val_if_fail (display->error_traps != NULL, Success);
|
||||||
|
|
||||||
|
/* Find the first trap that hasn't been popped already */
|
||||||
|
trap = NULL; /* quiet gcc */
|
||||||
|
for (tmp_list = display->error_traps;
|
||||||
|
tmp_list != NULL;
|
||||||
|
tmp_list = tmp_list->next)
|
||||||
|
{
|
||||||
|
trap = tmp_list->data;
|
||||||
|
|
||||||
|
if (trap->end_sequence == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_return_val_if_fail (trap != NULL, Success);
|
||||||
|
g_assert (trap->end_sequence == 0);
|
||||||
|
|
||||||
|
/* May need to sync to fill in trap->error_code if we care about
|
||||||
|
* getting an error code.
|
||||||
|
*/
|
||||||
|
if (need_code)
|
||||||
|
{
|
||||||
|
gulong processed_sequence;
|
||||||
|
gulong next_sequence;
|
||||||
|
|
||||||
|
next_sequence = XNextRequest (display->xdisplay);
|
||||||
|
processed_sequence = XLastKnownRequestProcessed (display->xdisplay);
|
||||||
|
|
||||||
|
/* If our last request was already processed, there is no point
|
||||||
|
* in syncing. i.e. if last request was a round trip (or even if
|
||||||
|
* we got an event with the serial of a non-round-trip)
|
||||||
|
*/
|
||||||
|
if ((next_sequence - 1) != processed_sequence)
|
||||||
|
{
|
||||||
|
XSync (display->xdisplay, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = trap->error_code;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* record end of trap, giving us a range of
|
||||||
|
* error sequences we'll ignore.
|
||||||
|
*/
|
||||||
|
trap->end_sequence = XNextRequest (display->xdisplay);
|
||||||
|
|
||||||
|
/* remove the Xlib callback */
|
||||||
|
_gdk_x11_error_handler_pop ();
|
||||||
|
|
||||||
|
/* we may already be outdated */
|
||||||
|
delete_outdated_error_traps (display);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_error_trap_pop (MetaDisplay *display)
|
meta_error_trap_pop (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
gdk_error_trap_pop_ignored ();
|
meta_error_trap_pop_internal (display, FALSE);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_error_trap_push_with_return (MetaDisplay *display)
|
|
||||||
{
|
|
||||||
gdk_error_trap_push ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_error_trap_pop_with_return (MetaDisplay *display)
|
meta_error_trap_pop_with_return (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
return gdk_error_trap_pop ();
|
return meta_error_trap_pop_internal (display, TRUE);
|
||||||
}
|
}
|
||||||
|
@@ -78,9 +78,8 @@ get_input_event (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
XIEvent *input_event;
|
XIEvent *input_event;
|
||||||
|
|
||||||
/* NB: GDK event filters already have generic events
|
XGetEventData (display->xdisplay, &event->xcookie);
|
||||||
* allocated, so no need to do XGetEventData() on our own
|
|
||||||
*/
|
|
||||||
input_event = (XIEvent *) event->xcookie.data;
|
input_event = (XIEvent *) event->xcookie.data;
|
||||||
|
|
||||||
switch (input_event->evtype)
|
switch (input_event->evtype)
|
||||||
@@ -860,6 +859,17 @@ handle_input_xevent (MetaDisplay *display,
|
|||||||
if (input_event == NULL)
|
if (input_event == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
switch (input_event->evtype)
|
||||||
|
{
|
||||||
|
case XI_Enter:
|
||||||
|
case XI_Leave:
|
||||||
|
case XI_FocusIn:
|
||||||
|
case XI_FocusOut:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
modified = xievent_get_modified_window (display, input_event);
|
modified = xievent_get_modified_window (display, input_event);
|
||||||
window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||||
|
|
||||||
@@ -934,12 +944,11 @@ handle_input_xevent (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
/* Don't send FocusIn / FocusOut to Clutter */
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
/* Don't pass these events through to Clutter / GTK+ */
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1041,7 +1050,7 @@ convert_property (MetaDisplay *display,
|
|||||||
conversion_targets[2] = display->atom_TIMESTAMP;
|
conversion_targets[2] = display->atom_TIMESTAMP;
|
||||||
conversion_targets[3] = display->atom_VERSION;
|
conversion_targets[3] = display->atom_VERSION;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
if (target == display->atom_TARGETS)
|
if (target == display->atom_TARGETS)
|
||||||
XChangeProperty (display->xdisplay, w, property,
|
XChangeProperty (display->xdisplay, w, property,
|
||||||
XA_ATOM, 32, PropModeReplace,
|
XA_ATOM, 32, PropModeReplace,
|
||||||
@@ -1116,7 +1125,7 @@ process_selection_request (MetaDisplay *display,
|
|||||||
unsigned long num, rest;
|
unsigned long num, rest;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
if (XGetWindowProperty (display->xdisplay,
|
if (XGetWindowProperty (display->xdisplay,
|
||||||
event->xselectionrequest.requestor,
|
event->xselectionrequest.requestor,
|
||||||
event->xselectionrequest.property, 0, 256, False,
|
event->xselectionrequest.property, 0, 256, False,
|
||||||
@@ -1740,12 +1749,12 @@ window_has_xwindow (MetaWindow *window,
|
|||||||
* busy around here. Most of this function is a ginormous switch statement
|
* busy around here. Most of this function is a ginormous switch statement
|
||||||
* dealing with all the kinds of events that might turn up.
|
* dealing with all the kinds of events that might turn up.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static void
|
||||||
meta_display_handle_xevent (MetaDisplay *display,
|
meta_display_handle_xevent (MetaDisplay *display,
|
||||||
XEvent *event)
|
XEvent *event)
|
||||||
{
|
{
|
||||||
Window modified;
|
Window modified;
|
||||||
gboolean bypass_compositor = FALSE, bypass_gtk = FALSE;
|
gboolean bypass_compositor = FALSE;
|
||||||
XIEvent *input_event;
|
XIEvent *input_event;
|
||||||
MetaMonitorManager *monitor;
|
MetaMonitorManager *monitor;
|
||||||
|
|
||||||
@@ -1754,13 +1763,13 @@ meta_display_handle_xevent (MetaDisplay *display,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_STARTUP_NOTIFICATION
|
#ifdef HAVE_STARTUP_NOTIFICATION
|
||||||
sn_display_process_event (display->sn_display, event);
|
if (sn_display_process_event (display->sn_display, event))
|
||||||
|
{
|
||||||
|
bypass_compositor = TRUE;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Intercept XRandR events early and don't attempt any
|
|
||||||
processing for them. We still let them through to Gdk though,
|
|
||||||
so it can update its own internal state.
|
|
||||||
*/
|
|
||||||
monitor = meta_monitor_manager_get ();
|
monitor = meta_monitor_manager_get ();
|
||||||
if (meta_monitor_manager_handle_xevent (monitor, event))
|
if (meta_monitor_manager_handle_xevent (monitor, event))
|
||||||
{
|
{
|
||||||
@@ -1789,7 +1798,7 @@ meta_display_handle_xevent (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
if (meta_screen_handle_xevent (display->screen, event))
|
if (meta_screen_handle_xevent (display->screen, event))
|
||||||
{
|
{
|
||||||
bypass_gtk = bypass_compositor = TRUE;
|
bypass_compositor = TRUE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1800,8 +1809,9 @@ meta_display_handle_xevent (MetaDisplay *display,
|
|||||||
|
|
||||||
if (event->type == UnmapNotify)
|
if (event->type == UnmapNotify)
|
||||||
{
|
{
|
||||||
if (meta_ui_window_should_not_cause_focus (display->xdisplay,
|
MetaUI *ui = display->screen->ui;
|
||||||
modified))
|
|
||||||
|
if (meta_ui_window_should_not_cause_focus (ui, modified))
|
||||||
{
|
{
|
||||||
meta_display_add_ignored_crossing_serial (display, event->xany.serial);
|
meta_display_add_ignored_crossing_serial (display, event->xany.serial);
|
||||||
meta_topic (META_DEBUG_FOCUS,
|
meta_topic (META_DEBUG_FOCUS,
|
||||||
@@ -1823,7 +1833,7 @@ meta_display_handle_xevent (MetaDisplay *display,
|
|||||||
#ifdef HAVE_XI23
|
#ifdef HAVE_XI23
|
||||||
if (meta_display_process_barrier_event (display, input_event))
|
if (meta_display_process_barrier_event (display, input_event))
|
||||||
{
|
{
|
||||||
bypass_gtk = bypass_compositor = TRUE;
|
bypass_compositor = TRUE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_XI23 */
|
#endif /* HAVE_XI23 */
|
||||||
@@ -1834,27 +1844,20 @@ meta_display_handle_xevent (MetaDisplay *display,
|
|||||||
*/
|
*/
|
||||||
if (handle_input_xevent (display, input_event, event->xany.serial))
|
if (handle_input_xevent (display, input_event, event->xany.serial))
|
||||||
{
|
{
|
||||||
bypass_gtk = bypass_compositor = TRUE;
|
bypass_compositor = TRUE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle_other_xevent (display, event))
|
if (handle_other_xevent (display, event))
|
||||||
{
|
|
||||||
bypass_gtk = TRUE;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!bypass_compositor)
|
if (!bypass_compositor)
|
||||||
{
|
{
|
||||||
MetaWindow *window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
MetaWindow *window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||||
|
|
||||||
if (meta_compositor_process_event (display->compositor, event, window))
|
meta_compositor_process_event (display->compositor, event, window);
|
||||||
bypass_gtk = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display->current_time = CurrentTime;
|
|
||||||
return bypass_gtk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2165,19 +2168,6 @@ meta_display_handle_event (MetaDisplay *display,
|
|||||||
return bypass_clutter;
|
return bypass_clutter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
|
||||||
xevent_filter (GdkXEvent *xevent,
|
|
||||||
GdkEvent *event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
MetaDisplay *display = data;
|
|
||||||
|
|
||||||
if (meta_display_handle_xevent (display, xevent))
|
|
||||||
return GDK_FILTER_REMOVE;
|
|
||||||
else
|
|
||||||
return GDK_FILTER_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
event_callback (const ClutterEvent *event,
|
event_callback (const ClutterEvent *event,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@@ -2187,20 +2177,90 @@ event_callback (const ClutterEvent *event,
|
|||||||
return meta_display_handle_event (display, event);
|
return meta_display_handle_event (display, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GSource source;
|
||||||
|
|
||||||
|
MetaDisplay *display;
|
||||||
|
GPollFD event_poll_fd;
|
||||||
|
} X11EventSource;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
x11_event_source_prepare (GSource *source,
|
||||||
|
gint *timeout)
|
||||||
|
{
|
||||||
|
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||||
|
MetaDisplay *display = source_x11->display;
|
||||||
|
|
||||||
|
*timeout = -1;
|
||||||
|
|
||||||
|
return XPending (display->xdisplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
x11_event_source_check (GSource *source)
|
||||||
|
{
|
||||||
|
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||||
|
MetaDisplay *display = source_x11->display;
|
||||||
|
|
||||||
|
if (source_x11->event_poll_fd.revents & G_IO_IN)
|
||||||
|
return XPending (display->xdisplay);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
x11_event_source_dispatch (GSource *source,
|
||||||
|
GSourceFunc callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||||
|
MetaDisplay *display = source_x11->display;
|
||||||
|
XEvent event;
|
||||||
|
|
||||||
|
XNextEvent (display->xdisplay, &event);
|
||||||
|
meta_display_handle_xevent (display, &event);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSourceFuncs x11_event_source_funcs = {
|
||||||
|
x11_event_source_prepare,
|
||||||
|
x11_event_source_check,
|
||||||
|
x11_event_source_dispatch,
|
||||||
|
};
|
||||||
|
|
||||||
|
static GSource *
|
||||||
|
x11_event_source_new (MetaDisplay *display)
|
||||||
|
{
|
||||||
|
GSource *source = g_source_new (&x11_event_source_funcs, sizeof (X11EventSource));
|
||||||
|
X11EventSource *source_x11 = (X11EventSource *) source;
|
||||||
|
|
||||||
|
source_x11->display = display;
|
||||||
|
source_x11->event_poll_fd.fd = ConnectionNumber (display->xdisplay);
|
||||||
|
source_x11->event_poll_fd.events = G_IO_IN;
|
||||||
|
g_source_add_poll (source, &source_x11->event_poll_fd);
|
||||||
|
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_display_init_events (MetaDisplay *display)
|
meta_display_init_events (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
gdk_window_add_filter (NULL, xevent_filter, display);
|
|
||||||
display->clutter_event_filter = clutter_event_add_filter (NULL,
|
display->clutter_event_filter = clutter_event_add_filter (NULL,
|
||||||
event_callback,
|
event_callback,
|
||||||
NULL,
|
NULL,
|
||||||
display);
|
display);
|
||||||
|
|
||||||
|
display->x11_event_source = x11_event_source_new (display);
|
||||||
|
g_source_attach (display->x11_event_source, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_display_free_events (MetaDisplay *display)
|
meta_display_free_events (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
gdk_window_remove_filter (NULL, xevent_filter, display);
|
|
||||||
clutter_event_remove_filter (display->clutter_event_filter);
|
clutter_event_remove_filter (display->clutter_event_filter);
|
||||||
display->clutter_event_filter = 0;
|
display->clutter_event_filter = 0;
|
||||||
|
|
||||||
|
g_source_unref (display->x11_event_source);
|
||||||
|
display->x11_event_source = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -92,7 +92,6 @@ meta_window_ensure_frame (MetaWindow *window)
|
|||||||
visual = NULL;
|
visual = NULL;
|
||||||
|
|
||||||
frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
|
frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
|
||||||
window->display->xdisplay,
|
|
||||||
visual,
|
visual,
|
||||||
frame->rect.x,
|
frame->rect.x,
|
||||||
frame->rect.y,
|
frame->rect.y,
|
||||||
|
@@ -1065,7 +1065,7 @@ meta_change_keygrab (MetaDisplay *display,
|
|||||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||||
|
|
||||||
if (meta_is_debugging ())
|
if (meta_is_debugging ())
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
if (grab)
|
if (grab)
|
||||||
XIGrabKeycode (display->xdisplay,
|
XIGrabKeycode (display->xdisplay,
|
||||||
META_VIRTUAL_CORE_KEYBOARD_ID,
|
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||||
@@ -1410,7 +1410,7 @@ grab_keyboard (MetaDisplay *display,
|
|||||||
/* Grab the keyboard, so we get key releases and all key
|
/* Grab the keyboard, so we get key releases and all key
|
||||||
* presses
|
* presses
|
||||||
*/
|
*/
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
/* Strictly, we only need to set grab_mode on the keyboard device
|
/* Strictly, we only need to set grab_mode on the keyboard device
|
||||||
* while the pointer should always be XIGrabModeAsync. Unfortunately
|
* while the pointer should always be XIGrabModeAsync. Unfortunately
|
||||||
|
@@ -560,7 +560,7 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We want to find out when the current selection owner dies */
|
/* We want to find out when the current selection owner dies */
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
attrs.event_mask = StructureNotifyMask;
|
attrs.event_mask = StructureNotifyMask;
|
||||||
XChangeWindowAttributes (xdisplay,
|
XChangeWindowAttributes (xdisplay,
|
||||||
current_wm_sn_owner, CWEventMask, &attrs);
|
current_wm_sn_owner, CWEventMask, &attrs);
|
||||||
@@ -619,7 +619,7 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* select our root window events */
|
/* select our root window events */
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
/* We need to or with the existing event mask since
|
/* We need to or with the existing event mask since
|
||||||
* gtk+ may be interested in other events.
|
* gtk+ may be interested in other events.
|
||||||
@@ -757,8 +757,7 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
screen->keys_grabbed = FALSE;
|
screen->keys_grabbed = FALSE;
|
||||||
meta_screen_grab_keys (screen);
|
meta_screen_grab_keys (screen);
|
||||||
|
|
||||||
screen->ui = meta_ui_new (screen->display->xdisplay,
|
screen->ui = meta_ui_new ();
|
||||||
screen->xscreen);
|
|
||||||
|
|
||||||
screen->tile_preview_timeout_id = 0;
|
screen->tile_preview_timeout_id = 0;
|
||||||
|
|
||||||
@@ -838,7 +837,7 @@ meta_screen_free (MetaScreen *screen,
|
|||||||
meta_stack_free (screen->stack);
|
meta_stack_free (screen->stack);
|
||||||
meta_stack_tracker_free (screen->stack_tracker);
|
meta_stack_tracker_free (screen->stack_tracker);
|
||||||
|
|
||||||
meta_error_trap_push_with_return (screen->display);
|
meta_error_trap_push (screen->display);
|
||||||
XSelectInput (screen->display->xdisplay, screen->xroot, 0);
|
XSelectInput (screen->display->xdisplay, screen->xroot, 0);
|
||||||
if (meta_error_trap_pop_with_return (screen->display) != Success)
|
if (meta_error_trap_pop_with_return (screen->display) != Success)
|
||||||
meta_warning ("Could not release screen %d on display \"%s\"\n",
|
meta_warning ("Could not release screen %d on display \"%s\"\n",
|
||||||
|
@@ -3953,7 +3953,7 @@ meta_window_create_sync_request_alarm (MetaWindow *window)
|
|||||||
window->sync_request_alarm != None)
|
window->sync_request_alarm != None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (window->display);
|
meta_error_trap_push (window->display);
|
||||||
|
|
||||||
/* In the new (extended style), the counter value is initialized by
|
/* In the new (extended style), the counter value is initialized by
|
||||||
* the client before mapping the window. In the old style, we're
|
* the client before mapping the window. In the old style, we're
|
||||||
@@ -8038,7 +8038,7 @@ warp_grab_pointer (MetaWindow *window,
|
|||||||
*x = CLAMP (*x, 0, window->screen->rect.width-1);
|
*x = CLAMP (*x, 0, window->screen->rect.width-1);
|
||||||
*y = CLAMP (*y, 0, window->screen->rect.height-1);
|
*y = CLAMP (*y, 0, window->screen->rect.height-1);
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
meta_topic (META_DEBUG_WINDOW_OPS,
|
meta_topic (META_DEBUG_WINDOW_OPS,
|
||||||
"Warping pointer to %d,%d with window at %d,%d\n",
|
"Warping pointer to %d,%d with window at %d,%d\n",
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
void meta_error_trap_push (MetaDisplay *display);
|
void meta_error_trap_push (MetaDisplay *display);
|
||||||
void meta_error_trap_pop (MetaDisplay *display);
|
void meta_error_trap_pop (MetaDisplay *display);
|
||||||
|
|
||||||
void meta_error_trap_push_with_return (MetaDisplay *display);
|
|
||||||
/* returns X error code, or 0 for no error */
|
/* returns X error code, or 0 for no error */
|
||||||
int meta_error_trap_pop_with_return (MetaDisplay *display);
|
int meta_error_trap_pop_with_return (MetaDisplay *display);
|
||||||
|
|
||||||
|
260
src/ui/ui.c
260
src/ui/ui.c
@@ -39,8 +39,9 @@ static void meta_ui_accelerator_parse (const char *accel,
|
|||||||
|
|
||||||
struct _MetaUI
|
struct _MetaUI
|
||||||
{
|
{
|
||||||
Display *xdisplay;
|
GdkDisplay *display;
|
||||||
Screen *xscreen;
|
GdkScreen *screen;
|
||||||
|
|
||||||
MetaFrames *frames;
|
MetaFrames *frames;
|
||||||
|
|
||||||
/* For double-click tracking */
|
/* For double-click tracking */
|
||||||
@@ -60,200 +61,17 @@ meta_ui_init (void)
|
|||||||
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
Display*
|
|
||||||
meta_ui_get_display (void)
|
|
||||||
{
|
|
||||||
return GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
meta_ui_get_screen_number (void)
|
|
||||||
{
|
|
||||||
return gdk_screen_get_number (gdk_screen_get_default ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For XInput2 */
|
|
||||||
#include "display-private.h"
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
is_input_event (XEvent *event)
|
|
||||||
{
|
|
||||||
MetaDisplay *display = meta_get_display ();
|
|
||||||
|
|
||||||
return (event->type == GenericEvent &&
|
|
||||||
event->xcookie.extension == display->xinput_opcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We do some of our event handling in frames.c, which expects
|
|
||||||
* GDK events delivered by GTK+. However, since the transition to
|
|
||||||
* client side windows, we can't let GDK see button events, since the
|
|
||||||
* client-side tracking of implicit and explicit grabs it does will
|
|
||||||
* get confused by our direct use of X grabs in the core code.
|
|
||||||
*
|
|
||||||
* So we do a very minimal GDK => GTK event conversion here and send on the
|
|
||||||
* events we care about, and then filter them out so they don't go
|
|
||||||
* through the normal GDK event handling.
|
|
||||||
*
|
|
||||||
* To reduce the amount of code, the only events fields filled out
|
|
||||||
* below are the ones that frames.c uses. If frames.c is modified to
|
|
||||||
* use more fields, more fields need to be filled out below.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
maybe_redirect_mouse_event (XEvent *xevent)
|
|
||||||
{
|
|
||||||
GdkDisplay *gdisplay;
|
|
||||||
GdkDeviceManager *gmanager;
|
|
||||||
GdkDevice *gdevice;
|
|
||||||
MetaUI *ui;
|
|
||||||
GdkEvent *gevent;
|
|
||||||
GdkWindow *gdk_window;
|
|
||||||
Window window;
|
|
||||||
XIEvent *xev;
|
|
||||||
XIDeviceEvent *xev_d = NULL;
|
|
||||||
XIEnterEvent *xev_e = NULL;
|
|
||||||
|
|
||||||
if (!is_input_event (xevent))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
xev = (XIEvent *) xevent->xcookie.data;
|
|
||||||
|
|
||||||
switch (xev->evtype)
|
|
||||||
{
|
|
||||||
case XI_ButtonPress:
|
|
||||||
case XI_ButtonRelease:
|
|
||||||
case XI_Motion:
|
|
||||||
xev_d = (XIDeviceEvent *) xev;
|
|
||||||
window = xev_d->event;
|
|
||||||
break;
|
|
||||||
case XI_Enter:
|
|
||||||
case XI_Leave:
|
|
||||||
xev_e = (XIEnterEvent *) xev;
|
|
||||||
window = xev_e->event;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdisplay = gdk_x11_lookup_xdisplay (xev->display);
|
|
||||||
ui = g_object_get_data (G_OBJECT (gdisplay), "meta-ui");
|
|
||||||
if (!ui)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
|
|
||||||
if (gdk_window == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
gmanager = gdk_display_get_device_manager (gdisplay);
|
|
||||||
gdevice = gdk_x11_device_manager_lookup (gmanager, META_VIRTUAL_CORE_POINTER_ID);
|
|
||||||
|
|
||||||
/* If GDK already thinks it has a grab, we better let it see events; this
|
|
||||||
* is the menu-navigation case and events need to get sent to the appropriate
|
|
||||||
* (client-side) subwindow for individual menu items.
|
|
||||||
*/
|
|
||||||
if (gdk_display_device_is_grabbed (gdisplay, gdevice))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
switch (xev->evtype)
|
|
||||||
{
|
|
||||||
case XI_ButtonPress:
|
|
||||||
case XI_ButtonRelease:
|
|
||||||
if (xev_d->evtype == XI_ButtonPress)
|
|
||||||
{
|
|
||||||
GtkSettings *settings = gtk_settings_get_default ();
|
|
||||||
int double_click_time;
|
|
||||||
int double_click_distance;
|
|
||||||
|
|
||||||
g_object_get (settings,
|
|
||||||
"gtk-double-click-time", &double_click_time,
|
|
||||||
"gtk-double-click-distance", &double_click_distance,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (xev_d->detail == ui->button_click_number &&
|
|
||||||
xev_d->event == ui->button_click_window &&
|
|
||||||
xev_d->time < ui->button_click_time + double_click_time &&
|
|
||||||
ABS (xev_d->event_x - ui->button_click_x) <= double_click_distance &&
|
|
||||||
ABS (xev_d->event_y - ui->button_click_y) <= double_click_distance)
|
|
||||||
{
|
|
||||||
gevent = gdk_event_new (GDK_2BUTTON_PRESS);
|
|
||||||
|
|
||||||
ui->button_click_number = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gevent = gdk_event_new (GDK_BUTTON_PRESS);
|
|
||||||
ui->button_click_number = xev_d->detail;
|
|
||||||
ui->button_click_window = xev_d->event;
|
|
||||||
ui->button_click_time = xev_d->time;
|
|
||||||
ui->button_click_x = xev_d->event_x;
|
|
||||||
ui->button_click_y = xev_d->event_y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gevent = gdk_event_new (GDK_BUTTON_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
gevent->button.window = g_object_ref (gdk_window);
|
|
||||||
gevent->button.button = xev_d->detail;
|
|
||||||
gevent->button.time = xev_d->time;
|
|
||||||
gevent->button.x = xev_d->event_x;
|
|
||||||
gevent->button.y = xev_d->event_y;
|
|
||||||
gevent->button.x_root = xev_d->root_x;
|
|
||||||
gevent->button.y_root = xev_d->root_y;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case XI_Motion:
|
|
||||||
gevent = gdk_event_new (GDK_MOTION_NOTIFY);
|
|
||||||
gevent->motion.type = GDK_MOTION_NOTIFY;
|
|
||||||
gevent->motion.window = g_object_ref (gdk_window);
|
|
||||||
break;
|
|
||||||
case XI_Enter:
|
|
||||||
case XI_Leave:
|
|
||||||
gevent = gdk_event_new (xev_e->evtype == XI_Enter ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
|
|
||||||
gevent->crossing.window = g_object_ref (gdk_window);
|
|
||||||
gevent->crossing.x = xev_e->event_x;
|
|
||||||
gevent->crossing.y = xev_e->event_y;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we've gotten here, we've created the gdk_event and should send it on */
|
|
||||||
gdk_event_set_device (gevent, gdevice);
|
|
||||||
gtk_main_do_event (gevent);
|
|
||||||
gdk_event_free (gevent);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkFilterReturn
|
|
||||||
ui_filter_func (GdkXEvent *xevent,
|
|
||||||
GdkEvent *event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
if (maybe_redirect_mouse_event (xevent))
|
|
||||||
return GDK_FILTER_REMOVE;
|
|
||||||
else
|
|
||||||
return GDK_FILTER_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
MetaUI*
|
MetaUI*
|
||||||
meta_ui_new (Display *xdisplay,
|
meta_ui_new (void)
|
||||||
Screen *screen)
|
|
||||||
{
|
{
|
||||||
GdkDisplay *gdisplay;
|
|
||||||
MetaUI *ui;
|
MetaUI *ui;
|
||||||
|
|
||||||
ui = g_new0 (MetaUI, 1);
|
ui = g_new0 (MetaUI, 1);
|
||||||
ui->xdisplay = xdisplay;
|
ui->display = gdk_display_get_default ();
|
||||||
ui->xscreen = screen;
|
ui->screen = gdk_screen_get_default ();
|
||||||
|
|
||||||
gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
|
ui->frames = meta_frames_new (gdk_screen_get_number (ui->screen));
|
||||||
g_assert (gdisplay == gdk_display_get_default ());
|
|
||||||
|
|
||||||
ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
|
|
||||||
/* GTK+ needs the frame-sync protocol to work in order to properly
|
/* GTK+ needs the frame-sync protocol to work in order to properly
|
||||||
* handle style changes. This means that the dummy widget we create
|
* handle style changes. This means that the dummy widget we create
|
||||||
* to get the style for title bars actually needs to be mapped
|
* to get the style for title bars actually needs to be mapped
|
||||||
@@ -262,25 +80,14 @@ meta_ui_new (Display *xdisplay,
|
|||||||
*/
|
*/
|
||||||
gtk_widget_show (GTK_WIDGET (ui->frames));
|
gtk_widget_show (GTK_WIDGET (ui->frames));
|
||||||
|
|
||||||
gdk_window_add_filter (NULL, ui_filter_func, NULL);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
|
|
||||||
|
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_ui_free (MetaUI *ui)
|
meta_ui_free (MetaUI *ui)
|
||||||
{
|
{
|
||||||
GdkDisplay *gdisplay;
|
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
||||||
|
|
||||||
gdisplay = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
||||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", NULL);
|
|
||||||
|
|
||||||
gdk_window_remove_filter (NULL, ui_filter_func, NULL);
|
|
||||||
|
|
||||||
g_free (ui);
|
g_free (ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +112,6 @@ meta_ui_get_frame_borders (MetaUI *ui,
|
|||||||
|
|
||||||
Window
|
Window
|
||||||
meta_ui_create_frame_window (MetaUI *ui,
|
meta_ui_create_frame_window (MetaUI *ui,
|
||||||
Display *xdisplay,
|
|
||||||
Visual *xvisual,
|
Visual *xvisual,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
@@ -314,7 +120,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
gint screen_no,
|
gint screen_no,
|
||||||
gulong *create_serial)
|
gulong *create_serial)
|
||||||
{
|
{
|
||||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
|
GdkDisplay *display = ui->display;
|
||||||
GdkScreen *screen = gdk_display_get_screen (display, screen_no);
|
GdkScreen *screen = gdk_display_get_screen (display, screen_no);
|
||||||
GdkWindowAttr attrs;
|
GdkWindowAttr attrs;
|
||||||
gint attributes_mask;
|
gint attributes_mask;
|
||||||
@@ -363,7 +169,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
|||||||
* as long as you pass in a colormap.
|
* as long as you pass in a colormap.
|
||||||
*/
|
*/
|
||||||
if (create_serial)
|
if (create_serial)
|
||||||
*create_serial = XNextRequest (xdisplay);
|
*create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (display));
|
||||||
window =
|
window =
|
||||||
gdk_window_new (gdk_screen_get_root_window(screen),
|
gdk_window_new (gdk_screen_get_root_window(screen),
|
||||||
&attrs, attributes_mask);
|
&attrs, attributes_mask);
|
||||||
@@ -397,10 +203,9 @@ void
|
|||||||
meta_ui_map_frame (MetaUI *ui,
|
meta_ui_map_frame (MetaUI *ui,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
{
|
{
|
||||||
|
GdkDisplay *display = ui->display;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
GdkDisplay *display;
|
|
||||||
|
|
||||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
||||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
@@ -411,10 +216,9 @@ void
|
|||||||
meta_ui_unmap_frame (MetaUI *ui,
|
meta_ui_unmap_frame (MetaUI *ui,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
{
|
{
|
||||||
|
GdkDisplay *display = ui->display;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
GdkDisplay *display;
|
|
||||||
|
|
||||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
||||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
@@ -632,13 +436,13 @@ meta_ui_get_default_mini_icon (MetaUI *ui)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
{
|
{
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
|
|
||||||
display = gdk_x11_lookup_xdisplay (xdisplay);
|
display = ui->display;
|
||||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||||
|
|
||||||
/* we shouldn't cause focus if we're an override redirect
|
/* we shouldn't cause focus if we're an override redirect
|
||||||
@@ -650,38 +454,6 @@ meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
|
||||||
meta_text_property_to_utf8 (Display *xdisplay,
|
|
||||||
const XTextProperty *prop)
|
|
||||||
{
|
|
||||||
GdkDisplay *display;
|
|
||||||
char **list;
|
|
||||||
int count;
|
|
||||||
char *retval;
|
|
||||||
|
|
||||||
list = NULL;
|
|
||||||
|
|
||||||
display = gdk_x11_lookup_xdisplay (xdisplay);
|
|
||||||
count = gdk_text_property_to_utf8_list_for_display (display,
|
|
||||||
gdk_x11_xatom_to_atom_for_display (display, prop->encoding),
|
|
||||||
prop->format,
|
|
||||||
prop->value,
|
|
||||||
prop->nitems,
|
|
||||||
&list);
|
|
||||||
|
|
||||||
if (count == 0)
|
|
||||||
retval = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retval = list[0];
|
|
||||||
list[0] = g_strdup (""); /* something to free */
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev (list);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||||
MetaFrameType type,
|
MetaFrameType type,
|
||||||
@@ -701,8 +473,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
|
|||||||
|
|
||||||
if (!font_desc)
|
if (!font_desc)
|
||||||
{
|
{
|
||||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
GdkScreen *screen = ui->screen;
|
||||||
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
|
|
||||||
GtkWidgetPath *widget_path;
|
GtkWidgetPath *widget_path;
|
||||||
|
|
||||||
style = gtk_style_context_new ();
|
style = gtk_style_context_new ();
|
||||||
@@ -941,10 +712,9 @@ gboolean
|
|||||||
meta_ui_window_is_widget (MetaUI *ui,
|
meta_ui_window_is_widget (MetaUI *ui,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkDisplay *display = ui->display;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
||||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
|
13
src/ui/ui.h
13
src/ui/ui.h
@@ -42,12 +42,7 @@ typedef enum
|
|||||||
|
|
||||||
void meta_ui_init (void);
|
void meta_ui_init (void);
|
||||||
|
|
||||||
Display* meta_ui_get_display (void);
|
MetaUI* meta_ui_new (void);
|
||||||
|
|
||||||
gint meta_ui_get_screen_number (void);
|
|
||||||
|
|
||||||
MetaUI* meta_ui_new (Display *xdisplay,
|
|
||||||
Screen *screen);
|
|
||||||
void meta_ui_free (MetaUI *ui);
|
void meta_ui_free (MetaUI *ui);
|
||||||
|
|
||||||
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
void meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||||
@@ -65,7 +60,6 @@ void meta_ui_get_frame_mask (MetaUI *ui,
|
|||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
|
|
||||||
Window meta_ui_create_frame_window (MetaUI *ui,
|
Window meta_ui_create_frame_window (MetaUI *ui,
|
||||||
Display *xdisplay,
|
|
||||||
Visual *xvisual,
|
Visual *xvisual,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
@@ -139,12 +133,9 @@ GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
|
|||||||
GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui);
|
GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui);
|
||||||
GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
|
GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
|
||||||
|
|
||||||
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
gboolean meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
|
||||||
char* meta_text_property_to_utf8 (Display *xdisplay,
|
|
||||||
const XTextProperty *prop);
|
|
||||||
|
|
||||||
void meta_ui_set_current_theme (const char *name);
|
void meta_ui_set_current_theme (const char *name);
|
||||||
gboolean meta_ui_have_a_theme (void);
|
gboolean meta_ui_have_a_theme (void);
|
||||||
|
|
||||||
|
@@ -230,7 +230,7 @@ read_rgb_icon (MetaDisplay *display,
|
|||||||
int mini_w, mini_h;
|
int mini_w, mini_h;
|
||||||
gulong *data_as_long;
|
gulong *data_as_long;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
type = None;
|
type = None;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
result = XGetWindowProperty (display->xdisplay,
|
result = XGetWindowProperty (display->xdisplay,
|
||||||
@@ -504,7 +504,7 @@ get_kwm_win_icon (MetaDisplay *display,
|
|||||||
*pixmap = None;
|
*pixmap = None;
|
||||||
*mask = None;
|
*mask = None;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
icons = NULL;
|
icons = NULL;
|
||||||
result = XGetWindowProperty (display->xdisplay, xwindow,
|
result = XGetWindowProperty (display->xdisplay, xwindow,
|
||||||
display->atom__KWM_WIN_ICON,
|
display->atom__KWM_WIN_ICON,
|
||||||
|
@@ -1665,12 +1665,12 @@ meta_window_x11_client_message (MetaWindow *window,
|
|||||||
char *str1;
|
char *str1;
|
||||||
char *str2;
|
char *str2;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
str1 = XGetAtomName (display->xdisplay, first);
|
str1 = XGetAtomName (display->xdisplay, first);
|
||||||
if (meta_error_trap_pop_with_return (display) != Success)
|
if (meta_error_trap_pop_with_return (display) != Success)
|
||||||
str1 = NULL;
|
str1 = NULL;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
str2 = XGetAtomName (display->xdisplay, second);
|
str2 = XGetAtomName (display->xdisplay, second);
|
||||||
if (meta_error_trap_pop_with_return (display) != Success)
|
if (meta_error_trap_pop_with_return (display) != Success)
|
||||||
str2 = NULL;
|
str2 = NULL;
|
||||||
@@ -2298,7 +2298,7 @@ meta_window_x11_new (MetaDisplay *display,
|
|||||||
wm_state_to_string (existing_wm_state));
|
wm_state_to_string (existing_wm_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XAddToSaveSet can only be called on windows created by a different
|
* XAddToSaveSet can only be called on windows created by a different
|
||||||
@@ -2309,7 +2309,7 @@ meta_window_x11_new (MetaDisplay *display,
|
|||||||
*/
|
*/
|
||||||
XAddToSaveSet (display->xdisplay, xwindow);
|
XAddToSaveSet (display->xdisplay, xwindow);
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
|
|
||||||
event_mask = PropertyChangeMask;
|
event_mask = PropertyChangeMask;
|
||||||
if (attrs.override_redirect)
|
if (attrs.override_redirect)
|
||||||
|
@@ -191,7 +191,7 @@ get_property (MetaDisplay *display,
|
|||||||
results->bytes_after = 0;
|
results->bytes_after = 0;
|
||||||
results->format = 0;
|
results->format = 0;
|
||||||
|
|
||||||
meta_error_trap_push_with_return (display);
|
meta_error_trap_push (display);
|
||||||
if (XGetWindowProperty (display->xdisplay, xwindow, xatom,
|
if (XGetWindowProperty (display->xdisplay, xwindow, xatom,
|
||||||
0, G_MAXLONG,
|
0, G_MAXLONG,
|
||||||
False, req_type, &results->type, &results->format,
|
False, req_type, &results->type, &results->format,
|
||||||
@@ -736,6 +736,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay *display,
|
|||||||
return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
|
return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
text_property_to_utf8 (Display *xdisplay,
|
||||||
|
const XTextProperty *prop)
|
||||||
|
{
|
||||||
|
char *ret = NULL;
|
||||||
|
char **local_list = NULL;
|
||||||
|
int count = 0;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
|
||||||
|
if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ret = g_strdup (local_list[0]);
|
||||||
|
|
||||||
|
out:
|
||||||
|
meta_XFree (local_list);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
text_property_from_results (GetPropertyResults *results,
|
text_property_from_results (GetPropertyResults *results,
|
||||||
char **utf8_str_p)
|
char **utf8_str_p)
|
||||||
@@ -750,8 +773,7 @@ text_property_from_results (GetPropertyResults *results,
|
|||||||
tp.format = results->format;
|
tp.format = results->format;
|
||||||
tp.nitems = results->n_items;
|
tp.nitems = results->n_items;
|
||||||
|
|
||||||
*utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
|
*utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
|
||||||
&tp);
|
|
||||||
|
|
||||||
if (tp.value != NULL)
|
if (tp.value != NULL)
|
||||||
XFree (tp.value);
|
XFree (tp.value);
|
||||||
|
Reference in New Issue
Block a user