Package: gdk

Function gdk-device-grab

Lambda List

gdk-device-grab (device window grab-ownership owner-events event-mask cursor time)

Arguments

device -- a gdk-device object. To get the device you can use the gtk-current-event-device or gdk-event-device functions if the grab is in reaction to an event. Also, you can use the gdk-device-manager-client-pointer function but only in code that is not triggered by a gdk-event event and there are not other means to get a meaningful gdk-device object to operate on.
window -- a gdk-window object which will own the grab, the grab window
grab-ownership -- a gdk-grab-ownership value which specifies the grab ownership
owner-events -- if false then all device 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 of type gdk-event-mask, which is used in accordance with owner-events.
cursor -- a gdk-cursor object to display while the grab is active if the device is a pointer. If this is nil then the normal cursors are used for window and its descendants, and the cursor for window is used elsewhere.
time -- an unsigned integer with the timestamp of the event which led to this pointer grab. This usually comes from the gdk-event event, though +gdk-current-time+ can be used if the time is not known.

Return Value

:sucess if the grab was successful.

Details

Grabs the device so that all events coming from this device are passed to this application until the device is ungrabbed with the gdk-device-ungrab function, or the window becomes unviewable. This overrides any previous grab on the device by this client.

Device grabs are used for operations which need complete control over the given device events, either pointer or keyboard. For example in GTK this is used for drag and drop operations, popup menus and such.

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 gdk-event-grab-broken events that are emitted when the grab ends unvoluntarily.
 

See also

2021-12-13