Commit Graph

68 Commits

Author SHA1 Message Date
Matthias Clasen
2cce508b33 x11: Remove some leftover event struct access 2020-02-21 00:51:03 -05:00
Matthias Clasen
b1eaa502df events: reorganize getters
Restructure the getters for event fields to
be more targeted at particular event types.

Update all callers, and replace all direct
event struct access with getters.

As a side-effect, this drops some unused getters.
2020-02-21 00:51:03 -05:00
Matthias Clasen
31bf9da63a Strip const from GdkEvent
Events are refcounted structs, and we generally don't
pass these as const.
2020-02-21 00:51:02 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
f11b1d258b x11: Pass the right surface to the dnd filter 2020-02-21 00:47:52 -05:00
Matthias Clasen
e45711e727 x11: Remove an unnecessary check
We are not creating GDK_NOTHING events anymore. Yay
2020-02-21 00:47:52 -05:00
Matthias Clasen
15501afdbb x11: Change the wm protocols filter api
Instead of passing a half-constructed event and expect
it to be filled in, pass the surface as in argument, and
add an out argument for a newly constructed GdkEvent.
2020-02-21 00:40:52 -05:00
Matthias Clasen
94fe0944cc x11: Don't pass a GdkEvent to shape cache filters
The filter functions never look at that event, and
we want to get out of the business of passing half-
constructed events around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
9c4f19e8ed x11: Don't pass a GdkEvent to xsettings filters
The filter functions never look at that event, and
we want to get out of the business of passing half-
constructed events around.
2020-02-21 00:40:52 -05:00
Matthias Clasen
30740f0e2c x11: use event constructors
This is not quite complete and only handles the
simple cases.
2020-02-21 00:40:52 -05:00
Samuel Thibault
99eee5cea9 Revert "gdk: deactivate/activate surface on keyboard grabs"
This reverts commits 35417a5a74 and
01455399e8.

This reintroduces #85, but see discussion in
https://gitlab.gnome.org/GNOME/gtk/merge_requests/433 for the unforeseen
invasive consequences of these commits.
2019-04-30 16:48:16 +02:00
Matthias Clasen
eacbeb9efd x11: Don't emit GDK_NOTHING events
They are good for nothing.
2019-03-06 23:42:36 -05:00
Benjamin Otte
dd30a288f2 x11: Split drag and drop contexts
While doing so, turn the drop context into a GdkDrop subclass and no
longer pretend to be a GdkDragContext.
2018-06-18 23:49:52 +02:00
Benjamin Otte
5e159e2ca0 x11: Replace the hardcoded DND filter
Use the new method of connecting to the xevent signal instead.

Also, don't consume the xevent, there might be other code listening for
it. And we don't use PropertyNotify in the generic code path anymore, so
it'll just be ignored there.
2018-06-18 23:49:52 +02:00
Benjamin Otte
b1f384eec2 x11: Don't sneakily allocate memory in initializers 2018-06-18 23:49:52 +02:00
Matthias Clasen
5a319f66af Merge branch 'window-activate-grab-4-again' into 'master'
gdk: activate surface on keyboard grabs

Closes #85

See merge request GNOME/gtk!174
2018-06-18 11:36:09 +00:00
Samuel Thibault
35417a5a74 gdk: activate surface on keyboard grabs
In 01455399e8 ("gdk: do not deactivate surface on keyboard grabs"), we
made gdk avoid deactivating surfaces when another application takes a
keyboard grab, by using has_focus_window instead of has_focus. That however
broke activating surfaces when the gdk application acquired a grab itself,
in which case has_focus_window is false but has_focus is true.

We thus actually need to use both: surfaces should be activated either
because we have normal keyboard focus, or because we grabbed the keyboard.

This also renames HAS_FOCUS to APPEARS_FOCUSED to better reflect its
role.

Fixes #85
2018-06-18 10:31:15 +02:00
Benjamin Otte
40321d331f x11: Remove useless check
The check survived from GTK2 when that function could still return
GdkPixmap and GdkFont objects and was accompanied by this comment:

  /* We may receive events such as NoExpose/GraphicsExpose
   * and ShmCompletion for pixmaps
   */
2018-06-10 02:33:53 +02:00
Samuel Thibault
01455399e8 gdk: do not deactivate surface on keyboard grabs
When pressing e.g. a window manager shortcut, which acquires keyboard grab,
Xorg would send FocusOut NotifyGrab then FocusIn NotifyUngrab.  Currently
gdk would then deactivate the current surface, which makes accessibility
screen readers think that we have switched to a non-accessible application
and came back again, and thus reannounce the application frame etc. which we
don't want when e.g. just raising volume.

And actually, receiving FocusOut NotifyGrab does not mean losing the
X focus, it only means an application aqcuired a grab, i.e. it is
temporarily stealing keyboard events. On Wayland, this isn't even
notified actually.

This commit makes gdk only deactivate surfaces when there was an actual
focus switch to another window, as determined by has_focus_window (instead
of just has_focus), which happens either normally through FocusOut with
NotifyNormal, or during grabs through FocusOut with NotifyWhileGrabbed.

Fixes #85
2018-04-30 10:57:53 +02:00
Alexander Larsson
3dce0dcca7 GdkSurface: Rename lots of stuff from window->surface
Mostly these are internal things, but the major public change is
that event.window is now event.surface.
2018-03-20 15:14:10 +01:00
Alexander Larsson
9a7e721181 GdkSurface: Rename various functions and variables
This is an automatic rename of various things related
to the window->surface rename.

Public symbols changed by this is:
 GDK_MODE_WINDOW
 gdk_device_get_window_at_position
 gdk_device_get_window_at_position_double
 gdk_device_get_last_event_window
 gdk_display_get_monitor_at_window
 gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_drag_window
 gdk_draw_context_get_window
 gdk_drawing_context_get_window
 gdk_gl_context_get_window
 gdk_synthesize_window_state
 gdk_surface_get_window_type
 gdk_x11_display_set_window_scale
 gsk_renderer_new_for_window
 gsk_renderer_get_window
 gtk_text_view_buffer_to_window_coords
 gtk_tree_view_convert_widget_to_bin_window_coords
 gtk_tree_view_convert_tree_to_bin_window_coords

The commands that generated this are:

git sed -f g "GDK window" "GDK surface"
git sed -f g window_impl surface_impl
(cd gdk; git sed -f g impl_window impl_surface)
git sed -f g WINDOW_IMPL SURFACE_IMPL
git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE
git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface
git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface
git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface
git sed -f g gsk_renderer_get_window gsk_renderer_get_surface
git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface

(cd gdk; git sed -f g window_type surface_type)
git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type

git sed -f g window_at_position surface_at_position
git sed -f g event_window event_surface
git sed -f g window_coord surface_coord
git sed -f g window_state surface_state
git sed -f g window_cursor surface_cursor
git sed -f g window_scale surface_scale
git sed -f g window_events surface_events
git sed -f g monitor_at_window monitor_at_surface
git sed -f g window_under_pointer surface_under_pointer
(cd gdk; git sed -f g for_window for_surface)
git sed -f g window_anchor surface_anchor
git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL
git sed -f g native_window native_surface
git sed -f g source_window source_surface
git sed -f g dest_window dest_surface
git sed -f g drag_window drag_surface
git sed -f g input_window input_surface

git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 12:05:26 +01:00
Alexander Larsson
890080ebf7 GdkWindow -> GdkSurface: File renames
Rename all *window.[ch] source files.

This is an automatic operation, done by the following commands:

for i in $(git ls-files gdk | grep window); do
    git mv $i $(echo $i | sed s/window/surface/);
    git sed -f g $(basename $i) $(basename $i | sed s/window/surface/) ;
done

git checkout NEWS* po-properties po
2018-03-20 11:46:11 +01:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Benjamin Otte
365707e4eb x11: Run event filters on all windows
The event filters that were split out in commit
65beb0fc22 need to be run for every event
window and not just for the root window.
2018-02-13 10:34:06 +01:00
Matthias Clasen
89f6b8751e Remove gdk_window_add_filter
Drop the public filtering API. The x11 backend already has
the ::xevent signal as replacement. The win32 backend needs
a similar signal to replace filtering.

Reshuffle header inclusions in the x11 backend a little bit
to avoid a cyclic inclusion between gdkprivate-x11.h and
gdkdisplay-x11.h that is otherwise causing problems.
2018-02-07 15:12:03 -05:00
Matthias Clasen
65beb0fc22 x11: Don't use gdk_window_add_filter
This function is going away.
2018-02-07 12:24:40 -05:00
Emmanuele Bassi
888dfe499d Drop the Big GDK Lock
GDK has a lock to mark critical sections inside the backends.
Additionally, code that would re-enter into the GTK main loop was
supposed to hold the lock.

Back in the Good Old Days™ this was guaranteed to kind of work only on
the X11 backend, and would cause a neat explosion on any other GDK
backend.

During GTK+ 3.x we deprecated the API to enter and leave the critical
sections, and now we can remove all the internal uses of the lock, since
external API that uses GTK+ 4.x won't be able to hold the GDK lock.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:07:10 +01:00
Carlos Garnacho
3021edc38d gdk/x11: s/gdk_event_free/g_object_unref/ 2017-12-14 01:05:48 +01:00
Carlos Garnacho
64decbfd74 gdk: Remove GdkEventType argument from GdkEvent union
It won't stand true anymore that the GdkEventType argument is the
first field of the GdkEvent* structs. All callers have been updated
to use event->any.type instead.
2017-12-14 00:58:32 +01:00
Carlos Garnacho
b9db0b55cb gdk: Refurbish GdkEvent struct hierarchy
Make all specific event structs contain a GdkEventAny, so the base
struct can be extended without modifying structs all over the place.
2017-12-14 00:58:32 +01:00
Benjamin Otte
fb0fdddd76 x11: Refactor xevent filtering some more
We now have a GdkX11Display::xevent signal that gets emitted for every
XEvent and allows you to interrupt processing via TRUE/FALSE return
values.
These return values to correspond to GDK_FILTER_REMOVE and
GDK_FILTER_CONTINUE respectively.

The GDK_FILTER_TRANSLATE case from gdk_window_add_filter() is now meant
to be handled via gdk_display_put_event().
2017-12-13 01:55:56 +01:00
Benjamin Otte
0d1ea05658 x11: Add GdkX11Display:translate-event signal
This is supposed to replace gdk_window_add_filter() in the long run.
2017-12-13 00:56:52 +01:00
Benjamin Otte
f34297cfba x11: Constify XEvent usage 2017-12-13 00:56:52 +01:00
Benjamin Otte
8a453924a0 gdk: Remove gdk_event_put(), peek() etc
We don't want to treat events like they don't belong to displays. So
instead, people should use gdk_display_put/peek/get_event().
2017-12-13 00:56:52 +01:00
Matthias Clasen
2daa7d1a53 x11: Stop using GdkScreen in api
This type is going away, so switch to using GdkX11Screen
everywhere.
2017-11-17 10:51:55 -05:00
Matthias Clasen
bdb442be21 x11: Reduce uses of the root window
Avoid calling the get_root_window api that returns
a GdkWindow in some places, and instead use the X
root window directly.
2017-11-09 22:52:37 -05:00
Emmanuele Bassi
d2e9a5fa88 x11: Use backend-specific API to get GdkScreen
The gdk_display_get_default_screen() function was removed, but the X11
GdkEventSource still lobs around GdkX11Screen instances.
2017-11-02 06:42:49 +00:00
Matthias Clasen
9f6b556dc2 Stop using foreign windows for xsettings
Stop wrapping the xsettings manager window in a foreign
window. This means that we cannot use the gdk window filter
APIs anymore, so just do the filtering in a non-generic
way.
2017-11-01 22:55:17 -04:00
Matthias Clasen
2d6bd1ae6d Drop gdk_window_get_screen
This includes removing the GdkScreen argument from the
create_window_impl display vfunc.
2017-10-31 17:25:01 -04:00
Carlos Garnacho
fb81d7fc8f gdk/x11: Implement GDK_CROSSING_TOUCH_BEGIN/END/DEVICE_CHANGE events
The behavior where a touchpoint takes over the pointer position is
really backend dependent. Since this went away from the generic code,
implement it here.
2017-09-19 18:40:51 +02:00
Matthias Clasen
6baac526b9 x11: drop a useless list
We were keeping all the event sources in a list, only to remove
them at the end of their life. Not useful.
2016-05-01 13:26:35 -04:00
Carlos Garnacho
d55b8151f2 x11: Avoid setting has_pointer_focus if a EWMH compliant WM is present
This is mostly useful to have focus behave sanely on lack of WM, so avoid
any check there if we're positive there is a WM handling focus.

https://bugzilla.gnome.org/show_bug.cgi?id=677329
2016-02-12 22:05:30 +01:00
Owen W. Taylor
f50a3af1b7 Handle recursion from motion event handlers
If a motion event handler (or other handler running from the flush-events
phase of the frame clock) recursed the main loop then flushing wouldn't
complete until after the recursed main loop returned, and various aspects
of the state would get out of sync.

To fix this, change flushing of the event queue to simply mark events as
ready to flush, and let normal event delivery handle the rest.

https://bugzilla.gnome.org/show_bug.cgi?id=705176
2013-11-11 23:17:14 -05:00
Owen W. Taylor
d446dda920 gdk_display_get_event: don't unqueue events from the windowing system when paused
Unqueuing events from the windowing system when paused could result
in weird reordering if event filters resulted in application-visible
behavior. Since we now resume events when the frame clock is frozen,
we now no longer count on low-level event handling running while
event handling is paused.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:50 -05:00
Matthias Clasen
144a5687c9 gdk: Don't use GDK_THREADS_ENTER/LEAVE macros internally
These are just wrappers for the functions, and we want to
deprecate them. Stopping to use them internally is a good
first step.
2012-07-30 18:01:47 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Carlos Garnacho
e89d6b8741 configure: Check for XGetEventData()
This is a call only available in recent libX11, only the XI2 code
depends on this within GDK, but XI2 implies having GenericEvents
available too.
2011-05-27 11:53:26 +02:00
Carlos Garnacho
55cc9f3339 gdk: Add _gdk_x11_event_translator_get_window()
This method can be implemented by event translators so they
return the right window from XGenericEventCookie events, as
ev->xany.window isn't meaningful for these.

GdkEventSource now also uses this to find out the right window
filters to apply.
2011-05-18 22:34:33 +02:00
Carlos Garnacho
53d77a829a gdk: Move XGetEventData() call to GdkEventSource
This function should be called just once across every possible
event translator and GdkFilterFunc that wants to deal with
any cookie event.
2011-05-18 22:34:32 +02:00
Benjamin Otte
e67347a3c8 x11: Fill in event->any.window before calling filter functions
a) We advertise it for GdkFilterFunc
b) It's necessary to differentiate between different event types with
   multi-backend GTK.
2011-02-01 06:33:01 +01:00