Patch from George Liebl to add a GdkGrabStatus enumeration to use as a

Thu Jul  6 11:54:03 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
	gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
	gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
	gdk/x11/gdkmain-x11.c:

	Patch from George Liebl to add a GdkGrabStatus enumeration to use
	as a return value of gdk_*_grab(). Previously, we just
	returned the X11 values directly.
This commit is contained in:
Owen Taylor 2000-07-06 16:20:45 +00:00 committed by Owen Taylor
parent f60e216527
commit 0611f06b5a
16 changed files with 156 additions and 51 deletions

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -1,3 +1,14 @@
Thu Jul 6 11:54:03 2000 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdktypes.h gdk/linux-fb/gdkmain-fb.c
gdk/nanox/gdkmain-nanox.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkwin32.h
gdk/x11/gdkmain-x11.c:
Patch from George Liebl to add a GdkGrabStatus enumeration to use
as a return value of gdk_*_grab(). Previously, we just
returned the X11 values directly.
Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com> Thu Jul 6 11:27:44 2000 Owen Taylor <otaylor@redhat.com>
* gdk/x11/Makefile.am: Patch from George Liebl to * gdk/x11/Makefile.am: Patch from George Liebl to

View File

@ -88,18 +88,18 @@ gint gdk_input_add (gint source,
gpointer data); gpointer data);
void gdk_input_remove (gint tag); void gdk_input_remove (gint tag);
gint gdk_pointer_grab (GdkWindow *window, GdkGrabStatus gdk_pointer_grab (GdkWindow *window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
GdkWindow *confine_to, GdkWindow *confine_to,
GdkCursor *cursor, GdkCursor *cursor,
guint32 time); guint32 time);
void gdk_pointer_ungrab (guint32 time); void gdk_pointer_ungrab (guint32 time);
gint gdk_keyboard_grab (GdkWindow *window, GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,
gboolean owner_events, gboolean owner_events,
guint32 time); guint32 time);
void gdk_keyboard_ungrab (guint32 time); void gdk_keyboard_ungrab (guint32 time);
gboolean gdk_pointer_is_grabbed (void); gboolean gdk_pointer_is_grabbed (void);
gint gdk_screen_width (void); gint gdk_screen_width (void);
gint gdk_screen_height (void); gint gdk_screen_height (void);

View File

@ -145,6 +145,19 @@ typedef enum
GDK_ERROR_MEM = -4 GDK_ERROR_MEM = -4
} GdkStatus; } GdkStatus;
/* We define specific numeric values for these constants,
* since old application code may depend on them matching the X values
* We don't actually depend on the matchup ourselves.
*/
typedef enum
{
GDK_GRAB_SUCCESS = 0,
GDK_GRAB_ALREADY_GRABBED = 1,
GDK_GRAB_INVALID_TIME = 2,
GDK_GRAB_NOT_VIEWABLE = 3,
GDK_GRAB_FROZEN = 4
} GdkGrabStatus;
typedef void (*GdkInputFunction) (gpointer data, typedef void (*GdkInputFunction) (gpointer data,
gint source, gint source,
GdkInputCondition condition); GdkInputCondition condition);

View File

@ -155,7 +155,7 @@ _gdk_windowing_init_check (int argc, char **argv)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_pointer_grab (GdkWindow * window, gdk_pointer_grab (GdkWindow * window,
gint owner_events, gint owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
@ -183,7 +183,7 @@ gdk_pointer_grab (GdkWindow * window,
if(cursor) if(cursor)
gdk_fb_cursor_unhide(); gdk_fb_cursor_unhide();
return 0; return GDK_GRAB_SUCCESS;
} }
/* /*
@ -266,7 +266,7 @@ gdk_pointer_is_grabbed (void)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_keyboard_grab (GdkWindow * window, gdk_keyboard_grab (GdkWindow * window,
gint owner_events, gint owner_events,
guint32 time) guint32 time)
@ -280,7 +280,7 @@ gdk_keyboard_grab (GdkWindow * window,
if(!owner_events) if(!owner_events)
_gdk_fb_keyboard_grab_window = gdk_window_ref(window); _gdk_fb_keyboard_grab_window = gdk_window_ref(window);
return 0; return GDK_GRAB_SUCCESS;
} }
/* /*

View File

@ -42,7 +42,7 @@ gdk_get_use_xshm (void)
return gdk_use_xshm; return gdk_use_xshm;
} }
gint GdkGrabStatus
gdk_pointer_grab (GdkWindow * window, gdk_pointer_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
@ -68,7 +68,7 @@ gdk_pointer_is_grabbed (void)
return gdk_xgrab_window != NULL; return gdk_xgrab_window != NULL;
} }
gint GdkGrabStatus
gdk_keyboard_grab (GdkWindow * window, gdk_keyboard_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
guint32 time) guint32 time)

View File

@ -472,7 +472,7 @@ event_mask_string (GdkEventMask mask)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_pointer_grab (GdkWindow * window, gdk_pointer_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
@ -511,9 +511,9 @@ gdk_pointer_grab (GdkWindow * window,
confine_to, confine_to,
time); time);
else else
return_val = Success; return_val = GDK_GRAB_SUCCESS;
if (return_val == Success) if (return_val == GDK_GRAB_SUCCESS)
{ {
if (!GDK_DRAWABLE_DESTROYED (window)) if (!GDK_DRAWABLE_DESTROYED (window))
{ {
@ -531,13 +531,13 @@ gdk_pointer_grab (GdkWindow * window,
*/ */
SetCapture (xwindow); SetCapture (xwindow);
#endif #endif
return_val = GrabSuccess; return_val = GDK_GRAB_SUCCESS;
} }
else else
return_val = AlreadyGrabbed; return_val = GDK_GRAB_ALREADY_GRABBED;
} }
if (return_val == GrabSuccess) if (return_val == GDK_GRAB_SUCCESS)
{ {
p_grab_window = window; p_grab_window = window;
p_grab_cursor = xcursor; p_grab_cursor = xcursor;
@ -616,7 +616,7 @@ gdk_pointer_is_grabbed (void)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_keyboard_grab (GdkWindow * window, gdk_keyboard_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
guint32 time) guint32 time)
@ -632,12 +632,12 @@ gdk_keyboard_grab (GdkWindow * window,
if (!GDK_DRAWABLE_DESTROYED (window)) if (!GDK_DRAWABLE_DESTROYED (window))
{ {
k_grab_owner_events = owner_events != 0; k_grab_owner_events = owner_events != 0;
return_val = GrabSuccess; return_val = GDK_GRAB_SUCCESS;
} }
else else
return_val = AlreadyGrabbed; return_val = GDK_GRAB_ALREADY_GRABBED;
if (return_val == GrabSuccess) if (return_val == GDK_GRAB_SUCCESS)
k_grab_window = window; k_grab_window = window;
return return_val; return return_val;

View File

@ -1326,7 +1326,7 @@ gdk_input_win32_grab_pointer (GdkWindow *window,
/* FIXME: if failure occurs on something other than the first /* FIXME: if failure occurs on something other than the first
device, things will be badly inconsistent */ device, things will be badly inconsistent */
if (result != Success) if (result != GDK_GRAB_SUCCESS)
return result; return result;
#endif #endif
} }
@ -1353,7 +1353,7 @@ gdk_input_win32_grab_pointer (GdkWindow *window,
} }
} }
return Success; return GDK_GRAB_SUCCESS;
} }

View File

@ -152,15 +152,6 @@
/* Define corresponding Windows types for some X11 types, just for laziness. */ /* Define corresponding Windows types for some X11 types, just for laziness. */
typedef PALETTEENTRY XColor; typedef PALETTEENTRY XColor;
/* Define some of the X11 constants also here, again just for laziness */
/* Error codes */
#define Success 0
/* Grabbing status */
#define GrabSuccess 0
#define AlreadyGrabbed 2
/* Some structs are somewhat useful to emulate internally, just to /* Some structs are somewhat useful to emulate internally, just to
* keep the code less #ifdefed. * keep the code less #ifdefed.
*/ */

View File

@ -314,7 +314,7 @@ _gdk_input_grab_pointer (GdkWindow * window,
void void
_gdk_input_ungrab_pointer (guint32 time) _gdk_input_ungrab_pointer (guint32 time)
{ {
GdkInputWindow *input_window; GdkInputWindow *input_window = NULL; /* Quiet GCC */
GdkDevicePrivate *gdkdev; GdkDevicePrivate *gdkdev;
GList *tmp_list; GList *tmp_list;

View File

@ -202,6 +202,26 @@ gdk_get_use_xshm (void)
return gdk_use_xshm; return gdk_use_xshm;
} }
static GdkGrabStatus
gdk_x11_convert_grab_status (gint status)
{
switch (status)
{
case GrabSuccess:
return GDK_GRAB_SUCCESS;
case AlreadyGrabbed:
return GDK_GRAB_ALREADY_GRABBED;
case GrabInvalidTime:
return GDK_GRAB_INVALID_TIME;
case GrabNotViewable:
return GDK_GRAB_NOT_VIEWABLE;
case GrabFrozen:
return GDK_GRAB_FROZEN;
}
g_assert_not_reached();
}
/* /*
*-------------------------------------------------------------- *--------------------------------------------------------------
* gdk_pointer_grab * gdk_pointer_grab
@ -225,7 +245,7 @@ gdk_get_use_xshm (void)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_pointer_grab (GdkWindow * window, gdk_pointer_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
GdkEventMask event_mask, GdkEventMask event_mask,
@ -273,7 +293,7 @@ gdk_pointer_grab (GdkWindow * window,
confine_to, confine_to,
time); time);
if (return_val == Success) if (return_val == GrabSuccess)
{ {
if (!GDK_WINDOW_DESTROYED (window)) if (!GDK_WINDOW_DESTROYED (window))
return_val = XGrabPointer (GDK_WINDOW_XDISPLAY (window), return_val = XGrabPointer (GDK_WINDOW_XDISPLAY (window),
@ -290,8 +310,8 @@ gdk_pointer_grab (GdkWindow * window,
if (return_val == GrabSuccess) if (return_val == GrabSuccess)
gdk_xgrab_window = (GdkWindowObject *)window; gdk_xgrab_window = (GdkWindowObject *)window;
return return_val; return gdk_x11_convert_grab_status (return_val);
} }
/* /*
@ -359,22 +379,26 @@ gdk_pointer_is_grabbed (void)
*-------------------------------------------------------------- *--------------------------------------------------------------
*/ */
gint GdkGrabStatus
gdk_keyboard_grab (GdkWindow * window, gdk_keyboard_grab (GdkWindow * window,
gboolean owner_events, gboolean owner_events,
guint32 time) guint32 time)
{ {
gint return_val;
g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (window != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
if (!GDK_WINDOW_DESTROYED (window)) if (!GDK_WINDOW_DESTROYED (window))
return XGrabKeyboard (GDK_WINDOW_XDISPLAY (window), return_val = XGrabKeyboard (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
owner_events, owner_events,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
time); time);
else else
return AlreadyGrabbed; return_val = AlreadyGrabbed;
return gdk_x11_convert_grab_status (return_val);
} }
/* /*