Commit Graph

9310 Commits

Author SHA1 Message Date
Matthias Clasen
61c83f9ffe gdk: Documentation fixups
Document some missing symbols.
2020-06-05 20:59:51 -04:00
Matthias Clasen
ed1872f0a8 Merge branch 'frame-clock-start-time' into 'master'
Tweaks to frame clock for better ties to vsync

See merge request GNOME/gtk!2043
2020-06-05 18:33:48 +00:00
Ray Strode
972134abe4 x11: Defer _NET_WM_FRAME_DRAWN update until frame usable by compositor
With the vendor provided Nvidia driver there is a small window of time
after drawing to a GL surface before the updates to that surface
can be used by the compositor.

Drawing is already coordinated with the compositor through the frame
synchronization protocol detailed here:

https://fishsoup.net/misc/wm-spec-synchronization.html

Unfortunately, at the moment, GdkX11Surface tells the compositor the
frame is ready immediately after drawing to the surface, not later,
when it's consumable by the compositor.

This commit defers announcing the frame as ready until it's consumable
by the compositor. It does this by listening for the X server to announce
damage events associated with the frame drawing.  It tries to find the
right damage event by waiting until fence placed at buffer swap time
signals.
2020-06-05 10:01:13 -04:00
Ray Strode
f8770b78ea x11: Factor out some of frame sync code into subroutines
This commit moves some of the end frame sync counter handling
code to subroutines.

It's a minor readability win, but the main motivation is to
make it easier in a subsequent commit to defer updating the
sync counter until a more appropriate time.
2020-06-05 10:01:13 -04:00
Ray Strode
10f2b11fda x11: Add back support for the damage extension
commit 14bf58ec5d dropped support
for using the DAMAGE extension since there was no code that
needed it.

We're going to need it again, however, to address an NVidia
vendor driver issue.

This commit does the plumbing to add it back.
2020-06-05 10:01:13 -04:00
Yariv Barkan
f5de46670b 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.
2020-06-05 11:57:49 +02:00
Alexander Larsson
91af8a705b 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.
2020-06-05 11:30:47 +02:00
Alexander Larsson
82c314f1af 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.)
2020-06-05 11:16:57 +02:00
Sebastian Keller
2bd938952d 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 20:44:55 +02:00
Matthias Clasen
b814970bdd Merge branch 'fix-frameclock-going-backwards' into 'master'
Fix frameclock going backwards

See merge request GNOME/gtk!2011
2020-06-01 12:25:20 +00:00
Emmanuele Bassi
79105962a7 Remove position from GdkScrollEvent
Scroll events do not have a position, so they shouldn't implement the
GdkEventClass.get_position() virtual function; nor they should have an x
and y fields that never get updated.
2020-06-01 10:49:33 +01:00
Alexander Larsson
a36e2bc764 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)`.
2020-06-01 10:53:24 +02:00
Matthias Clasen
cbe81fd443 Merge branch 'drop-fallback-c89' into 'master'
Drop fallback-c89.c

See merge request GNOME/gtk!1999
2020-05-31 18:14:14 +00:00
Christoph Reiter
2d5cf2b4c4 Drop fallback-c89.c
We require a C compiler supporting C99 now. The main purpose of
these fallbacks was for MSVC. From what I can see this is now all supported
by MSVC 2015+ anyway.

The only other change this includes is to replace isnanf() with the
(type infering) C99 isnan() macro, because MSVC doesn't provide isnanf().
2020-05-31 17:09:23 +02:00
Emmanuele Bassi
43e5ca9a1b docs: Fix annotations
- Use the same name for the argument in the declaration, definition,
   and documentation
 - Use "optional" instead of the deprecated "allow-none"
2020-05-31 15:04:51 +01:00
Benjamin Otte
c337887e29 xxx: Add a hack to make paintables transform to/from objects
See also: https://gitlab.gnome.org/GNOME/glib/merge_requests/1251
2020-05-30 19:26:46 -04:00
Benjamin Otte
3c1cca13b7 wayland: Remove function declaration for nonexisting function 2020-05-30 10:46:49 -04:00
Matthias Clasen
346bba6592 Bring back gdk_display_put_event
It is still needed in WebKit.
2020-05-29 09:26:50 -04:00
Matthias Clasen
c7a9d7b56b Merge branch 'im-context-key-forward' into 'master'
Add back keyboard related apis

See merge request GNOME/gtk!1977
2020-05-29 00:10:39 +00:00
Matthias Clasen
266a3a5267 Export keymap translation again
This is needed in WebKit webdriver test environment.
2020-05-28 15:15:53 -04:00
Matthias Clasen
48f8affb2c gdk: Make event-related apis private
Without a way to create events, there is no point
in allowing gdk_display_put_event to be used from
the outside. And little good can come out of using
the other apis, so just make them all private.
2020-05-28 14:53:08 -04:00
Alexander Larsson
a27fed47e0 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.
2020-05-28 17:44:51 +02:00
Alexander Larsson
9ef3e70040 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).
2020-05-28 15:13:07 +02:00
Alexander Larsson
f1215d2d77 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.
2020-05-28 15:12:32 +02:00
Alexander Larsson
0ad73da68a frame clock: Used drawn_time (as well as presentation time) in profiler marks. 2020-05-28 15:12:32 +02:00
Alexander Larsson
e2a4be0243 FrameClock debug: Log drawn_time if set 2020-05-28 15:12:32 +02:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
646a1c2b88 win32: Drop an unsed variable 2020-05-26 22:23:43 -04:00
Matthias Clasen
c47553e319 gdk: Drop no-longer-used documentation
Thread support is gone, and we don't have that
section in the docs anymore.
2020-05-26 20:52:41 -04:00
Matthias Clasen
45f162fc50 gdk: Remove an unused texture api
gdk_gl_texture_from_surface wasn't used anywhere,
so lets drop it.
2020-05-26 20:43:47 -04:00
Matthias Clasen
a20291f235 gdk: Drop some unused event queue functions 2020-05-26 20:43:47 -04:00
Matthias Clasen
3468b2fc44 gdk: Clean up gdkinternals.h
Remove definitions that are just leftovers with
nothing behind them anymore.
2020-05-26 20:43:47 -04:00
Matthias Clasen
aa0d0dc510 gdk: Drop _gdk_windowing_args
We are no longer parsing commandline args, so this
was a useless leftover that was still defined in
the win32 backend.
2020-05-26 20:13:13 -04:00
Matthias Clasen
9c82946e45 docs: Drop a mention of gdk_window_move()
We don't have windows anymore, and they don't move
anymore either.
2020-05-26 20:05:34 -04:00
Matthias Clasen
e5a9255555 gdk: Move the GdkGeometry typedef to gdkinternals.h
The struct was already there, so this is just a leftover.
2020-05-26 20:04:40 -04:00
Matthias Clasen
e14322137f gdk: Drop the GdkByteOrder enum
Move it to the private gdkvisual-x11.h header, which
is the only place where its used.
2020-05-26 19:45:01 -04:00
Matthias Clasen
f27d855c68 gdk: Drop the GdkEventMask enum
This is not used in public api anymore.
Some of the backends still use it internally,
so keep it in gdkinternals.h for now.
2020-05-26 19:39:31 -04:00
Matthias Clasen
0553b10214 gdk: Drop the GdkSurfaceTypeHint enum
This is not used in public api anymore.
Some of the backends still use it internally,
so keep it in gdkinternals.h for now.
2020-05-26 19:34:59 -04:00
Matthias Clasen
7fb5b970f5 gdk: Drop GDK_PARENT_RELATIVE
This define is not used anywhere.
2020-05-26 19:21:55 -04:00
Matthias Clasen
bd3f4599ed Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master

Closes #2778

See merge request GNOME/gtk!1966
2020-05-26 02:41:37 +00:00
Matthias Clasen
ec39ddee63 Help static analysis with an assertion
It is hard for clang to see that layouts will
always be smaller than num_layouts, so just assert
that.
2020-05-25 20:56:09 -04:00
Emmanuele Bassi
0cf5b66e7b Add private accessor for GdkKeyEvent.translated
Avoid accessing the event structure directly, even from within GTK.
2020-05-24 15:19:01 +01:00
Matthias Clasen
6d8153d8fd gdk: Short-circuit some surface setters
Don't call into the backends when the input region
or shadow width don't actually change. This avoid
distracting calls in debug logs, and just generally
is the right thing to do.
2020-05-20 10:55:27 -04:00
Timm Bäder
ae711d8301 gdkdisplay-wayland: only remove one monitor
Ids here are unique, so break out of the loop once we found the monitor
with the given ID.
2020-05-20 15:51:11 +02:00
Rico Tzschichholz
ebaeb9f3b8 gdk: Preserve typed event parameter of GdkSurface:event signal for gir
In conjunction to https://gitlab.gnome.org/GNOME/gtk/merge_requests/1936
2020-05-20 08:48:34 +02:00
Christian Hergert
fa08d848ca device: remove get_toplevel from surface_at_position vfunc
This is not used anymore now that surfaces are always toplevel in the
semantics of GdkWindow where child windows were available. We can drop
that and simplify the vfunc just a bit more.

Fixes #2765
2020-05-19 13:07:38 -07:00
Olivier Fourdan
93f9138c9b x11: update inhibit shortcuts on grab broken
On X11, shortcuts inhibition is emulated using a grab on the keyboard.

So if another widget ungrabs the keyboard behind our back (for example
when a popup window is dismissed) that effectively disables the effects
of the shortcut inhibition on the surface and we need to update the
shortcut inhibition status accordingly.

Check for "grab-broken" events on the surface and clear existing
shortcuts inhibition for the matching seat, so that the client can be
notified and may decide to re-enable shortcut inhibition if desired.
2020-05-19 14:51:25 +02:00
Emmanuele Bassi
dd4d6930b5 Use the right types for the GdkSurface::event arguments
We pass the GdkEvent as a pointer, because the autogenerated marshallers
don't know how to handle GTypeInstance-derived classes.

Since the GValue box that we use in the marshaller passes the GdkEvent
instance as is, we also need to acquire a reference before invoking the
closure, and release it afterwards, to ensure that the GdkEvent instance
survices the invocation.
2020-05-19 12:21:22 +01:00
Emmanuele Bassi
9bd9a11de4 docs: Fix the argument name to match
Both gtk-doc and g-i require the name of the argument of a function to
match in the declaration, definition, and gtk-doc stanza.
2020-05-18 14:55:25 +01:00
Matthias Clasen
d6818475d7 gdk: Simplify gdk_display_supports_input_shapes
Make this a display property, and do away with
the vfunc in favor of a private setter, to match
how we handle other display characteristics.
2020-05-17 22:05:24 -04:00