Commit Graph

7775 Commits

Author SHA1 Message Date
Matthias Clasen
9c84f7645e x11: Don't beep on untrusted displays
This can trigger BadAccess, and we don't
want that.

Fixes: #3862
2021-04-20 21:41:48 -04:00
Matthias Clasen
536da7a15c 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:52:55 -04:00
John Ralls
242b76a771 Add a public header for Cocoa access functions.
Some applications need to access gdk_quartz_window_get_nsview,
gdk_quartz_window_get_nswindow, and gdk_quartz_event_get_nsevent
so move these from the private gdkquartz-gtk-only.h to a new
header gdkquartz-cocoa-access.h. Don't include this header in
gdkquartz.h so that user code that doesn't need to access these
functins isn't required to compile with Objective C/C++.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/1737
2021-04-16 16:56:55 -07:00
Matthias Clasen
3a70781d40 Merge branch 'fix_elcapitan_support' into 'gtk-3-24'
Fix building on OS X El Capitan 10.11

See merge request GNOME/gtk!3402
2021-04-16 20:02:09 +00:00
Chun-wei Fan
416e6b9cdd gdkglcontext-win32.c: Avoid C4715 warning
We can just group the code for the desktop GL codepath and the EGL
codepath a bit so that we can just have a single location where we
return TRUE upon a successful setup of our WGL/EGL context, and avoid
the C4715 warning that is considered an error when building with
GLib-2.68.x or later using Visual Studio, when we are building without
EGL support.
2021-04-16 15:08:41 +08:00
Matthias Clasen
c3503fcc84 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 20:42:21 -04:00
Matthias Clasen
dfea8c31d9 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 14:30:48 -04:00
Matthias Clasen
a3ff6e279c 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:43:08 -04:00
René de Hesselle
8627a9a569 Fix building on OS X El Capitan 10.11
The preprocessor directives for proper OS version support are missing
their last digit, rendering the checks defunct.

Improves on https://gitlab.gnome.org/GNOME/gtk/-/issues/3592 but does
not fully fix as other issues have surfaced down the line.
2021-04-05 22:20:25 +02:00
Robert Mader
86ef0e6094 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:10:04 +02:00
Matthias Clasen
71c64e650d Merge branch 'gtk-3-24-minimize-no-decorations' into 'gtk-3-24'
GDK quartz: Keep window without decoration miniaturizable

See merge request GNOME/gtk!3281
2021-03-27 03:32:07 +00:00
Olivier Fourdan
39db784704 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:35:13 +01:00
Matthias Clasen
1ce5494ffd wayland: Pass layout information in key events
We were always setting group to 0, causing accelerator
interpretation to always go off the first configured
layout, not the active one.

Fixes: #1825
2021-03-15 14:48:05 -04:00
Matthias Clasen
b94955e614 Merge branch 'gdk-win32-use-window-from-point-api' into 'gtk-3-24'
GdkWin32: Fix mouse events in presence of transparent windows on the desktop

See merge request GNOME/gtk!2767
2021-03-11 01:10:20 +00:00
Cédric Krier
238bb38249 Keep window without decoration miniaturizable
Closes #2345
2021-03-10 16:08:14 +01:00
Knuckx
d7d6098281 WinTab - Add support for Wheel/Rotation axis - Rebase and fix conflicts for merge 2021-03-05 23:35:29 +00:00
Steven Calwas
86d38e6ae2 Fix window unresponsive to mouse after app-switch w/drawing tablet
Partially fixes issue #2191 regarding switching to another app while
hovering a stylus over a drawing tablet causes subsequent mouse
clicks in the app to be ignored. I was not able to reproduce the
other behavior described in #2191 concerning tiling a window.
2021-03-05 14:37:29 -05:00
Matthias Clasen
94befed65f Merge branch 'issue1549' into 'gtk-3-24'
Handle Wintab cursors that are recognized after GDK app init

See merge request GNOME/gtk!2458
2021-03-05 18:53:42 +00:00
Luca Bacci
fa2ae10599
Fix leak of event structures
Inside generate_button_event, if _gdk_input_ignore_core is > 0 we
leak an event structure. Fix that.
2021-03-01 10:51:38 +01:00
Sebastian Dröge
ac69c05a31 Use the proper cairo.Format type instead of overriding to gint via annotations in gdk_window_create_similar_surface() 2021-02-20 12:43:53 +02:00
Carlos Garnacho
4d30400987 gdk/wayland: Look for font settings recursively
Use the infrastructure already available to look up keys, instead.
This does the right thing and looks up the setting across all
sources.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3680
2021-02-18 16:51:28 +01:00
Robert Mader
d3316a37ed wayland/window: Add API to add extra surfaces for frame callbacks
This is useful when clients use subsurfaces independently of GDK.
For example if a client creates a subsurface that covers a GdkWindow
entirely. If this subsurface is opaque, Wayland compositors may not
emit callbacks for the surface of the GdkWindow any more.
Adding the covering subsurface via this new API ensures the
GdkWindow will continue to update in this case.
2021-02-12 13:18:29 +01:00
Jonas Ådahl
ddb9bae3d4 Merge branch 'gtk-surface-release-3-24' into 'gtk-3-24'
Support gtk-shell surface release destructor

See merge request GNOME/gtk!2074
2021-01-29 16:21:09 +00:00
Matthias Clasen
a8c12a4c96 Merge branch 'gtk-3-24' into 'gtk-3-24'
Adds support for Android/Chrome on-screen keyboard

See merge request GNOME/gtk!3130
2021-01-29 00:59:15 +00:00
Maxim Zakharov
b31a80cd64 Adds support for Android/Chrome on-screen keyboard
Adds event listener for input events; converts input data into
key press and key release commands depending on inputType of the event.
2021-01-29 11:23:51 +11:00
Carlos Garnacho
02a02fac56 gdk/wayland: Mark matched settings from the portal as valid
Commit e6209de962 added some checks on TranslationEntry.valid in
order to figure out whether using the new font settings or the
old g-s-d ones. However that's only set in the non-sandboxed case.

This makes sandboxed applications fallback to the old (and also
non-existing with modern g-s-d) settings, possibly resulting in
ugly defaults being picked.

Fix this by also marking TranslationEntry elements as valid when
using the settings portal, precisely those entries that we are able
to read and match with our own table.
2021-01-14 16:09:27 +01:00
Carlos Garnacho
7ab4c9a68b Merge branch 'fix-tablet-3.24' into 'gtk-3-24'
Wayland: Fix segfault when receiving tablet/touch events for surfaces that have already been destroyed client-side

See merge request GNOME/gtk!2809
2021-01-10 13:18:15 +00:00
wisp3rwind
19a740e277 Wayland: ignore touch/tablet events on destroyed surfaces
When destroying a wl_surface (e.g. when a window or menu is closed), the
surface may continue to exist in the compositor slightly longer than on
the client side. In that case, the surface can still receive input
events, which need to be ignored gracefully.
In particular, this prevents segfaulting on wl_surface_get_user_data()
in that situation.

Reported in
https://gitlab.gnome.org/GNOME/gtk/-/issues/3296

The same issue for pointers/keyboards was reported in
https://bugzilla.gnome.org/show_bug.cgi?id=693338

and fixed with in
bfd7137ffb
3625f17857
a8fc099a72
2021-01-10 12:00:28 +01:00
Carlos Garnacho
cae5e60113 Merge branch 'avoid-pointer-reset' into 'gtk-3-24'
wayland: avoid set_cursor() when unchanged or invisible

See merge request GNOME/gtk!2822
2021-01-06 19:53:30 +00:00
Matthias Clasen
c87b21351c Merge branch 'workaround-win32-intel-blit' into 'gtk-3-24'
gdkglcontext-win32.c: Workaround Intel glBlitFramebuffer() issues

See merge request GNOME/gtk!2996
2021-01-06 16:13:02 +00:00
Chun-wei Fan
79e512ab0b gdkglcontext-win32.c: Workaround Intel glBlitFramebuffer() issues
Intel OpenGL drivers have an issue where the results of a series of
glBlitFramebuffer() can delay updating the display, when we use GDK_GL=always,
which is manifested when attempting to enter text in text boxes.

This attempts to work around this issue by requiring a glFlush() call and a
retry to the same glBlitFramebuffer() calls to avoid delays in keystrokes when
using GDK_GL=always and when not using libANGLE OpenGL/ES emulation, when an
Intel OpenGL driver is being used.

Special thanks to Lukas K. for the analysis and coming up with a workaround,
which this patch builds upon.

Fixes issue 3487
2020-12-23 19:01:31 +08:00
Maxim Zakharov
ba845fa7b2 fix touchscreen events processing in broadway.js
Makes event listeners active explicitly if supported; corrects
handling for deleted surfaces preventing javascript errors in
accessing deleted objects; makes event identifiers unique for
broadwayd when executing in Chrome on Android.

Partially fixes #1493
2020-12-18 12:22:47 +11:00
Adrien Plazas
c4f8eb7ec9 gdkpixbuf-drawable: Free the pixbuf on Cairo error
This avoids leaking the pixbuf.
2020-12-14 16:18:45 +01:00
wisp3rwind
cf7f7df10c wayland: avoid set_cursor() when unchanged or invisible
In pointer_surface_update_scale(), only rescale the cursor surface when
the scale has actually changed and the cursor is on at least one output.

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3350

Right now, this issue is not completely understood, so it might also
involve some questionable handling of cursor surface by sway/wlroots.

However, irrespective of that issue, this patch avoids unnecessary calls to the
compositor, and there should be no drawback: Whenever the pointer enters
a new output, pointer_surface_update_scale() will be called again, such
that correct scaling of the cursor is still ensured.

There is a slight difference: When the cursor leaves the last output,
previously the image was reset to scale factor 1. Now, it keeps whatever
was last. That might be more sensible than the previous behaviour,
assuming that it's likely that when the cursor enter an output again, it
has the same scaling. Alternatively, if one cares about resource usage
at this level, it might make more sense to destroy the surface then
rescaling to 1.
2020-11-13 16:20:02 +01:00
Luca Bacci
67be62aeaf
GdkWin32: Fix mouse events in presence of transparent windows on the desktop
In gdkdevice-win32.c we are interested in knowing which window
receives mouse input at a specific location.

Only WindowFromPoint is the right API for the task, other API's
(such as (Real)ChildWindowFromPoint(Ex)) have shortcomings because
they are really designed for other purposes. For example, only
WindowFromPoint is able to look through transparent layered windows.

So even if we want to find a direct child we have to use
WindowFromPoint and then walk up the hierarchy.

Fixes: #370, #417
See: !2767
2020-11-11 14:34:40 +01:00
Jonas Ådahl
ba31560970 wayland: Bail loudly if invalid geometry is set
There is some bug somewhere where the geometry ends up being correct.
Mutter didn't handle this gracefully, and is to be changed to simply
respect the protocol and error out the client that sends bogus data.

Prepare for this by instead of sending bogus data, complain loudly if it
would happen dropping the invalid geometry on the floor instead of
sending it.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1527
2020-11-11 10:17:59 +01:00
kai-berlin
bd4b55ddbf broadway: Set modifier state of scroll events
Set modifier state of scroll events, so Ctrl-scroll
works.

Fixes: #2733
2020-11-03 19:43:21 -05:00
Sam Bazley
a91de44755 gdk: Fix parent relative background crash
When setting a window's background to ParentRelative on X11, the window
depths must match to avoid a BadMatch error. Query the X server for the
parent window rather that relying on the parent passed to
gtk_window_new() to prevent crashes with reparented windows.

Fixes: #3288
2020-10-27 18:29:21 +00:00
Luca Bacci
0cb78a9808
GdkW32: remove klassTEMPSHADOW
Fixes issue #2019

See !2749
2020-10-27 18:12:42 +01:00
John Ralls
d0b09a8823 [imquartz] Set the filter key to passthrough regardless of selector.
Remove all of the selectors. They just set the passthrough anyway so
there's not much point to maintaining them and they weren't the
complete set of possible selectors.
2020-10-13 14:36:12 -07:00
LRN
69b43edd55 Merge branch 'w32-transient-ordering-rollback' into 'gtk-3-24'
GDK W32: transient Z-order rollback

See merge request GNOME/gtk!1769
2020-10-08 05:16:11 +00:00
Matthias Clasen
88e8a5272e Merge branch 'cursor-docs' into 'gtk-3-24'
gdkcursor: Add annotations for gdk_cursor_new_for_display()

See merge request GNOME/gtk!2640
2020-09-29 13:32:36 +00:00
Philip Withnall
4d5368e56e gdkcursor: Add annotations for gdk_cursor_new_for_display()
It can fail on Wayland, and is also (transfer full).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-09-29 14:05:38 +01:00
Robert Mader
5bd8f8c5a3 gdk/wayland: Add support for primary-selection-unstable-v1
Additionally to gtk_primary_selection, the gtk-private predecessor,
support the upstream unstable protocol.

This allows the primary selection to work on Kwin and potentially
other compositors, as well as dropping the private version eventually.

Closes https://gitlab.gnome.org/GNOME/gtk/-/issues/2591
2020-09-27 13:40:40 +02:00
Jonas Ådahl
a184b5bf51 wayland: Emit dummy configure event when resizing while fixed
When a fixed size is active (e.g. the window is maximized),
gtk_window_resize() shouldn't take immediate effect, so the request was
dropped. This made GTK unhappy if this happened, it will freeze updating
the window until it received the new size it demanded.

Handle this by being nice and emitting a dummy GDK_CONFIGURE event with
the old size where we previously ignored it. It won't resize the window
immediately, so it shouldn't have a visible effect, and the size GTK
requested is still saved away for when the window is unmaximized, but
emitting the event will make GTK receive the event it expects.

We still drop the request on the floor, e.g. if we still haven't seen
the initial configuration, just as we do when actually doing the resize.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2907
2020-09-07 17:57:32 +02:00
Carlos Garnacho
a98001978c gdk: Keep a reference on the last source device
This device may go away, which means we have a pointer to a possibly
stale object. Keep a reference here, and let future events bring this
accounting up-to-date when the mouse pointer is next updated via other
device.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/855
2020-08-31 15:43:54 +02:00
Julien Ropé
f26c026aaf Fix resource leak in gdk_display_close() under Wayland
When using the gdk_display_close(), the handle to the Wayland compositor was not released.
This could cause the consumption of all available handles, preventing other processes from accessing the display.

Fixing this by calling wl_display_disconnect() when releasing the GdkWaylandDisplay object.

Signed-off-by: Julien Ropé <jrope@redhat.com>
2020-08-31 14:01:38 +02:00
Matthias Clasen
3795d0ad8c Merge branch 'wip/exalm/hotspot-fix-324' into 'gtk-3-24'
wayland: Fix dnd hotspot movement

See merge request GNOME/gtk!2491
2020-08-26 23:48:48 +00:00
Alexander Mikhaylenko
c67e3f37da wayland: Fix dnd hotspot movement
_gdk_wayland_window_offset_next_wl_buffer() moves the window relatively to
its current position, pass it a delta instead of new position.
2020-08-27 04:02:24 +05:00
Carlos Garnacho
b1bbb37154 gdk/wayland: Use double-click/drag-threshold settings from g-d-s
Handle both these settings, and the older settings-daemon ones for
backwards compatibility. The keys are already checked for existence
in the schema, so it will just use the existing ones.
2020-08-27 00:30:51 +02:00
Carlos Garnacho
e6209de962 gdk/wayland: Look for font settings in gsettings-desktop-schemas
Prefer this location, but also look for the old location in
settings-daemon for backwards compatibility. This applies to both
direct settings lookups and via the settings portal.
2020-08-27 00:30:38 +02:00
Steven Calwas
4c10134295 Handle Wintab cursors that are recognized after GDK app init
Previously, a GDK application handled the Wintab cursors (stylus,
eraser, etc.) only during app initialization. If new cursors were
recognized by Wintab during app execution, the app would not know
about them.

This fix still handles Wintab cursors known during app initialization.
In addition, when Wintab recognizes new cursors and notifies the app
via a WT_CSRCHANGE message, the app handles the new cursors, creating
new Wintab device objects for them.

Closes #1549
2020-08-20 22:54:36 -07:00
John Ralls
69135bcfe3 Accommodate macOS 11.0 Big Sur in gdk_quartz_osx_version.
This may need to be changed next year, it depends on what Apple
decides to do with version numbers going forward.

Also updated GdkOSXVersion to include Catalina and Big Sur.
2020-08-11 17:08:53 -07:00
Chun-wei Fan
0cbeee3857 Merge branch 'move-msvc-projects' into 'gtk-3-24'
Visual Studio projects: move projects to win32/

See merge request GNOME/gtk!2248
2020-07-24 02:43:18 +00:00
Chun-wei Fan
2dca4e310d Merge branch 'gtk3.win.egl.unfullscreen' into 'gtk-3-24'
gdkwindow-win32.c: Fix GLES glitches during un-fullscreen

See merge request GNOME/gtk!645
2020-07-24 02:39:25 +00:00
Chun-wei Fan
844555384b Merge branch 'gles-windows-arm64' into 'gtk-3-24'
GDK/Win32: Force GLES if running on ARM64

See merge request GNOME/gtk!827
2020-07-24 02:37:33 +00:00
Chun-wei Fan
522e5d4fa5 Merge branch 'win32-native-input' into 'gtk-3-24'
Use native Windows API for converting keystrokes to characters

See merge request GNOME/gtk!991
2020-07-24 02:27:41 +00:00
Ian Douglas Scott
72d80b8002 gdk: update gdkkeysyms.h with ./gdkkeysyms-update.pl script
There is a default keybinding set with `XF86Keyboard`, but GTK isn't
aware of this keysym. This adds it, as well as a couple others.

See 751e44568c
2020-07-21 13:22:04 -07:00
Philip Zander
5b81864211 Fix 2 warnings, formatting 2020-07-16 15:44:08 +02:00
Philip Zander
9bf9c76365 Remove VK_PACKET handling code that has become unnecessary 2020-07-16 15:01:50 +02:00
Philip Zander
5413892b7d Formatting 2020-07-16 15:01:50 +02:00
Philip Zander
e6f05da6ef Use native Windows API for converting keystrokes to characters
Instead of using the incomplete GTK-internal emulation, use the WM_CHAR
messages sent by Windows. Make the IME input method the default for all
languages on Windows.
2020-07-16 15:01:47 +02:00
Chun-wei Fan
1feb169bfa Visual Studio projects: move projects to win32/
This will simplify our source tree a bit
2020-07-16 18:57:03 +08:00
Christian Rauch
8e99b3f079 wayland: prefer a manually requested size over the configure hint
When a window receives a resize request, it might ignore this new size and
use the compositor's size hints instead to restore to floating mode.

This commit changes that behaviour in that a window will always prefer
the manually resized dimensions over the compositor's hint.
2020-07-15 16:14:25 +01:00
Emmanuele Bassi
e0da315783 Merge branch 'wip/mbiggio/quartz-device-axes-reset' into 'gtk-3-24'
quartz: mimic source device axes

See merge request GNOME/gtk!2208
2020-07-10 15:48:18 +00:00
Simon McVittie
b4d120fcb4 build: Don't export GResource-related symbols with newer GLib
This makes the desired behaviour explicit, and matches the behaviour
seen with Meson, where "external : false" is the default.

Before GNOME/glib!1468, not passing --internal to the resource compiler
meant "no special export attribute, do what you would normally do",
so these symbols were not exported due to our global use of
-fvisibility=hidden.

However, since GNOME/glib!1468, not passing --internal to the resource
compiler results in the symbols being decorated with G_MODULE_EXPORT,
which overrides -fvisibility=hidden. This was necessary because Windows
DLLs normally behave a bit like the equivalent of ELF libraries with
-fvisibility=hidden.

Signed-off-by: Simon McVittie <smcv@debian.org>
Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/2919
2020-07-09 16:57:42 +01:00
Biggio
4b953dee70 quartz: mimic source device axes
Input devices such as stylus pens have additional axes besides (x,y)
coordinates. In order for these devices to work properly, their additional
axes need to be mimicked from the physical device to the associated
virtual pointer when they become active.
2020-07-08 15:26:06 +02:00
Caolán McNamara
2b74662b2b gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface
so LibreOffice can reuse toplevels and get the right task icons

references;
 https://gitlab.gnome.org/GNOME/gtk/-/issues/767
 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html
 e0d6ad1d5e
 https://bugs.documentfoundation.org/show_bug.cgi?id=125934
 https://bugzilla.redhat.com/show_bug.cgi?id=1334915
 https://bugreports.qt.io/browse/QTBUG-77182
2020-07-07 21:14:21 +01:00
Chun-wei Fan
98996aa60b GDK/Win32: Force GLES if running on ARM64
If GLES support is enabled on Windows, force GLES mode if we are running
on a ARM64 version of Windows (i.e. Windows 10 for ARM).

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

Note that eventually we could update the libepoxy build files for Windows
to not check nor enable WGL when building for ARM64 Windows, as the WGL
items do not work, although they do build.
2020-07-07 16:53:01 +08:00
John Ralls
04ed7fe7db [Quartz]Fix some deprecation and unused variable warnings. 2020-06-20 11:16:18 -07:00
John Ralls
3f5cf71039 [Quartz] Correct availability macro name. 2020-06-20 10:06:19 -07:00
John Ralls
c884308da3 [Quartz] Only normal toplevels should be in the Windows menu.
The Quartz Window Manager adds to the Windows menu all NSWindows with
titles. Since we assign a default title to all windows that produced a
rather cluttered Windows menu containing among other things dialogs.
Setting aside that dialogs don't belong in the Windows menu, if
a dialog was hidden for reuse instead of destroyed it would persist in
the Windows menu and if clicked there would show, but because it wasn't
running wouldn't respond to events and so couldn't be hidden again and
would remain on top of its parent window.

Ref: https://bugs.gnucash.org/show_bug.cgi?id=797807
2020-06-20 09:49:44 -07:00
Alexander Larsson
7638bcc8e9 Merge branch 'frame-clock-alternative-approach' into 'gtk-3-24'
Frame clock alternative approach

See merge request GNOME/gtk!1931
2020-06-15 10:49:41 +00:00
Yariv Barkan
cf91cf4825 frame clock: fix scheduling
Fix scheduling of the frame clock when we don't receive "frame drawn"
messages from the compositor.

If we received "frame drawn" events recently, then the "smooth frame
time" would be in sync with the vsync time. When we don't receive frame
drawn events, the "smooth frame time" is simply incremented by constant
multiples of the refresh interval. In both cases we can use this smooth
time as the basis for scheduling the next clock cycle.

By only using the "smooth frame time" as a basis we also benefit from
more consistent scheduling cadence. If, for example, we got "frame
drawn" events, then didn't receive them for a few frames, we would still
be in sync when we start receiving these events again.
2020-06-15 08:53:23 +02:00
Yariv Barkan
b80bc06b99 frame clock: adjust reported frame time
When an animation is started while the application is idle, that often
happens as a result of some external event. This can be an input event,
an expired timer, data arriving over the network etc. The result is that
the first animation clock cycle could be scheduled at some random time,
as opposed to follow up cycles which are usually scheduled right after a
vsync.

Since the frame time we report to the application is correlated to the
time when the frame clock was scheduled to run, this can result in
uneven times reported in the first few animation frames. In order to fix
that, we measure the phase of the first clock cycle - i.e. the offset
between the first cycle and the preceding vsync. Once we start receiving
"frame drawn" signals, the cadence of the frame clock scheduling becomes
tied to the vsync. In order to maintain the regularity of the reported
frame times, we adjust subsequent reported frame times with the
aforementioned phase.
2020-06-15 08:53:17 +02:00
Emmanuel Gil Peyrot
75a9f8dc92 Switch to GL_ARB_framebuffer_object
GTK+ 3.0 was currently using GL_EXT_framebuffer_object, which is
deprecated as the ARB version has been merged into OpenGL 3.0 as well as
OpenGL ES 2.0, and provides laxer requirements.
2020-06-11 21:24:17 +02:00
Sebastian Keller
9459be11a9 wayland: Signal gtk-shell surface destruction to the server
This adds a "release" destructor for the gtk_surface1 interface which
signals to the server that a surface has been destroyed on the client
side, which the current "destroy" does not do.

Ideally the protocol would have specified a destroy request marked as
destructor to handle this automatically, however this is no longer
possible due to the destroy method being implicitly generated in the
absence of an explicit request in the protocol. Adding a destroy request
marked as destructor now would generate a new destroy method that
unconditionally would send the request to the server, which would break
clients running on servers not supporting that request.
2020-06-11 11:38:21 +02:00
Yariv Barkan
c7c404833f frame clock: schedule in refresh intervals
When the application does not receive "frame drawn" signals we schedule
the clock to run more or less at intervals equal to the last known
refresh interval. In order to minimize clock skew we have to aim for
exact intervals.

(cherry picked from commit f5de46670b)
2020-06-05 11:59:52 +02:00
Alexander Larsson
3466bfdf2d frame clock: Better handle non-regular clock cycles
We try to step the frame clock in whole refresh_interval steps, but to
avoid drift and rounding issues we additionally try to converge it to
be synced to the physical vblank (actually the time we get the
frame-drawn message from the compositor, but these are tied together).

However, the convergence to vsync only really makes sense if the new
frame_time actually is tied to the vsync. It may very well be that
some other kind of event (say a network or mouse event) triggered
the redraw, and not a vsync presentation.

We used to assume that all frames that are close in time (< 4 frames
apart) were regular and thus tied to the vsync, but there is really no
guarantee of that. Even non regular times could be rapid.

This commit changes the code to only do the convergence-to-real-time
if the cause of the clock cycle was a thaw (i.e. last frame drawn and
animating). Paint cycles for any other kind of reason are always
scheduled an integer number of frames after the last cycle that was
caused by a thaw.

(cherry picked from commit 91af8a705b)
2020-06-05 11:50:04 +02:00
Alexander Larsson
87721d0da7 frame clock: Track if paint is caused by thaw or not
When we get to a paint cycle we now know if this was caused by a
thaw, which typically means last frame was drawn, or some other event.

In the first case the time of the cycle is tied to the vblank in some
sense, and in the others it is essentially random. We can use this
information to compute better frame times. (Will be done in later
commits.)

(cherry picked from commit 82c314f1af)
2020-06-05 11:49:56 +02:00
Alexander Larsson
ede4d06192 Fix frameclock going backwards
When we run the frameclock RUN_FLUSH_IDLE idle before the paint,
then gdk_frame_clock_flush_idle() sets
```
  priv->phase = GDK_FRAME_CLOCK_PHASE_BEFORE_PAINT
```
at the end if there is a paint comming.

But, before doing the paint cycle it may handle other X events, and
during that time the phase is set to BEFORE_PAINT. This means that the
current check on whether we're inside a paint is wrong:

```
  if (priv->phase != GDK_FRAME_CLOCK_PHASE_NONE &&
     priv->phase != GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS)
    return priv->smoothed_frame_time_base;
```

This caused us to sometimes use this smoothed_frame_time_base even
though we previously reported a later value during PHASE_NONE, thus
being non-monotonic.

We can't just additionally check for the BEGIN_PAINT phase though,
becasue if we are in the paint loop actually doing that phase we
should use the time base. Instead we check for `!(BEFORE_PAINT &&
in_paint_idle)`.

(cherry picked from commit a36e2bc764)
2020-06-05 11:06:42 +02:00
Sebastian Keller
7998c53396 wayland: Remove unused fribidi include
The included fribidi header is not used in gdkkeys-wayland.c and already
included in gdk.c which causes linker issues due to the header defining
a global variable.
2020-06-04 21:08:20 +02:00
Alexander Larsson
1a598c32d9 frame-clock: Ensure we're always monotonic
A call to frame gdk_frame_clock_get_frame_time() outside of the paint
cycle could report an un-error-corrected frame time, and later a
corrected value could be earlier than the previously reported value.

We now always store the latest reported time so we can ensure
monotonicity.

(cherry picked from commit a27fed47e0)
2020-05-28 17:48:32 +02:00
Alexander Larsson
687b49c18a frame-clock: New approach in smoothing frame clock
In commit c6901a8b, the frame clock reported time was changed from
simply reporting the time we ran the frame clock cycle to reporting a
smoothed value that increased by the frame interval each time it was
called.

However, this change caused some problems, such as:
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1415
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1416
 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1482

I think a lot of this is caused by the fact that we just overwrote the
old frame time with the smoothed, monotonous timestamp, breaking
some things that relied on knowing the actual time something happened.

This is a new approach to doing the smoothing that is more explicit.
The "frame_time" we store is the actual time we ran the update cycle,
and then we separately compute and store the derived smoothed time and
its period, allowing us to easily return a smoothed time at any time
by rounding the time difference to an integer number of frames.

The initial frame_time can be somewhat arbitrary, as it depends on the
first cycle which is not driven by the frame clock. But follow-up
cycles are typically tied to the the compositor sending the drawn
signal. It may happen that the initial frame is exactly in the middle
between two frames where jitter causes us to randomly round in
different directions when rounding to nearest frame. To fix this we
additionally do a quadratic convergence towards the "real" time,
during presentation driven clock cycles (i.e. when the frame times are
small).

(cherry picked from commit 9ef3e70040)
2020-05-28 17:10:14 +02:00
Alexander Larsson
ac30f9b4cc frame clock: Use compositor refresh rate info even if presentation time not set
On my X11 + nvidia setup gnome-shell doesn't report presentation times.
However it does report refresh rate. We were mostly using this in our
calculation except when computing predicted presentation time, were
it fell back on the default 60Hz.

(cherry picked from commit f1215d2d77)
2020-05-28 17:05:51 +02:00
Alexander Larsson
c03480cbd3 FrameClock debug: Log drawn_time if set
(cherry picked from commit e2a4be0243)
2020-05-28 17:05:38 +02:00
Andreas Butti
ecbed15d47 Support for macOS Pen / Eraser input #1551
This fix is based on this patch: https://bugzilla.gnome.org/show_bug.cgi?id=695701
2020-05-19 16:10:07 +02:00
Carlos Garnacho
948782b7e5 gdk/wayland: Handle disorderly tablet/pad disconnects
If the tablet gets removed/freed while there are pad events in flight,
we leave a dangling pointer from the pad to the tablet, which may
lead to invalid reads/writes when handling the pad event(s).

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2748
2020-05-15 18:47:14 +02:00
Rene Hopf
69334021a2 force redraw in glareawhen buffer_age is 0
Reading form the back buffer is not allowed on software renderers,
and this is reported by the buffer age, so reading from GL_BACK
should not be done when the age is 0

Closes #64
2020-05-10 21:21:08 +02:00
Руслан Ижбулатов
f67bad2346 GDK W32: Use SPI_GETFONTSMOOTHINGTYPE instead of SPI_GETCLEARTYPE
It turns out that SPI_GETCLEARTYPE always returns TRUE.

Fixes #1774 (for real this time).
2020-05-10 07:17:50 +00:00
Alberto Fanjul
1e2d72144a Prevent crashes on gdk wayland implementation using offscreen windows 2020-04-28 15:14:53 +02:00
LRN
95fd38426c Merge branch 'gtk-3-24-w32-xsettings-defaults' into 'gtk-3-24'
GDK W32: Correctly infer gtk-xft-antialias & gtk-xft-rgba

See merge request GNOME/gtk!1741
2020-04-26 21:36:00 +00:00
Руслан Ижбулатов
217158995a GDK W32: Correctly infer gtk-xft-antialias & gtk-xft-rgba
Instead of hardcoding gtk-xft-antialias, use SPI_GETFONTSMOOTHING to
determine whether antialiasing is enabled.

Make gtk-xft-rgba query more complex - try to determine display
orientation, then use that to rotate subpixel structure. This
won't help with monitors that have naturally vertical subpixels,
but should improve things for monitors that are rotated (as long
as Windows display settings are adjusted accordingly).

Partially fixes #1774
2020-04-26 20:40:57 +00:00
Руслан Ижбулатов
00f06f2480 GDK W32: Remove stacking functions
Stacking functions enforce non-native stacking behaviour that is
mostly unneeded, and doing so introduces bugs and complicates things.
2020-04-26 19:16:02 +00:00
Руслан Ижбулатов
83ebdbdbf4 Revert "GDK W32: Use SWP_NOOWNERZORDER everywhere it can be applied"
This reverts commit fc2008f240.

Turns out, we *don't* have code to maintain Z-order. Restacking
code is not doint that, it just enforces a few weird Z-order-related
behaviours.
2020-04-26 19:11:45 +00:00
Luca Bacci
1697be5e44
Fix function signature 2020-04-23 19:21:36 +02:00
Matthias Clasen
a2b101ba5b Merge branch 'fno-common-3-24' into 'gtk-3-24'
Add a missing extern, to fix building with -fno-common (3.24 branch)

See merge request GNOME/gtk!1632
2020-04-11 15:16:55 +00:00
Jonas Ådahl
cf060b4c7d wayland: Move warning about transient-less temporaries to map()
We shouldn't warn in a funtion that seemingly only checks how something
eventually should be mapped.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2589
2020-04-08 11:43:49 +02:00
Matthias Clasen
99bae0fb5f Merge branch 'wip/wayland-unconfigured-cut-shadow-2' into 'gtk-3-24'
wayland: Always store unconfigured size

See merge request GNOME/gtk!1638
2020-04-07 11:31:56 +00:00
Simon McVittie
b35cd705a7 build: Generate gdk.gresource.xml in sorted order
The order in which the resources get embedded matters for reproducible
builds. In the Meson build system, gen-gdk-gresources-xml already sorts
the list, but in the Autotools build system they were previously taken
in readdir() order.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-07 10:50:04 +01:00