Commit Graph

10250 Commits

Author SHA1 Message Date
Vincent Bernat
2ebde276d1 x11: ensure WM class is not null even if display is initialized early
With gtkmm, when using `Application()`, the display is initialized
before we know the application name and therefore, the program class
associated to the display is NULL.

Instead of providing a default value, we set it equal to program name
when NULL. Moreover, we give up on capitalizing the class name to keep
the code super simple. Also, not using a capitalized name is
consistent with `gdk_x11_display_open()`. If someone has a good reason
to use a capitalized name, here is how to do it.

```c
  class_hint = XAllocClassHint ();
  class_hint->res_name = (char *) g_get_prgname ();
  if (display_x11->program_class)
    {
      class_hint->res_class = (char *) g_strdup (display_x11->program_class);
    }
  else if (class_hint->res_name && class_hint->res_name[0])
    {
      class_hint->res_class = (char *) g_strdup (class_hint->res_name);
      class_hint->res_class[0] = g_ascii_toupper (class_hint->res_class[0]);
    }
  XSetClassHint (xdisplay, impl->xid, class_hint);
  g_free (class_hint->res_class);
  XFree (class_hint);
```

Fix eff53c023a ("x11: set a default value for program_class")
2021-08-10 09:14:36 +02:00
Chun-wei Fan
8acce5f294 gdk/win32: Drop local DnD protocol
It is basically not used by default and is pretty much broken at this point, so
it's about time to drop it.

Let's focus on fixing the OLE2 DnD protocol.
2021-08-06 17:16:27 +08:00
Matthias Clasen
2a528df977 Merge branch 'titlebar-gesture' into 'master'
Delegate titlebar action to the compositor if possible

See merge request GNOME/gtk!3797
2021-08-02 01:14:08 +00:00
Vincent Bernat
eff53c023a x11: set a default value for program_class
This was also the behaviour with GTK 3. We use the capitalized program
name.

Fixes #4138

Signed-off-by: Vincent Bernat <vincent@bernat.ch>
2021-07-30 23:22:32 +02:00
Florian Müllner
0c7b1431d7 gdk/toplevel: Add gdk_toplevel_titlebar_gesture()
Where supported, this allows delegating the titlebar action to the
compositor instead of trying to replicate its behavior client-side.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602
2021-07-29 21:39:32 +02:00
Matthias Clasen
cc6ecc8b62 Merge branch 'source-static-name' into 'master'
Avoid copying static debug strings

See merge request GNOME/gtk!3789
2021-07-29 11:59:02 +00:00
Matthias Clasen
19b534f7de Avoid copying static debug strings
The g_source_set_name calls were showing up as a
major source of strdups in our profiles. Avoid that
by using new GLib api when available.
2021-07-28 22:42:46 -04:00
Marc-André Lureau
1b080826db gdk: add missing Since annotation
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-07-27 21:01:31 +04:00
Matthias Clasen
910f23ea19 Merge branch 'wip/otte/widgetfactory-dnd' into 'master'
Improve DND

See merge request GNOME/gtk!3785
2021-07-27 04:12:58 +00:00
Benjamin Otte
131be5f2e8 contentformats: Add gdk_content_formats_parse() 2021-07-27 04:13:42 +02:00
Benjamin Otte
6a5d555f58 contentformats: Change the format of gdk_content_formats_to_string()
Now, we just print a whitespace-separated list of GTypes and mime types.

This makes this neat for 2 things:

1. Parsing it (see next commit)
2. Using it in GtkBuilder (see commits after that)

In particular, the common case of supporting a single GType (or mime
type) looks like just printing the GType (or mime type), which in
GtkBuilder looks like
<property name="formats">GdkTexture</property>
2021-07-26 02:28:49 +02:00
Benjamin Otte
f5dc71021f dnd: Guard drags with a reference when finishing
Usually the "dnd-finished" signal will be used to unref the GdkDrag. In
those cases, we would lose the object, so that when we do the final
drag_drop_done() afterwards, we wouldn't have a remaining reference.

With the reference guard, this now works.
2021-07-26 02:18:54 +02:00
Emmanuele Bassi
527b2c5ab1 Merge branch 'no-pposition' into 'master'
gdk/x11: Do not set PPosition hint

See merge request GNOME/gtk!3781
2021-07-24 11:45:00 +00:00
Florian Müllner
4d0c2997cf gdk/x11: Do not set PPosition hint
It is good practice for (floating) window managers to respect explicit
position hints from clients (as long as the window wouldn't end up
off-screen etc.).

Before commit 13d3afa56e, GTK had a flag for setting the PPosition hint,
but now does so unconditionally. However the real intention is to *not*
request a fixed position, so don't do that.
2021-07-24 06:32:16 +02:00
Matthias Clasen
fce23c981b Add more sysprof marks
Add a few more marks during gtk_init to figure out where
our startup time goes, and avoid the sysprof initialization
from distorting the first mark.
2021-07-22 14:47:02 -04:00
Benjamin Otte
620ccdabb5 glx: Get rid fo DrawableInfo
Store the frame counter in the surface, where it belongs.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
4b12dc6547 gdkdisplay-win32.c: Don't call ReleaseDC() unnecessarily
The dummy Win32 window that we use to capture display change events and
to create dummy WGL contexts was created with CS_OWNDC, so we really do
not need to (and should not) call ReleaseDC() on the HDC that we
obtained from it, so drop these calls.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
bd69d7e23f GDK-Win32: init_gl(): Default to WGL for now
Since the shaders need to be updated for using with GLES (libANGLE at
least), default to WGL for now.  Unfortunately it is not that common for
Windows to have GLES support, in which the easiest way to obtain such
support is via Google's libANGLE.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
8648486400 GDK-Win32: Fixup, and cleanup WGL HDC handling
It turns out that the problem of the WGL window not drawing was due to
the fact that I messed up where I placed SwapBuffers() during the
conversion... doh:|

At the same time, stop storing the HDC in the GdkWin32GLContextWGL, but
instead always create it along the surface we created, so that it is ready
for use for operating with WGL when we are not dealing with "surfaceless"
contexts.  If we are dealing with "surfaceless" contexts, just use the
HDC of the dummy window that we created when we created the
Gdk(Win32)Display.

WGL contexts should now be in working order at this point.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
6c00117119 Split out WGL/EGL stuff and simplify things
This commit attempts to split GdkWin32GLContext into two parts, one for
WGL and the other for EGL (ANGLE), and attempts to simplify things a
bit, by:

*  We are already creating a Win32 window to capture display changes,
   so we can just use that to act as our dummy window that we use to
   find out the pixel format that the system supports for WGL.  We also
   use it to obtain the dummy legacy WGL context that we will always
   require to create our more advanced Core WGL contexts.

*  Like what is done in X11, store up the WGL pixel format or the
   EGLConfig in our GdkWin32Display.

*  Ensure we do not create the dummy WGL context unnecessarily.

In this way, we can successfully create the WGL/EGL contexts, however
there are some issues at this point:

*  For WGL, the code successfully initializes and realizes the WGL
   Contexts, but for some reason things became invisible.  When running
   gtk4-demo, this can be verified by seeing the mouse cursor changing
   when moved to spots where one can resize the window, although they
   were invisible.

*  For EGL, the code initializes EGL but could not realize the EGL
   context as shaders failed to compile.  It seems like the shader issue
   is definitely outside the scope of this MR.
2021-07-22 16:28:16 +02:00
Benjamin Otte
9c4c4eaaa1 gl: Fix issue with EGL + nvidia
nvidia sets the default draw buffer to GL_NONE if EGL contexts are
initially bound to EGL_NO_SURFACE which is exactly what we are doing. So
bind them to GL_BACK when drawing, as they should be.

See https://phabricator.services.mozilla.com/D118743 for a discussion
about EGL_NO_CONTEXT and draw buffers.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
969b3257a7 GDK: Add debug option for WGL usage
This way, one can force using WGL on Windows even if EGL support was
enabled.  Also update the help text for gl-egl as it will apply for
Windows, albeit a bit later.
2021-07-22 16:28:16 +02:00
Chun-wei Fan
65c6af31e1 GDK-Win32: Move some functions out of gdkglcontext-win32.c
We want these to be out of the way as we split between WGL and EGL/ANGLE
GL contexts, so that they don't get in the way.
2021-07-22 16:28:16 +02:00
Benjamin Otte
6b8bc83420 display: Move GL selection code into gdkdisplay-x11.c
This has the benefit that we can refactor it and make sure we deal with
GdkDisplay::init_gl() not being called at all because
GDK_DEBUG=gl-disable had been specified.
2021-07-22 16:28:16 +02:00
Benjamin Otte
30aaab5c6c x11: Move code from GdkGLContextX11
It's not used there, but both backends have independent
immplementationgs for it.

I want to get rid of GdkGLContextX11 and moving code from it is the
first step.
2021-07-22 16:28:16 +02:00
Benjamin Otte
e06e0e8555 gdk: Move GL context construction to GdkGLContext
Now that we have the display's context to hook into, we can use it to
construct other GL contexts and don't need a GdkSurface vfunc anymore.

This has the added benefit that backends can have different GdkGLContext
classes on the display and get new GLContexts generated from them, so
we get multiple GL backend support per GDK backend for free.

I originally wanted to make this a vfunc on GdkGLContextClass, but
it turns out all the abckends would just call g_object_new() anyway.
2021-07-22 16:27:32 +02:00
Benjamin Otte
9f1d6e1f44 gl: Move vfunc
Instead of
  Display::make_gl_context_current()
we now have
  GLContext::clear_current()
  GLContext::make_current()

This fits better with the backends (we can actually implement
clearCurrent on macOS now) and makes it easier to implement different GL
backends for backends (like EGL/GLX on X11).

We also pass a surfaceless boolean to make_current() so the calling code
can decide if a surface needs to be bound or not, because the backends
were all doing whatever, which was very counterproductive.
2021-07-22 16:27:32 +02:00
Benjamin Otte
15ed1a329e gl: Require EGL_KHR_surfaceless_context with egl
The code to create and manage a fake egl surface to bind to is
complex and completely untested because everyone seems to support this
extension.

nvidia and Mesa do support it and according to Mesa devs, adding support
in a new driver is rather simple and Mesa drivers gain that feature
automatically, so all future drivers shoould have it.
2021-07-22 16:27:31 +02:00
Benjamin Otte
505436340b gdk: Get rid of paint contexts
... or more exactly: Only use paint contexts with
gdk_cairo_draw_from_gl().

Instead of paint contexts being the only contexts who call swapBuffer(),
any context can be used for this, when it's used with
begin_frame()/end_frame().

This removes 2 features:

1. We no longer need a big sharing hierarchy. All contexts are now
   shared with gdk_display_get_gl_context().
2. There is no longer a difference between attached and non-attached
   contexts. All contexts work the same way.
2021-07-22 16:27:31 +02:00
Benjamin Otte
a27434a8a7 gl: Store the context::in-frame state in the current context
Do not treat the context as already current when the value
of context::in-frame changes.

This is so we can bind to EGL_NO_SURFACE if context::in-frame == false
and to context::surface if context::in-frame == true.

This allows getting rid of the attached property in future commits.
2021-07-22 16:27:31 +02:00
Benjamin Otte
2c987861a6 gl: Deprecate gdk_gl_context_get_shared_context()
It's not used anymore. And in particular we do want to keep the display
context private, so we're not gonna return it from this function.
2021-07-22 16:27:31 +02:00
Benjamin Otte
c7320df0c9 gdk: Add gdk_gl_context_is_shared()
... and use it in the GL renderers.
2021-07-22 16:27:31 +02:00
Benjamin Otte
e4f0418003 gdk: Require EGL version 1.4 across the board
Mesa currently ships 1.5.
2021-07-22 16:23:56 +02:00
Benjamin Otte
430b6f8fb1 gdk: Add GdkDisplay::init_gl vfunc
The vfunc is called to initialize GL and it returns a "base" context
that GDK then uses as the context all others are shared with. So the GL
context share tree now looks like:

+ context from init_gl
  - context1
  - context2
  ...

So this is a flat tree now, the complexity is gone.

The only caveat is that backends now need to create a GL context when
initializing GL so some refactoring was needed.

Two new functions have been added:

* gdk_display_prepare_gl()
  This is public API and can be used to ensure that GL has been
  initialized or if not, retrieve an error to display (or debug-print).
* gdk_display_get_gl_context()
  This is a private function to retrieve the base context from
  init_gl(). It replaces gdk_surface_get_shared_data_context().
2021-07-22 16:23:56 +02:00
Benjamin Otte
ba3e80cbfa wayland: Don't pass GL config to get_egl_surface()
There's only one GL config.
2021-07-22 16:23:56 +02:00
Benjamin Otte
7cd4282bad wayland: Move fbconfig into the display
Create it during init and then reuse it for all contexts.

While doing that, also improve error reporting - that's not used yet but
will in later commits.
2021-07-22 16:23:56 +02:00
Benjamin Otte
01e9fa9adb gdk: Allow GdkDrawContext with a %NULL surface
This is not used yet, but it allows surfaceless GL contexts.

For that purpose, we need to make the display a construct-only property,
so that it can be set when the surface isn't.

This adds a bunch of very picky checks in the constructor so nothing bad
can happen.
2021-07-22 16:23:56 +02:00
Benjamin Otte
581e01b2da gdk: Add a private struct to GdkDisplay
... and move some members from the GdkDisplay struct.

We've always wanted to add one to isolate the display from the backends
a bit more, but so far it's never happened.

Now that I'm about to add more data to GdkDisplay, it's a good excuse to
start.
2021-07-22 16:23:56 +02:00
Benjamin Otte
5a3b4de1b7 x11: Redo choice between EGL and GLX
We try EGL first, but are very picky about what we accept.
If that fails, we try to go with GLX instead.
And if that also fails, we try EGL again, but this time accept anything.

The idea here is that EGL is the preferred method going forward, but GLX is
the tried and tested method that we know works. So if we detect issues with
EGL, we want to avoid using it in favor of GLX.

Also add a GDK_DEBUG=gl-egl option to force EGL at all costs and not try
GLX.
2021-07-22 16:23:56 +02:00
Benjamin Otte
74288eceaf x11: Properly record the error when initializing GL
That way, we can give a useful error message when things break down for
users.

These error messages could still be improved in places (like looking at
the actual EGL error codes), but that seemed overkill.
2021-07-22 16:23:56 +02:00
Benjamin Otte
37ba057128 x11: Do not call glXQueryExtension()
epoxy does that already.
2021-07-22 16:23:56 +02:00
Benjamin Otte
6d5ba9590b x11: Get Visual from EGL directly
Query the EGL_VISUAL_ID from the egl Config and select a config with the
matching Visual.

This is currently broken on Mesa because it does not expose any RGBA
X Visuals in any EGL config, so we always end up with opaque Windows.

https://gitlab.freedesktop.org/mesa/mesa/-/issues/149
2021-07-22 16:23:56 +02:00
Benjamin Otte
215f792851 x11: Store the GLX drawable in the surface
Also, stop using a dummy window for unattached GL contexts and instead
use the display's leader surface.

Again, this mirrors EGL.
2021-07-22 16:23:56 +02:00
Benjamin Otte
1c55b32879 x11: Use single GLX fbconfig and store it in the display
This mirrors the code for the EGL config.
2021-07-22 16:23:56 +02:00
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
Vlad Zahorodnii
2c023cdaed gdk/wayland: Clean up gestures if pointer capability is withdrawn
If the pointer capability is added, pointer swipe and pinch gestures
will be created. However, if the pointer capability is removed, the
gesture objects won't be destroyed.

If the pointer capability is removed and added several times in a row,
for example due to plugging and unplugging physical mouse, this can lead
to leaking the old gesture objects.

In order to prevent that, this change makes the seat destroy swipe and
pinch gestures when the pointer capability is withdrawn.
2021-07-21 20:52:16 +03: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
Chun-wei Fan
ac64d2d910 GDK-Win32: Clean up HiDPI support and WGL a bit
Make _gdk_win32_display_get_monitor_scale_factor() less complex, by:

*  Drop the preceding underscore.

*  Dropping an unused parameter.

*  Using a GdkSurface instead of a HWND, as the HWND that we pass into
   this function might have been taken from a GdkSurface, which are now
   always created with CS_OWNDC.  This means if a GdkSurface was passed
   in, we ensure that we only acquire the DC from the HWND once, and do
   not attempt to call ReleaseDC() on it.

*  Store the HDC that we acquire from the GdkSurface's HWND into the
   surface, and use that as the HDC we need for our GdkGLContext.

*  Drop the gl_hwnd from GdkWin32Display, as that is really should be
   stored in the GdkSurface.

*  For functions that were updated, name GdkWin32Display variables as
   display_win32 and GdkSurface variables as surface, to unify things.

*  Stop calling ReleaseDC() on the HDC that we use for OpenGL, since
   they were acquired from HWND's created with CS_OWNDC.
2021-07-19 18:30:42 +08:00
Chun-wei Fan
49a76257cd gdksurface-win32.c: Create all surfaces with CS_OWNDC
We want to ensure that we have things set up properly for drag surfaces
as well.
2021-07-19 17:36:54 +08:00
Jeremy Tan
2784b03b2d gdkkeys-win32.c: fix initialisation of key_state in update_keymap
It apparently worked by chance in the past, but now causes e.g.
alphanumeric characters to be interpreted as half-width katakana
when using the Japanese IME.
2021-07-09 12:46:49 +08:00
Marc-André Lureau
337c5e5e59 Add missing "Since: 4.X" tags
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-07-07 23:35:38 +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
4efb661ae6 wayland: Look for cursor themes in $HOME
We should look in the same places that libXcursor does,
so add $XDG_DATA_HOME/icons and $HOME/.icons to the list.

Fixes: #4080
2021-06-29 16:57:15 -04:00
Matthias Clasen
92177d9663 Merge branch 'wip/chergert/gdk-macos-gdkdrop' into 'master'
GdkDrop suport for macOS backend

See merge request GNOME/gtk!3683
2021-06-24 15:03:19 +00:00
Matthias Clasen
6a29b64850 Merge branch 'dnd-fixes' into 'master'
dnd: Add another assertion

See merge request GNOME/gtk!3689
2021-06-24 15:01:29 +00:00
Vlad Zahorodnii
3969d8b028 gdk/wayland: Fix pointer-gestures version selection
version == GDK_ZWP_POINTER_GESTURES_V1_VERSION will fail if the
compositor implements version 2 of pointer-gestures-v1.
2021-06-21 09:51:45 +03:00
Matthias Clasen
92c6485adf docs: Tweak wording
Instead of drag'n'drop, say drag-and-drop. That is easier
to read, and less unclear on the markdown syntax implications.
2021-06-19 08:03:47 -07:00
Matthias Clasen
4df9314039 wayland: Fix some dnd corner case
We must call gdk_drag_drop_done() when the drag ends,
successfully or not. Without this, we get an unwarranted
emission of ::cancel after a successful drop.

Since only the first call to gdk_drag_drop_done() is taking
effect, it is safe to call as a fallback, after emitting
::dnd-finished. If the application connects to that signal
and calls gdk_drag_drop_done() itself, its call will take
precedence.

This matches what the X11 implementation does.
2021-06-19 08:03:21 -07:00
Matthias Clasen
c8ad4d5deb dnd: Add another assertion
Assert that gdk_drop_finish() is called after the
drop is performed.
2021-06-19 07:50:41 -07:00
Matthias Clasen
13a2db2238 Merge branch 'fix-3798' into 'master'
GDK-Win32: Fix drag surface positioning (issue #3798)

Closes #3798

See merge request GNOME/gtk!3659
2021-06-18 17:31:51 +00:00
Chun-wei Fan
e35490ba5b gdkdrag-win32.c: Fix drag surface positioning
Determine the root_x and root_y coordinates of the drag surface by
relying on the coordinates of the surface where the drag is being
carried out, plus the coordinates that we receive from the drag event,
which is in-line with what the X11 backend does.

This will prevent the drag surface from being initially drawn at the
correct position, but jumping towards the top-left corner of the screen
shortly afterwards.

The DnD support will still need some more updates to function correctly
on Windows, but at least this is a small improvement.

Fixes issue #3798.
2021-06-18 18:07:50 +08:00
Christian Hergert
3fd931d392 macos: implement GdkDrop for macOS
This gets the basic mechanics of the drop portion of DnD working on the
macOS backend. You can drag, for example, from TextEdit into GNOME
Text Editor when using the macOS backend.

Other content formats are supported, and match what is currently
supported by the clipboard backend as the implementation to read
from the pasteboard is shared.

Currently, we look up the GdkDrag for the new GdkDrop. However,
nothing is stashing the drag away for further lookup. More work is
needed on GdkMacosDrag for that to be doable.
2021-06-17 17:26:42 -07:00
Christian Hergert
6c1dce2878 macos: make pasteboard usage reusable
We will want to be able to reuse the pasteboard reading code from
the macOS DnD drop backend. This just removes the pasteboard
bits from the implementation and allows that to be passed in as in
both clipboard and DnD cases we'll have a specific NSPasteboard
to read from.
2021-06-17 17:19:19 -07:00
Christian Hergert
ad1260505d macos: check for GdkMacosBaseView before using as such
We can get events for external windows such as those from native
file chooser dialogs.
2021-06-17 17:18:19 -07:00
Matthias Clasen
22827f2cc7 macos: Fix a compiler warning 2021-06-17 17:14:14 -07:00
Christian Hergert
b64370cd48 macos: move drag motion to GdkMacosDrag
This doesn't help to be pushed off into the surface, as it makes things
more different than the X11 implementation.
2021-06-17 13:24:39 -07:00
Christian Hergert
6c8e176cc0 macos: fix position of drag surface 2021-06-17 13:23:38 -07:00
Christian Hergert
057bda6cd7 macos: register known clipboard types for drag destination 2021-06-17 13:23:18 -07:00
Christian Hergert
352898ae9e inspector: fix compilation with broadway 2021-06-17 11:54:00 -07:00
Chun-wei Fan
ba7ec29dc0 gdksurface-win32.c: Fix up popup placement
If we are undergoing a surface move, just apply the next_layout anyways,
even if we are not moving a toplevel surface.

Update the way how we obtain the x and y coordinates of a surface, if it
is a toplevel, apply the x and y coordinates from the results from we
obtained the underlying Win32 HWND, as we did before.  But if it is a
popup, use gdk_win32_surface_get_geometry() to obtain the correct x and
y coordinates to place our popup surface.

Also correct how we compute the shadow dimensions, and the final popup
rectangle as we attempt to layout the popup surface, since GDK-Win32
keeps track of the shadow dimensions in system (unscaled) units, not GDK
units.

Fixes issue #3793.
2021-06-16 16:25:29 +08:00
Chun-wei Fan
85b595bd14 gdksurface-win32.c: Fix formatting for popup functions 2021-06-16 15:02:56 +08:00
Matthias Clasen
a6b4e53dca Merge branch 'macos-input-method' into 'master'
fix: make input method work again in gtk4

Closes #3968

See merge request GNOME/gtk!3668
2021-06-14 19:20:06 +00:00
Zhi
5776fcd955 fix: make the new nsview as the first responder.
Make the new view as the first responder(focused) so the new view can
accept events from input method.

Fixes #3968.
2021-06-15 00:09:46 +08:00
Matthias Clasen
938bfff3dd Add type annotations for filename arguments
Add missing "(type filename)" annotations for string
arguments that are filenames.

Fixes: #633
2021-06-12 11:12:06 -04:00
Matthias Clasen
effc7a619d Docs: Tweaks
Remove some more redundant "or NULL" blurbs.
2021-06-05 17:38:23 -04:00
Matthias Clasen
fe774c1ad8 Merge branch 'powimod_icon' into 'master'
Load icon from executable on Windows

Closes #3713

See merge request GNOME/gtk!3326
2021-06-05 12:47:08 +00:00
Matthias Clasen
7f4630abac wayland: Add a comment
I just had to debug this to rediscover how it works, so
add a comment for next time.
2021-06-04 08:30:52 -04:00
Matthias Clasen
da9cd4659e Merge branch 'bilelmoussaoui/markdown-links' into 'master'
docs: use markdown syntax for hyperlinks

See merge request GNOME/gtk!3589
2021-06-04 02:45:25 +00:00
Matthias Clasen
15b24a000d Apply 1 suggestion(s) to 1 file(s) 2021-06-04 01:53:12 +00:00
Carlos Garnacho
8288d9e87c gdk/wayland: Break only implicit grabs on wl_pointer.leave w/ pressed buttons
The releasing of grabs while a button is pressed (e.g. after starting dnd, or
dragging the window, or going to overview with a pressed button, etc...) was
generalized here in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1879.

However we shouldn't break all grabs here. In the case of grabbing popups,
compositors will still emit crossing events between client surfaces (e.g.
popping up and selecting a menu item via press-drag-release), breaking all
grabs here means inconsistent client state, that was
https://gitlab.gnome.org/GNOME/gtk/-/issues/2746.

That was fixed in mutter, by essentially making implicit grabs
owner_events=FALSE, however that breaks the mentioned use pattern entirely.
Mutter is changing this behavior back, so GTK should handle these crossing
events.

The grab that we are interested in breaking here is the implicit pointer
one. Popups will be dismissed via other means if the compositor says their
active grab needs breaking. This still leaves dnd/move/resize drags in
one place, while not allowing #2746 to happen with popups.
2021-06-03 17:13:12 +02: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
Bilal Elmoussaoui
8ebdd256a5 docs: fix broken links 2021-05-27 00:18:23 +00:00
Bilal Elmoussaoui
a196a35d1d gdk: fix wrong doc annotation 2021-05-25 16:07:51 +00:00
Bilal Elmoussaoui
02672a521a docs: use markdown syntax for hyperlinks 2021-05-25 13:14:01 +00:00
Matthias Clasen
4c2761302a doc: Syntax fixes
No, we can't have links that say [constructor@...] or
[mehtod@...] or [methoc@...] or [methos@...] or [metohd@...].
And no, not [signals@...] either.
2021-05-25 07:33:55 -04:00
Chun-wei Fan
52d1c0c271 media/gstreamer: Support using GL for video for Windows
Add support to share the WGL context in GDK with the WGL context in GStreamer,
so that we can also use OpenGL in the gstreamer media backend to playback
videos.  For now OpenGL/ES is not supported for this under Windows.

The process of setting this up in Windows is a little bit more involved, as:

*  The OpenGL support in GstGL requires a GL 4.1 Core context, but we may just
   get the GL version from wglCreateContextAttribsARB() that we pass into the
   attributes, which is 3.2 by default.  So, try to ask for a 4.1 Core context
   first if we are asking for anything less.

*  There is only one GstDisplay available for Windows, so we just use
   gst_gl_display_new().

*  We must explicitly tell libepoxy that we are using wglMakeCurrent() outside
   of libepoxy that is being used in GdkGL, otherwise we would end up crashing
   as the GL/WGL function pointers would become invalid.

*  We must also deactivate temporarily the underlying WGL context that was made
   current by gdk_gl_context_make_current() so that when
   gst_gl_display_create_context() calls wglShareLists(), we won't get bitten
   by error 0xaa (resource busy), as some drivers don't handle this well when
   the GL context is current in another thread.

For the last two points we make use of macros defined by the platforms that the
build is done for to help us carry out the necessary tasks as needed.

Thanks to Matthew Waters for the info on integrating GstGL and windowing
toolkits on Windows.
2021-05-24 16:36:40 +08:00
Matthias Clasen
be944053e0 docs: More syntax fixes
The syntax for interface links is [iface@...], not
[interface@...].
2021-05-22 21:21:10 -04:00
Matthias Clasen
71aac48042 docs: More syntax fixes
[`func@Foo`] is not the right link syntax either.
2021-05-22 21:20:10 -04:00
Matthias Clasen
6cb4dda5d6 gdk: Cosmetic docs changes 2021-05-22 17:25:26 -04: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
Bilal Elmoussaoui
c5eb2f5d16 gdk: annotate Content Serialize/Deserialize return_error 2021-05-19 18:10:34 +00: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
Matthias Clasen
6537728c7b Merge branch 'wip/chergert/fix-gi-typo' into 'master'
gdk: fix typo in G-I attribute

See merge request GNOME/gtk!3545
2021-05-12 18:43:33 +00:00
Christian Hergert
ae9b4f8940 gdk: fix typo in G-I attribute 2021-05-12 10:53:56 -07:00
Chun-wei Fan
6d33e9058c Win32: Add EGLDisplay getter
Like what was done for Wayland and X11, add an API to retrieve the EGLDisplay
if one is being used in place of WGL.
2021-05-12 22:16:56 +08:00
Emmanuele Bassi
2588f9cee6 wayland: Add EGLDisplay getter
Getting an EGLDisplay object is messy; might as well expose the function
we use internally to save some time, just like we did for the X11
backend.
2021-05-11 12:46:03 +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
6120519e8e Merge branch 'ebassi/egl-x11' into 'master'
Prefer EGL to GLX for the GL support on X11

See merge request GNOME/gtk!3540
2021-05-10 22:51:11 +00: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
Matthias Clasen
7745f67583 broadway: Add a setter for display scale
This is useful when using Broadway as a headless
display server.

Fixes: #3934
2021-05-10 07:19:26 -04:00
Matthias Clasen
374225ae6a Cosmetics 2021-05-09 19:32:48 -04: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
Guido Günther
e40c869d0d gdk/wayland: Take transform into account when setting physical size
Width and height of a GdkMonitor are derived via wl_output which
talks about physical dimensions of a device and compositors usually
implement this as the untransformed values (e.g. weston, wlroots).

Since the GTK client has no way to figure out if a monitor was rotated,
transform the physical dimensions according to the applied wayland
transform to have the physical dimensions match the logical ones.

Mutter flips the physical dimensions itself but doesn't announce the
transform so this shouldn't break anything there.
2021-05-05 14:55:07 +02:00
Matthias Clasen
b012a5c67e Merge branch 'static-analysis-fixes' into 'master'
Static analyis fixes

See merge request GNOME/gtk!3501
2021-05-03 19:21:42 +00:00
Carlos Garnacho
be4216e051 gdk/wayland: Support the xdg-activation wayland protocol
This protocol implements the IPC necessary to focus application
windows across launcher/launchee. Add support for it.
2021-05-03 17:20:50 +02:00
Matthias Clasen
e2722f03ac x11: A few static analysis fixes 2021-05-03 07:44:38 -04:00
Matthias Clasen
1be4684441 gdktoplevelsize: Comment out some unused code
This is not currently useful, and clang complains.
2021-05-03 07:44:38 -04:00
Matthias Clasen
2b0c474117 Add gdk_wayland_device_get_xkb_keymap
This can be useful to get more detailed information
about keyboard configuration.
2021-05-02 21:02:09 -04:00
Matthias Clasen
0f74798a82 Add 4.4 version macros 2021-05-02 21:02:09 -04:00
Matthias Clasen
945b32ca1b Merge branch 'mesa.win32.fixes' into 'master'
gdkglcontext-win32.c: Fix running with Mesa drivers

See merge request GNOME/gtk!3483
2021-05-02 22:42:35 +00:00
Matthias Clasen
7ab8109ef8 contentdeserializer: Fix an oversight
The argument passed with string_deserializer must be
a charset name. Passing the mimetype there does not
make sense.
2021-05-01 22:44:41 -04:00
Matthias Clasen
97afffba4e wayland: Rewrite shm format debug spew
Rewrite this in a way that doesn't depend on kernel
header defines at the time the wayland scanner was run.

This was causing the build to break on Centos 8, where
a bunch of fourcc formats are missing.
2021-05-01 11:17:28 -04:00
Bilal Elmoussaoui
ec38e53249 gdk: add zero-terminated annotation to content_formats_get_gtypes 2021-04-30 15:43:33 +02:00
Bilal Elmoussaoui
e473e7a83a gdk: fix content_formats_get_mime_types annotation 2021-04-30 15:43:17 +02:00
Chun-wei Fan
66e7f3b404 gdkglcontext-win32.c: Fix running with Mesa drivers
Some GL drivers such as Mesa-D3D12 do not allow one to call SetPixelFormat() on
a given HDC if one pixel format has been already set for it, so first check the
HDC with GetPixelFormat() to see whether a pixel format has already been set
with the HDC, and only attempt to acquire the pixel format if one has not been
set.

This will fix running with GL/NGL on Windows using the Mesa drivers.
2021-04-29 12:12:01 +08:00
David Lechner
2a610267eb gdk/wayland/cursor/os-compatibility: fix build when memfd_create is not available
When building for homebrew/linuxbrew on Ubuntu 16.04, memfd_create() is
not available and causes the build to fail.

This adds a proper check for the function.
2021-04-27 11:46:39 -05: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
Benjamin Otte
1a12ea6e5a Merge branch 'wip/otte/for-master' into 'master'
clipboard: Make sure G_TYPE_STRING is nul-terminated

Closes #3899

See merge request GNOME/gtk!3476
2021-04-26 21:15:32 +00:00
Benjamin Otte
1be899459c clipboard: Fix reading of files
Make sure writing a terminating null byte actually works and we don't
just ignore the error message.
2021-04-26 21:32:57 +02:00
Benjamin Otte
f34e3c573b clipboard: Make sure G_TYPE_STRING is nul-terminated
When reading text, we need to check we terminate the G_TYPE_STRING
string with a null byte, because the clipboard does not guarantee one.

So just append a \0 to the stream.

Fixes #3899
2021-04-26 21:32:57 +02:00
Matthias Clasen
2c34abed20 wayland: Print all layouts in debug spew 2021-04-26 00:16:41 -04:00
Matthias Clasen
d225f14657 gdk: Avoid synthetic motion confusion
Don't emit a synthetic motion event on a surface
that is grab-shadowed by a popup. This has been
known to confuse GTK, at times.

Fixes: #3439
2021-04-22 21:09:54 -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
05af726446 Merge branch 'wayland-xdg-surface-setup' into 'master'
wayland: Don't duplicate xdg_surface setup code

See merge request GNOME/gtk!3191
2021-04-16 15:16:28 +00:00
David Keijser
db8bf5e7b9 wayland: Don't duplicate xdg_surface setup code 2021-04-16 16:23:16 +02:00
David Keijser
5bbdf3a807 wayland: Avoid directly accessing shadow property of parent surface 2021-04-16 16:13:07 +02:00
Chun-wei Fan
14632e11da GDK: Fix builds against latest stable GLib with MSVC
GLib-2.68.x now considers warning C4098 ('void' function returning a value) as
an error, so avoid doing that.
2021-04-16 11:39:09 +08:00
Matthias Clasen
d1d009b491 Merge branch 'x11-quiet-exit' into 'master'
x11: Be quiet on exit by default

See merge request GNOME/gtk!3436
2021-04-14 00:32:05 +00: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
Emmanuele Bassi
b0990aa8e2 wayland: Build with G_DISABLE_ASSERT 2021-04-12 21:26:02 -04:00
Matthias Clasen
cce36ae701 wayland: Improve font setting fallback more
We may get a response from the portal that contains
no useful settings at all. In that case, we should
fallback as well.

Fixes: #3838
2021-04-07 19:24:09 -04:00
Carlos Garnacho
07167fdf22 surface: Always set PHASE_PAINT as pending when updates are scheduled
At times (most often when closing subsurfaces that are scheduling
relayouts) the PHASE_PAINT handling gets broken with the following
sequence:

1. Surface receives wl_callback.done for the previous frame.
   Surface is thawed.
2. A new update on the surface is scheduled. PHASE_PAINT is
   requested directly on the frame clock. priv->pending_phase is
   left unset in the surface.
3. Surface gets frozen
4. Frame clock processes the update scheduled at 2. The surface
   is frozen, so paint is prevented. PHASE_PAINT is considered
   handled.
5. Compositor emits wl_callback.done again. Surface is thawed.
6. At this point the machinery is off
   - The surface didn't paint but has pending update regions
   - priv->draw_needed is set in the toplevel and other portions
     of the widget tree
   - So queueing redraws is ineffective at eventually calling
     gdk_surface_schedule_update() again on the toplevel surface.
   - We don't paint anymore, so this broken state is not flushed
     until other subsurface changes manage to schedule the missing
     update.

To fix this, always set PHASE_PAINT in priv->pending_phase when
doing gdk_surface_schedule_update(). If the frame clock turns
around before the surface is thawed, it will still be waiting to
be processed the next iteration.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3750
2021-04-07 23:06:06 +02:00
Matthias Clasen
62f10b1b8f wayland: Improve font setting fallback
When we don't get stettings from the portal, the current
fallback is 'awful fonts'. There is no need for that. Instead,
set the fallback values to grayscale antialiasing with slight
hinting.
2021-04-07 08:50:14 -04:00
Robert Mader
56d37ceed0 gdk/wayland: Defer processing of globals closures
... until all globals have been received.

The dependency tracking introduced in 4e9be39518 only allows to
specify required globals and processes the closures as soon as
the requirements have been met. There are, however, also optional
dependencies - most notably the primary_selection protocol.
Currently we rely on the fact that compositors like Mutter announce
it before `wl_seat`, even though the order is not specified in
the spec.

Process globals closures only after all globals have been announced,
so optional dependencies can be accommodated.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/3791
2021-03-30 15:20:00 +02:00
Matthias Clasen
7644605dfc Plug a small memory leak 2021-03-27 19:11:56 -04:00
Matthias Clasen
08f68cce40 gdk: Add an arg check to gdk_device_get_timestamp
Pointed out by Emmanuele Bassi.
2021-03-26 11:09:50 -04:00
Matthias Clasen
7849590a82 gdk: Add gdk_device_get_timestamp
Give each device a timestamp that reflects the last
user activity with that device, as reflected in the
events that are produced for this device.
2021-03-26 11:09:05 -04:00
Matthias Clasen
f131d68fef gdk: Add gdk_device_get_timestamp
Give each device a timestamp that reflects the last
user activity with that device, as reflected in the
events that are produced for this device.
2021-03-26 10:30:33 -04:00
Carlos Garcia Campos
50b70298c0 clipboard: Fix a crash when GdkContentProviderUnion doesn't support the given data format
After iterating all the providers, all of them returning unsupported
error, gdk_content_provider_union_get_value() returns FALSE without
filing the given GError. Then gdk_clipboard_read_value_internal()
assumes there's a GError when FALSE is returned and
g_task_return_error() fails. We can just chain up to parent
implementation to ensure the GError is filled with unsupported error.
2021-03-25 15:10:00 +01:00
Matthias Clasen
5531906973 Merge branch 'gles-fallback' into 'master'
gdkglcontext-wayland: Fallback to GLES 2.0 after legacy failed

See merge request GNOME/gtk!3327
2021-03-24 11:21:21 +00:00
Tom Schoonjans
d5de73fb9d gdkmacosglcontext: fix compilation error
See https://developer.apple.com/documentation/appkit/nsopenglpixelformat/1436219-initwithattributes?language=occ
2021-03-24 10:08:11 +00: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
Emmanuel Gil Peyrot
aced6030ee gdkglcontext-wayland: Fallback to GLES 2.0 after legacy failed
This lets the NGL backend be selected instead of the Cairo backend on
devices which expose both GL and GLES, but have better support of GLES.

Tested on a PinePhone.
2021-03-21 20:37:04 +00:00
dparisot
82b11623f4 Load icon from executable on Windows 2021-03-21 15:24:28 +01:00
Chun-wei Fan
38ad068d9b GDK-Win32: Remove extraneous call to _gdk_win32_append_event()
Apparently, by comparing with the other backends, we should not call
_gdk_win32_append_event() after calling gdk_scroll_event_new() but we should
call it after calling gdk_scroll_event_new_discrete(), which was why we didn't
restore the cursor after we scroll using the mouse wheel and didn't manage to
remove the shade that appears after we scrolled to the very top or very bottom.

Also, as suggested by the reporter, use IDC_SIZEALL for the system cursor that
we fall back to if no cursor theme is installed, as with other Windows
programs.

This should really fix issue #3581.
2021-03-17 11:22:23 +08:00
Matthias Clasen
74e2bb4cf1 dnd: Add some warnings to the docs
Add some warnings about pitfalls of the async dnd api.
2021-03-16 14:48:44 -04: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
Matthias Clasen
f279c7b1c2 Merge branch 'fix-3581' into 'master'
gdkcursor-win32.c: Add cursor map for all-scroll (issue #3581)

Closes #3581

See merge request GNOME/gtk!3298
2021-03-15 22:32:23 +00:00
Matthias Clasen
e3dcc3d369 wayland: Fix cross-layout accelerators
GTK traditionally lets you activate keyboard shortcuts
even if they are for a non-active layout. But it is meant
to only activate with a keysym from a non-active layout
when that symbol is not present in the current layout.
That last condition was lost when key event handling
was redone for GTK4. Bring it back.
2021-03-15 17:14:49 -04:00
Matthias Clasen
568fe2e97b wayland: Add debug spew for active keyboard layouts
Print out what we think the active keyboard layout is,
when it changes, with GDK_DEBUG=input.
2021-03-15 17:14:49 -04:00
Matthias Clasen
1eebf0ebd1 wayland: Emit keys-changed on layout changes
We were forgetting to do this in when layout changes are
communicated via handle_modifiers.
2021-03-15 12:34:23 -04:00
Chun-wei Fan
54b3048584 gdkcursor-win32.c: Add cursor map for all-scroll
This makes sure that we don't have cursors disappearing on Windows upon
scrolling because we can't find a cursor that exists on the system during
a scroll, and unlike GTK-3.x, we do not default to the arrow pointer on GTK4.

Just mimic what we have on X11 and Wayland: the trusty standard arrow pointer.

Fixes issue #3581.
2021-03-15 17:16:33 +08:00
Benjamin Otte
dbd19bf27a x11: Don't call _gdk_surface_update_size() all the time
We were calling _gdk_surface_update_size() every frame, even if the
window size didn't change. This would cause us to discard all cached
buffers and redraw the whole screen.

This was BAD.
2021-03-15 03:16:50 +01:00
Benjamin Otte
97fad45237 surface: Remove unused gdk_surface_get_unscaled_size()
Also remove unscaled_width/height members in the win32 backend.

Both of those are unused.
2021-03-15 02:56:28 +01:00
Chun-wei Fan
e941e2be7d gdksurface-win32.c: Fix window menu positioning
We ought to get the coordinates of where the window menu should be
displayed using gdk_win32_surface_get_root_coords(), instead of rounding
the position that we obtained with gdk_event_get_position().

Also rename items a bit in the same function, and call
gdk_event_get_event_type() for consistency with the other backends.

Fixes issue #3704.
2021-03-12 18:45:43 +08:00
Matthias Clasen
47c1b50eba cursor: Use a table for cursor names
This gets all the names into view at the same time.
2021-03-11 16:37:35 +00:00
Matthias Clasen
494bdad887 contentprovider: Convert some more markup 2021-03-11 16:37:34 +00:00
Matthias Clasen
d5e9e10d0a toplevel: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
d262f740b2 texture: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
d886ab9229 surface: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
6be66205cc seat: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
abb6fe326f popup: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
d6c763f2ae monitor: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
34533b544a glcontext: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Matthias Clasen
d92647a92b drop: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00