Commit Graph

1752 Commits

Author SHA1 Message Date
Benjamin Otte
30a4150c8e x11: Use boolean instead of enum for errors in xsettings code 2013-02-19 14:33:36 +01:00
Benjamin Otte
23b039c8cd x11: Move error reporting to where the error happens
Also, use g_warning() instead of fprintf().
2013-02-19 14:33:36 +01:00
Benjamin Otte
b36b89151e x11: Move length checking into return_if_fail() macro 2013-02-19 14:33:36 +01:00
Benjamin Otte
e3206b9de4 x11: Use GDK error trapping code 2013-02-19 14:33:36 +01:00
Benjamin Otte
c84e303fb5 x11: Split out xsettings string reading code 2013-02-19 14:33:36 +01:00
Benjamin Otte
2b83062fc6 x11: Clean up xsettings header
Move private struct definitions into source file, remove unneeded C++
guards.
2013-02-19 14:33:36 +01:00
Benjamin Otte
0c58cb744c x11: Add debugging output for xsettings code 2013-02-19 14:33:36 +01:00
Benjamin Otte
08a6f554c3 x11: Use glib malloc funcs for XSettings 2013-02-19 14:32:41 +01:00
Benjamin Otte
7800e68b73 x11: Call grab functions directly
... instead of going via vfuncs.
2013-02-19 14:32:41 +01:00
Benjamin Otte
eb4792128f x11: Pass the GdkScreen to the XSettingsClient 2013-02-19 14:32:41 +01:00
Benjamin Otte
bb4953f3e8 x11: Fold xsettings-common.[ch] into xsettings-client.[ch] 2013-02-19 14:32:41 +01:00
Benjamin Otte
63f0797e70 x11: Return XSetting without copying 2013-02-19 14:32:41 +01:00
Benjamin Otte
1f95eddbda x11: Don't store last change serial
It's unused anyway
2013-02-19 14:32:41 +01:00
Benjamin Otte
8fa1b2bb9d xsettings: Remove XSettingsList type
Use GHashTable throughout
2013-02-19 14:32:41 +01:00
Benjamin Otte
d7ea5b5266 xsettings: Use glib byte order functions 2013-02-19 14:32:40 +01:00
Benjamin Otte
c1a4a1da10 xsettings: Remove unused function
Remove xsettings_client_new() and rename
xsettings_client_new_with_grab_funcs() to xsettings_client_new()
2013-02-19 14:32:40 +01:00
Owen W. Taylor
69d42639b2 GdkWindowX11: the root window is not a toplevel
The macros we had for checking for toplevel windows were passing
through the root window, which was not intentional and meant that
for the root window WINDOW_IS_TOPLEVEL() returned TRUE but
window->impl->toplevel was NULL, causing gdk_window_create_cairo_surface()
to crash.
2013-02-16 11:56:17 -05:00
Owen W. Taylor
ff935c5738 Ignore window manager protocol messages for destroyed windows
If we get, for example, a _NET_WM_FRAME_DRAWN or _NET_WM_PING
message on a destroyed window, then we should just ignore it.
2013-02-14 17:19:53 -05:00
Owen W. Taylor
bb11195ec0 GdkFrameClock: Clean up the public API
* remove gdk_frame_clock_get_frame_time_val(); a convenience
  function that would rarely be used.
* remove gdk_frame_clock_get_requested() and
  ::frame-requested signal; while we might want to eventually
   be able to track the requested phases for a clock, we don't
  have a current use case.
* Make gdk_frame_clock_freeze/thaw() private: they are only
  used within GTK+ and have complex semantics.
* Remove gdk_frame_clock_get_last_complete(). Another convenience
  function that I don't have a current use case for.
* Rename:
  gdk_frame_clock_get_start() => gdk_frame_clock_get_history_start()
  gdk_frame_clocK_get_current_frame_timings() => gdk_frame_clock_get_timings()
2013-02-14 17:19:52 -05:00
Owen W. Taylor
d5edf9c072 GdkFrameTimings: strip down to a minimal public API
Since we're not exporting the ability to create your own frame
clock for now, remove the setters for GdkFrameTimings fields.
Also remove all setters and getters for fields that are more
about implementation than about quantities that are meaningful
to the applcation and just access the fields directly within
GDK.
2013-02-14 17:19:52 -05:00
Owen W. Taylor
515e5f74aa Merge GdkFrameHistory into GdkFrameClock
Now that GdkFrameClock is a  class, not interface, there's no real advantage
to splitting the frame history into an aggregate object, so directly
merge it into GdkFrameClock.
2013-02-14 17:19:52 -05:00
Owen W. Taylor
be22b9fbb9 GdkWindow: make the frame clock an inherent property of the window
Instead of making the frame clock a settable property of a window, make
toplevel windows inherently have a frame clock when created (getting
rid of the default frame clock.) We need to create or destroy frame
clocks when reparenting a window to be a toplevel, or to not be a
toplevel, but otherwise the frame clock for a window is immutable.
2013-02-14 17:19:52 -05:00
Owen W. Taylor
06c4598fc5 GdkX11DeviceManagerXI2: handle focus events not on a known window
If we get a focus event for a X window we don't recognize, just
ignore it and avoid a g-critical when
_gdk_device_manager_core_handle_focus() is called with a NULL window.
2013-02-14 17:19:51 -05:00
Owen W. Taylor
645b5f398d Reimplement _NET_WM_SYNC_REQUEST inside X11 backend
Deprecate gdk_window_enable_synchronized_configure() and
gdk_window_configure_done() and make them no-ops. Implement the
handling of _NET_WM_SYNC_REQUEST in terms of the frame cycle -
we know that all processing will be finished in the next frame
cycle after the ConfigureNotify is received.
2013-02-14 17:19:51 -05:00
Owen W. Taylor
8865ebcc80 Fix up for newer draft of wm-spec
* 64-bit quantities are consistently ordered low-32-bits / high-32-bits
* data.l[4] in _NET_WM_SYNC_REQUEST indicates which counter to update
2013-02-14 17:19:51 -05:00
Owen W. Taylor
fb44ea8a85 Add gdk_frame_timings_get_predicted_presentation_time()
For an operation like synchronizing audio to video playback, we need to
be able to predict the time that a frame will be presented. The details
of this depend on the windowing system, so make the backend predict
a presentation time for ::begin-frame and set it on the GdkFrameTimings.

The timing algorithm of GdkFrameClockIdle is adjusted to give predictable
presentation times for frames that are not throttled by the windowing
system.

Helper functions:

 gdk_frame_clock_get_current_frame_timings()
 gdk_frame_clock_get_refresh_info()

are added for operations that would otherwise be needed multiple times
in different locations.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:51 -05:00
Owen W. Taylor
8855bf052d Add GDK_DEBUG=frames
Add a debug option to print out detailed statistics about each frame drawn.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:51 -05:00
Owen W. Taylor
0def26ecf1 GdkWindowX11: Communicate gdk_frame_timings_get_slept_before() to the compositor
We want the compositor to do different things for frames where
"slept before" is TRUE. Communicate to the compositor that
frame is a no-delay frame (slept_before=FALSE) by ending the frame
by increasing the counter value by 1, and that the frame is a
normal frame (slept_before=TRUE) by increasing the counter value
by 3.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:50 -05:00
Owen W. Taylor
15ee04c66f Add GdkFrameHistory and GdkFrameTimings, handle _NET_WM_FRAME_TIMINGS
In order to be able to track statistics about how well we are drawing,
and in order to be able to do sophisticated things with frame timing
like predicting per-frame latencies and synchronizing audio with video,
we need to be able to track exactly when previous frames were drawn
to the screen.

Information about each frame is stored in a new GdkFrameTimings object.
A new GdkFrameHistory object is added which keeps a queue of recent
GdkFrameTimings (this is added to avoid further complicating the
implementation of GdkFrameClock.)

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:50 -05:00
Owen W. Taylor
d761df7e0c GdkWindowX11: Only start a frame when we emit damage
Instead of communicating the start of a frame to the window manager
as soon as we begin a frame, start a frame only when we know we've
actually created damage to the contents of a window.

(This uses cairo_set_mime_data() as a notification mechanism - a
clever suggestion from Uli Schlachter.)

The advantage of this is that we aren't forcing the compositor to
do a frame cycle and send _NET_WM_FRAME_DRAWN - depending on how the
compositor is structured that might either cause it to do extra
work or it might send _NET_WM_FRAME_DRAWN early and upset frame
timing.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:50 -05:00
Owen W. Taylor
d446dda920 gdk_display_get_event: don't unqueue events from the windowing system when paused
Unqueuing events from the windowing system when paused could result
in weird reordering if event filters resulted in application-visible
behavior. Since we now resume events when the frame clock is frozen,
we now no longer count on low-level event handling running while
event handling is paused.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:50 -05:00
Owen W. Taylor
6557a775df GdkWindowX11: start off with an odd frame-counter value
By starting with an odd frame counter value, we make the mapping
and initial paint of the window an atomic operation, avoiding
any visual artifacts from an unpainted window.

Possible improvement: start the frame when doing gdk_window_show(),
so that the same improvement occurs for windows that were previously
shown and are being mapped again.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:48 -05:00
Owen W. Taylor
355e305c16 Freeze the update counter for unmapped windows
When a window is unmapped, freeze its frame clock. This avoids doing
unnecessary work, but also means that we won't block waiting for
_NET_WM_FRAME_DRAWN messages that will never be received since the
frame ended while the window was withdrawn.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:48 -05:00
Owen W. Taylor
8a6895fe52 Use _NET_WM_FRAME_DRAWN to synchronize frame drawing
As part of the extended _NET_WM_SYNC_REQUEST_COUNTER protocol,
we get a _NET_WM_FRAME_DRAWN message for each frame we draw. Use this
to synchronize the updates we are doing with the compositing manager's
drawing, and ultimately with with display refresh.

We now set the sync request counters on all windows, including
override-redirect windows, since it is also useful to do synchronized,
atomic updates for such windows.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:48 -05:00
Owen W. Taylor
69f457426a Switch to an extended form of _NET_WM_SYNC_REQUEST_COUNTER
By exporting two XSync counters on a toplevel window, we subscribe
to an extended form of the _NET_WM_SYNC_REQUEST_COUNTER protocol,
where the window manager can initiate an atomic frame, as previously,
but the application can also do so by incrementing the new counter to
an odd value, and then to an even value to finish the frame.

See:
https://mail.gnome.org/archives/wm-spec-list/2011-October/msg00006.html

The support for 64-bit integers that GLib requires is used to
simplify the logic.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:48 -05:00
Owen W. Taylor
1824796bfb GdkFrameClock: add freeze/thaw
Add the ability to freeze a frame clock, which pauses its operation,
then thaw it again later to resume.

Initially this is used to implement freezing updates when we are
waiting for ConfigureNotify in response to changing the size of
a toplevel.

We need a per-window clock for this to work properly, so add that
for the X11 backend.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:48 -05:00
Owen W. Taylor
001f960a43 GdkDisplayX11: Don't use substructure events in internal accounting
We may receive events because SubstructureNotifyMask has been selected
for the root window. (Most likely, this would occur because GTK+
is being used inside a window manager like Metacity or Mutter.)
This can confuse various types of internal accounting, so detect
such events and comprehensively ignore them for GDK's internal
purposes. We still need to generate GDK events for these cases
because you can select for substructure events with
GDK_SUBSTRUCTURE_MASK.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:47 -05:00
Cosimo Cecchi
c896adc9e9 settings: add a gtk-recent-files-enabled GtkSetting
Backed by an XSetting, so g-s-d can set it according to the GSettings
value.

https://bugzilla.gnome.org/show_bug.cgi?id=693724
2013-02-13 12:06:43 -05:00
Jasper St. Pierre
002ac992d1 gdkdevicemanager-x11: Request XI2.3
Since XIQueryVersion, the bad API that it is, enforces the version from
the first client that requests it, for clients to be able to use the new
features in XI2.3, we need to ensure that we pass XIQueryVersion 2.3 as
the version that we support. We know that GTK+ won't be confused by the
new features.

https://bugzilla.gnome.org/show_bug.cgi?id=692467
2013-01-28 12:53:39 -05:00
Jasper St. Pierre
e340049eb8 gdkdevicemanager-x11: Always request XI2.2
The X server should fill in the minor version that it supports in the
case where it only supports the older version, so we can safely always
pass a higher version number than is potentially supported by the
server.

libXi was designed to be stable in the case where it doesn't recognize
requests or events/replies, so this should still work in a case where
we have new versions of the X server, and GTK+, but an old version of
libXi, at least for however well that setup should work.

https://bugzilla.gnome.org/show_bug.cgi?id=692467
2013-01-28 12:45:01 -05:00
John Lindgren
ce6b77c25b XSettingsList is now a typedef for GHashTable.
https://bugzilla.gnome.org/show_bug.cgi?id=692605
2013-01-27 01:08:25 +01:00
John Lindgren
885b43dd3a Use hash-based conversions for XSETTINGS names.
https://bugzilla.gnome.org/show_bug.cgi?id=692605
2013-01-27 01:08:25 +01:00
Olivier Fourdan
dac6a76ef2 x11: implement gdk_window_apply_fullscreen_mode()
for the X11 backend using the EWMH mechanism
_NET_WM_FULLSCREEN_MONITORS.

https://bugzilla.gnome.org/show_bug.cgi?id=691856
2013-01-25 13:16:57 +01:00
Benjamin Otte
1205e3b043 x11: unconst-cast result of g_get_prgname()
X doesn't like const...
2013-01-13 23:47:39 +01:00
Geoff Reedy
2fcbe3a9b4 x11: add missing checks that a hint is supported
Before acting on any hint that is set by the window manager we must
first check that the hint is supported by the current window manager.
Checking that a property has a value is insufficient as it may have
been set by a previous window manager which did support the hint.

https://bugzilla.gnome.org/show_bug.cgi?id=691515
2013-01-12 18:38:37 -05:00
Matthias Clasen
5adecf183b Move single-include guards inside include guards
gcc has optimizations for include guards that only work
if they are outermost in the the header.
https://bugzilla.gnome.org/show_bug.cgi?id=689810
2012-12-28 09:57:56 -05:00
Jasper St. Pierre
9dc4c5ce73 xi2: Abort early if we don't have a proper GDK window
This can happen in mutter or other applications that use GDK filters
but don't actually create GDK windows for everything they get events
for.

https://bugzilla.gnome.org/show_bug.cgi?id=689401
2012-12-13 10:51:38 -05:00
Matthias Clasen
256f168525 Obtain the recent files max age setting from xsettings
This will help with implementing desktop-wide policy for
retaining of history.

https://bugzilla.gnome.org/show_bug.cgi?id=689047
2012-11-29 23:10:33 -05:00
Cosimo Cecchi
e09cf6978e gdk: only emit display-opened after the default display has been set
This avoids a case where the display has been opened, but calling
gdk_display_get_default() in the callback doesn't work.

Reviewed-by: Benjamin Otte <otte@redhat.com>
2012-10-08 18:44:09 -04:00
Benjamin Otte
f9ddfa28b8 x11: Put function in header, don't declare them extern 2012-10-06 15:55:30 -04:00