switch on the op passed in, not the active op. Gives us the right cursor

2002-02-24  Havoc Pennington  <hp@pobox.com>

	* src/display.c (xcursor_for_op): switch on the op passed in, not
	the active op. Gives us the right cursor during resizing, etc.

	* src/errors.c: rearrange all the error stuff to adapt to the GDK
	change a while back, so now we print our X errors again

	* src/display.c (meta_display_begin_grab_op): remove KeyPressMask
	and KeyReleaseMask from the XGrabPointer(), this caused BadValue
	and kept the grab from ever succeeding. Fixes the problem with the
	GTK resize grip - this is why you shouldn't break your X error
	spew. ;-)

	* src/display.c: debug spew tweaks

	* src/window.c (meta_window_client_message): do some
	s/verbose/topic/ stuff
This commit is contained in:
Havoc Pennington 2002-02-24 19:58:27 +00:00 committed by Havoc Pennington
parent 2d01419577
commit bedddaa717
6 changed files with 145 additions and 42 deletions

View File

@ -1,3 +1,22 @@
2002-02-24 Havoc Pennington <hp@pobox.com>
* src/display.c (xcursor_for_op): switch on the op passed in, not
the active op. Gives us the right cursor during resizing, etc.
* src/errors.c: rearrange all the error stuff to adapt to the GDK
change a while back, so now we print our X errors again
* src/display.c (meta_display_begin_grab_op): remove KeyPressMask
and KeyReleaseMask from the XGrabPointer(), this caused BadValue
and kept the grab from ever succeeding. Fixes the problem with the
GTK resize grip - this is why you shouldn't break your X error
spew. ;-)
* src/display.c: debug spew tweaks
* src/window.c (meta_window_client_message): do some
s/verbose/topic/ stuff
2002-02-23 Havoc Pennington <hp@pobox.com>
* src/ui.c (meta_ui_init): fix the

View File

@ -177,7 +177,8 @@ meta_display_open (const char *name)
*/
display->name = g_strdup (XDisplayName (name));
display->xdisplay = xdisplay;
display->error_traps = NULL;
display->error_traps = 0;
display->error_trap_handler = NULL;
display->server_grab_count = 0;
display->workspaces = NULL;
@ -430,7 +431,7 @@ meta_display_close (MetaDisplay *display)
GSList *winlist;
GSList *tmp;
if (display->error_traps)
if (display->error_traps > 0)
meta_bug ("Display closed with error traps pending\n");
winlist = meta_display_list_windows (display);
@ -685,7 +686,9 @@ event_callback (XEvent *event,
event->xbutton.time < (display->last_button_time + display->double_click_time))
{
display->is_double_click = TRUE;
meta_verbose ("This was the second click of a double click\n");
meta_topic (META_DEBUG_EVENTS,
"This was the second click of a double click\n");
}
else
{
@ -1381,6 +1384,10 @@ meta_spew_event (MetaDisplay *display,
break;
case MotionNotify:
name = "MotionNotify";
extra = g_strdup_printf ("win: 0x%lx x: %d y: %d",
event->xmotion.window,
event->xmotion.x,
event->xmotion.y);
break;
case EnterNotify:
name = "EnterNotify";
@ -1695,7 +1702,7 @@ xcursor_for_op (MetaDisplay *display,
{
MetaCursor cursor = META_CURSOR_DEFAULT;
switch (display->grab_op)
switch (op)
{
case META_GRAB_OP_RESIZING_SE:
cursor = META_CURSOR_SE_RESIZE;
@ -1743,7 +1750,8 @@ meta_display_begin_grab_op (MetaDisplay *display,
Window grabwindow;
Cursor cursor;
meta_verbose ("Doing grab op %d on window %s button %d pointer already grabbed: %d\n",
meta_topic (META_DEBUG_WINDOW_OPS,
"Doing grab op %d on window %s button %d pointer already grabbed: %d\n",
op, window->desc, button, pointer_already_grabbed);
grabwindow = window->frame ? window->frame->xwindow : window->xwindow;
@ -1758,34 +1766,40 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (pointer_already_grabbed)
display->grab_have_pointer = TRUE;
/* We XGrabPointer even if we already have an autograb,
* just to set the cursor and event mask
*/
cursor = xcursor_for_op (display, op);
#define GRAB_MASK (PointerMotionMask | PointerMotionHintMask | \
ButtonPressMask | ButtonReleaseMask)
meta_error_trap_push (display);
if (XGrabPointer (display->xdisplay,
grabwindow,
False,
PointerMotionMask | PointerMotionHintMask |
ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask,
GRAB_MASK,
GrabModeAsync, GrabModeAsync,
None,
cursor,
timestamp) == GrabSuccess)
{
display->grab_have_pointer = TRUE;
meta_debug_spew ("Successful XGrabPointer()\n");
meta_topic (META_DEBUG_WINDOW_OPS,
"XGrabPointer() returned GrabSuccess\n");
}
meta_error_trap_pop (display);
if (meta_error_trap_pop (display) != Success)
{
meta_topic (META_DEBUG_WINDOW_OPS,
"Error trapped from XGrabPointer()\n");
if (display->grab_have_pointer)
display->grab_have_pointer = FALSE;
}
#undef GRAB_MASK
XFreeCursor (display->xdisplay, cursor);
if (!display->grab_have_pointer)
{
meta_verbose ("XGrabPointer() failed\n");
meta_topic (META_DEBUG_WINDOW_OPS,
"XGrabPointer() failed\n");
return FALSE;
}
@ -1796,7 +1810,8 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (!display->grab_have_keyboard)
{
meta_verbose ("grabbing all keys failed\n");
meta_topic (META_DEBUG_WINDOW_OPS,
"grabbing all keys failed\n");
return FALSE;
}
}
@ -1811,7 +1826,8 @@ meta_display_begin_grab_op (MetaDisplay *display,
&display->grab_initial_window_pos.x,
&display->grab_initial_window_pos.y);
meta_verbose ("Grab op %d on window %s successful\n",
meta_topic (META_DEBUG_WINDOW_OPS,
"Grab op %d on window %s successful\n",
display->grab_op, display->grab_window->desc);
g_assert (display->grab_window != NULL);

View File

@ -130,7 +130,9 @@ struct _MetaDisplay
MetaEventQueue *events;
GSList *screens;
GHashTable *window_ids;
GSList *error_traps;
int error_traps;
int (* error_trap_handler) (Display *display,
XErrorEvent *error);
int server_grab_count;
/* This window holds the focus when we don't want to focus

View File

@ -26,11 +26,6 @@
#include <stdlib.h>
#include <gdk/gdk.h>
static int (* saved_gdk_error_handler) (Display *display,
XErrorEvent *error);
static int (* saved_gdk_io_error_handler) (Display *display);
static int x_error_handler (Display *display,
XErrorEvent *error);
static int x_io_error_handler (Display *display);
@ -38,23 +33,66 @@ static int x_io_error_handler (Display *display);
void
meta_errors_init (void)
{
saved_gdk_error_handler = XSetErrorHandler (x_error_handler);
saved_gdk_io_error_handler = XSetIOErrorHandler (x_io_error_handler);
XSetErrorHandler (x_error_handler);
XSetIOErrorHandler (x_io_error_handler);
}
void
meta_error_trap_push (MetaDisplay *display)
{
/* GDK resets the error handler on each push */
int (* old_error_handler) (Display *,
XErrorEvent *);
gdk_error_trap_push ();
/* old_error_handler will just be equal to x_error_handler
* for nested traps
*/
old_error_handler = XSetErrorHandler (x_error_handler);
/* Replace GDK handler, but save it so we can chain up */
if (display->error_trap_handler == NULL)
{
g_assert (display->error_traps == 0);
display->error_trap_handler = old_error_handler;
g_assert (display->error_trap_handler != x_error_handler);
}
display->error_traps += 1;
}
int
meta_error_trap_pop (MetaDisplay *display)
{
int result;
g_assert (display->error_traps > 0);
/* just use GDK trap, but we do the sync since GDK doesn't */
XSync (display->xdisplay, False);
return gdk_error_trap_pop ();
result = gdk_error_trap_pop ();
display->error_traps -= 1;
if (display->error_traps == 0)
{
/* check that GDK put our handler back; this
* assumes that there are no pending GDK traps from GDK itself
*/
int (* restored_error_handler) (Display *,
XErrorEvent *);
restored_error_handler = XSetErrorHandler (x_error_handler);
g_assert (restored_error_handler == x_error_handler);
/* remove this */
display->error_trap_handler = NULL;
}
return result;
}
static int
@ -63,9 +101,17 @@ x_error_handler (Display *xdisplay,
{
int retval;
gchar buf[64];
MetaDisplay *display;
XGetErrorText (xdisplay, error->error_code, buf, 63);
display = meta_display_for_x_display (xdisplay);
if (display->error_traps > 0)
{
/* we're in an error trap, chain to the trap handler
* saved from GDK
*/
meta_verbose ("X error: %s serial %ld error_code %d request_code %d minor_code %d)\n",
buf,
error->serial,
@ -73,7 +119,22 @@ x_error_handler (Display *xdisplay,
error->request_code,
error->minor_code);
retval = saved_gdk_error_handler (xdisplay, error);
g_assert (display->error_trap_handler != NULL);
g_assert (display->error_trap_handler != x_error_handler);
retval = (* display->error_trap_handler) (xdisplay, error);
}
else
{
meta_bug ("Unexpected X error: %s serial %ld error_code %d request_code %d minor_code %d)\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
retval = 1; /* compiler warning */
}
return retval;
}
@ -107,3 +168,5 @@ x_io_error_handler (Display *xdisplay)
return 0;
}

View File

@ -267,7 +267,8 @@ meta_frame_sync_to_window (MetaFrame *frame,
if (!(need_move || need_resize))
return;
meta_verbose ("Syncing frame geometry %d,%d %dx%d (SE: %d,%d)\n",
meta_topic (META_DEBUG_GEOMETRY,
"Syncing frame geometry %d,%d %dx%d (SE: %d,%d)\n",
frame->rect.x, frame->rect.y,
frame->rect.width, frame->rect.height,
frame->rect.x + frame->rect.width,

View File

@ -2969,7 +2969,8 @@ meta_window_client_message (MetaWindow *window,
y_root = event->xclient.data.l[1];
action = event->xclient.data.l[2];
meta_verbose ("Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d\n",
meta_topic (META_DEBUG_WINDOW_OPS,
"Received _NET_WM_MOVERESIZE message on %s, %d,%d action = %d\n",
window->desc,
x_root, y_root, action);
@ -3040,7 +3041,8 @@ meta_window_client_message (MetaWindow *window,
if (button != 0)
{
meta_verbose ("Beginning move/resize with button = %d\n", button);
meta_topic (META_DEBUG_WINDOW_OPS,
"Beginning move/resize with button = %d\n", button);
meta_display_begin_grab_op (window->display,
window,
op,