Commit Graph

9188 Commits

Author SHA1 Message Date
Benjamin Otte
6c61c7bf0b Don't use GdkAtom where const char * is used
Those are all forgotten transitions while updating code to new APIs.
2020-02-23 01:59:19 +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
ec383a2388 Add detail to gdk_drag_begin docs
Mention that GTK keeps a reference while the drag
operation is ongoing.
2020-02-22 19:10:16 -05: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
7edfcc37a3 Merge branch 'wip/wayland-fix-popup-grabs' into 'master'
Fix Wayland popup grabs

See merge request GNOME/gtk!1463
2020-02-22 20:51:32 +00:00
Jonas Ådahl
f0b0076a1c wayland/popup: Emit un-withdrawn event earlier
Otherwise grabbing the seat will appear to have failed.
2020-02-22 20:09:38 +01:00
Jonas Ådahl
71323a8b48 wayland/popup: Remove unnecessary checks when mapping popup
We only call this when we're not already mapped so don't check that. We
also only call this when we should be mapped so don't check that either.
2020-02-22 20:08:37 +01: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
b002572824 Merge branch 'wip/otte/dnd' into 'master'
stuff

See merge request GNOME/gtk!1460
2020-02-22 14:53:13 +00:00
Matthias Clasen
767849d6d2 Remove GdkSeatGrabPrepareFunc from headers
It is not used in public api anymore.
2020-02-22 08:11:34 -05:00
Matthias Clasen
76e115b910 Add a warning when a grab fails
This reveals that the grabs for popover menus
always fail now, causing the menus to not properly
hide.
2020-02-22 08:11:34 -05:00
Benjamin Otte
f9b7825a47 device: Inline function into return_if_fail() 2020-02-22 07:33:40 +01:00
Benjamin Otte
e3aee62b18 drop: Guard variable with correct compiler flags 2020-02-22 07:33:40 +01:00
Benjamin Otte
ce3ed45e81 surface: Inline function
Fixes compile error with -DG_DISBALE_CHECKS
2020-02-22 07:33:40 +01:00
Benjamin Otte
be4b34aa8f events: Use GdkDrop as event sequence
This allows treating drop events like touch events, which GTK groups by
event sequence.

It's a bit ugly that we just case the GdkDrop pointer, but event
sequences are only meant to be unique pointer ids, so it's fine.
2020-02-22 07:33:40 +01:00
Jonas Ådahl
2f13ac2e4d gdk/wayland: Avoid relayout with the same properties
When a popup is already showing, and gdk_surface_present_popup() is
called, if the layout didn't change, we're not really interested in
relayouting.

In the future, we'll be able to get notified if position of the popup
would change by some environmental changes, but until then, just don't
support it.
2020-02-21 21:55:16 +01:00
Jonas Ådahl
1d6100e7b0 gdk/popup-layout: Remove leftover struct field
The layouts never "seal", as they did in an earlier revision, so remove
the seal field.
2020-02-21 21:42:52 +01:00
Benjamin Otte
5577cfa40c surface: Don't take a display argument in gdk_surface_new_popup()
The display can be taken from the surface, it must not be different.
2020-02-21 21:13:09 +01: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
d7d7957b04 profiling: Avoid one extra printf
We already format the message, no need to use
printf again to combine that with the kind string.
2020-02-21 07:26:19 -05:00
Matthias Clasen
376f5eacbd profiling: Avoid criticals
With events no longer GObjects, the type class is
longer around for peeking.
2020-02-21 07:23:40 -05:00
Matthias Clasen
497a43a4ba gdk: Drop event structs from the headers
All events are GdkEvents now.
2020-02-21 00:51:03 -05:00
Matthias Clasen
4947b94a41 Stop exporting check_event_sanity 2020-02-21 00:51:03 -05:00
Matthias Clasen
7bb6abb1d4 win32: Remove some leftover event struct access
And leftover old event api calls.
2020-02-21 00:51:03 -05:00
Matthias Clasen
de91e10a1b wayland: Fix a release build warning 2020-02-21 00:51:03 -05:00
Matthias Clasen
1ef30c110f Clean up GdkEventType docs 2020-02-21 00:51:03 -05:00
Matthias Clasen
6fd913b361 Some event struct packing improvements
Rearrange a few things, and move some booleans
into the Any struct, by using a bitfield there.

Some more cleanup could be done - the flags field
with its PENDING and FLUSHED members appears
entirely unused. Nobody is setting those flags.
2020-02-21 00:51:03 -05:00
Matthias Clasen
84edce3732 Streamline event structs
Use proper types (GdkModifierType, double), and drop
some unused fields (send_event, display).
2020-02-21 00:51:03 -05: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
563dd65530 Always deliver focus events to toplevels
Its was GTK expects. This change gets rid of the "Ignoring an
unexpected focus event from GDK on a non-toplevel surface."
warning.
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
f1cf0eb3fc Drop gdk_set/get_show_events
We don't need a separate api to turn on debugging
for events.
2020-02-21 00:51:02 -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
1026bfb1ac events: Drop all setters
GdkEvent is now truly readonly.
2020-02-21 00:51:02 -05:00
Matthias Clasen
92288205d4 events: Drop target and related target
GTK no longer uses this, so we can drop it.
2020-02-21 00:51:02 -05:00
Matthias Clasen
e5223b1cee main: Stop calling gdk_event_set_target
GTK is no longer relying on this.
2020-02-21 00:51:02 -05:00
Matthias Clasen
cd2b58574d Drop GDK_NOTHING
Events of type GDK_NOTHING are good for nothing.
2020-02-21 00:47:53 -05:00
Matthias Clasen
3830e13b98 Make GdkEvent a boxed type 2020-02-21 00:47:53 -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
835556c270 Drop gdk_event_new and gdk_event_copy
These functions are no longer used outside of gdkevents.c.
2020-02-21 00:47:52 -05:00
Matthias Clasen
59cc216985 display: Stop using gdk_event_copy
Events are effectively readonly in GDK now, so we can just
take a reference, no need for a copy.
2020-02-21 00:47:52 -05:00
Matthias Clasen
fe21223d48 win32: Use event constructors 2020-02-21 00:47:52 -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
9a1497f582 events: Drop GDK_DESTROY
No backend is emitting GDK_DESTROY events anymore, so no
need to carry this 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
c9d9ccdb8c broadway: Use event constructors
Convert all of Broadways event handling to use the new
constructors.
2020-02-21 00:40:52 -05:00
Matthias Clasen
324aa39cb8 gdk: Use constructor for grab broken 2020-02-21 00:40:52 -05:00
Matthias Clasen
d6c5ecbea3 gdk: Use event constructors for dnd 2020-02-21 00:40:50 -05:00
Matthias Clasen
ef004c64c6 events: Drop x_root/y_root
We are not using these fields anymore.
2020-02-21 00:39:43 -05:00
Matthias Clasen
f15e90b194 broadway: Stop setting x_root/y_root in events
These fields are not used in GTK anymore, and are
going away soon.
2020-02-21 00:39:43 -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
Matthias Clasen
7f2564aabe wayland: Clean up coordinate handling
Get rid of the get_coordinates function and just
use the structs directly.
2020-02-21 00:39:12 -05:00
Matthias Clasen
07ffa9ad6b wayland: Use event constructors
Convert all of Waylands event handling to use the new
constructors.
2020-02-21 00:39:12 -05:00
Matthias Clasen
67035d2e35 gdk: Add event constructors
Add private API to construct events. This is a step towards
making events readonly, and not objects anymore.

The constructors here are sufficient to convert the Wayland
backend over. More may be added for other backends as needed.

Open issues:
 - history
2020-02-21 00:39:12 -05:00
Dominique Leuenberger
8b9ad1e963
build: gdk/wayland/cursor depends on wayland-client
On distros where wayland-client.h might not be directly in /usr/include
we fail to find the correct headers otherwise.
2020-02-20 17:07:02 +01:00
Benjamin Otte
9660ae5556 Merge branch 'wip/xdg-popup-async-relayout' into 'master'
Synchronous popup layout

See merge request GNOME/gtk!1241
2020-02-19 18:57:14 +00: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
37f4c644d3 gdk/surface: Reset position after hiding
The x and y position of GdkSurface is only valid when visible, so reset
them to their inital state after hiding.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
46d40cd4bd wayland: Simplify logic deciding whether to use xdg_popup
From a handful of hueristics and guess-work, to a single
`surface->surface_type == GDK_SURFACE_POPUP`.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
11dbc384ab wayland: Fix top-most-popup check
We can map a non-grabbing popup wherever, it's just the grabbing
popup-chain that needs to be ensured not to break any ordering rules.

Fix this by managing two lists; one of open popups, and another for
grabbing ones.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
ebd3ee9880 gdk: Move GdkGeometry declaration to gdktypes.h 2020-02-19 09:47:18 +01:00
Jonas Ådahl
339a04da7c gdk: Move GdkGravity to gdktypes.h 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
Jonas Ådahl
2bb0eddfb5 wayland: Simplify popup parent discovery
Now popups surfaces are always created with the parent set, so we don't
need to implement vorious guess work to try to find what the parent
might be. Remove that code and just use GdkSurface::parent which is
where the parent set during construction ends up at.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
49fcbc27ca wayland: Remove old "gdk-attached-grab-surface" hackery
The corresponding code in gtk/ is long gone, so it's luckly unused these
days.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
7fafa5133b wayland/surface: Add per surface configuration event queues
Add event queues specifically for surface configuration events
(xdg_surface.configure, xdg_toplevel.configure, xdg_popup.configure etc)
so that a configuration can be completed without having side effects on
other surfaces. This will be used to synchronously configure specific
GdkSurfaces, as is needed by the Gtk layout mechanisms.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
0d086872ae gdk/wayland/surface: Use dedicated bool for frame callback freezing
The freezing is conditioned on various state, so lets make the thawing a
bit more robust. Without this there was a risk that we'd thaw too many
times if there was a frame callback requested while the conditions for
the freezing were not met.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
f284e1d483 wayland: Remove position method split
Position can only be done via gdk_surface_queue_relayout(); the legacy
way is no longer possible, so remove the legacy positioning code.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
4e78dd2ae0 gdk/surface: Use enum type for surface type 2020-02-19 09:47:18 +01:00
Benjamin Otte
7ca149ff90 Remove gdk_content_provider_new_with_formats()
See the removal of gdk_content_provider_new_with_callback() for a
rationale.
2020-02-18 02:40:00 +01:00
Benjamin Otte
9a7607b419 contentprovider: Add a union content provider 2020-02-17 21:56:16 +01:00
Benjamin Otte
da83457a60 dnd: Remove gdk_content_provider_new_with_callback()
Content providers are meant to be immutable, apart from very special
cases, but in those cases they need to emit
gdk_content_provider_content_changed().

Having a constructor that just uses a get_func invites abuse of this
by not making developers aware of those requirments.
In fact, all users in GTK failed to do this.

Instead, code should use the GtkDragSource::prepare signal to create
content providers when needed.

The same problem exists with gdk_content_provider_new_with_formats(),
but this commit doesn't touch that.
2020-02-16 20:10:31 +01:00
Benjamin Otte
8d2ed36a1b contentprovider: Add gdk_content_provider_new_typed()
Gets around the boilerplate required to create and initialize a GValue
by having this function doing it via G_VALUE_COLLECT().
2020-02-16 20:10:30 +01:00
Benjamin Otte
762c4602fb wayland: Destroy the offer on gdk_drop_finish()
Otherwise the compositor won't be aware the dnd failed and will in turn
not notify the drag source.
2020-02-16 20:10:30 +01:00
Benjamin Otte
5a726bc665 drop: Add a state machine for tracking events 2020-02-16 20:10:30 +01:00
Benjamin Otte
47c8026e38 Merge branch 'wip/otte/dnd' into 'master'
some DND fixes

See merge request GNOME/gtk!1440
2020-02-15 23:45:25 +00:00
Benjamin Otte
46bbb397e1 wayland: Use a magic mime type for local DND
Otherwise the compositor gets all confused when it's trying to make
drag happen but we know it's not going to happen.

After all, we exchange data behind its back, we just need to keep it
informed.
2020-02-15 22:33:57 +01:00
Benjamin Otte
a824da66d9 drop: Ensure all relevant formats are available
1. GdkDrop does deserialization, so add the deserialize formats

2. If the drop is local, we can copy straight from the drag, so we can
   also copy all its formats. This fixes cases where the backend would
   drop formats it doesn't support.
2020-02-15 20:02:44 +01:00
Matthias Clasen
e5d83eea30 events: Make proximity and scroll events have tools
The Wayland backend tries to set device tools on these
events, and it was just an oversight that they don't
carry them.
2020-02-15 09:44:34 -05:00
Matthias Clasen
8ef7013165 Drop gdk_surface_new_temp
GTK is not using this API anymore, and we want
to consolidate our surface types to just toplevels
and popups.
2020-02-14 21:20:12 +01:00
Matthias Clasen
b6cb1a6eb3 Merge branch 'master-subtract-base-size' into 'master'
gdk: Subtract base size when checking aspect ratio

See merge request GNOME/gtk!1331
2020-02-14 13:19:42 +00:00
David Hogan
c4111dad31 Fixed OpenGL extension detection for extensions promoted to OpenGL core.
For a given OpenGL context, macOS in particular does not support enumeration / detection of OpenGL features that have been promoted to core OpenGL functionality. It is possible other drivers are the same. This change assumes support for GL_ARB_texture_non_power_of_two with OpenGL 2.0+, GL_ARB_texture_rectangle with OpenGL 3.1+ and GL_EXT_framebuffer_blit with OpenGL 3.0+. I failed to find definitive information on whether GL_GREMEDY_frame_terminator has been promoted to OpenGL core, or whether GL_ANGLE_framebuffer_blit or GL_EXT_unpack_subimage have been promoted to core in OpenGL ES. This change results in a significant GtkGLArea performance boost on macOS.

Closes #2428
2020-02-14 05:41:01 +11:00
Emmanuele Bassi
cdd7e4c5ec Add a notify function to GdkContentProvider
The callback-based content providers need a GDestroyNotify function to
free the data passed to them on construction, otherwise they are going
to leak.
2020-02-13 14:53:25 +00:00
Benjamin Otte
052d0f6e60 gdk: Remove gdk_cairo_get_clip_rectangle()
The function is fundamentally broken for unbounded surfaces.
If a surface is unbounded, we cannot represent this as a
cairo_rectangle_int_t, and using the return value doesn't work because
it's already used for something else.

In GTK3, unbounded surfaces aren't a problem, but GTK4 uses recording
surfaces.

So better remove that function before we keep using it and using it
wrong.
2020-02-13 07:36:38 +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
d9c59a7c8c profiler: Add G_GNUC_PRINTF markers to silence warnings
I was getting CI failures like:
 ../gdk/gdkprofiler.c: In function ‘add_markvf’:
../gdk/gdkprofiler.c:111:3: error: function ‘add_markvf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
2020-02-12 13:36:04 +01:00
Alexander Larsson
324202a56c profiler: Clean up profiler marks for frameclock
This drops the marks for before/after-paint as they are internal
things that very rarely use any time, and also flush/resume-events
as any events reported here will get separate marks so will be easy
to see anyway.

Also, we rename the entire frameclock cycle to "frameclock cycle"
rather than "paint_idle" which is rather cryptic.
2020-02-12 13:20:32 +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
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +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
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Alexander Larsson
685fd3c33d fixup! Add gdk_profiler_add_markf() to do printf formating 2020-02-12 10:11:53 +01:00
Alexander Larsson
8a1c51db1c Use the new gdk_profiler_add_markf() function 2020-02-12 09:59:03 +01:00
Alexander Larsson
6de85c0a68 Add gdk_profiler_add_markf() to do printf formating
This allows us to avoid hand-rolling g_strdup_printf calls,
but also moves the printf into the called function where
it doesn't bloat the code of the calling function if the profiler
is not running.
2020-02-12 09:58:52 +01:00
Alexander Larsson
36808e0c81 profiler: Always mark events with the kind 2020-02-11 19:51:49 +01:00
Emmanuele Bassi
c69595a3a9 vulkan: Handle VK_ERROR_UNKNOWN
A newly added Vulkan 1.2 error.
2020-02-11 14:47:22 +00:00
Emmanuele Bassi
1806af1e83 Declare global counter only in debug builds 2020-02-11 14:47:22 +00:00
Emmanuele Bassi
62352dd1fc Fix compiler warnings in the release build
We have a bunch of debug-only variables that get set and never used
outside of debug code paths, and the compiler is not happy about it.
2020-02-11 13:39:52 +00:00
Emmanuele Bassi
02ac7ff0aa Initialise out variable
Otherwise we might return an undefined value, and the compiler will be
very cross at us.
2020-02-11 13:39:52 +00: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
Matthias Clasen
07988fc17f win32: One more build fix 2020-02-09 23:04:10 -05:00
Matthias Clasen
4f79676b0b win32: Fix the build 2020-02-09 22:58:53 -05:00
Matthias Clasen
900ff743f1 Merge branch 'main-cleanup' into 'master'
Cleanup in gtkmain.h

See merge request GNOME/gtk!1403
2020-02-10 03:55:11 +00:00
Benjamin Otte
fce37b137d gdk: Make gdk_keyval_name() return a const char
The string is const, so return it like that.
2020-02-09 16:50:22 -05:00
Matthias Clasen
ba825dce29 docs: Remove a mention of gtk_main_do_event 2020-02-09 10:37:24 -05:00
Matthias Clasen
be2ba89900 Fix a doc comment
Signals take two colons.
2020-02-08 19:27:32 -05:00
Matthias Clasen
8703c7b7ac Merge branch 'better-test-isolation-2' into 'master'
Better test isolation

See merge request GNOME/gtk!1391
2020-02-06 04:53:07 +00:00
Benjamin Otte
0ad791277a Merge branch 'wip/otte/css' into 'master'
Some CSS cleanup

See merge request GNOME/gtk!1389
2020-02-05 14:04:12 +00:00
Matthias Clasen
9a446f2041 frameclock: cosmetics
Redo the profiler marks for the frame clock signals
to look more uniform.
2020-02-05 06:28:39 -05:00
Matthias Clasen
9e6ae7acd8 gdk: Silence some compiler warnings
These cause unused variable warnings in release builds.
2020-02-05 06:28:39 -05:00
Benjamin Otte
546a748cd8 widget: Replace style-updated signal with css_changed vfunc
1. Rename the thing
2. Turn it from a signal to a vfunc
3. Pass the GtkCssStyleChange to it

We don't export any public API about the GtkCssStyleChange yet, it's
just a boring opaque struct.
2020-02-05 02:46:13 +01:00
Benjamin Otte
7e8d8218b9 Revert "Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()"
We're not in the business of adding Cairo APIs. That's Cairo's job.

Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.

This reverts commit afa6cc2369.
2020-02-04 16:43:59 +01:00
Alexander Larsson
85e59220a5 filechooser portal: Free portal proxy when bus connection closes
This was blocking the clean exit from the testdbus shutdown in
the defaultvalues test. The proxy was keeping the connection alive
which blocks g_test_dbus_down().
2020-02-04 14:08:10 +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
f84fdfc0c1 Merge branch 'sigma' into 'master'
gdk: Handle small final sigma in gdk_keyval_convert_case

See merge request GNOME/gtk!1351
2020-02-02 12:04:09 +00: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
Alexander Larsson
99c89d61e1 Merge branch 'icon-theme-rework' into 'master'
Rework icon themes

See merge request GNOME/gtk!1368
2020-01-30 17:30:10 +00:00
Alexander Larsson
5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson
2ec51b7010 icon-theme: Update the docs 2020-01-30 10:53:43 +01:00
Matthias Clasen
929d325560 profiler: Exit gracefully on SIGTERM
This is nice, since it lets me quickly launch a test app
and terminate it with Ctrl-C and still produce a usable
sysprof trace.
2020-01-30 10:04:38 +01:00
Alexander Larsson
afa6cc2369 Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()
This is useful in some parts of the icon theme APIs.
2020-01-29 19:06:16 +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
Matthias Clasen
83cccfc984 Merge branch 'gdk-device-leak-fix' into 'master'
GdkDevice leak fix

See merge request GNOME/gtk!1358
2020-01-29 10:44:42 +00:00
Timm Bäder
b3f454ed98 Merge branch 'fix-doc-typo' into 'master'
Fix a doc typo

See merge request GNOME/gtk!1364
2020-01-29 07:49:13 +00:00
Luca Bacci
f0fe2e0743 Fix a doc typo 2020-01-28 20:42:03 +00: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
Sebastian Keller
5040d81e03 gdkseatdefault: Unref removed slave devices
Adding a slave device adds a ref, but removing it does not unref it.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/1358
2020-01-27 01:37:14 +01:00
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Alex Henrie
f15a34c7e4 gdk: Handle small final sigma in gdk_keyval_convert_case 2020-01-24 17:10:07 -07:00
Matthias Clasen
4e58541d52 Make wayland load cursors on demand
Copy just enough of libwayland-cursor to make our own
loading. This lets us drop the dependency on libwayland-cursor,
and changes the startup cost for cursor theme loading
from 25ms to 0.1ms.

At the same time, simplify the handling of scaled cursors -
instead of creating an array of theme objects, just make a
single theme object provide all scaled cursor sizes.
2020-01-24 17:27:45 -05:00
Matthias Clasen
59a31e05bc gdk: Add a profiler mark for paint_idle
This is the big frame clock function where most
signals are emitted, and it can keep us away from
the mainloop for a long time.
2020-01-22 23:44:01 -05:00
Matthias Clasen
527b67af3d wayland: Add a mark for cursor loading
This is much too slow.
2020-01-22 23:44:01 -05:00
Matthias Clasen
3c03d7970a More profiler reshuffling
Add more of the marks without requiring a debug build.
2020-01-22 23:44:01 -05:00
Matthias Clasen
fea42def61 surface: Always dd events to the profiler trace
We want to get this data for release builds as well.
2020-01-22 16:36:54 -05:00
Matthias Clasen
56b8d1dfbe frame clock: Redo the profiler marks
Instead of reporting the frame clock phases as defined,
report the duration of the signal emissions, which is more
useful for tracking down what is taking time.
2020-01-22 16:36:02 -05:00
Matthias Clasen
dfea9bf0e8 wayland: Add profiler marks around surface handling
Add marks for when we do commits, swap buffer or
receive frame events. These are the low-level start
and end points of the frame cycle, and it is useful
to see them in the profiler.
2020-01-22 15:12:03 -05:00
Matthias Clasen
36cb812ad8 surface: Add enter/leave events to profiler traces
These are just as likely to trigger extra work than
other mouse events, so it is useful to show them.
2020-01-22 15:12:03 -05:00
Matthias Clasen
05b98c3834 gdk: Make profiler support unconditional
We are still not providing samples unless debugging is enabled.
That needs a bit more work.
2020-01-21 11:50:12 -05:00
Vlad Zahorodnii
b36258f204 gdk: Subtract base size when checking aspect ratio
According to the ICCCM spec [1], one should subtract the base size from
the window size before checking that the aspect ratio falls in range.

This change fixes shrinking Firefox Picture-in-Picture windows when
running KDE Plasma (with KWin as the window manager).

[1] https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3
2020-01-19 02:22:44 +02:00
Matthias Clasen
46bb1a9b6a wayland: Fix release build warnings 2020-01-18 11:49:16 -05:00
Matthias Clasen
19280db075 x11: Fix release build warnings 2020-01-18 11:49:16 -05:00
Matthias Clasen
69fb3648b2 Tweak the file transfer portal _again_
This is a neverending story. I was seeing problems in tests where
the nested mainloop was picking up unrelated timeouts.

Break down and make this async. This changes the ordering in which
the (de)serializers are registered. If this is causing issues, we
can introduce priorities or something else.
2020-01-17 23:46:37 -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
Matthias Clasen
82dc7b903c Fix the filetransfer portal initialization
Reusing the cancellable only works if you don't throw
it away after first use.
2020-01-15 10:58:54 -05:00
Matthias Clasen
b020a3fcf9 Try harder to make ci not timeout
Make getting the file transfer portal proxy more
async, and avoid leaking a bus connection. This
causes GTestDBus to hang at the end of the test
run.
2020-01-14 18:32:05 -05:00
Matthias Clasen
806e159b8b Handle lack of file transfer portal
Don't block for 25 seconds trying to get a bus
connection. Give up after 1 second.
2020-01-14 01:03:48 -05:00
Robert Ancell
83867f9cbf Add missing (closure) GIR annotations 2020-01-13 14:26:50 +13:00
Robert Ancell
ea9f0df67b Fix incorrect use of GIR closure annotations.
They were being applied to the callback function, not the data that is passed
to that function.
2020-01-13 14:11:15 +13:00
Robert Ancell
2b6162116d Fix docstring errors with drag and drop code 2020-01-13 12:30:17 +13:00
Matthias Clasen
f5daecf353 Merge branch 'dnd-gestures-2' into 'master'
Add new dnd api

See merge request GNOME/gtk!1278
2020-01-11 06:09:58 +00:00
Alex Samorukov
f0cbd175cd gdk_quartz_keymap_translate_keyboard_state fills consumed_modifiers
incorrectly (closes #2102)

See merge request GNOME/gtk!1225
2020-01-10 22:18:24 +01:00
Matthias Clasen
8d3e1eb314 docs: Fix a typo 2020-01-09 00:31:13 -05:00
Matthias Clasen
187a701a99 content provider impl: Take mime types into account 2020-01-08 18:48:22 -05:00
Matthias Clasen
d116bbf0c8 docs: Expand the GDK dnd docs 2020-01-08 18:48:22 -05: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
3080592234 gdk: Make gdk_event_set_coords support dnd events
GTK event propagation code relies on this working.
2020-01-08 18:48:21 -05:00
Matthias Clasen
a76b187a5b drop: Add a convenience api
This is a question that drag-drop handlers frequently
need to answer, so make it easy.
2020-01-08 18:48:20 -05:00
Matthias Clasen
ea9f2abcc4 Add another callback-based provider
This one can be used in cases where data needs
to be served in multiple formats that may not
all be covered by content serializers.
2020-01-08 18:48:19 -05:00
Matthias Clasen
fdcfe0e80a Add a generic callback content provider
This one is convenient to use in cases where a
drag is just serving an existing GType which
is covered by content serializers.
2020-01-08 18:48:19 -05:00
Matthias Clasen
8137dea8c1 Add (de)serializers for GdkRGBA
This is a format that we use in various
color picker widgets, so support it in GDK.
2020-01-08 18:48:19 -05:00
Alex Samorukov
df9d9c1f8a impl_class->set_functions listed twice in the object 2020-01-08 14:15:45 +00:00
Alex Samorukov
d131c8d0e7 move [NSApplication sharedApplication] after _gdk_quartz_events_init() to avoid initialization issues
(cherry picked from commit 46c2451c5a3cd42aa5a94935bfc850a484288ff3)
2020-01-08 14:10:06 +00:00
Timm Bäder
2cbfb0e980 GdkGLContext: check for GL_KHR_debug for GL debug output
This is available in GLES.
2020-01-07 17:27:16 +01:00
Timm Bäder
095a378dbc GdkRGBA: Use floats instead of doubles 2020-01-07 17:27:15 +01:00
Matthias Clasen
2ee9752822 wayland: Remove debug spew 2020-01-06 08:19:01 -05:00
Matthias Clasen
759d53cfa0 wayland: Don't artificially prefer ASK
We were always adding ASK to the list of possible
actions, and preferring it. This was causing the
ask cursor to show up when both the source and
the target support ASK, even though it is only
meant to happen if you hold the Alt modifier.

Instead, use one of the supported actions as
preferred action.
2020-01-04 12:51:32 -05:00
Matthias Clasen
814d20d61a docs: Small clarifications to DND docs
Clear up the documentation around ASK handling
a bit.
2020-01-04 12:48:39 -05:00
Matthias Clasen
6cef520804 wayland: Minor cleanup
Stop storing selected_action, mainly since the name
is confusing. Instead, just pass the value directly
in the 2 places where it is used.
2020-01-04 12:48:39 -05:00
Matthias Clasen
8c77491150 wayland: Fix action handling more
When updating GdkDrop::actions from changes sent by
the compositor, we were inadvertently setting them to 0,
causing drops to appear impossible.
2020-01-04 09:38:31 -05:00
Matthias Clasen
709ebcedd4 wayland: Finish pending offer handling
When creating a new GdkDrop object on drag_enter, take pending
source_actions and action into account. The code to store the
pending actions was already there, they were just not passed
on to the drop object when we create it.
2020-01-04 09:38:01 -05:00
Matthias Clasen
47e6b88555 wayland: Clean up drags
We need to set the drag to NULL in gdk_wayland_drag_drop_done,
otherwise, all future drags will be considered local after the
first local one. Worse, they will also provide the wrong data.
2020-01-04 09:36:38 -05:00
Matthias Clasen
4b818495ca wayland: Fix dnd type negotiation
We need to call gdk_content_formats_union_serialize_mime_types
like GdkClipboard does, in order to get mime types that we can
sent out.
2020-01-01 12:51:19 -05:00
Matthias Clasen
1841ec4f8e contentprovider: cosmetic fix 2020-01-01 12:51:19 -05:00
Matthias Clasen
21708e4352 contentserializer: Fix an annotation 2020-01-01 12:51:19 -05:00
Matthias Clasen
15242d66e1 wayland: Pass root coordinates for dnd events
That is what the api currently requires, so provide it.

This fixes DND to work again, for the most part.
2019-12-30 12:00:53 -05:00
Matthias Clasen
94a0bc01f9 gdk: Populate dnd event coords
The GdkDrop emit... apis take root coordinates.
That should be changed to surface coordinates,
eventually. For now, make the functions fill
the x, y fields.
2019-12-30 11:58:11 -05:00
Matthias Clasen
677c4b140c gdk: Fix coordinates in dnd events
Don't store coordinates as shorts. Use doubles,
as everywhere else. Also add x, y in addition
to x_root, y_root, and actually return those
in gdk_event_get_coords.
2019-12-30 11:56:49 -05:00
Matthias Clasen
0bb9fc65ad Remove gdk_seat_grab
We are no longer using free-standing grabs
in GTK. The replacement is the autohide
functionality of popup surfaces.
2019-12-29 20:31:58 -05:00
Matthias Clasen
ad6fe9d6a0 surface: Only unpause events if we paused them
When a new popup surface is created, it may end up
getting a resume-events signal from its frame clock
without having seen a flush-events first.

Don't unpause events in that case, since it messes
up the displays pause counter.

This was causing criticals with tooltips.
2019-12-29 13:35:36 -05:00
Matthias Clasen
a73947e54f Remove more mir remnants
The mir backend was removed a while ago, so
GDK_WINDOWING_MIR is never defined.
2019-12-28 21:52:34 -05:00