Compare commits
12 Commits
3.24.3
...
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)
|
||||
{
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
|
||||
XSync (xdisplay, FALSE);
|
||||
|
||||
|
@ -92,6 +92,7 @@ struct _MetaDisplay
|
||||
Display *xdisplay;
|
||||
|
||||
int clutter_event_filter;
|
||||
GSource *x11_event_source;
|
||||
|
||||
Window leader_window;
|
||||
Window timestamp_pinging_window;
|
||||
@ -147,13 +148,10 @@ struct _MetaDisplay
|
||||
guint focused_by_us : 1;
|
||||
|
||||
/*< private-ish >*/
|
||||
guint error_trap_synced_at_last_pop : 1;
|
||||
MetaScreen *screen;
|
||||
GHashTable *xids;
|
||||
GHashTable *wayland_windows;
|
||||
int error_traps;
|
||||
int (* error_trap_handler) (Display *display,
|
||||
XErrorEvent *error);
|
||||
|
||||
int server_grab_count;
|
||||
|
||||
/* serials of leave/unmap events that may
|
||||
@ -256,6 +254,8 @@ struct _MetaDisplay
|
||||
/* Closing down the display */
|
||||
int closing;
|
||||
|
||||
GSList *error_traps;
|
||||
|
||||
/* Managed by group.c */
|
||||
GHashTable *groups_by_leader;
|
||||
|
||||
|
@ -446,7 +446,7 @@ meta_display_open (void)
|
||||
|
||||
meta_verbose ("Opening display '%s'\n", XDisplayName (NULL));
|
||||
|
||||
xdisplay = meta_ui_get_display ();
|
||||
xdisplay = XOpenDisplay (NULL);
|
||||
|
||||
if (xdisplay == NULL)
|
||||
{
|
||||
@ -472,9 +472,6 @@ meta_display_open (void)
|
||||
*/
|
||||
the_display->name = g_strdup (XDisplayName (NULL));
|
||||
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->display_opening = TRUE;
|
||||
|
||||
@ -835,7 +832,7 @@ meta_display_open (void)
|
||||
* now it always manages exactly one screen as specified by the DISPLAY
|
||||
* environment variable.
|
||||
*/
|
||||
i = meta_ui_get_screen_number ();
|
||||
i = DefaultScreen (the_display->xdisplay);
|
||||
screen = meta_screen_new (the_display, i, timestamp);
|
||||
|
||||
if (!screen)
|
||||
@ -1016,9 +1013,6 @@ meta_display_close (MetaDisplay *display,
|
||||
return;
|
||||
}
|
||||
|
||||
if (display->error_traps > 0)
|
||||
meta_bug ("Display closed with error traps pending\n");
|
||||
|
||||
display->closing += 1;
|
||||
|
||||
meta_prefs_remove_listener (prefs_changed_callback, display);
|
||||
@ -2212,7 +2206,7 @@ meta_change_button_grab (MetaDisplay *display,
|
||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||
|
||||
if (meta_is_debugging ())
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
/* GrabModeSync means freeze until XAllowEvents */
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington, error trapping inspired by GDK
|
||||
* code copyrighted by the GTK team.
|
||||
*
|
||||
/*
|
||||
* Copyright (C) 2014 Red Hat
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
@ -13,9 +12,11 @@
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
*
|
||||
* 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 <meta/errors.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
|
||||
* has some neat features (like knowing automatically if a sync is needed or not
|
||||
* and handling errors asynchronously when the error code isn't needed immediately),
|
||||
* 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().
|
||||
*
|
||||
* 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
|
||||
* use the GTK+ handling straight-up.
|
||||
* (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.)
|
||||
*/
|
||||
/* This is a copy-paste of the error handling code in GDK, modified
|
||||
* so that it works with mutter's internal structures, since we don't
|
||||
* have a GDK display open. */
|
||||
|
||||
/* compare X sequence numbers handling wraparound */
|
||||
#define SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
|
||||
|
||||
typedef struct _GdkErrorTrap GdkErrorTrap;
|
||||
|
||||
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
|
||||
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
|
||||
meta_error_trap_pop (MetaDisplay *display)
|
||||
{
|
||||
gdk_error_trap_pop_ignored ();
|
||||
}
|
||||
|
||||
void
|
||||
meta_error_trap_push_with_return (MetaDisplay *display)
|
||||
{
|
||||
gdk_error_trap_push ();
|
||||
meta_error_trap_pop_internal (display, FALSE);
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
|
||||
/* NB: GDK event filters already have generic events
|
||||
* allocated, so no need to do XGetEventData() on our own
|
||||
*/
|
||||
XGetEventData (display->xdisplay, &event->xcookie);
|
||||
|
||||
input_event = (XIEvent *) event->xcookie.data;
|
||||
|
||||
switch (input_event->evtype)
|
||||
@ -860,6 +859,17 @@ handle_input_xevent (MetaDisplay *display,
|
||||
if (input_event == NULL)
|
||||
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);
|
||||
window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||
|
||||
@ -934,12 +944,11 @@ handle_input_xevent (MetaDisplay *display,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Don't send FocusIn / FocusOut to Clutter */
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
/* Don't pass these events through to Clutter / GTK+ */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1041,7 +1050,7 @@ convert_property (MetaDisplay *display,
|
||||
conversion_targets[2] = display->atom_TIMESTAMP;
|
||||
conversion_targets[3] = display->atom_VERSION;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (target == display->atom_TARGETS)
|
||||
XChangeProperty (display->xdisplay, w, property,
|
||||
XA_ATOM, 32, PropModeReplace,
|
||||
@ -1116,7 +1125,7 @@ process_selection_request (MetaDisplay *display,
|
||||
unsigned long num, rest;
|
||||
unsigned char *data;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (XGetWindowProperty (display->xdisplay,
|
||||
event->xselectionrequest.requestor,
|
||||
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
|
||||
* dealing with all the kinds of events that might turn up.
|
||||
*/
|
||||
static gboolean
|
||||
static void
|
||||
meta_display_handle_xevent (MetaDisplay *display,
|
||||
XEvent *event)
|
||||
{
|
||||
Window modified;
|
||||
gboolean bypass_compositor = FALSE, bypass_gtk = FALSE;
|
||||
gboolean bypass_compositor = FALSE;
|
||||
XIEvent *input_event;
|
||||
MetaMonitorManager *monitor;
|
||||
|
||||
@ -1754,13 +1763,13 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
/* 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 ();
|
||||
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))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -1800,8 +1809,9 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
|
||||
if (event->type == UnmapNotify)
|
||||
{
|
||||
if (meta_ui_window_should_not_cause_focus (display->xdisplay,
|
||||
modified))
|
||||
MetaUI *ui = display->screen->ui;
|
||||
|
||||
if (meta_ui_window_should_not_cause_focus (ui, modified))
|
||||
{
|
||||
meta_display_add_ignored_crossing_serial (display, event->xany.serial);
|
||||
meta_topic (META_DEBUG_FOCUS,
|
||||
@ -1823,7 +1833,7 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
#ifdef HAVE_XI23
|
||||
if (meta_display_process_barrier_event (display, input_event))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
#endif /* HAVE_XI23 */
|
||||
@ -1834,27 +1844,20 @@ meta_display_handle_xevent (MetaDisplay *display,
|
||||
*/
|
||||
if (handle_input_xevent (display, input_event, event->xany.serial))
|
||||
{
|
||||
bypass_gtk = bypass_compositor = TRUE;
|
||||
bypass_compositor = TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (handle_other_xevent (display, event))
|
||||
{
|
||||
bypass_gtk = TRUE;
|
||||
goto out;
|
||||
}
|
||||
goto out;
|
||||
|
||||
out:
|
||||
if (!bypass_compositor)
|
||||
{
|
||||
MetaWindow *window = modified != None ? meta_display_lookup_x_window (display, modified) : NULL;
|
||||
|
||||
if (meta_compositor_process_event (display->compositor, event, window))
|
||||
bypass_gtk = TRUE;
|
||||
meta_compositor_process_event (display->compositor, event, window);
|
||||
}
|
||||
|
||||
display->current_time = CurrentTime;
|
||||
return bypass_gtk;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2165,19 +2168,6 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
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
|
||||
event_callback (const ClutterEvent *event,
|
||||
gpointer data)
|
||||
@ -2187,20 +2177,90 @@ event_callback (const ClutterEvent *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
|
||||
meta_display_init_events (MetaDisplay *display)
|
||||
{
|
||||
gdk_window_add_filter (NULL, xevent_filter, display);
|
||||
display->clutter_event_filter = clutter_event_add_filter (NULL,
|
||||
event_callback,
|
||||
NULL,
|
||||
display);
|
||||
|
||||
display->x11_event_source = x11_event_source_new (display);
|
||||
g_source_attach (display->x11_event_source, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_display_free_events (MetaDisplay *display)
|
||||
{
|
||||
gdk_window_remove_filter (NULL, xevent_filter, display);
|
||||
clutter_event_remove_filter (display->clutter_event_filter);
|
||||
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;
|
||||
|
||||
frame->xwindow = meta_ui_create_frame_window (window->screen->ui,
|
||||
window->display->xdisplay,
|
||||
visual,
|
||||
frame->rect.x,
|
||||
frame->rect.y,
|
||||
|
@ -1065,7 +1065,7 @@ meta_change_keygrab (MetaDisplay *display,
|
||||
mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
|
||||
|
||||
if (meta_is_debugging ())
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (grab)
|
||||
XIGrabKeycode (display->xdisplay,
|
||||
META_VIRTUAL_CORE_KEYBOARD_ID,
|
||||
@ -1410,7 +1410,7 @@ grab_keyboard (MetaDisplay *display,
|
||||
/* Grab the keyboard, so we get key releases and all key
|
||||
* 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
|
||||
* 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 */
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
attrs.event_mask = StructureNotifyMask;
|
||||
XChangeWindowAttributes (xdisplay,
|
||||
current_wm_sn_owner, CWEventMask, &attrs);
|
||||
@ -619,7 +619,7 @@ meta_screen_new (MetaDisplay *display,
|
||||
}
|
||||
|
||||
/* 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
|
||||
* gtk+ may be interested in other events.
|
||||
@ -757,8 +757,7 @@ meta_screen_new (MetaDisplay *display,
|
||||
screen->keys_grabbed = FALSE;
|
||||
meta_screen_grab_keys (screen);
|
||||
|
||||
screen->ui = meta_ui_new (screen->display->xdisplay,
|
||||
screen->xscreen);
|
||||
screen->ui = meta_ui_new ();
|
||||
|
||||
screen->tile_preview_timeout_id = 0;
|
||||
|
||||
@ -838,7 +837,7 @@ meta_screen_free (MetaScreen *screen,
|
||||
meta_stack_free (screen->stack);
|
||||
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);
|
||||
if (meta_error_trap_pop_with_return (screen->display) != Success)
|
||||
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)
|
||||
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
|
||||
* 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);
|
||||
*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,
|
||||
"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_pop (MetaDisplay *display);
|
||||
|
||||
void meta_error_trap_push_with_return (MetaDisplay *display);
|
||||
/* returns X error code, or 0 for no error */
|
||||
int meta_error_trap_pop_with_return (MetaDisplay *display);
|
||||
|
||||
|
262
src/ui/ui.c
262
src/ui/ui.c
@ -39,8 +39,9 @@ static void meta_ui_accelerator_parse (const char *accel,
|
||||
|
||||
struct _MetaUI
|
||||
{
|
||||
Display *xdisplay;
|
||||
Screen *xscreen;
|
||||
GdkDisplay *display;
|
||||
GdkScreen *screen;
|
||||
|
||||
MetaFrames *frames;
|
||||
|
||||
/* For double-click tracking */
|
||||
@ -60,200 +61,17 @@ meta_ui_init (void)
|
||||
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*
|
||||
meta_ui_new (Display *xdisplay,
|
||||
Screen *screen)
|
||||
meta_ui_new (void)
|
||||
{
|
||||
GdkDisplay *gdisplay;
|
||||
MetaUI *ui;
|
||||
|
||||
ui = g_new0 (MetaUI, 1);
|
||||
ui->xdisplay = xdisplay;
|
||||
ui->xscreen = screen;
|
||||
ui->display = gdk_display_get_default ();
|
||||
ui->screen = gdk_screen_get_default ();
|
||||
|
||||
gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
g_assert (gdisplay == gdk_display_get_default ());
|
||||
ui->frames = meta_frames_new (gdk_screen_get_number (ui->screen));
|
||||
|
||||
ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
|
||||
/* GTK+ needs the frame-sync protocol to work in order to properly
|
||||
* handle style changes. This means that the dummy widget we create
|
||||
* 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));
|
||||
|
||||
gdk_window_add_filter (NULL, ui_filter_func, NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_free (MetaUI *ui)
|
||||
{
|
||||
GdkDisplay *gdisplay;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -305,7 +112,6 @@ meta_ui_get_frame_borders (MetaUI *ui,
|
||||
|
||||
Window
|
||||
meta_ui_create_frame_window (MetaUI *ui,
|
||||
Display *xdisplay,
|
||||
Visual *xvisual,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -314,7 +120,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
||||
gint screen_no,
|
||||
gulong *create_serial)
|
||||
{
|
||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkScreen *screen = gdk_display_get_screen (display, screen_no);
|
||||
GdkWindowAttr attrs;
|
||||
gint attributes_mask;
|
||||
@ -363,7 +169,7 @@ meta_ui_create_frame_window (MetaUI *ui,
|
||||
* as long as you pass in a colormap.
|
||||
*/
|
||||
if (create_serial)
|
||||
*create_serial = XNextRequest (xdisplay);
|
||||
*create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (display));
|
||||
window =
|
||||
gdk_window_new (gdk_screen_get_root_window(screen),
|
||||
&attrs, attributes_mask);
|
||||
@ -397,10 +203,9 @@ void
|
||||
meta_ui_map_frame (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
@ -411,10 +216,9 @@ void
|
||||
meta_ui_unmap_frame (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
@ -632,13 +436,13 @@ meta_ui_get_default_mini_icon (MetaUI *ui)
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
Window xwindow)
|
||||
meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (xdisplay);
|
||||
display = ui->display;
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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
|
||||
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
MetaFrameType type,
|
||||
@ -701,8 +473,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
|
||||
if (!font_desc)
|
||||
{
|
||||
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
|
||||
GdkScreen *screen = ui->screen;
|
||||
GtkWidgetPath *widget_path;
|
||||
|
||||
style = gtk_style_context_new ();
|
||||
@ -941,10 +712,9 @@ gboolean
|
||||
meta_ui_window_is_widget (MetaUI *ui,
|
||||
Window xwindow)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkDisplay *display = ui->display;
|
||||
GdkWindow *window;
|
||||
|
||||
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
||||
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
||||
|
||||
if (window)
|
||||
|
15
src/ui/ui.h
15
src/ui/ui.h
@ -42,12 +42,7 @@ typedef enum
|
||||
|
||||
void meta_ui_init (void);
|
||||
|
||||
Display* meta_ui_get_display (void);
|
||||
|
||||
gint meta_ui_get_screen_number (void);
|
||||
|
||||
MetaUI* meta_ui_new (Display *xdisplay,
|
||||
Screen *screen);
|
||||
MetaUI* meta_ui_new (void);
|
||||
void meta_ui_free (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);
|
||||
|
||||
Window meta_ui_create_frame_window (MetaUI *ui,
|
||||
Display *xdisplay,
|
||||
Visual *xvisual,
|
||||
gint x,
|
||||
gint y,
|
||||
@ -139,11 +133,8 @@ GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap,
|
||||
GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui);
|
||||
GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui);
|
||||
|
||||
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
Window xwindow);
|
||||
|
||||
char* meta_text_property_to_utf8 (Display *xdisplay,
|
||||
const XTextProperty *prop);
|
||||
gboolean meta_ui_window_should_not_cause_focus (MetaUI *ui,
|
||||
Window xwindow);
|
||||
|
||||
void meta_ui_set_current_theme (const char *name);
|
||||
gboolean meta_ui_have_a_theme (void);
|
||||
|
@ -230,7 +230,7 @@ read_rgb_icon (MetaDisplay *display,
|
||||
int mini_w, mini_h;
|
||||
gulong *data_as_long;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
type = None;
|
||||
data = NULL;
|
||||
result = XGetWindowProperty (display->xdisplay,
|
||||
@ -504,7 +504,7 @@ get_kwm_win_icon (MetaDisplay *display,
|
||||
*pixmap = None;
|
||||
*mask = None;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
icons = NULL;
|
||||
result = XGetWindowProperty (display->xdisplay, xwindow,
|
||||
display->atom__KWM_WIN_ICON,
|
||||
|
@ -1665,12 +1665,12 @@ meta_window_x11_client_message (MetaWindow *window,
|
||||
char *str1;
|
||||
char *str2;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
str1 = XGetAtomName (display->xdisplay, first);
|
||||
if (meta_error_trap_pop_with_return (display) != Success)
|
||||
str1 = NULL;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
str2 = XGetAtomName (display->xdisplay, second);
|
||||
if (meta_error_trap_pop_with_return (display) != Success)
|
||||
str2 = NULL;
|
||||
@ -2298,7 +2298,7 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
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
|
||||
@ -2309,7 +2309,7 @@ meta_window_x11_new (MetaDisplay *display,
|
||||
*/
|
||||
XAddToSaveSet (display->xdisplay, xwindow);
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
|
||||
event_mask = PropertyChangeMask;
|
||||
if (attrs.override_redirect)
|
||||
|
@ -191,7 +191,7 @@ get_property (MetaDisplay *display,
|
||||
results->bytes_after = 0;
|
||||
results->format = 0;
|
||||
|
||||
meta_error_trap_push_with_return (display);
|
||||
meta_error_trap_push (display);
|
||||
if (XGetWindowProperty (display->xdisplay, xwindow, xatom,
|
||||
0, G_MAXLONG,
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
text_property_from_results (GetPropertyResults *results,
|
||||
char **utf8_str_p)
|
||||
@ -743,15 +766,14 @@ text_property_from_results (GetPropertyResults *results,
|
||||
XTextProperty tp;
|
||||
|
||||
*utf8_str_p = NULL;
|
||||
|
||||
|
||||
tp.value = results->prop;
|
||||
results->prop = NULL;
|
||||
tp.encoding = results->type;
|
||||
tp.format = results->format;
|
||||
tp.nitems = results->n_items;
|
||||
|
||||
*utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
|
||||
&tp);
|
||||
*utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
|
||||
|
||||
if (tp.value != NULL)
|
||||
XFree (tp.value);
|
||||
|
Reference in New Issue
Block a user