mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
gdk: Remove deprecated {keyboard,pointer}_{grab,ungrab} API
This commit is contained in:
parent
02d500ac70
commit
16ded8d47b
@ -24,16 +24,9 @@ gdk_flush
|
||||
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_pointer_grab
|
||||
GdkGrabStatus
|
||||
gdk_pointer_ungrab
|
||||
gdk_pointer_is_grabbed
|
||||
gdk_set_double_click_time
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_keyboard_grab
|
||||
gdk_keyboard_ungrab
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_beep
|
||||
|
||||
@ -101,7 +94,6 @@ gdk_window_type_get_type
|
||||
gdk_window_type_hint_get_type
|
||||
gdk_wm_decoration_get_type
|
||||
gdk_wm_function_get_type
|
||||
gdk_device_grab_info_libgtk_only
|
||||
gdk_add_option_entries_libgtk_only
|
||||
gdk_pre_parse_libgtk_only
|
||||
</SECTION>
|
||||
@ -119,7 +111,6 @@ gdk_display_get_default_screen
|
||||
gdk_display_get_device_manager
|
||||
gdk_display_pointer_ungrab
|
||||
gdk_display_keyboard_ungrab
|
||||
gdk_display_pointer_is_grabbed
|
||||
gdk_display_device_is_grabbed
|
||||
gdk_display_beep
|
||||
gdk_display_sync
|
||||
|
@ -1304,6 +1304,8 @@ create_moveresize_window (MoveResizeData *mv_resize,
|
||||
GdkWindowAttr attributes;
|
||||
gint attributes_mask;
|
||||
GdkGrabStatus status;
|
||||
GdkSeat *seat;
|
||||
GdkDevice *pointer;
|
||||
|
||||
g_assert (mv_resize->moveresize_emulation_window == NULL);
|
||||
|
||||
@ -1325,13 +1327,17 @@ create_moveresize_window (MoveResizeData *mv_resize,
|
||||
|
||||
gdk_window_show (mv_resize->moveresize_emulation_window);
|
||||
|
||||
seat = gdk_display_get_default_seat (mv_resize->display);
|
||||
pointer = gdk_seat_get_pointer (seat);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||
status = gdk_pointer_grab (mv_resize->moveresize_emulation_window,
|
||||
status = gdk_device_grab (pointer,
|
||||
mv_resize->moveresize_emulation_window,
|
||||
GDK_OWNERSHIP_APPLICATION,
|
||||
FALSE,
|
||||
GDK_BUTTON_RELEASE_MASK |
|
||||
GDK_POINTER_MOTION_MASK,
|
||||
NULL,
|
||||
NULL,
|
||||
timestamp);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS;
|
||||
|
||||
|
@ -27,59 +27,6 @@
|
||||
#include "gdkmain.h"
|
||||
#include "gdkwindow.h"
|
||||
|
||||
/**
|
||||
* gdk_pointer_ungrab:
|
||||
* @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
|
||||
* timestamp is available.
|
||||
*
|
||||
* Ungrabs the pointer on the default display, if it is grabbed by this
|
||||
* application.
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
|
||||
* instead.
|
||||
**/
|
||||
void
|
||||
gdk_pointer_ungrab (guint32 time)
|
||||
{
|
||||
gdk_display_pointer_ungrab (gdk_display_get_default (), time);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_pointer_is_grabbed:
|
||||
*
|
||||
* Returns %TRUE if the pointer on the default display is currently
|
||||
* grabbed by this application.
|
||||
*
|
||||
* Note that this does not take the inmplicit pointer grab on button
|
||||
* presses into account.
|
||||
*
|
||||
* Returns: %TRUE if the pointer is currently grabbed by this application.
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
|
||||
**/
|
||||
gboolean
|
||||
gdk_pointer_is_grabbed (void)
|
||||
{
|
||||
return gdk_display_pointer_is_grabbed (gdk_display_get_default ());
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_keyboard_ungrab:
|
||||
* @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
|
||||
* timestamp is available.
|
||||
*
|
||||
* Ungrabs the keyboard on the default display, if it is grabbed by this
|
||||
* application.
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
|
||||
* instead.
|
||||
**/
|
||||
void
|
||||
gdk_keyboard_ungrab (guint32 time)
|
||||
{
|
||||
gdk_display_keyboard_ungrab (gdk_display_get_default (), time);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_window_at_pointer:
|
||||
* @win_x: (out) (allow-none): return location for origin of the window under the pointer
|
||||
|
@ -245,12 +245,6 @@ void gdk_device_warp (GdkDevice *device,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
GDK_DEPRECATED_IN_3_16
|
||||
gboolean gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events);
|
||||
|
||||
GDK_AVAILABLE_IN_3_12
|
||||
GdkWindow *gdk_device_get_last_event_window (GdkDevice *device);
|
||||
|
||||
|
@ -1418,8 +1418,7 @@ _gdk_display_pointer_info_foreach (GdkDisplay *display,
|
||||
* @device: device to get the grab information from
|
||||
* @grab_window: (out) (transfer none): location to store current grab window
|
||||
* @owner_events: (out): location to store boolean indicating whether
|
||||
* the @owner_events flag to gdk_keyboard_grab() or
|
||||
* gdk_pointer_grab() was %TRUE.
|
||||
* the @owner_events flag to gdk_device_grab() was %TRUE.
|
||||
*
|
||||
* Determines information about the current keyboard grab.
|
||||
* This is not public API and must not be used by applications.
|
||||
@ -1453,71 +1452,6 @@ gdk_device_grab_info (GdkDisplay *display,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_grab_info_libgtk_only:
|
||||
* @display: the display for which to get the grab information
|
||||
* @device: device to get the grab information from
|
||||
* @grab_window: (out) (transfer none): location to store current grab window
|
||||
* @owner_events: (out): location to store boolean indicating whether
|
||||
* the @owner_events flag to gdk_keyboard_grab() or
|
||||
* gdk_pointer_grab() was %TRUE.
|
||||
*
|
||||
* Determines information about the current keyboard grab.
|
||||
* This is not public API and must not be used by applications.
|
||||
*
|
||||
* Returns: %TRUE if this application currently has the
|
||||
* keyboard grabbed.
|
||||
*
|
||||
* Deprecated: 3.16: The symbol was never meant to be used outside
|
||||
* of GTK+
|
||||
*/
|
||||
gboolean
|
||||
gdk_device_grab_info_libgtk_only (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkWindow **grab_window,
|
||||
gboolean *owner_events)
|
||||
{
|
||||
return gdk_device_grab_info (display, device, grab_window, owner_events);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_pointer_is_grabbed:
|
||||
* @display: a #GdkDisplay
|
||||
*
|
||||
* Test if the pointer is grabbed.
|
||||
*
|
||||
* Returns: %TRUE if an active X pointer grab is in effect
|
||||
*
|
||||
* Since: 2.2
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
|
||||
*/
|
||||
gboolean
|
||||
gdk_display_pointer_is_grabbed (GdkDisplay *display)
|
||||
{
|
||||
GList *seats, *s;
|
||||
GdkDevice *device;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
|
||||
|
||||
seats = gdk_display_list_seats (display);
|
||||
|
||||
for (s = seats; s; s = s->next)
|
||||
{
|
||||
device = gdk_seat_get_pointer (s->data);
|
||||
|
||||
if (gdk_display_device_is_grabbed (display, device))
|
||||
{
|
||||
g_list_free (seats);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (seats);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_device_is_grabbed:
|
||||
* @display: a #GdkDisplay
|
||||
|
@ -65,8 +65,6 @@ void gdk_display_pointer_ungrab (GdkDisplay *display,
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_device_ungrab)
|
||||
void gdk_display_keyboard_ungrab (GdkDisplay *display,
|
||||
guint32 time_);
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_display_device_is_grabbed)
|
||||
gboolean gdk_display_pointer_is_grabbed (GdkDisplay *display);
|
||||
#endif /* GDK_MULTIDEVICE_SAFE */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -81,28 +81,6 @@ const gchar * gdk_get_display_arg_name (void);
|
||||
GDK_DEPRECATED_IN_3_8_FOR(gdk_display_get_name (gdk_display_get_default ()))
|
||||
gchar* gdk_get_display (void);
|
||||
|
||||
#ifndef GDK_MULTIDEVICE_SAFE
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_device_grab)
|
||||
GdkGrabStatus gdk_pointer_grab (GdkWindow *window,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow *confine_to,
|
||||
GdkCursor *cursor,
|
||||
guint32 time_);
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_device_grab)
|
||||
GdkGrabStatus gdk_keyboard_grab (GdkWindow *window,
|
||||
gboolean owner_events,
|
||||
guint32 time_);
|
||||
#endif /* GDK_MULTIDEVICE_SAFE */
|
||||
|
||||
#ifndef GDK_MULTIDEVICE_SAFE
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_device_ungrab)
|
||||
void gdk_pointer_ungrab (guint32 time_);
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_device_ungrab)
|
||||
void gdk_keyboard_ungrab (guint32 time_);
|
||||
GDK_DEPRECATED_IN_3_0_FOR(gdk_display_device_is_grabbed)
|
||||
gboolean gdk_pointer_is_grabbed (void);
|
||||
#endif /* GDK_MULTIDEVICE_SAFE */
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_set_double_click_time (guint msec);
|
||||
|
@ -339,8 +339,8 @@ typedef enum
|
||||
* @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
|
||||
* @GDK_GRAB_FAILED: the grab failed for some other reason. Since 3.16
|
||||
*
|
||||
* Returned by gdk_device_grab(), gdk_pointer_grab() and gdk_keyboard_grab() to
|
||||
* indicate success or the reason for the failure of the grab attempt.
|
||||
* Returned by gdk_device_grab() to indicate success or the reason for the
|
||||
* failure of the grab attempt.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
224
gdk/gdkwindow.c
224
gdk/gdkwindow.c
@ -8120,230 +8120,6 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display,
|
||||
_gdk_display_enable_motion_hints (display, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_pointer_grab:
|
||||
* @window: the #GdkWindow which will own the grab (the grab window).
|
||||
* @owner_events: if %FALSE then all pointer events are reported with respect to
|
||||
* @window and are only reported if selected by @event_mask. If %TRUE then pointer
|
||||
* events for this application are reported as normal, but pointer events outside
|
||||
* this application are reported with respect to @window and only if selected by
|
||||
* @event_mask. In either mode, unreported events are discarded.
|
||||
* @event_mask: specifies the event mask, which is used in accordance with
|
||||
* @owner_events. Note that only pointer events (i.e. button and motion events)
|
||||
* may be selected.
|
||||
* @confine_to: (allow-none): If non-%NULL, the pointer will be confined to this
|
||||
* window during the grab. If the pointer is outside @confine_to, it will
|
||||
* automatically be moved to the closest edge of @confine_to and enter
|
||||
* and leave events will be generated as necessary.
|
||||
* @cursor: (allow-none): the cursor to display while the grab is active. If this is %NULL then
|
||||
* the normal cursors are used for @window and its descendants, and the cursor
|
||||
* for @window is used for all other windows.
|
||||
* @time_: the timestamp of the event which led to this pointer grab. This usually
|
||||
* comes from a #GdkEventButton struct, though %GDK_CURRENT_TIME can be used if
|
||||
* the time isn’t known.
|
||||
*
|
||||
* Grabs the pointer (usually a mouse) so that all events are passed to this
|
||||
* application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
|
||||
* the grab window becomes unviewable.
|
||||
* This overrides any previous pointer grab by this client.
|
||||
*
|
||||
* Pointer grabs are used for operations which need complete control over mouse
|
||||
* events, even if the mouse leaves the application.
|
||||
* For example in GTK+ it is used for Drag and Drop, for dragging the handle in
|
||||
* the #GtkHPaned and #GtkVPaned widgets.
|
||||
*
|
||||
* Note that if the event mask of an X window has selected both button press and
|
||||
* button release events, then a button press event will cause an automatic
|
||||
* pointer grab until the button is released.
|
||||
* X does this automatically since most applications expect to receive button
|
||||
* press and release events in pairs.
|
||||
* It is equivalent to a pointer grab on the window with @owner_events set to
|
||||
* %TRUE.
|
||||
*
|
||||
* If you set up anything at the time you take the grab that needs to be cleaned
|
||||
* up when the grab ends, you should handle the #GdkEventGrabBroken events that
|
||||
* are emitted when the grab ends unvoluntarily.
|
||||
*
|
||||
* Returns: %GDK_GRAB_SUCCESS if the grab was successful.
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_device_grab() instead.
|
||||
**/
|
||||
GdkGrabStatus
|
||||
gdk_pointer_grab (GdkWindow * window,
|
||||
gboolean owner_events,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindow * confine_to,
|
||||
GdkCursor * cursor,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWindow *native;
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkGrabStatus res = 0;
|
||||
gulong serial;
|
||||
GList *seats, *s;
|
||||
|
||||
g_return_val_if_fail (window != NULL, GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
|
||||
g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), GDK_GRAB_FAILED);
|
||||
|
||||
/* We need a native window for confine to to work, ensure we have one */
|
||||
if (confine_to)
|
||||
{
|
||||
if (!gdk_window_ensure_native (confine_to))
|
||||
{
|
||||
g_warning ("Can't confine to grabbed window, not native");
|
||||
confine_to = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Non-viewable client side window => fail */
|
||||
if (!_gdk_window_has_impl (window) &&
|
||||
!gdk_window_is_viewable (window))
|
||||
return GDK_GRAB_NOT_VIEWABLE;
|
||||
|
||||
native = gdk_window_get_toplevel (window);
|
||||
while (gdk_window_is_offscreen (native))
|
||||
{
|
||||
native = gdk_offscreen_window_get_embedder (native);
|
||||
|
||||
if (native == NULL ||
|
||||
(!_gdk_window_has_impl (native) &&
|
||||
!gdk_window_is_viewable (native)))
|
||||
return GDK_GRAB_NOT_VIEWABLE;
|
||||
|
||||
native = gdk_window_get_toplevel (native);
|
||||
}
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
serial = _gdk_display_get_next_serial (display);
|
||||
seats = gdk_display_list_seats (display);
|
||||
|
||||
for (s = seats; s; s = s->next)
|
||||
{
|
||||
device = gdk_seat_get_pointer (s->data);
|
||||
|
||||
res = GDK_DEVICE_GET_CLASS (device)->grab (device,
|
||||
native,
|
||||
owner_events,
|
||||
get_native_grab_event_mask (event_mask),
|
||||
confine_to,
|
||||
cursor,
|
||||
time);
|
||||
|
||||
if (res == GDK_GRAB_SUCCESS)
|
||||
_gdk_display_add_device_grab (display,
|
||||
device,
|
||||
window,
|
||||
native,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
owner_events,
|
||||
event_mask,
|
||||
serial,
|
||||
time,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
/* FIXME: handle errors when grabbing */
|
||||
|
||||
g_list_free (seats);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_keyboard_grab:
|
||||
* @window: the #GdkWindow which will own the grab (the grab window).
|
||||
* @owner_events: if %FALSE then all keyboard events are reported with respect to
|
||||
* @window. If %TRUE then keyboard events for this application are
|
||||
* reported as normal, but keyboard events outside this application
|
||||
* are reported with respect to @window. Both key press and key
|
||||
* release events are always reported, independant of the event mask
|
||||
* set by the application.
|
||||
* @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no timestamp is
|
||||
* available.
|
||||
*
|
||||
* Grabs the keyboard so that all events are passed to this
|
||||
* application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
|
||||
* This overrides any previous keyboard grab by this client.
|
||||
*
|
||||
* If you set up anything at the time you take the grab that needs to be cleaned
|
||||
* up when the grab ends, you should handle the #GdkEventGrabBroken events that
|
||||
* are emitted when the grab ends unvoluntarily.
|
||||
*
|
||||
* Returns: %GDK_GRAB_SUCCESS if the grab was successful.
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_device_grab() instead.
|
||||
**/
|
||||
GdkGrabStatus
|
||||
gdk_keyboard_grab (GdkWindow *window,
|
||||
gboolean owner_events,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWindow *native;
|
||||
GdkDisplay *display;
|
||||
GdkDevice *device;
|
||||
GdkGrabStatus res = 0;
|
||||
gulong serial;
|
||||
GList *seats, *s;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_GRAB_FAILED);
|
||||
|
||||
/* Non-viewable client side window => fail */
|
||||
if (!_gdk_window_has_impl (window) &&
|
||||
!gdk_window_is_viewable (window))
|
||||
return GDK_GRAB_NOT_VIEWABLE;
|
||||
|
||||
native = gdk_window_get_toplevel (window);
|
||||
|
||||
while (gdk_window_is_offscreen (native))
|
||||
{
|
||||
native = gdk_offscreen_window_get_embedder (native);
|
||||
|
||||
if (native == NULL ||
|
||||
(!_gdk_window_has_impl (native) &&
|
||||
!gdk_window_is_viewable (native)))
|
||||
return GDK_GRAB_NOT_VIEWABLE;
|
||||
|
||||
native = gdk_window_get_toplevel (native);
|
||||
}
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
serial = _gdk_display_get_next_serial (display);
|
||||
seats = gdk_display_list_seats (display);
|
||||
|
||||
for (s = seats; s; s = s->next)
|
||||
{
|
||||
device = gdk_seat_get_keyboard (s->data);
|
||||
|
||||
res = GDK_DEVICE_GET_CLASS (device)->grab (device,
|
||||
native,
|
||||
owner_events,
|
||||
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
|
||||
NULL,
|
||||
NULL,
|
||||
time);
|
||||
|
||||
if (res == GDK_GRAB_SUCCESS)
|
||||
_gdk_display_add_device_grab (display,
|
||||
device,
|
||||
window,
|
||||
native,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
owner_events, 0,
|
||||
serial,
|
||||
time,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
/* FIXME: handle errors when grabbing */
|
||||
|
||||
g_list_free (seats);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_window_geometry_changed:
|
||||
* @window: an embedded offscreen #GdkWindow
|
||||
|
@ -1886,8 +1886,6 @@ gtk_menu_shell_get_take_focus (GtkMenuShell *menu_shell)
|
||||
* should not display mnemonics or accelerators, since it cannot be
|
||||
* guaranteed that they will work.
|
||||
*
|
||||
* See also gdk_keyboard_grab()
|
||||
*
|
||||
* Since: 2.8
|
||||
*/
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user