Commit Graph

8977 Commits

Author SHA1 Message Date
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