Commit Graph

2619 Commits

Author SHA1 Message Date
Benjamin Otte
7cd728a0ea gdk: Make gdk_drop_status() take preferred action
This allows textview/text dnd to properly display a MOVE icon when in
the widget the drag started from but a COPY icon otherwise.
2020-03-02 04:43:56 +01:00
Matthias Clasen
7a39f2d49d Replace gdk_surface_is_visible by _get_mapped
The property  is called ::mapped, and we want to get
to standard getter naming.
2020-02-24 19:07:03 -05:00
Matthias Clasen
6be9e44786 gdk: Drop GdkDevice::input-mode and rename ::input-source
Drop the input-mode, since it only makes sense for
floating devices, which we don't have anymore. And renamt
::input-source to ::source, to match the getter.

Update all users.
2020-02-24 14:38:42 -05:00
Benjamin Otte
6e935d469a x11: Get rid of GdkAtom and APIs supporting it.
replace all uses with const char * (non-interned).
Also remove a lot fo juggling from atom to GdkAtom to string and back.

The X Atom hash table is now mapping to (again, non-interned) strings.
2020-02-23 01:59:26 +01:00
Benjamin Otte
28dced597f gdk: Remove gdk_text_property_to_utf8_list_for_display()
A lot of files became empty now, so they have been removed, which makes
this commit seem larger than it is.
2020-02-23 01:59:26 +01:00
Benjamin Otte
6442ec2f8d gdk: Remove gdk_utf8_to_string_target()
Only keep the X11 version around in the backend.
2020-02-23 01:59:00 +01:00
Benjamin Otte
992173c382 x11: Register DND atoms with all other atoms
It's 2020, there's no need to be restrained with registering atoms.
2020-02-23 01:59:00 +01:00
Benjamin Otte
b0f6996892 gdk: Remove gdk_surface_register_dnd()
All surfaces are expected to be DND surfaces from creation.
2020-02-23 01:59:00 +01:00
Matthias Clasen
7c1cfc5533 x11: Fix dnd coordinate handling
We were not properly converting the coordinates we
got to root coordinates. This was showing up as offsets
between the actual drop target and the area where drops
can happen, e.g. when dragging over a stack switcher
to switch pages.
2020-02-22 19:10:16 -05:00
Matthias Clasen
14122d1acb x11: Export gdk_x11_surface_get_root_coords privately
This lets us avoid a roundtrip through the surface vfuncs.
2020-02-22 19:10:16 -05:00
Matthias Clasen
f93d0f8fb5 x11: Keep a ref on GdkDrag objects
It is expected that backends keep a ref on the GdkDrag
objects that they create as long as the drag is ongoing.
2020-02-22 19:02:13 -05:00
Matthias Clasen
833b564946 x11: Avoid crashes in dnd
We were forgetting to clean up the ::xevent signal
handler in some error cases. Move the signal connection
later, when we know the drag is going forward, and
use g_signal_connect_object to make sure the signal
handler is not forgotten.
2020-02-22 19:02:13 -05:00
Matthias Clasen
1af94d0bce x11: Fix a crash in event handling
This was overlooked in 79b4510c6d.
2020-02-22 16:41:29 +00:00
Benjamin Otte
608e624ecf x11: When clearing old Drop, emit LEAVE event
This can happen when the old DND operation died (like due to a crash or
a broken XWayland compositor.
2020-02-21 18:19:16 +01:00
Benjamin Otte
808961564c gdk: Make DRAG_ENTER event take x/y coordinates
Make it mirror the behavior of ENTER/LEAVE events.
2020-02-21 18:19:16 +01:00
Matthias Clasen
2cce508b33 x11: Remove some leftover event struct access 2020-02-21 00:51:03 -05:00
Matthias Clasen
56d44b4cec x11: Stop using the send_event event field
The only use of this field is printing it out in a
debug message. We are going to drop it.
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
79b4510c6d x11: change event translator interface
Make the event translator return a new event, instead of
filling in a half-constructed one.

Update the two implementation in GdkX11Display and
GdkDeviceManagerXI2.
2020-02-21 00:47:51 -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
047c18844c x11: Don't generate GDK_DESTROY events
GTK does not differentiate between GDK_DESTROY and GDK_DELETE
anyway.
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
Matthias Clasen
91b94f51f2 x11: Stop setting x_root/y_root in events
These fields are not used by GTK anymore and
will be going away soon.
2020-02-21 00:39:43 -05:00
Matthias Clasen
a8e9d6c1f5 x11: Stop relying on root coordinates in events
The X11 dnd code was still using x_root/y_root in
GdkEventMotion in a couple of places. Stop doing so,
these field are going away soon.
2020-02-21 00:39:43 -05:00
Matthias Clasen
7e80c39aee Remove root coords from the GdkDrop api 2020-02-21 00:39:41 -05:00
Jonas Ådahl
ca71119a40 gdk/surface: Replace move_to_rect() with GdkPopupLayout based API
Replace the gdk_surface_move_to_rect() API with a new GdkSurface
method called gdk_surface_present_popup() taking a new GdkPopupLayout
object describing how they should be laid out on screen.

The layout properties provided are the same as the ones used with
gdk_surface_move_to_rect(), except they are now set up using
GdkPopupLayout.

Calling gdk_surface_present_popup() will either show the popup at the
position described using the popup layout object and a new unconstrained
size, or reposition it accordingly.

In some situations, such as when a popup is set to autohide, presenting
may immediately fail, in case the grab was not granted by the display
server.

After a successful present, the result of the layout can be queried
using the following methods:

 * gdk_surface_get_position() - to get the position relative to its
   parent
 * gdk_surface_get_width() - to get the current width
 * gdk_surface_get_height() - to get the current height
 * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor
   rectangle the popup was effectively positioned against given
   constraints defined by the environment and the layout rules provided
   via GdkPopupLayout.
 * gdk_surface_get_surface_anchor() - the same as the one above but for
   the surface anchor.

A new signal replaces the old "moved-to-rect" one -
"popup-layout-changed". However, it is only intended to be emitted when
the layout changes implicitly by the windowing system, for example if
the monitor resolution changed, or the parent window moved.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
40693412d3 x11: Make gdk_surface_get_position() return relative position
The returned position should be relative to the parent surface, but
GdkSurface::x,y were only managed properly for O-R windows. This makes
it correct for regular windows too.
2020-02-19 09:47:18 +01:00
Alexander Larsson
6e3dd6dd62 profile: Use separate names for frameclock marks instead of using details
The marks are averaged based on the name, so this makes more sense.

Also rename the map/unmap marks to have the same capitalization as
everything else.
2020-02-12 14:29:31 +01:00
Alexander Larsson
e3a67385f4 profiler: Add profiler marks for when surfaces are mapped and unmapped
This is done on the X11 side so we can tell when the map/unmap takes
effect and how long it took since the map request.
2020-02-12 12:44:43 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.

We also expand to  G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
2020-02-12 11:05:01 +01:00
Alexander Larsson
23211bcae8 hidpi: Rescan monitors when screen scale factor changes
All the code in e.g. init_randr15() divides the physical resolutions with
the screen scale, however if we get the screen scale from xsettings
rather than e.g. GDK_SCALE the initial setup is using the wrong value.

So, whenever the screen scale size is changed we need to trigger
a re-read of the randr data
2020-02-10 15:34:32 +01:00
Alexander Larsson
a3be0ec5f0 Don't use xsettings or xft defaults in testsuite
This adds a GDK_DEBUG=default-settings flag which disables reads
from xsettings and Xft resources, and enables this for the testsuite.

This is one less way to get different testresults depending on the
environment. In particular, it was failing the css tests for me
due to getting the wrong font size because i have a different dpi.
2020-02-03 15:11:35 +01:00
Alberts Muktupāvels
66af531ff3 display-x11: don't mention gdk_monitor_is_primary in the docs
https://gitlab.gnome.org/GNOME/gtk/merge_requests/1371#note_699272
2020-02-02 19:18:22 +02:00
Matthias Clasen
a46f9af1c0 Remove primary monitor api
We only have implementations of this on X11 and Win32,
so make it available as backend api there.

Update all callers to use either the backend api, or
just monitor 0.
2020-01-30 21:33:37 +01:00
Alberts Muktupāvels
248883089c x11: add support for _GTK_WORKAREAS_Dn
If window manager supports _GTK_WORKAREAS use per-monitor work areas.

https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1300
2020-01-29 14:38:08 +02:00
Sebastian Keller
9c6669be48 gdk/x11: Properly unref removed device in XI2 device manager
When a device is added, there are two references to it by the device
manager, the initial one and the one used for the id_table. Removing a
device only removed the reference added by the id_table resulting in the
GdkDevice being leaked.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 21:42:34 +01:00
Matthias Clasen
19280db075 x11: Fix release build warnings 2020-01-18 11:49:16 -05:00
Carlos Garnacho
357e215fb8 gdkdrag/x11: Issue XdndLeave on cancellation
According to XDND "The XdndLeave message cancels the session.",
issue one when cancelling a drag, so the dest side has an opportunity
to forget about the GdkDrop.
2020-01-16 15:03:24 +01:00
Carlos Garnacho
4716c9ae2f gdkdrag/x11: Drop timestamp argument from gdk_drag_do_leave()
This is not necessary for the XdndLeave message, nor used.
2020-01-16 15:02:16 +01:00
Carlos Garnacho
5aad3d7d0e gdk/x11: Ensure to hide DnD surface after failed operation
The drag source might be cached and held alive, only disposed after
future drag begin operations. Ensure the drag surface gets hidden
properly or might might stay transparent but mapped till then.
2020-01-16 13:34:08 +01:00
Carlos Garnacho
fe36c24b07 gdk/x11: Ensure to sync type list after sending XdndEnter
Otherwise we are not ensured the GdkDrop is up-to-date, might even
be a stale one from an older DnD operation.
2020-01-16 13:33:57 +01:00
Carlos Garnacho
682068f887 gdk/x11: Serialize gtype content formats before sending Xdnd enter
This ensures GType handlers get serialized to mimetypes at the time
the drag dest inspects the XdndTypeList property.
2020-01-16 13:31:40 +01:00
Carlos Garnacho
f6f331efe3 gdk/x11: Forward suggested action (if any) to XdndStatus
Go ahead with the suggested action, so the drag source may update
cursor feedback properly, and eventually result in the correct
action.
2020-01-08 18:48:21 -05:00
Matthias Clasen
bf2c29a36a x11: Only update cursors if we have any
We were accessing an on-demand created hash table
without checking if it had been created first.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2308
2019-12-13 14:46:00 -05:00