Commit Graph

11027 Commits

Author SHA1 Message Date
Benjamin Otte
7ef5f6ef1a display: Remove x/y/w/h from create_surface() 2023-04-26 21:03:34 +02:00
Marc-André Lureau
ff9cd989c6 gdk/win32: fix defined but not used warnings
[30/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkmain-win32.c.obj
../gdk/win32/gdkmain-win32.c:146:1: warning: 'gdk_win32_finalize_ole' defined but not used [-Wunused-function]
  146 | gdk_win32_finalize_ole (void)
      | ^~~~~~~~~~~~~~~~~~~~~~
../gdk/win32/gdkmain-win32.c:113:1: warning: 'gdk_win32_finalize_com' defined but not used [-Wunused-function]
  113 | gdk_win32_finalize_com (void)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:37:58 +04:00
Marc-André Lureau
5b69df96fe gdk/win32: fix hr set but not used
A number of warnings are produced:

[23/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkinput-dmanipulation.c.obj
../gdk/win32/gdkinput-dmanipulation.c: In function 'reset_viewport':
../gdk/win32/gdkinput-dmanipulation.c:354:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  354 |   HRESULT hr;
      |           ^~

Try to do something sensible instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:37:58 +04:00
Marc-André Lureau
d8ead56b9c gdk/win32: fix g_string_free warning
../gdk/win32/gdkclipdrop-win32.c: In function 'transmute_cf_shell_id_list_to_text_uri_list':
C:/msys64/ucrt64/include/glib-2.0/glib/gstring.h:72:5: warning: ignoring return value of 'g_string_free_and_steal' declared with attribute 'warn_unused_result' [-Wunused-result]

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:14:57 +04:00
Marc-André Lureau
0e2d7111eb gdk/win32: fix GDK_NOTE redefined warning
In file included from ../gdk/win32/gdkdrag-win32.c:201:
../gdk/win32/gdkprivate-win32.h:45: warning: "GDK_NOTE" redefined
   45 | #define GDK_NOTE(type,action)                             \
      |
../gdk/win32/gdkdrag-win32.c:40: note: this is the location of the previous definition
   40 | #define GDK_NOTE(a,b)

Fixes: bc159207bd ("gdk: Drop old debug macros")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-25 16:11:11 +04:00
Takao Fujiwara
26e3824d1d gdkdisplaymanager: Add missing nullable to display name 2023-04-25 12:08:08 +09:00
Benjamin Otte
104b5ef157 surface: reformat function
Make the function follow usual coding conventions.

And while doing that, remove duplicate functionality.
2023-04-22 16:35:16 +02:00
Benjamin Otte
893862a51a surface: Refactor code
Move the early exit conditions to the top and turn them into early exits
instead of nesting if statements.
2023-04-22 16:33:35 +02:00
Benjamin Otte
823eb4c6d9 surface: Fold function into its only caller
No other changes
2023-04-22 16:29:58 +02:00
Benjamin Otte
be0ed15b40 surface: Stop maintaining an unused linked list
wat?
2023-04-22 16:27:27 +02:00
Benjamin Otte
040af44b00 surface: Remove in_update tracking
It's 2023, we use frame clocks now and don't have nested surface drawing
anymore.
2023-04-22 16:24:16 +02:00
Benjamin Otte
4154f87418 surface: Stop tracking the active update area
It's unused.
2023-04-22 16:10:24 +02:00
Marc-André Lureau
250414d6b3 gdk/win32: drop some unused variables
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-17 04:50:17 +00:00
Marc-André Lureau
d69cdf6c05 gdk: drop libangle GLES minimum version
GLES 2.0 version is fine now with current gtk according to B. Otte.
Let's use the same minimum requirement for all implementations.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-17 04:50:17 +00:00
Marc-André Lureau
9532657fa2 gdk: use GLES when on win32/ANGLE
When using GDK_DEBUG=gl-egl, we end up using GL, but that is not well supported:

Creating EGL context version 3.0 (debug:no, forward:no, legacy:yes, es:no)
Created EGL context[0000000000000004]
OpenGL version: 0.0 (legacy)
* GLSL version: (NULL)
* Max texture size: -1059701680
* Extensions checked:
 - GL_KHR_debug: no
 - GL_EXT_unpack_subimage: yes
 - OES_vertex_half_float: no

** (gtk4-demo.exe:14324): WARNING **: 19:16:41.468: Compile failure in
vertex shader:
ERROR: 0:7: 'gl_Position' : undeclared identifier
---8<---

Use GLES when EGL implementation is ANGLE.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-17 04:50:17 +00:00
Marc-André Lureau
3cb2115212 gdk: drop unused vertex_array_object
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-04-17 04:50:17 +00:00
Benjamin Otte
8965d6c7f8 gl: Only allow RGB(A)8 on GLES2
GLES2 has no idea what 16bit textures even are, let alone floating point.
2023-04-17 05:57:44 +02:00
Benjamin Otte
62951c7277 wayland: Don't leak all surfaces
X11 does add an extra reference to surfaces that gets released when the
DestroyNotify event arrives.
Wayland doesn't ave such an event, so that reference never gets
released.

This fixes a copy/paste error introduced in commit 590f3dfa1f.
2023-04-16 19:28:21 +02:00
Benjamin Otte
8e00f6e5e5 wayland: Don't insta-crash when a surface gets disposed
We want to remove the event queue from the list of event queues, not the
surface.
Otherwise the freed queue stays in the list and the next time an event
comes in, we access invalid memory.

Fixes thinko introduced in commit 7fafa5133b.

Luckily, we leak all surfaces, so this problem never occured.
2023-04-16 19:28:21 +02:00
Matthias Clasen
189aced844 wayland: Improve logging for primary selection 2023-04-15 15:02:52 +02:00
Georges Basile Stavracas Neto
9c013d40c1 gdk/vulkancontext: Use more appropriate present mode
Check if the driver supports MAILBOX and prefer using it; in its
absense, checkif the driver supports IMMEDIATE and prefer using
it; finally, if neither of them are supported, use the guaranteed
to be supported FIFO mode.
2023-04-13 13:54:45 -03:00
Benjamin Otte
cfaf1b3e71 x11: Remove commented outdated code
... and it's copy/paste into the win32 backend
2023-04-13 17:15:35 +02:00
Benjamin Otte
9763d83a9d gdk: Remove unused vfunc 2023-04-13 17:15:35 +02:00
Benjamin Otte
75bea01a86 wayland: Keep EGL window around when hidden
See previous commit:

We want to keep resources around as long as the surface exists.
2023-04-13 05:19:18 +02:00
Benjamin Otte
5d3cec5441 wayland: Don't destroy the wl_surface on hide()
We want to keep the wl_surface around, because surfaces create their
resources on construct and keep them until destroyed. See the HWND ond
Windows and the XWindow on X11.

This is relevant for graphics resources, where we want to have access
to the VkSurface and eglSurface while the GdkSurface is hidden.
We also want these surfaces to be permanent and not change during the
lifetime of the GdkSurface.

What we can - and must - destroy however are the xdg surfaces, because
those handle visibility on screen.
And we also need to ensure no buffer is attached, so that during the
next creation of the xdg surface we don't get a protocol error.
2023-04-13 04:23:35 +02:00
Benjamin Otte
891242920e wayland: Split out a function
We have a create_wl_surface(), create a matching destroy_wl_surface().
2023-04-13 02:56:12 +02:00
Benjamin Otte
b375f17f09 wayland: Remove useless function
gdk_wayland_surface_maybe_resize() just calls
gdk_wayland_surface_update_size(), so make all callers call that one
instead.

The check that it does is done by the other function again.
2023-04-13 02:48:47 +02:00
Benjamin Otte
ec69990126 wayland: Remove an old workaround
This workaround - were it ever to trigger - is broken today. It destroys
the wl_surface and all associated structs but does not recreate the
xdg_popup or xdg_toplevel struct, so it would cause a hidden window.

The workaround looked a lot different when it was introduced in commit
83b54bab57, too - both in what it did and
in what the vfuncs did that it called.
2023-04-13 02:44:05 +02:00
Georges Basile Stavracas Neto
5c27a0dd2b vulkan: Support fractional scaling
Basically what GL does, but without any debug or feature flag
to gatekeep it, since the Vulkan backend itself is experimental
already.

Ceil surface sizes, and floor coordinates, to the fractional scale
value.
2023-04-03 11:10:27 -03:00
Matthias Clasen
5e95c22844 wayland: Be more careful about scale-factor
Only emit notify::scale-factor if it actually
changes. This potentially avoids a lot of work
in GTK (reloading icons, etc).
2023-04-02 13:23:19 -04:00
Matthias Clasen
70269a5aee docs: Add some details 2023-04-02 13:18:51 -04:00
Matthias Clasen
4746ffc4eb Make fractional scaling for GL opt-in
Fractional scaling with the GL renderer is
experimental for now, so we disable it unless
GDK_DEBUG=gl-fractional is set.

This will give us time to work out the kinks.
2023-04-02 11:05:57 -04:00
Matthias Clasen
fa58dd9256 Use fractional scale for the GL renderer
This commit combines changes in the Wayland backend,
the GL context frontend, and the GL renderer to switch
them all to use the fractional scale.

In the Wayland backend, we now use the fractional scale
to size the EGL window.

In the GL frontend code, we use the fractional scale to
scale the damage region and surface in begin/end_frame.

And in the GL renderer, we replace gdk_surface_get_scale_factor()
with gdk_surface_get_scale().
2023-04-02 09:22:56 -04:00
Matthias Clasen
76ac91512b Deprecate gdk_surface_create_similar_surface
This function is part of the cairo drawing API and
we are moving away from that. Update all callers.
2023-04-01 23:09:19 -04:00
Matthias Clasen
075bea788b Add gdk_surface_get_scale
Add a scale property to GdkSurface and use the
fractional scale for it on Wayland.
2023-04-01 19:09:16 -04:00
Benjamin Otte
6d4d9af14e wayland: Use fractional scaling with the Cairo renderer
Cairo can do that, so just enable it:

 * Create surfaces with the correct fractionally scaled size.
 * Set the Cairo surface's device scale to that number.
2023-04-01 20:05:06 +02:00
Benjamin Otte
84b235aac1 wayland: Allow creating fractional Cairo surfaces
We don't do that yet, because the buffer scale code can't deal with it,
but we can do it now.
2023-04-01 20:05:05 +02:00
Benjamin Otte
1a71e82fc5 wayland: Use wp_viewport to set buffer scale
Instead of setting the buffer scale via the buffer-scale command, set it
via the viewport.

This technically allows setting fractional scales, but we're not doing
that.
2023-04-01 20:05:01 +02:00
Benjamin Otte
8dd5d649b8 wayland: Use GdkFractionalScale for surface scale
We still always round it to integers when we read it, but we store it as a fraction.

So we could now use it for fractional scaling.
2023-04-01 18:23:38 +02:00
Benjamin Otte
40ac6f22a3 wayland: Introduce GdkFractionalScale type
We want to use it later for various things, this just adds the
infrastructure we will need.
2023-04-01 18:23:38 +02:00
Matthias Clasen
ffdbb9077c wayland: Some debug spew tweaks 2023-04-01 09:31:12 -04:00
Benjamin Otte
54e8bd898a wayland: Add support for the fractional scale protocol
April fools!

No, really.
The fractional scale protocol is just a way to track the surface scale,
but not a way to draw fractional content.
This commit uses it for that, so tht we don't rely on tracking outputs.

This also allows magnifiers etc to send us a larger (integer) scale if
they would like that, that is not represented by the outputs.
2023-04-01 12:57:03 +02:00
Benjamin Otte
b4492a97bf wayland: Use wl_seat_get_version() 2023-04-01 02:22:21 +02:00
Benjamin Otte
6f93f52b56 wayland: Use zwp_pointer_gestures_v1_get_version() 2023-04-01 02:22:21 +02:00
Benjamin Otte
68b8c5cd99 wayland: Use gtk_shell1_get_version()
... or correct gtk_surface1_get_version() alternative.
2023-04-01 02:22:21 +02:00
Benjamin Otte
9d99259cbd wayland: Use wl_data_device_manager_get_version() 2023-04-01 02:22:21 +02:00
Benjamin Otte
55b5c847f7 wayland: Use zxdg_output_manager_v1_get_version() 2023-04-01 02:22:21 +02:00
Benjamin Otte
3d3d22e844 wayland: Remove unused variable
Also, Wayland has get_version() functions, so if we ever need it, we can
use that.
2023-04-01 02:22:21 +02:00
Benjamin Otte
ae2c28af89 wayland: Check correct interface
buffer scale is a surface property, so check the version of the surface
interface, not the compositor one.
2023-04-01 02:22:21 +02:00
Benjamin Otte
c7499a33fd wayland: Use wl_compositor_get_version()
Wayland has functions to check versions, so use those.
2023-04-01 02:22:21 +02:00