Commit Graph

2950 Commits

Author SHA1 Message Date
Benjamin Otte
c7b62d89e3 glx: Implement support for EXT_swap_control
XWayland (at least on gnome-shell) does not support SGI_swap_control,
which we were using to unset the swap interval.

It does support EXT_swap_control though, which is the more modern
version of the same thing, so this commit adds support for that.

And now GDK_DEBUG=no-vsync gives me >1000fps instead of just 60fps,
2023-05-24 21:44:43 +02:00
Benjamin Otte
7573a9d2a7 gl: Rewrite update area tracking code
Make it more generic. That way we could dynamically change the number of
buffers we track.

We don't do that yet though.
2023-05-24 21:44:29 +02:00
Matthias Clasen
e5f1e4545d gdk: Change the private export handle api
Make unexport_handle take the handle, so we
can in the future deal with multiple exports.

Update the one caller in gtkwindow.c to pass
the handle.
2023-05-14 23:49:44 -04:00
Matthias Clasen
2cd5b4df1b Add missing va marshallers
Whenever we pass a marshaller to g_signal_new,
call g_signal_set_va_marshaller with the corresponding
va marshaller.
2023-05-13 12:38:24 -04:00
Benjamin Otte
6cc1548c5f Merge branch 'wip/carlosg/x11-artifacts' into 'main'
gdk/x11: Invalidate whole surface after size change

See merge request GNOME/gtk!5857
2023-04-29 18:11:21 +00:00
Carlos Garnacho
24302315fb gdk/x11: Invalidate whole surface after size change
The Expose events following a ConfigureNotify may arrive at
a time that we did not resize the surface yet, making these
expose events a no-op. Even though gsk/gtk take care of the
window content itself, this might lead to unrendered portions
of the window shadow.

This may be seen with GSK_RENDERER=cairo and GDK_BACKEND=x11,
attempting to tile a window (e.g. gtk4-demo) left or right.
The window will show black rectangles or other artifacts in
the window shadow areas that correspond to the newly painted
portions (as the window needs to expand vertically).

In order to fix this with a similar behavior to Wayland,
consider ourselves the whole surface invalidated after resize,
in order to ensure everything is painted from scratch.
2023-04-29 11:51:32 +02:00
Benjamin Otte
5f833f1d31 glcontext: Compute matching version the simple way
Do it all in one function instead of requiring two different ones.
2023-04-27 02:13:32 +02:00
Benjamin Otte
ab2a548479 glx: Make sure highest possible GL version is created
Mirror EGL here.
2023-04-27 02:13:32 +02:00
Benjamin Otte
f86429177a gdk: Introduce GdkGLVersion
... and use it.

Makes the code simpler.
2023-04-27 02:13:32 +02:00
Benjamin Otte
9d0448756f display: Remove ::create_surface() vfunc
Instead, have a toplevel_type and popup_type in GdkDisplay and
call g_object_new() with those types.
2023-04-26 21:03:34 +02:00
Benjamin Otte
cb642bec25 gdk: Remove GDK_SURFACE_DRAG enum member
I want to remove the whole enum, but this value was used all over the
place. So removing it first ensures I didn't forget anything.
2023-04-26 21:03:34 +02:00
Benjamin Otte
486196c979 x11: Add private gdk_x11_drag_surface_new()
... and use it.
2023-04-26 21:03:34 +02:00
Benjamin Otte
83faacabe3 x11: Set frame clock in ::constructed 2023-04-26 21:03:34 +02:00
Benjamin Otte
31aae62f9a x11: Move window construction to ::constructed() 2023-04-26 21:03:34 +02:00
Benjamin Otte
cbe89b955a x11: Get rid of sizes when constructing surfaces
Just call XCreateWindow with 0, 0, 1, 1 size.
2023-04-26 21:03:34 +02:00
Benjamin Otte
2d827978a6 x11: Remove unused variable 2023-04-26 21:03:34 +02:00
Benjamin Otte
7ef5f6ef1a display: Remove x/y/w/h from create_surface() 2023-04-26 21:03:34 +02: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
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
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
Matthias Clasen
a1c5a806b3 Convert headers to #pragma once
The conversion was done by guard2one.
2023-03-31 15:11:10 -04:00
Ivan Molodetskikh
11d9bbfd6e x11/surface: Get current drag surface size with compute-size signal
Query and update size of drag surfaces, similarly to how it's done for
the Wayland backend in the previous commit.
2023-03-14 19:41:44 -07:00
Matthias Clasen
5cca7488d4 x11: Stop using g_slice 2023-03-14 14:56:42 -04:00
Jonas Ådahl
f2a0a8b8be x11/surface: Clear compute_size idle source also when destroying
Doing it on hide() is not enough, since in some edge cases we didn't
ever actually map, we just attempted to compute the size, e.g. in
response to a ConfigureNotify event, then the window was destroyed.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2678
2023-03-10 23:34:50 +01:00
Carlos Garnacho
ae94417f80 gdk/x11: Also grab keyboard during XDnD grabs
The drag source must handle events and messaging, this also
includes keyboard handling for accessibility and cancellation.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5604
2023-02-18 23:02:22 +01:00
Carlos Garnacho
824e983372 gdk/x11: Reset all scroll valuators on enter
We no longer need to make much distinction between multiple logical
devices, plus it breaks esp. with the Xwayland input device distribution.
Just iterate across all devices and reset their scroll valuators.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4160
2023-02-04 13:13:19 +01:00
Benjamin Otte
c17049c6d1 Merge branch 'wip/otte/gl-is-current' into 'main'
gdk: Add private GLContext::is_current() check

Closes #5392

See merge request GNOME/gtk!5463
2023-02-02 21:56:32 +00:00
Matthias Clasen
8796950651 Deprecate more startup-notification API 2023-02-02 08:30:32 +01:00
Benjamin Otte
c6cef6db52 gdk: Add private GLContext::is_current() check
... and use this check in gdk_gl_context_make_current() and
gdk_gl_context_get_current() to make sure the context really is still
current.

The context no longer being current can happen when external GL
implementations make their own contexts current in the same threads GDK
contexts are used in.
And that can happen for example by WebKit.

Theoretically, this should also allow external EGL code to run in X11
applications when GDK chooses to use GLX, but I didn't try it.

Fixes #5392
2023-02-02 04:23:51 +01:00
Matthias Clasen
746d12fc43 Silence a compiler warning
Clang was complaining that we never use the
value stored in mime_type. Just don't store it,
we are only interested in the side-effect
(interning the string).
2023-01-13 12:07:40 -05:00
Matthias Clasen
0073bb79a7 Deprecate gdk_display_put_event
The documentation already tells you not to
use this function.

Ifdef the remaining users in the X11 backend.
2023-01-09 15:46:25 -05:00
Matthias Clasen
8349ae2bc4 x11: Make a call NULL-safe
Make it safe to call gdk_x11_app_launch_context_get_startup_notify_id
with a NULL info.
2023-01-04 16:37:31 -05:00
Carlos Garnacho
7fab1b85ad gdk/x11: Emit "remove" s-n message from gdk_toplevel_set_startup_id
In the way towards deprecating gdk_display_notify_startup_complete(),
make gdk_toplevel_set_startup_id() on X11 perform this piece of messaging
itself. It should be harmless that the message is emitted twice, if
callers do still use that API.
2023-01-03 14:58:25 +01:00
Carlos Garnacho
c24358cfbc gdk/x11: Clear all data in GdkSurfaceX11 finalization
Currently, the GdkSurfaceX11 implementation relies that the upper
layers hid the surface before destruction, and that no
GdkSurfaceClass.compute_resize happened between them. If these
circumstances happened, there would be a compute_size timeout left
dangling after the surface got destroyed, poking at incorrect data
later on. Something that looks like this was reported in the
recent mutter-x11-frames "SSD frames server":

    mutter-x11-frames:423016): GLib-GObject-WARNING **: 19:41:16.869: invalid unclassed pointer in cast to 'GtkWindow'

    Thread 1 "mutter-x11-fram" received signal SIGTRAP, Trace/breakpoint trap.
    g_logv (log_domain=0x7ffff7f7c4f8 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=<optimized out>) at ../../../glib/gmessages.c:1433
    1433	../../../glib/gmessages.c: No such file or directory.
    (gdb) bt
    #0  g_logv (log_domain=0x7ffff7f7c4f8 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=<optimized out>) at ../../../glib/gmessages.c:1433
    #1  0x00007ffff73470ff in g_log (log_domain=log_domain@entry=0x7ffff7f7c4f8 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x7ffff7f84da8 "invalid unclassed pointer in cast to '%s'")
        at ../../../glib/gmessages.c:1471
    #2  0x00007ffff7f72892 in g_type_check_instance_cast (type_instance=type_instance@entry=0x5555558e04b0, iface_type=<optimized out>) at ../../../gobject/gtype.c:4144
    #3  0x00007ffff791e77d in toplevel_compute_size (toplevel=<optimized out>, size=0x7fffffffe170, widget=0x5555558e04b0) at ../../../gtk/gtkwindow.c:4227
    #4  0x00007ffff7f4f3b0 in g_closure_invoke (closure=0x555555898cc0, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7fffffffdeb0, invocation_hint=invocation_hint@entry=0x7fffffffde30)
        at ../../../gobject/gclosure.c:832
    #5  0x00007ffff7f62076 in signal_emit_unlocked_R
        (node=node@entry=0x55555588feb0, detail=detail@entry=0, instance=instance@entry=0x55555560e990, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffdeb0)
        at ../../../gobject/gsignal.c:3796
    #6  0x00007ffff7f68bf5 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffe050) at ../../../gobject/gsignal.c:3549
    #7  0x00007ffff7f68dbf in <emit signal ??? on instance 0x55555560e990 [GdkX11Toplevel]> (instance=<optimized out>, signal_id=<optimized out>, detail=detail@entry=0) at ../../../gobject/gsignal.c:3606
    #8  0x00007ffff7a8de96 in gdk_toplevel_notify_compute_size (toplevel=<optimized out>, size=size@entry=0x7fffffffe170) at ../../../gdk/gdktoplevel.c:112
    #9  0x00007ffff7a4b15a in compute_toplevel_size (surface=surface@entry=0x55555560e990 [GdkX11Toplevel], update_geometry=update_geometry@entry=1, width=width@entry=0x7fffffffe220, height=height@entry=0x7fffffffe224)
        at ../../../gdk/x11/gdksurface-x11.c:281
    #10 0x00007ffff7a4c3b2 in compute_size_idle (user_data=0x55555560e990) at ../../../gdk/x11/gdksurface-x11.c:356
    #11 0x00007ffff733f67f in g_main_dispatch (context=0x55555563f6e0) at ../../../glib/gmain.c:3444
    #12 g_main_context_dispatch (context=context@entry=0x55555563f6e0) at ../../../glib/gmain.c:4162
    #13 0x00007ffff733fa38 in g_main_context_iterate (context=0x55555563f6e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../glib/gmain.c:4238
    #14 0x00007ffff733fcef in g_main_loop_run (loop=loop@entry=0x5555560874a0) at ../../../glib/gmain.c:4438
    #15 0x0000555555557de0 in main (argc=<optimized out>, argv=<optimized out>) at ../src/frames/main.c:68

It perhaps makes sense to warn in these situations, but either way
it sounds like gdk_surface_x11_finalize() could enforce the correct
behavior by ensuring there is no dangling timeouts/data. This commit
does that.
2022-12-07 13:16:36 +01:00
Luca Bacci
f788e994a9 GLX: Add extra glXMakeContextCurrent () call to work around a DRI issue
Reference: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7808

Fixes #4499, #5387, #5170
2022-12-02 14:20:43 +01:00
Matthias Clasen
fe56f3413a Don't emit ::notify from a getter
GdkX11Keymap ddetermines the direction of the
keymap on demand, and was emitting notify::direction
2022-11-26 21:53:33 -05:00
Matthias Clasen
2bab8cca5f gdk: Rename GDK_SURFACE_TEMP
We use this value only for drag surfaces, so call it that.
2022-11-17 22:49:56 -05:00
Matthias Clasen
b12d31d189 Fix spelling errors
These were pointed out by codespell.
2022-11-17 22:49:45 -05:00
Matthias Clasen
1c99ed542a Add gdk_toplevel_export_handle
This code is backend-specific, and should not live
in gtkwindow.c.
2022-11-09 16:28:29 +01:00
Luca Bacci
ac60bc6095 X11: Provide settings in logical pixels
This makes GtkSettings values on X11 match what we get on
other backends.

Reporting size settings in logical pixels (i.e for scale
== 1) is useful for properly supporting mixed-DPI setups.
As X11 doesn't support mixed-DPI setups anyway, XSettings
doesn't bother providing logical values. Thus we scale
from physical to logical values ourselves.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5223
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/5230
2022-11-01 13:09:28 +01:00
Luca Bacci
995f00d23f Merge branch 'forward-port-mr-991-to-gtk4-2' into 'main'
Use native Windows API for converting keystrokes to characters

Closes #2944

See merge request GNOME/gtk!4986
2022-10-17 19:20:08 +00:00
Philip Zander
c84c469b78 Use native Windows API for converting keystrokes to characters 2022-10-17 19:36:48 +02:00
Matthias Clasen
4aabc45685 Drop gdkintl.h
This header was merely including gi18n-lib.h.
Just do that directly.
2022-09-23 23:33:42 -04:00
Matthias Clasen
a8af7caae1 Rename gdk-private.h to gdkprivate.h
The extra - does not add any value.
2022-09-23 23:23:27 -04:00
Matthias Clasen
c24a69549d Rename gdkdebug.h to gdkdebugprivate.h
This is the naming convention for private headers.
2022-09-23 23:12:01 -04:00
Matthias Clasen
ce4c2154f4 x11: Use the new debug macros 2022-09-23 18:11:48 -04:00
Matthias Clasen
8bd3ec2ba1 Make the gl-legacy debug flag always available
No need to restrict this to debug builds.
2022-09-21 21:09:08 -04:00
Matthias Clasen
a99b05525d Make the nograbs flag always available
No need to restrict this to debug builds.
2022-09-21 20:53:46 -04:00
Matthias Clasen
183709c522 Fix default-settings handling
This is meant to be always available, but we
were checking for debug in one place.
2022-09-21 20:45:43 -04:00