Commit Graph

2834 Commits

Author SHA1 Message Date
Benjamin Otte
82eb947f41 x11: Remove glx version check
We only work with GLX >= 1.3 anyway, so don't explicitly check for it
and pretend to do something else that doesn't work otherwise.
2021-07-22 16:06:06 +02:00
Benjamin Otte
485dae9f25 x11: Remove unused struct member
We don't care if the GL context is direct at all.
2021-07-22 16:06:06 +02:00
Benjamin Otte
eb3423312f Revert "x11: Always fall back to GLX on NVIDIA"
This reverts commit c35a6725b9.

This approach doesn't work because if NVIDIA doesn't work for EGL, the
EGL implementation won't be provided by NVIDIA, so checking the vendor
doesn't work.
2021-07-22 16:06:06 +02:00
Benjamin Otte
04c2093d5c x11: Remove the dummy surface
Instead, use the display's "leader surface" when no surface is required,
because we have it lying around.

Really, we want to use EGL_NO_SURFACE, but if that's not supported...
2021-07-22 16:06:06 +02:00
Benjamin Otte
ccd5992a83 x11: Remove GdkVisual
It's not used anymore.
2021-07-22 16:06:06 +02:00
Benjamin Otte
ca8d9fbe0b x11: Rework Visual selection
Instead of going via GdkVisual, doing a preselection and letting the GL
initialization improve it, let the GL initialization pick an X Visual
directly using X Visual code directly.

The code should select the same visuals as before as it tries to apply
the same logic, but it's a rewrite, so I expect I messed something up.
2021-07-22 16:06:06 +02:00
Benjamin Otte
62bac44a21 glx: Remove Visual cache
1. We're using EGL most of the time anyway, so if we wanted to cache
   things, we'd need to port it there.
2. Our GL handling is massively configurable, so determining when to use
   the cache and when not is a challenge.
3. It makes startup nondeterministic and depend on whether a GTK4 app
   has previously been started on this display and nobody thinks about
   that when debugging.
4. The only benefit of the caching is delaying GL initialization - which
   made sense in GTK3 where almost no app used GL but doesn't make sense
   in GTK4 where almost every app uses GL.

So unless I find a big benefit to reintroducing it, this cache will be
gone for good.
2021-07-22 16:06:05 +02:00
Benjamin Otte
0ddd06113d x11: Move GL init code into the GL context
No functional changes, just shuffling code.
2021-07-22 16:06:05 +02:00
Benjamin Otte
b1fbc2ef24 x11: Store the EGL surface in the GdkSurfaceX11
Avoids having to use private data, though the benefit is somewhat
limited as we still have to put the destructor in the egl code and can't
just put it in gdk_surface_x11_finalize().
2021-07-22 16:06:05 +02:00
Benjamin Otte
c787fe7ecb x11: Store the EGL config in the display
We only have one config, because we use the same Visual everywhere.
Store this config in the GdkDisplayX11 struct for easy access.

Also do this on initialize, because if creating the config fails, we
want to switch to GLX instead of failing to do GL at all.

This also simplifies a lot of code as we can share Visual, Colormap, etc
across surfaces.
2021-07-22 16:06:05 +02:00
Benjamin Otte
bdb49720be x11: Move the EGL display into the private struct
There's no need to use g_object_set_data() for it.

We can also stop caching it elsewhere because we know the display has
it.

And finally, we can remove the display->have_egl boolean and use
display->egl_display != NULL instead. We initialize the display at
startup, so that variable is the perfect indicator.
2021-07-22 16:06:05 +02:00
Benjamin Otte
1d448a2b8a x11: Pass the display, not the screen
Screens are on their way out.
2021-07-22 16:06:05 +02:00
Benjamin Otte
c5df081904 x11: Simplify code
These variables were a lot more important in GTK3, but now we just want
to pass them through to X.
2021-07-22 16:06:05 +02:00
Benjamin Otte
8a2f3e1fe5 x11: Move function call
The GLX visual selection is GLX specific, so it can be handled by the GLX
code.

There should be no reordering here, the call was just moved.
2021-07-22 16:06:05 +02:00
Benjamin Otte
8dfc627e46 glx: Don't initialize GLX multiple times.
Either it is initialized or it isn't.
2021-07-22 16:06:05 +02:00
Benjamin Otte
0fce30070f x11: Initialize GL at startup
We need to initialize GL to select the Visual we are going to use for
all our Windows.

As the Visual needs to be known before we know if we are even gonna use
GL later, we can't avoid initializing it.

Note that this previously happened, too. It was just hidden behind the
GdkScreen initialization.
2021-07-22 16:06:05 +02:00
Benjamin Otte
8bfe82f686 x11: Don't share cached GLX visuals with GTK3
We don't want to bind ourselves to GTK3 - both because we don't want to
accidentally cause bugs in a different codebase and because we want to
deviate from it.

While doing so, also store visuals as visuals and not as integers.
And only store one Visual because GTK4 only uses one visual.

And then remove the code that is leftover for dealing with the
compatibility Visual for GTK3.

PS: I'm kinda proud of my STRINGIFY_WITHOUT_BRACKETS hack.
2021-07-22 16:06:05 +02:00
Benjamin Otte
7d32ec51e7 x11: Reorder code
Initialize the GL visuals from gdkdisplay.c so the call into the GL
stack isn't hidden in gdkvisual.c

This is relevant for further commits.
2021-07-22 16:06:05 +02:00
Benjamin Otte
5784f8c2f9 x11: Stop reordering visuals
The old code was ordering visuals by depth, but considering that these
days we either use the default visual or a 32bit RGBA visual, that
reordering does not have an effect anymore.

In theory, the only effect is that the GLX Visual selection might select
a different replacement Visual when it checks for improved GL Visuals, but
even there I can't come up with a case where that matters, because
again, the visuals are only reordered by depth and we want to keep the
depth.

In any case, make this a separate commit so bisecting can find this
problem if it ever shows up.
2021-07-22 16:06:05 +02:00
Benjamin Otte
74e01ddec5 x11: Remove unused function
Now that we can't create extra GdkX11Screens anymore, this also means
that there is exactly 1 GdkX11Screen per GdkX11Display.
2021-07-22 16:06:05 +02:00
Benjamin Otte
1347573139 x11: Move code where it belongs
Instead of the display telling the screen to tell the visuals to tell
the display to initialize itself, just init the display directly.

What a concept.
2021-07-22 16:06:05 +02:00
Benjamin Otte
0ae2acfb1a x11: Remove XComposite
It's only used during DND to allow use of the root window's cow window
as a DND target, because apparently gnome-shell used to think that was a
great idea to DND to the overview.

Somebody complain to gnome-shell devs about it not being a good idea if
they want it fixed.
Potentially using Wayland is a better idea though.

This reverts 85ae875dcb

Related: https://bugzilla.gnome.org/show_bug.cgi?id=601731
2021-07-20 14:00:25 -04:00
Benjamin Otte
afc5f46ca9 x11: Remove unused headers 2021-07-20 14:00:25 -04:00
hudeng
fd0d3283e0 gdk: fix gtk app startup with 'g_value_set_boxed: assertion G_VALUE_HOLDS_BOXED (value) failed error message' when xsettings use 'XSETTINGS_TYPE_COLOR' type 2021-07-02 17:23:56 +08:00
Matthias Clasen
80c33ca2dd Merge branch 'wip/otte/for-master' into 'master'
x11: Be more careful with NVIDIA workaround

See merge request GNOME/gtk!3620
2021-06-02 14:57:52 +00:00
Matthias Clasen
fff2b3c710 gdk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Benjamin Otte
5af6c37f8c x11: Be more careful with NVIDIA workaround
Check that we are indeed running inside an Xorg server before enabling
the workaround.

XWayland or other nested X servers deadlock when that workaround is
applied.
2021-05-22 01:43:31 +02:00
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Emmanuele Bassi
b3d6928f35 x11: Pair eglInitialize with eglTerminate
If we bail out after EGL initialization we want to go back to a stable
state and not leave EGL hanging.
2021-05-13 18:23:50 +01:00
Emmanuele Bassi
3d8ba93f59 x11: Loosen the match for the NVIDIA driver
It seems nVidia puts a different string in the GL_VENDOR than the one it
uses for GLX.
2021-05-13 18:22:30 +01:00
Emmanuele Bassi
abc2d7e4a9 x11: Add EGLDisplay getter
Getting an EGLDisplay object is messy; might as well expose the function
we use internally to save some time.
2021-05-11 12:42:16 +01:00
Emmanuele Bassi
69856a9aac x11: Don't update GLX visuals with EGL
We're going to get into a messy situation, with both GLX and EGL
initialized.

If we're already using EGL, skip the whole cache.
2021-05-10 21:19:14 +01:00
Emmanuele Bassi
c35a6725b9 x11: Always fall back to GLX on NVIDIA
At least until we can guarantee that EGL-X11 works fine there.
2021-05-10 20:44:35 +01:00
Emmanuele Bassi
a57f79006a x11: Move the damage fences into the GLX code
It's GLX-specific anyway, there's no need to complicate things by having
half the code in the generic path, and half in the GLX one.
2021-05-10 20:44:35 +01:00
Emmanuele Bassi
6600b0b507 x11: Add debug toggle for preferring GLX
Mostly as a way to compare the EGL and GLX implementations.
2021-05-10 20:44:35 +01:00
Emmanuele Bassi
9a19e3c741 x11: Add profiler marks for SwapBuffers 2021-05-10 20:44:35 +01:00
Emmanuele Bassi
8924d614c0 x11: Use EGL for GL support
This makes the X11 backend similar to the Wayland one, when it comes to
OpenGL.

Fall back to GLX only if EGL support is not available.
2021-05-10 20:44:35 +01:00
Emmanuele Bassi
03f76eccf5 x11: Decouple GLX from GdkX11GLContext
If we want to add an EGL implementation for the X11 backend, we are
going to need to move the GLX bits into their own class. The first step
is to declare GdkX11GLContext as an abstract type, and then subclass it
into a GdkX11GLContextGLX type, which includes the whole GLX
implementation.
2021-05-10 20:44:35 +01:00
Carlos Garnacho
081e127377 gdk/x11: Ensure to map the non-ewmh moveresize emulation window before use
Otherwise, we don't deem it as able to be grabbed, which we intend to do
immediately after.
2021-05-07 15:51:52 +02:00
Dan Cîrnaț
13b94dab10 Conditional check for gdesktopappinfo header
GDesktopAppInfo is not available on macOS and needs to be disabled
2021-05-06 10:38:41 +02:00
Matthias Clasen
e2722f03ac x11: A few static analysis fixes 2021-05-03 07:44:38 -04:00
Matthias Clasen
f37662c655 x11: Try harder to find the right monitor
If we deal with a panel, we end up with no monitor,
and crash, which isn't great and isn't necessary.

Fixes: #3900
2021-04-26 23:20:10 -04:00
Matthias Clasen
142984cbf7 Merge branch 'untrusted-beep' into 'master'
x11: Don't beep on untrusted displays

Closes #3862

See merge request GNOME/gtk!3463
2021-04-21 10:12:39 +00:00
Matthias Clasen
5587ee0c30 x11: Don't beep on untrusted displays
This can trigger BadAccess, and we don't
want that.

Fixes: #3862
2021-04-20 21:42:57 -04:00
Matthias Clasen
ce2a433ca1 Fix a possible crash in gtk_show_uri
g_file_get_basename can return NULL.
Deal with it somehow.

Fixes: #3883
2021-04-19 16:49:02 -04:00
Matthias Clasen
6f11165dd1 x11: Be quiet on exit by default
The condition we check for to catch X servers going away
may not be accurate anymore, and the warning shows up in
logs, causing customers to be concerned. So, be quiet by
default, unless the user explicitly asked for a message.
2021-04-13 14:52:48 -04:00
Olivier Fourdan
80ba38a0b3 x11/dnd: Ignore XErrors from the COW
The DnD code for X11 adds the composite overlay window (aka COW) to the
cache.

Yet the X11 requests to get and release the COW may trigger XErrors that
we ought to ignore otherwise the client will abort.

Fixes: #3715
2021-03-22 15:38:58 +01:00
Kjell Ahlstedt
0f6b91109e gdkglcontext-x11: Don't assume that cairo-xlib.h is in cairo directory
If cairo is a subproject, it's not necessarily installed when gtk
is built. In the source tree, cairo's headers are not stored in
a directory called 'cairo'.
2021-03-16 11:47:16 +01:00