Commit Graph

9500 Commits

Author SHA1 Message Date
Matthias Clasen
fd1033f974 surface: Add width and height properties 2020-08-08 09:24:30 -04:00
Matthias Clasen
16505a4d1e gdk: Move the ::popup-layout-changed signal
Move this signal from GdkSurface to GtkPopup,
where it belongs.
2020-08-08 09:24:30 -04:00
Matthias Clasen
0b21883518 toplevel: Revise docs wording a bit
The documentation of ::compute-size didn't quite
keep up with the changes in the MR. Fix it up.
2020-08-07 14:56:42 -04:00
Matthias Clasen
1ccab92813 Merge branch 'matthias/fix-min-size' into 'master'
Matthias/fix min size

See merge request GNOME/gtk!2404
2020-08-07 18:46:24 +00:00
Matthias Clasen
a95012caa3 Check sanity of toplevel sizes
Emit a warning when sizes returned in GdkToplevelSize
don't look sane. This is the case in the failing
reftest.
2020-08-07 12:45:19 -04:00
Jonas Ådahl
6724d4250f wayland/toplevel: Don't leak wl_callback used during present() 2020-08-07 14:01:16 +02:00
Jonas Ådahl
c27f811462 wayland/surface: Destroy toplevel present callback if ignored
We might break the loop early, e.g. if we're unmapped before the round
trip finishes, and to avoid the callback to write to invalid stack
memory, destroy the callback so it won't be invoked.

Fixes: #3026
2020-08-07 09:06:21 +02:00
Jonas Ådahl
3590923c8b wayland/surface: Fix toplevel present roundtrip condition
We should round trip until we both have received callback and have
ensured we received the initial configuration.
2020-08-07 09:06:21 +02:00
Matthias Clasen
26542778f7 Merge branch 'dnd-leaks' into 'master'
Dnd leaks

See merge request GNOME/gtk!2391
2020-08-07 00:34:38 +00:00
Matthias Clasen
12450cfcef wayland: Don't leak content formats
We were not unreffing the formats here.
2020-08-06 20:02:33 -04:00
Matthias Clasen
71373ff6fb drop: Don't leak the surface and formats 2020-08-06 20:02:33 -04:00
Matthias Clasen
1fa9261fe3 contentdeserializer: Add some missing annotations 2020-08-06 20:02:33 -04:00
Matthias Clasen
0c82aa314c Fix a leak in scroll event compression
We were leaking the last event in a sequence
of scroll events.
2020-08-06 19:31:38 -04:00
Andreas Persson
71cec2ef5d gdk/toplevel: fix declarations of GdkToplevelSize
GDK_AVAILABLE_IN_ALL was missing from gdk_toplevel_size_get_bounds and
gdk_toplevel_size_set_max_size was declared though it doesn't exist.
2020-08-06 16:14:10 +02:00
Matthias Clasen
1d7b273669 docs: Clean up dangling links in gdk docs
Clean up references to no-longer-existing APIs.
2020-08-05 15:45:43 -04:00
Matthias Clasen
d7c4f93c76 Merge branch 'wip/compute-size' into 'master'
Compute size via signal

See merge request GNOME/gtk!2325
2020-08-05 16:19:19 +00:00
Jonas Ådahl
2ff74eb667 gdk/toplevel: Negotiate surface size via a compute-size signal
GTK will not up front know how to correctly calculate a size, since it
will not be able to reliably predict the constraints that may exist
where it will be mapped.

Thus, to handle this, calculate the size of the toplevel by having GDK
emitting a signal called 'compute-size' that will contain information
needed for computing a toplevel window size.

This signal may be emitted at any time, e.g. during
gdk_toplevel_present(), or spontaneously if constraints change.

This also drops the max size from the toplevel layout, while moving the
min size from the toplevel layout struct to the struct passed via the
signal,

This needs changes to a test case where we make sure we process
GDK_CONFIGURE etc, which means we also needs to show the window and
process all pending events in the test-focus-chain test case.
2020-08-05 15:49:00 +02:00
Matthias Clasen
8870ec5e7b Merge branch 'hex-color-parse' into 'master'
Hex color parse

Closes #2931

See merge request GNOME/gtk!2356
2020-08-05 11:46:55 +00:00
Chun-wei Fan
edc1c28236 GdkGLContext: Drop gdk_gl_context_has_[framebuffer_blit|frame_terminator]()
gdk_gl_context_has_framebuffer_blit() and gdk_gl_context_has_frame_terminator()
were only used by by GDK/Win32, and they do not provide performance advantages
in GTK master, so clean up the code a bit by dropping them.
2020-08-05 18:56:57 +08:00
Chun-wei Fan
d2291abe2a gdksurface-win32.c: Fix resizing
Use gdk_surface_get_geometry() to get the correct x and y coordinates of the
window that we are resizing, so that the window does not reposition itself
automatically at the top-left corner at resizing as we to used hard-code the x
and y coordinates to 0.
2020-08-05 16:23:14 +08:00
Chun-wei Fan
5ce0098adc gdkvulkancontext-win32.c: Implement ->begin_frame()
By doing so, we ensure that resizes of windows will work on Vulkan renderer, by
first calling gdk_win32_surface_handle_queued_move_resize() before we proceed
as usual
2020-08-05 16:23:14 +08:00
Chun-wei Fan
46a8a3fe31 gdk[cairo|gl]context-win32.c: Use gdk_win32_surface_handle_queued_move_resize()
Use the shared function that was added in the previous commit, to simplify
things.

Also make gdk_win32_surface_get_queued_window_rect() and
gdk_win32_surface_apply_queued_move_resize() back into static functions, since
they are now used only by the code in gdksurface-win32.c
2020-08-05 16:23:14 +08:00
Chun-wei Fan
c6ada2a329 gdksurface-win32.c: Add function to handle queued moves/resizes
Since we need to deal with queued moves and resizes in the Cairo, GL and Vulkan
draw contexts, and the logic involved in all three of these are largely
similar, add a function gdk_win32_surface_handle_queued_move_resize() that will
handle this, which will be shared between these three types of draw contexts.
2020-08-05 16:23:12 +08:00
Chun-wei Fan
69bb4f8beb GDK-Win32: Move some functions around
Move gdk_win32_surface_get_queued_window_rect() and
gdk_win32_surface_apply_queued_move_resize() to gdksurface-win32.c, since these
functions are not only used for Cairo draw contexts, but is also used for GL
draw contexts, and will be used for Vulkan draw contexts.
2020-08-05 15:38:08 +08:00
Chun-wei Fan
06f28af80f gdksurface-win32.c: Fix Aerosnap computation
Don't get the default display when we compute the Aerosnap region, but instead
get it from the underlying GdkSurface that we are using for the computation.

Also, don't unref the monitors that we obtain from the display in the wrong
place, which was why we had crashes whenever we triggered AeroSnap code (and we
are actually not supposed to do that as they are owned by the GdkDisplay that
is owned by the GdkSurface we are using), and this will eliminate lots of
criticals that are spewed as a result.
2020-08-05 15:38:08 +08:00
Jonas Ådahl
4ee82e8175 gdk/toplevel: Fix typo in documentation 2020-08-04 16:53:10 +02:00
Matthias Clasen
9659d3f78a Merge branch 'applaunch-warning' into 'master'
x11: Ignore stray DestroyNotify events

Closes #3006

See merge request GNOME/gtk!2355
2020-08-03 03:30:59 +00:00
Matthias Clasen
1f3327d326 rgba: Use pango_color_parse_with_alpha
Use this newly exported pango function, so we
can support hex colors with alpha like #rrggbbaa.

Fixes: #2931
2020-08-02 23:30:33 -04:00
Matthias Clasen
4152e90e7e x11: Ignore stray DestroyNotify events
There's no use in making a delete event with a
NULL surface. Just ignore such events.

Fixes: #3006
2020-08-02 22:45:28 -04:00
Matthias Clasen
5a55f6ff7b gdk: Fix gdk_surface_get_layout_monitor
We are determining the monitor by maximizing the
intersection; that only works if our rectangle
is not empty.

Fixes: #3003
2020-08-02 21:29:18 -04:00
Rico Tzschichholz
371cdf3250 gdk/x11: Add annotations to improve GIR API 2020-07-31 20:56:36 +02:00
Matthias Clasen
1087ff48f0 Merge branch 'glib-build-fix' into 'master'
widget: Drop unnecessary includes

See merge request GNOME/gtk!2328
2020-07-31 18:52:50 +00:00
Matthias Clasen
358f66482d Merge branch 'master.win32' into 'master'
Some improvements for GDK/Win32

See merge request GNOME/gtk!2327
2020-07-31 17:10:47 +00:00
Carlos Garnacho
9564cba492 gdk: Fix toplevel calculation on pointer grab switch
This check used to read if (grab || device_type != GDK_DEVICE_TYPE_PHYSICAL),
the grab check was only reserved to physical devices, which the current
pointer device definitely doesn't act like. So the condition was "fixed" the
wrong way around, and the latter check is now moot, so the condition should
really go away. We always want to check the new toplevel under the pointer
here.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2970
2020-07-31 18:53:01 +02:00
Chun-wei Fan
20388f83f5 GDK-Win32: Use SetProcessDpiAwarenessContext() where available
This allows us to use DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 for the
DPI awareness mode, which will help us to better support use cases with
multiple monitors.  This is actualy a more advaned version of the
current PROCESS_PER_MONITOR_DPI_AWARE via using SetProcessDpiAwareness().

Note that this is not enabled by default, but also enabled via using
GDK_WIN32_PER_MONITOR_HIDPI, as in the PROCESS_PER_MONITOR_DPI_AWARE
case.

Note also, that appliation compatibility settings and DPI-awareness
manifests takes precedence over this API call, as before.
2020-07-31 23:20:25 +08:00
Chun-wei Fan
85706dc39d gdkglcontext-win32.c: Create a global shared GL context
Like the other backends, we ought to create our WGL/EGL GL contexts like
the following:

"Create a global GL context that connects all GL contexts on a display
and lets us share textures between them."
2020-07-31 23:19:28 +08:00
Chun-wei Fan
07166a55ee gdksurface-win32.c: Deal with modal and decoration props
Handle these cases, especially the modal case, which we did not handle
previously after the conversion to surface subtypes.
2020-07-31 23:19:28 +08:00
Matthias Clasen
2dfa5ac804 x11: Stop using GTimeVal
It has been deprecated, and that is breaking our
ci builds with -Werror.
2020-07-31 10:58:53 -04:00
Carlos Garnacho
96452a2e46 gdk: Rename gdk_seat_get_physical_devices() to gdk_seat_get_devices()
We don't want to tell what they are, and the distinction is now less
clear. Remove the adjective from the function name.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
46eb054337 gdk: Drop gdk_device_get_device_type()
There is no longer a hierarchy of devices, or none that is seen
on the outside.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
4a2050e220 gdk/x11: Make device type a X11 detail
The only legit uses of device types are here in gdk/x11, move the
concept of device type to X11, so we can drop it from public API.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
3c68db8e47 gdk: Make gdk_device_list_physical_devices() private
Physical devices should probably be accounted internally in gdk/x11,
make this out of private API so at least the implementation details
don't leak.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
9912c80d70 gdk: Drop gdk_device_get_associated_device()
Devices are no longer associated like this, the seat should be used
to resolve queries on other devices.
2020-07-30 18:30:13 +02:00
Carlos Garnacho
7991032aeb gdk/x11: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:19:44 +02:00
Carlos Garnacho
0cbc857ea4 gdk/win32: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Carlos Garnacho
398c1d1ad7 gdk/macos: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Carlos Garnacho
94982dbab7 gdk: Avoid gdk_device_get_associated_device()
Query the seat for that.
2020-07-30 18:17:42 +02:00
Benjamin Otte
4dc2ab61c9 Merge branch 'wip/otte/geometry' into 'master'
Some GdkGeometry cleanups

See merge request GNOME/gtk!2322
2020-07-30 15:31:27 +00:00
Benjamin Otte
13d3afa56e Remove unused GDK_HINT_POS 2020-07-30 17:06:15 +02:00
Benjamin Otte
3dd0e6d0b1 Remove gravity from GdkGeometry
It's always northwest
2020-07-30 17:06:15 +02:00
Benjamin Otte
11db6ad574 Remove aspect ratio from GdkGeometry
It's unused.
2020-07-30 17:06:15 +02:00
Benjamin Otte
ebcef256ab gdk: Remove unused flags 2020-07-30 17:06:15 +02:00
Benjamin Otte
b12b06e917 gdk: Remove base_size and increment from GdkGeometry
It's unused.
2020-07-30 16:55:45 +02:00
Chun-wei Fan
a481733b40 GDK/Win32: Force GLES if running on ARM64
If GLES support is enabled on Windows, force GLES mode if we are running
on a ARM64 version of Windows (i.e. Windows 10 for ARM).

This is required as ARM64 versions of Windows only provide a software
implementation of OpenGL 1.1/1.2, which is not enough for our purposes.
Thus, we could make instead use the GLES support provided via Google's
libANGLE (which emulates OpenGL/ES 3 with Direct3D 9/11), so that we
can run GtkGLArea programs under OpenGL/ES in ARM64 versions of Windows.

Note that eventually we could update the libepoxy build files for Windows
to not check nor enable WGL when building for ARM64 Windows, as the WGL
items do not work, although they do build.
2020-07-30 14:30:13 +08:00
Chun-wei Fan
cf0175ffce OpenGL/ES: Fix 'R' and 'B' bits inverted on Windows
We need to use GL_BGRA instead of GL_RGBA when doing glReadPixels() on
EGL on Windows (ANGLE) so that the red and blue bits won't be displayed
inverted.

Also fix the logic where we determine whether to bit blit or redraw
everything.
2020-07-30 14:30:13 +08:00
Chun-wei Fan
257fd990d1 Add a EGL renderer (via ANGLE) for Windows
This is for adding a EGL-based renderer which is done via the ANGLE
project, which translate EGL calls to Direct3D 9/11.  This is done as a
possible solution to issue #105, especially for cases where the needed
full GL extensions to map OpenGL to Direct3D is unavailable or
unreliable, or when the OpenGL implementation from the graphics drivers
are problematic.

To enable this, do the following:
-Build ANGLE and ensure the ANGLE libEGL.dll and libGLESv2.dll are
 available.  A sufficiently-recent ANGLE is needed for things to
 work correctly--note that the copy of ANGLE that is included in
 qtbase-5.10.1 is sufficient.  ANGLE is licensed under a BSD 3-clause
 license.
-Build libepoxy on Windows with EGL support enabled.
-Currently, prior to running GTK+ programs, the GDK_DEBUG envvar needs
 to be set with gl-gles as at least one of the flags.

Known issues:
-Only OpenGL ES 3 is supported, ANGLE's ES 2 does not support the needed
 extensions, notably GL_OES_vertex_array_object, but its ES 3 support is
 sufficient.
-There is no autodetection or fallback mechanism to enable using
 EGL/Angle automatically yet.  There are no plans to do this in this
 commit.
2020-07-30 14:26:33 +08:00
Chun-wei Fan
12a23162b3 build: Check for EGL support in libepoxy on Windows
...EGL support needs to be explicitly enabled during the build of
libepoxy on Windows as it is not enabled by default on Windows.

With this, we can add an EGL renderer for Windows that make use of
Google's libANGLE, which is a library that translates OpenGL/ES calls
to Direct3D 9/11, which will provide better hardware compatibility
on Windows and would act as one of the foundations to resolve issue #105.
2020-07-30 14:26:33 +08:00
Matthias Clasen
0b11e78064 Merge branch 'display-cleanup' into 'master'
Display cleanup

See merge request GNOME/gtk!2319
2020-07-30 03:55:23 +00:00
Matthias Clasen
488722e7c4 docs: Don't refer to nonexisting functions
gdk_surface_input_shape_combine_mask() no longer
exists.
2020-07-29 23:00:57 -04:00
Matthias Clasen
7df070d681 gdk: Move default group api to the X11 backend
This is the only place where it is implemented.
2020-07-29 22:58:37 -04:00
Matthias Clasen
4d012a6d95 Rename gdk_surface_queue_expose
We don't have expose events anymore; instead, there
is a ::render signal. So rename queue_expose to
queue_render to match.

Update all callers.
2020-07-29 22:40:01 -04:00
Matthias Clasen
c1eedf6845 gdk: Stop exporting gdk_surface_freeze_updates
The only legitimate use for freezing the frame clock
is in GDK backends. Exporting this function for
applications makes no sense.
2020-07-29 22:30:44 -04:00
Jonas Ådahl
c7c71137b2 gdk/monitor: Remove gdk_monitor_work_area and GdkMonitor::work-area
It's not a portable API, so remove it. The corresponding backend
specific functions are still available, if they were implemented, e.g.
gdk_macos_monitor_get_workarea() and gdk_x11_monitor_get_workarea().
2020-07-29 17:57:30 +02:00
Matthias Clasen
fc47e79cb6 Document gdk_device_tool_get_axes 2020-07-28 21:58:06 -04:00
Matthias Clasen
2a92ee22da gdk: Small doc fixup
We no longer use <!-- --> for plurals, gtk-doc is smart
enough to detect them without that.
2020-07-28 21:53:56 -04:00
Matthias Clasen
b5f256937f Merge branch 'wip/carlosg/device-api-cleanup' into 'master'
Cleanups to device/event API

See merge request GNOME/gtk!2313
2020-07-28 23:49:35 +00:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
25ea17a6fc gdk: Drop source_device argument from _gdk_display_device_grab_update()
It's just passed around and used nowhere.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
4a2bbed157 gdk: Make events hold an axis array matching GdkAxisUse
Instead of doing device-specific translations of array positions,
use GdkAxisUse as an array index right away.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
7629f6d533 gdk: Make GdkDevice axis API internal
All outside interaction happens through gdk_event_get_axis(), no
device poking is necessary, nor axis to array index translations.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
230ce9bfde gdk: Remove gdk_device_get_axes()
Besides the implicit x/y assumptions, devices don't have axes. Those
are actually provided by the GdkDeviceTool driving the device, and
different tools may have different axes.

It does not make sense to offer this API that can change beneath
someone's feet, we now have gdk_device_tool_get_axes() which is static
to the tool.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
b52ad33031 gdk: Add gdk_seat_get_tools() API call
There's GdkSeat::tool-added and ::tool-removed, but there's no
API to query the known tools. Add this call.
2020-07-29 00:11:34 +02:00
Carlos Garnacho
254007a142 gdk: Add gdk_device_tool_get_axes()
Axes are actually a per-tool property, we just adapt devices to the
current tool.
2020-07-28 17:37:09 +02:00
Carlos Garnacho
a2876b5cb4 gdkdevice: Remove gdk_device_get_state()
This is not needed nor recommended anymore, all reasons to maybe
need this were all kept within gdk.
2020-07-28 17:36:18 +02:00
Carlos Garnacho
3285f52dc8 gdk: Drop GDK_SOURCE_CURSOR
Looking at the xf86-input-wacom driver code, this is not even a thing
anymore. Drop this device type, in modern days there's
GDK_DEVICE_TOOL_TYPE_MOUSE for this.
2020-07-28 15:25:28 +02:00
Timm Bäder
9cdf9847c2 gl: Add a gdk_gl_context_has_debug accessor
Check if the label_object_ etc. functions are gonna do anything at all.
The g_type_name_from_instance calls keep poppoing up in profiles.
2020-07-28 05:34:12 +02:00
Christian Hergert
0243736003 macos: support ARM/PowerPC time conversion for DisplayLink times
When converting DisplayLink frame presentation times, we need to take into
account the arch-specific types. This tracks changes in GNOME/GLib!1566 so
that precision is not lost.
2020-07-27 12:49:57 -07:00
Matthias Clasen
73f4f518b8 gdk: Improve struct packing in places
Plug some holes in our structs by rearranging
a few fields. This is was done looking at
pahole output.
2020-07-25 11:57:37 -04:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Chun-wei Fan
89f7d841ab gdk/gdkarrayimpl.c: Fix build on Visual Studio
It seems like initializing something to an empty array using `{}` is a GCCism,
so just stuff a 0 within the braces to accomplish the same thing.
2020-07-24 16:25:24 +08:00
Matthias Clasen
2e07fcd680 Merge branch 'wip/chergert/quartz4u' into 'master'
Merge GDK macOS branch

See merge request GNOME/gtk!2272
2020-07-21 22:22:41 +00:00
Christian Hergert
9dbf99d91a macos: prototype new GDK backend for macOS
This is fairly substantial rewrite of the GDK backend for quartz and
renamed to macOS to allow for a greenfield implementation.

Many things have come across from the quartz implementation fairly
intact such as the eventloop integration design and discovery of
event windows from the NSEvent.

However much has been changed to fit in with the new GDK design and
how removal of child GdkWindow have been completely eliminated.
Furthermore, the new GdkPopup allows for regular NSWindow to be used
to provide popovers unlike the previous implementation.

The object design more closely follows the ideal for a GDK backend.

Views have been broken out into subclasses so that we can support
multiple GSK renderer paths such as GL and Cairo (and Metal in the
future). However mixed mode GL and Cairo will not be supported. Currently
only the Cairo renderer has been implemented.

A new frame clock implementation using CVDisplayLink provides more
accurate information about when to draw drawing the next frame. Some
testing will need to be done here to understand the power implications
of this.

This implementation has also gained edge snapping for CSD windows. Some
work was also done to ensure that CSD windows have opaque regions
registered with the display server.

     ** This is still very much a work-in-progress **

Some outstanding work that needs to be done:

 - Finish a GL context for macOS and alternate NSView for GL rendering
   (possibly using speciailized CALayer for OpenGL).
 - Input rework to ensure that we don't loose remapping of keys that was
   dropped from GDK during GTK 4 development.
 - Make sure input methods continue to work.
 - Drag-n-Drop is still very much a work in progress
 - High resolution input scrolling needs various work in GDK to land
   first before we can plumb that to NSEvent.
 - gtk/ has a number of things based on GDK_WINDOWING_QUARTZ that need
   to be updated to use the macOS backend.

But this is good enough to start playing with and breaking things which
is what I'd like to see.
2020-07-21 14:45:12 -07:00
Christian Hergert
0154a7f528 gdk: disable file transfer portal on macOS 2020-07-21 14:45:12 -07:00
Christian Hergert
7884ab6161 build: fix linking support on macOS with Clang
This was preventing any sort of building on macOS, even though the quartz
backend is currently non-functional. Fixing this is a pre-requisite to
getting a new macOS backend compiling.
2020-07-21 14:45:12 -07:00
Matthias Clasen
bc542c5304 gdk: Update gdkkeysyms.h
Run the gdkkeysyms-update.pl script to pick up several
new keysyms:
GDK_dead_lowline
GDK_dead_aboveverticalline
GDK_dead_belowverticalline
GDK_dead_longsolidusoverlay
GDK_Keyboard
GDK_WWAN
GDK_RFKill
GDK_AudioPreset
2020-07-21 16:55:28 -04:00
Timm Bäder
11f07cb5ad GdkRGBA: Fix typo in documentation 2020-07-17 05:49:11 +02:00
Benjamin Otte
90b7b84337 array: Add a bunch of new features
* GDK_ARRAY_BY_VALUE
  #define this to get GArray-like behavior
* gdk_array_splice (v, 0, 0, NULL, 25)
  Adding items but passing NULL as the items will zero() them.
* gdk_array_set_size()
  A nicer way to call gdk_array_splice()
* constify getters
2020-07-16 18:09:58 +02:00
Benjamin Otte
a4cd974912 array: Add null-termination 2020-07-16 18:09:57 +02:00
Benjamin Otte
8bf8ac5076 Add GdkArray
This is a scary idea where you #define a bunch of preprocessor values
and then #include "gdkarrayimpl.c" and end up with a dynamic array for
that data type.

See https://en.wikipedia.org/wiki/X_Macro for what's going on.

What are the advantages over using GArray or GPtrArray?

 * It's typesafe
   Because it works like C++ templates, we can use the actual type of
   the object instead of having to use gpointer.

 * It's one less indirection
   instead of 2 indirections via self->array->data, this array is
   embedded, so self->array is the actual data, and just one indirection
   away. This is pretty irrelevant in general, but can be very noticable
   in tight loops.

 * It's all inline
   Because the whole API is defined as static inline functions, the
   compiler has full access to everything and can (and does) optimize
   out unnecessary calls, thereby speeding up some operations quite
   significantly, when full optimizations are enabled.

 * It has more features
   In particular preallocation allows for avoiding malloc() calls, which
   can again speed up tight loops a lot.
   But there's also splice(), which is very useful when used with
   listmodels.
2020-07-16 18:09:57 +02:00
Matthias Clasen
c12261a6ec Merge branch 'wip/fix-picom-crasher' into 'master'
x11: Don't set up frame sync fence on unsupported compositors

Closes #2927

See merge request GNOME/gtk!2245
2020-07-15 01:40:49 +00:00
Emmanuel Gil Peyrot
74a4432688 gdk/wayland: Add an API to inhibit and uninhibit idle
This uses the idle-inhibit protocol from wayland-protocols, to attach an
inhibitor to the GdkSurface.  The inhibit function can be called as many
times as the user wants, but the uninhibit function MUST be called as
many times to unset the idle inhibition.

This has been tested on Sway.
2020-07-14 21:47:22 +02:00
Ray Strode
d0ec616fba x11: Don't set up frame sync fence on unsupported compositors
Not all compositors support _NET_WM_FRAME_DRAWN.  In cases
where the compositor doesn't support _NET_WM_FRAME_DRAWN we don't
need to do all the fancy damage tracking and fence watching.

Furthermore, if the compositor doesn't support _NET_WM_FRAME_DRAWN,
it's possible that one frame will start before the previous frame has
made it through the pipeline, leading to a blown assertion.

This commit side-steps the unnecessary code and associated assertion
when _NET_WM_FRAME_DRAWN isn't supported.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2927
2020-07-14 14:33:12 -04:00
Matthias Clasen
d441e7106b x11: Plug a memory leak
Don't leak atoms when we're storing the clipboard.
2020-07-09 18:19:32 -04:00
Carlos Garnacho
c0c5ce2f9b gdk/x11: Ignore regular crossing events while in implicit grabs
If we create an implicit grab on a surface, leave the surface, and
release the button, we would get 2 XI_Leave events, one with mode
XINotifyNormal when the pointer leaves the surface, and another with
mode XINotifyUngrab when the button is released.

Meanwhile, the upper layers rely on crossing events being paired,
and particularly in no crossing event being sent until the implicit
grab is dismissed (either by releasing it, or via more pervasive
grabs).

Ignoring the set of XINotifyNormal events while an implicit grab
is active adapts the X11 backend to this behavior. If the grab were
released or taken away by another grab, a crossing event with one
of the other XINotify*Grab/XINotify*Ungrab will be generated.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2879
2020-07-09 17:02:07 +02:00
Caolán McNamara
7e97c2513f gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface
so LibreOffice can reuse toplevels and get the right task icons

references;
 https://gitlab.gnome.org/GNOME/gtk/-/issues/767
 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html
 e0d6ad1d5e
 https://bugs.documentfoundation.org/show_bug.cgi?id=125934
 https://bugzilla.redhat.com/show_bug.cgi?id=1334915
 https://bugreports.qt.io/browse/QTBUG-77182
2020-07-07 15:56:12 +01:00
Ray Strode
56b3669411 x11: Avoid thawing surface until frame is drawn
Since commit 972134abe4 a frame getting
drawn has three states (with the vendor nvidia driver at least):

1. drawn by gtk waiting on the GPU
2. drawn by GPU waiting on the compositor
3. drawn by compositor

Those three states are encoded in two flags: frame_pending and
frame_still_painting.

frame_pending means step 1 is done, but step 2 and 3 are still
in progress.  frame_still_painting means step 2 is still in progress.

After step 1 is finished the surface is frozen until step 3 is finished.

When the compositor notifies gtk it's done with step 3, with a
_NET_WM_FRAME_DRAWN client message, the toolkit thaws the surface to
allow the next frame to proceed.

The compositor sometimes sends gtk a _NET_WM_FRAME_DRAWN client message
between steps 1 and 2.  This message should be ignored because it's not
a reply to the current frame.

Unfortunately, gtk currently assumes if it gets a _NET_WM_FRAME_DRAWN
client message while waiting for step 2 that it's actually at step 3,
and proceeds to draw a new frame while the existing frame is still
pending, leading to a blown assertion.

This commit addresses the problem by ignoring _NET_WM_FRAME_DRAWN
client messages from the compositor unless actually expecting one.

Fixes: #2902
2020-06-30 14:36:15 -04:00
Ray Strode
e3b5b76cdd x11: Handle window getting unmapped while frame still pending
Since commit 972134abe4 we now call
glClientWaitSync for the vendor nvidia driver, to know when a frame
is ready for the compositor to process.

If a surface is hidden while a frame is still being rendered by the GPU,
the surface will never produce the damage event the code relies on to
trigger the call to glClientWaitSync. This leaves the fence dangling,
and the next time the surface is shown, it will start a fresh frame
and blow an assertion since the fence from the last frame is still
hanging around.

This commit ensures a frame gets fully wrapped up before hiding a
surface.
2020-06-30 14:36:07 -04:00
Matthias Clasen
9f2926dde3 gdk: Better help for GDK_DEBUG
Include docstrings and format the list of supported
values better.

Also, add the same warning we have for GTK_DEBUG when
the environment variable is ignored.
2020-06-28 13:42:02 -04:00