Commit Graph

1067 Commits

Author SHA1 Message Date
Emmanuele Bassi
739588cc3c wayland: Add declaration of private get_type() function 2017-04-28 23:03:14 +01:00
Emmanuele Bassi
7619c9c739 wayland: Mark private function as static 2017-04-28 22:47:29 +01:00
Emmanuele Bassi
82800fae52 wayland: Mark private function as static
The selection_lookup_offer_by_atom() function is private to the file and
not used elsewhere.
2017-04-28 22:21:19 +01:00
Olivier Fourdan
502e0a3a9e wayland: make key event log more explicit
With Wayland, GDK_DEBUG=events would log key events but not explicitly
state whether the event is a key press or release, or if it's
originating from a key repeat.

Add some more verbosity to make sure these informations are logged on
key delivery when GDK_DEBUG is set.

https://bugzilla.gnome.org/show_bug.cgi?id=781767
2017-04-28 13:09:39 +02:00
Florian Müllner
5527732763 gdk: Relicense translate_wm_button_layout_to_gtk()
It is generally a good idea to license individual files under the
same terms as the project license (in particular when the mismatch
boils down to having copied the wrong license header), so relicense
the code under the LGPL.

https://bugzilla.gnome.org/show_bug.cgi?id=781422
2017-04-27 21:05:12 +02:00
Matthias Clasen
2e7db0d662 Fix a typo 2017-04-21 18:28:56 -04:00
Matthias Clasen
2761fae728 Work around a wayland crash
For some reason, we are seeing damage being NULL here.
While that should never be the case, crashing on it is
unkind and makes the Wayland experience unusable.
2017-03-30 09:15:29 -04:00
Timm Bäder
ec2062498f glcontext: Fix buffer age comparison
The old code had a dead >=3 branch, causing flickering.
2017-03-21 19:04:58 +01:00
Timm Bäder
12b7d30a2d GdkWaylandWindow: Force window titles to valid utf8
Use the new g_utf8_make_valid in case the given title is not valid utf8.
Also bump the glib requirement to 2.51.5.
2017-03-20 20:04:26 +01:00
Olivier Fourdan
bbf7c6a715 wayland: make sure to clear up the number of keys
Make sure to clear up the number of keys being pressed on enter/leave so
that we don't end up with leftovers if a new window is mapped by a
keyboard shortcut.

https://bugzilla.gnome.org/show_bug.cgi?id=779374
2017-03-01 16:10:44 +01:00
Olivier Fourdan
4c533e17f5 wayland: do not cancel key repeat on key press
The key repeat is stopped as soon as a key is pressed, so if the user
quickly presses a key while another is already pressed and being
repeated, key repeat gets cancelled:

 - key1 press
 - key1 repeat
 - key2 press -> key1 repeat stopped
 - key1 release
 - key 2 is not repeated even though it's kept depressed

This is a different behavior from X11, which confuses migrating users.

To mimic the X11 behavior, keep track of the number of keys pressed
simultaneously and cancel key repeat only when none is pressed.

This way, if a user pressed a key while another one is being repeated,
the new key press can possibly be repeated as well.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=778019
2017-02-27 11:53:03 +01:00
Olivier Fourdan
83b54bab57 wayland: Fix a race condition with xdg_popup resize
When resizing an xdg_popup immediately after the initial mapping, there
is a race condition between the client and the compositor which is
processing the initial size given by the xdg_positioner, leading to the
xdg_popup to be eventually of the wrong size.

Only way to make sure the size is correct in that case is to hide and
show the window again. Considering this occurs before the initial
configure is processed, it should not be noticeable.

https://bugzilla.gnome.org/show_bug.cgi?id=772505
2017-02-24 10:07:17 +01:00
Olivier Fourdan
afa78fcffe wayland: do not clamp anchor values
Clamping the anchor values as introduced in commit 9a5ffcd to fix bug
777176 breaks menu positioning.

By keeping the anchors rectangle size greater than zero, we end up
deducting some positive value from the original position, so there is no
need to clamp() actually, keeping the values positive is enough and
avoids the issue with menu positioning on the menubar.

An additional benefit is to make the code a lot simpler.

https://bugzilla.gnome.org/show_bug.cgi?id=778009
2017-02-06 09:29:38 +01:00
Carlos Garnacho
4ebf98f440 wayland: Ensure to set gtk_surface dbus properties after hide()
Currently hiding destroys the wl_surface and all related interfaces,
(including the gtk_surface1) so the next time the GdkWindow is mapped,
we don't bother to set the DBus properties. Toggle the check off so
it's actually issued again after the GdkWindow gets a gtk_surface1.

https://bugzilla.gnome.org/show_bug.cgi?id=773686
2017-01-25 18:12:51 +01:00
Carlos Garnacho
f686dfb575 Revert "wayland: Push NULL buffer when hiding a GdkWindow"
This reverts commit 6beb0b91c9.
2017-01-20 14:04:37 +01:00
Carlos Garnacho
6beb0b91c9 wayland: Push NULL buffer when hiding a GdkWindow
This is how windows are meant to be hidden as per the wayland
protocol, there's no need to destroy the xdg_surface and other
interfaces.

Also, rename gdk_wayland_window_hide_surface() to clear_surface(),
as that's what it does.

https://bugzilla.gnome.org/show_bug.cgi?id=773686
2017-01-19 16:18:54 +01:00
Rui Matos
7a1b30f16e gdk/wayland: Always get the seat's key modifiers from the GdkKeymap
Elsewhere we already go through the keymap to get modifiers so we
should do the same here. In fact, this was relying on xkb modifier
mask values being bitwise compatible with GdkModifierType which isn't
necessarily true.

https://bugzilla.gnome.org/show_bug.cgi?id=770112
2017-01-17 18:24:28 +01:00
Rui Matos
515b71f14c gdk/wayland: Don't add GDK_META_MASK to gdk mod masks if MOD1 is set
Gtk+ treats MOD1 as a synonym for Alt, and does not expect it to be
mapped around, so we should avoid adding GDK_META_MASK if MOD1 is
already included to avoid confusing gtk+ and applications that rely on
that behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=770112
2017-01-17 18:24:28 +01:00
Jonas Ådahl
7ca6d7585f wayland: Handle subsurface as popup parent
When a subsurface is used as a parent of a popup, GDK needs to traverse
up to the transient-for as the next parent, to properly find the parent
used by the popup positioner. This is because the parent of a popup
must always either be an xdg_popup or an xdg_surface, but traversing
the "parent" (in GDK terms) upwards from a subsurface will end up on
the fake root window before we hit the actual parent (in Wayland terms).

https://bugzilla.gnome.org/show_bug.cgi?id=776225
2017-01-17 09:02:41 +01:00
Mohammed Sadiq
8ffecabd93 wayland: avoid an unnecessary g_list_length call
https://bugzilla.gnome.org/show_bug.cgi?id=777363
2017-01-16 21:42:05 -05:00
Olivier Fourdan
4259aba883 wayland: avoid 0 width/height anchor rectangle
Passing a rectangle with zero width or height to xdg_shell-v6
set_anchor_rect() will cause a protocol error and terminate the client,
as with gedit when pressing the Win key.

Reason for this is because the rectangle used to set the anchor comes
from gtk_text_layout_get_iter_location() which uses the pango layout
width/height, which can be empty if there is not character at the given
location.

Make sure we don't use 0 as width or height as an anchor rectangle to
avoid the protocol error, and compensate the logical position of the
given rectangle if the size is changed, so that the actual position
remains as expected by the client.

https://bugzilla.gnome.org/show_bug.cgi?id=777176
2017-01-16 13:55:51 +01:00
Rui Matos
ae61220c9f gdk/wayland: Handle non-existant gsettings keys
Since we're a library, crashing on gsettings keys, whose presence is out
of our control, isn't appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=775846
2017-01-10 15:17:32 +01:00
Rui Matos
b46da27d34 gdk/wayland: Add support for the gtk-enable-primary-paste gsetting
The gsetting was recently added so that we can have this configurable
on the wayland backend too.

https://bugzilla.gnome.org/show_bug.cgi?id=775846
2017-01-10 15:17:27 +01:00
Benjamin Otte
7ade6e3f46 gdk: Remove testing functions
They were unused and unimplemented.
2017-01-08 03:46:30 +01:00
Georges Basile Stavracas Neto
a001ddf7bf vulkan: Use LGPL v2 2017-01-04 16:02:44 -02:00
Georges Basile Stavracas Neto
c6ec982ac6 vulkan: Turn headers to LGPL 2017-01-04 18:40:20 +01:00
Georges Basile Stavracas Neto
3887548d55 wayland: Add support for Vulkan renderer
Mirror what's done with the X11 Vulkan renderer implementation,
with the addition of the extra Wayland window synchronization on
end_paint() override.
2017-01-04 13:24:08 +01:00
Alexander Larsson
330c7feaa2 gdk: Drop gdk_window_reparent
We're not currently using this, and dropping it allows us to loose
a bunch of code which leads us towards the goal of having GdkWindow
only for toplevels (and reparenting makes not sense for toplevels).
2016-12-16 12:35:03 +01:00
Alexander Larsson
5bf28a3869 gdk: Drop support for native (and thus foreign) subwindows
We can't really support these on e.g. wayland anyway, and we're trying
to get rid of subwindow at totally in the long term, so lets drop this.
It allows us to drop a lot of complexity.
2016-12-16 12:28:44 +01:00
Olivier Fourdan
5c3192c75a wayland: apply empty input shape on parent commit
For subsurfaces, the new state which includes the input shape is not
applied by the compositor if the subsurface is in effective synchronous
mode.

So we need to apply the input shape once parent surface is in effective
desynchronized mode, which is when it's committed, otherwise the input
shape may never be applied if the widget is not using being_paint() /
end_paint() to draw on its subsurface, like clutter does.

We do that only for empty input shape as those won't need update when
the subsurface is resized, for all other non-empty input shape, the
client still has to use begin_paint()/end_paint() for the input shape to
be applied.

https://bugzilla.gnome.org/show_bug.cgi?id=774534
2016-12-15 13:27:39 +01:00
Benjamin Otte
cd2b898353 wayland: Sync attributes also when drawing with GL
Probably syncing attributes shouldn't happen when drawing in the first
place, but what do I know about Wayland. ¯\_(ツ)_/¯
2016-12-06 18:02:11 +01:00
Benjamin Otte
a85a97c1a1 wayland: Uncomment erroneously commented out code
I read the code as if (use_gl) instead of if (!use_gl) and commented it
out in bddfd7bb41. That broke drawing on
Wayland without OpenGL completely.

Whoops.

Now it's back.
2016-12-06 17:51:35 +01:00
Benjamin Otte
8915be00d1 gdkgl: Add gdk_gl_context_get_damage()
This is a way to query the damaged area of the backbuffer.

The GL renderer uses this to compute the extents of that damage region
(computed via buffer age) and use them to minimize the area to redraw.

This changes the semantics of GL rendering to "When calling
gdk_window_begin_frame() with a GL context, the area by
gdk_gl_context_get_damage() needs to be redrawn and every other pixel of
the backbuffer is guaranteed to be correct.
After gdk_window_end_frame() on a GL-drawn window, the whole backbuffer
must be correct.

We can always glXBufferSwap() now because of this.
2016-12-05 15:02:47 +01:00
Benjamin Otte
ca78f5d3cb gdk: Make gdk_window_begin_draw_frame() take a draw context
... instead of a gl context.

This requires some refactoring in the way we mark the shared context as
drawing: We now call begin_frame/end_frame() on it and ignore the call
on the main context.
Unfortunately we need to do this check in all vfuncs, which sucks. But I
haven't found a better way.
2016-12-05 15:02:47 +01:00
Benjamin Otte
725a7236c0 gdk: Turn GdkGLContext into a GdkDrawContext 2016-12-05 15:02:47 +01:00
Benjamin Otte
e87b472143 glcontext: Make begin/end_draw() paired
This way, we can query the GL context's state via
gdk_gl_context_is_drawing().

Use this function to make GL contexts as attached and grant them access
to the front/backbuffer for rendering.

All of this is still unused because GL drawing is still disabled.
2016-12-05 15:02:47 +01:00
Benjamin Otte
182d18bcd1 gdk: Large GL refactoring
No visible changes as GL rendering is disabled at the moment.

What was done:

1. Move window->invalidate_for_new_frame to glcontext->begin_frame
This moves the code to where it is used (the GLContext) and prepares it
for being called where it is used when actually beginning to draw the
frame.

2. Get rid of buffer-age usage
We want to let the application render directly to the backbuffer.
Because of that, we cannot make any assumptions about the contents the
application renders outside the clip area.
In particular GskGLRenderer renders random stuff there but not actual
contents.

3. Pass the actual GL context
Previously, we passed the shared context to end_frame, now we pass the
actual GL context that the application uses for rendering. This is so
that the vfuncs could prepare the actual contexts for rendering (they
don't currently).

4. Simplify the code
The previous code set up the final drawing method in begin_frame.
Instead, we now just ensure the clip area is something we can render
and decide on the actual method in end_frame.
This is both more robust (we can change the clip area in between if we
want to) and less code.
2016-12-05 15:02:47 +01:00
Benjamin Otte
bddfd7bb41 gdk: Remove all code that only existed because of use_gl
Now that we don't use GL anymore, this code is unnecessary.
2016-12-05 15:02:47 +01:00
Matthias Clasen
92a1abcd23 wayland: Don't warn if we loose the compositor connection
And instead, exit cleanly. This avoids filling the logs with
these warnings from every single application that has a
connection to the compositor.
2016-11-30 13:45:04 -05:00
Benjamin Otte
efd04b47aa gdk: Make GdkDrawingContext not per-backend
No backend is using it, and we can put the backend-specific drawing code
into GdkGLContext.
2016-11-30 15:52:22 +01:00
Olivier Fourdan
39200e75b6 wayland: Place subsurfaces relative to their parent
Now that subsurfaces can be created as child of another GdkWindow (and
not just the root window), they must be placed according to the location
of their parent, i.e. the abs_x/abs_y must be updated and taken int
account when placing and moving subsurfaces under Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=774917
2016-11-24 09:32:41 +01:00
Benjamin Otte
2a27b7ecc6 API: Remove gdk_window_process_all_updates()
It's completely unused since we have a frame clock.
2016-11-23 19:10:34 +01:00
Benjamin Otte
cb18752f94 gdk: Make each backend have a custom GdkDrawingContext subclass 2016-11-20 07:19:52 +01:00
Carlos Garnacho
665c3a2877 wayland: Keep last scale factor on surfaces after it left all outputs
This can be triggered on workspace switches, and on hidpi results in
the scale factor being reset to 1 while the window is not in the
current workspace.

https://bugzilla.gnome.org/show_bug.cgi?id=774476
2016-11-18 13:24:31 -05:00
Florian Müllner
d163aba030 gdkdisplay-wayland: Add API to set startup notification ID
For wayland clients, the startup notification ID is currently only set
from the DESKTOP_STARTUP_ID environment variable. As that variable is
only set for clients launched via exec(), startup completion is not
indicated correctly for DBus-activated applications unless an explicit
ID is specified - usually that is not the case, as the default handling
uses gdk_notify_startup_complete().
To address this, we need API to set the startup notification ID from GTK
as we have on X11.

https://bugzilla.gnome.org/show_bug.cgi?id=768531
2016-11-09 14:18:14 -05:00
Benjamin Otte
d2c26c471c gdk: Remove attributes_mask from gdk_window_new()
The only remaining values were always treated as 0, so we just hardcode
them to 0.
2016-11-07 01:33:43 +01:00
Benjamin Otte
24d0baec38 API: gdk: Add gdk_window_new_popup()
... and use it.
2016-11-06 23:47:56 +01:00
Benjamin Otte
b30afff511 API: wayland: Add gdk_wayland_window_new_subsurface()
... and use it instead of gdk_window_new().
2016-11-06 21:36:43 +01:00
Benjamin Otte
7a6cab14eb gdkwindow: Remove GdkWindowAttr.type_hint
Instead, let the callers call gdk_window_set_type_hint(). Which is
surprsingly what every backend did.
2016-11-06 16:22:21 +01:00
Benjamin Otte
9707f4d3b3 API: gdk: Remove title from gdk_window_new()
Use gdk_window_set_title() afterwards instead.
2016-11-05 03:32:27 +01:00
Benjamin Otte
33e7a7898f API: gdk: Remove gdk_window_set_override_redirect()
When you want an override-redirect window, you create it that way.
Changing that behavior is not supported anywhere (but on X of course).
2016-11-05 03:32:27 +01:00
Benjamin Otte
7c474c689a wayland: Remove all mentions of visuals 2016-11-04 00:17:57 +01:00
Benjamin Otte
4585af5719 gdk: Remove visual APIs from GdkScreen
gdk_screen_list_visuals(), gdk_screen_get_system_visual() and
gdk_screen_get_rgba_visual() are gone now.
2016-11-04 00:02:37 +01:00
Olivier Fourdan
2324b96a32 wayland: check valid pending cairo surface
gdk_wayland_window_attach_image() is normally called from
gdk_window_end_paint() to notify the compositor of newly staged drawing.

If any of the drawing code inadvertently dispatches the wayland event
loop (for instance with a gdk_flush() call), then it's possible that by
the time gdk_window_end_paint() is called, the staged drawing is already
destroyed.

This commit bypasses the attach_image call in scenarios where the staged
drawing is prematurely dropped.

https://bugzilla.gnome.org/show_bug.cgi?id=773274
2016-11-03 08:50:34 +01:00
Benjamin Otte
d249e77bcb API: screen: Remove gdk_screen_is_composited()
Switch code to use gdk_display_is_composited() instead.

The new code also doesn't use a vfunc to query the property but rather
requires the backend to call set_composited()/set_rgba() to change the
value.
2016-10-29 04:49:47 +02:00
Benjamin Otte
45c0379f87 API: gdk: Remove visual querying APIs
They are unused, only work on the default display anyway and visuals are
on their way out.
2016-10-28 05:22:50 +02:00
Benjamin Otte
f420dc7456 API: gdk: Remove gdk_window_get_visual()
With it, remove window->visual.
2016-10-28 05:22:49 +02:00
Benjamin Otte
6cc94ff176 gdk: Remove GdkWindow.depth member variable
It's unused.
2016-10-28 05:22:32 +02:00
Matthias Clasen
e041345fcb Remove the last uses of GDK_DISPLAY_OBJECT
This is an obsolete macro.
2016-10-25 16:01:50 -04:00
Alexander Larsson
70935f0952 Drop support for offscreen GdkWindows
These complicate a lot of GdkWindow internals to implement features
that not a lot of apps use, and will be better achieved using gsk.
So, we just drop it all.
2016-10-25 09:54:37 +02:00
Carlos Garnacho
31db11dd5b wayland: Allow grabless xdg_popups
xdg_shell v6 allows grabless popups, whose behavior is not that
different from override redirect windows with no grab to take
keyboard input (and pointer events outside).

This means we can relax the requirement to have a grab before
creating an xdg_popup. The warning is still useful to have so
people stop relying on gdk_window_show();gdk_device_grab() being
an ok pattern to popup a window, it's been moved to wayland
implementation of gdk_device_grab() instead, so we warn if trying
to grab a GDK_WINDOW_TEMP window that's already visible.

https://bugzilla.gnome.org/show_bug.cgi?id=771694
2016-10-20 11:41:59 +02:00
Matthias Clasen
a0140cad15 Reduce a warning to a message
The warning interferes with having a testcase to check this behavior,
so reduce this to a message.
2016-10-17 19:11:32 -04:00
Benjamin Otte
eace2cf421 API: Remove gdk_window_set_background()
Backgrounds are always transparent black.
2016-10-16 18:17:21 +02:00
Benjamin Otte
662001b60a API: Remove ability to set visuals on windows
And with it, gtk_widget_get_visual() and gtk_widget_set_visual() are
gone.

We now always use the RGBA visual (if available) and otherwise fall back
to the system visual.
2016-10-16 18:17:21 +02:00
Benjamin Otte
89f2e17f91 API: Remove gdk_window_set_composited()
And the related call gdk_display_supports_composite().
2016-10-16 18:17:21 +02:00
Benjamin Otte
8d54c641f1 screen: Remove unused vfunc
GdkScreenClass.broadcast_client_message was unused, but a bunch of
backends still had functions (not) implementing it.
2016-10-16 18:17:21 +02:00
Benjamin Otte
9be9e00a0e API: screen: Remove gdk_screen_make_display_name()
It's identical to gdk_display_get_name().
2016-10-16 18:17:21 +02:00
Benjamin Otte
6b9e481e38 API: screen: Remove gdk_screen_get_active_window()
... and gdk_screen_get_window_stack().

Those functions were originally added in
5afb4f0f11 but do not seem to be used as
they are not implemented anywhere but in X.

As GDK is not meant to fulfill window management functionality I'm going
to remove these functions without replacements.
2016-10-16 18:17:21 +02:00
Benjamin Otte
26f9b584be API: gdk: Remove gdk_screen_get_number()
It's useless everywhere but in internal X11 code.
2016-10-16 18:17:21 +02:00
Benjamin Otte
0be88cc76e API: Remove gdk_screen_get_width() and gdk_screen_get_height()
... and gdk_screen_get_width_mm() and gdk_screen_get_height_mm() and
the shortcut counterparts that call these functions on the default
screen.

Modern display servers don't provide an ability to query the size of a
screen or display so we shouldn't allow that either.
2016-10-16 18:17:21 +02:00
Benjamin Otte
f7cebf5c1f wayland: Use GdkMonitor APIs 2016-10-16 18:17:21 +02:00
Adam Jackson
434ce02ebe Use eglGetPlatformDisplay{,EXT} if available
Calling eglGetDisplay forces libEGL to guess what kind of pointer you
passed it. Different EGL libraries will do different things here, and in
particular glvnd will do something different than Mesa. Since we do have
an API that allows us to explicitly type the display, use it.

The explicit call to eglGetProcAddress is working around a bug in
libepoxy 1.3, which does not understand the EGL concept of client
extensions. Since it does not, the normal epoxy resolver for
eglGetPlatformDisplayEXT would not find any provider for that entry
point, and crash when you attempted to call it.

Signed-off-by: Adam Jackson <ajax@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=772415
2016-10-10 14:17:09 -04:00
Adam Jackson
3b11575f0b Fix some EGLDisplay * abuse
EGLDisplays are already opaque pointers, and eglGetDisplay returns an
EGLDisplay not a pointer to one.

Signed-off-by: Adam Jackson <ajax@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=772415
2016-10-10 14:17:09 -04:00
Matthias Clasen
d053d5c58f Rename Makefile references from 3.0 to 4.0
This is almost certainly incomplete.
Needs careful scrutiny
2016-10-07 10:34:50 -04:00
Jonas Ådahl
f7c0661a61 wayland: Only 'moved-to-rect' if move_to_rect() was used
Don't emit the 'moved-to-rect' signal if move_to_rect() was used.

https://bugzilla.gnome.org/show_bug.cgi?id=771516
2016-09-30 06:40:30 -04:00
Gustavo Noronha Silva
7292b03559 wayland: always sync state after a frame is painted
Opaque region, margin and input region were only being synced when a cairo
paint happened. That caused GL paints to sometimes end up with bad state.
Move calls to sync state to gdk_window_impl_wayland_end_paint.

https://bugzilla.gnome.org/show_bug.cgi?id=771553
2016-09-28 10:17:09 +02:00
Olivier Fourdan
dbd0923b5f wayland: Avoid negative size constraints
Setting the shadow width earlier as done with commit 4cb1b96 to address
bug 771561 proved to cause unexpected side effects on size_allocate
signal propagation.

As the window is sized correctly earlier, the size_allocate signal is
not emitted again in gtk_widget_size_allocate_with_baseline() which
prevents clutter-gtk from relocating its child widget correctly.

To avoid this issue, revert commit 4cb1b96 but make sure the values
passed as min and max size is never negative in Wayland as this is a
protocol error.

With this, the min/max size will be wrong for a short amount of time,
during the state transition, until the shadow width is updated from
gdk_window_set_shadow_width().

This approach is much safer and less intrusive than changing the
size_allocate logic in gtk.

This reverts commit 4cb1b9645e.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=771915
2016-09-28 09:28:52 +02:00
Jonas Ådahl
c529d0a96e wayland: Move and resize popup after it was configured
A popup may have moved and resized when configured. Make sure every
layer knows about this and call gdk_window_move_resize() with the
configured dimension and position. This won't actually move the
window, but might resize it.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
d792400d7c wayland: Transform moved_to_rect result properly
The result of move_to_rect, received from the xdg_popup.configure
event, needs to be translated to the correct coordinate space; that is
from real parent window geometry to coordinates relative to the gdk
window set as transient-for.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
74d237df41 wayland: Use helper to translate to real parent window geometry
Use a helper to translate a coordinate from non-real GdkWindow parent
to window geometry coordinate space of the real GdkWindow parent,
meaning the coordinate space of the GdkWindow of the parent used as a
xdg_popup parent where (0, 0) is inside of the shadow margin.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
bc6630bb7d wayland: Don't pass parent when creating dynamic positioner
When using the dynamic positioner (i.e. positioning from move_to_rect)
we can always rely on having a proper transient-for to position
relative to, so lets drop the ignored parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
9a2ce3a485 wayland: Don't pass transient-for when getting real parent
It's always derived from transient-for so no need to pass it.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
50e33308db wayland: Fix south-west anchor rect calculation
https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
4d2c0a843a wayland: Don't pass non-changing state when calculating popup rects
https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Jonas Ådahl
e656a14764 wayland: Move move_to_rect related code closer together
Move the code used for calculating the result of move_to_rect
(final_rect, flipped_rect etc) closer to the other move_to_rect
functions (i.e. next to create_dynamic_positioner), and let the
xdg_popup configure handler just call the calculation function.

https://bugzilla.gnome.org/show_bug.cgi?id=771117
2016-09-14 11:29:32 +08:00
Olivier Fourdan
eb17ee1c26 wayland: unmap popup along with its toplevel
If an application umaps the toplevel from its popup callback, this can
lead to a protocol error.

Make sure we mark popup parent and use that to check if their parent is
the toplevel being unmapped in which case we shall unmap the popup first
to avoid the protocol error.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=770906
2016-09-12 10:03:58 +02:00
Timm Bäder
476c1c44a5 gdkdisplay-wayland: Fix some memory leaks 2016-09-08 11:34:13 +02:00
Jonas Ådahl
98b0f78200 wayland: Warn when an application tries to map popup incorrectly
When a popup is mapped but will not be the top most popup (for example
the parent is not the current top most popup, or if there already is a
popup mapped but the parent is a toplevel), warn and ignore it instead
of continuing, as continuing would be a protocol violation.

https://bugzilla.gnome.org/show_bug.cgi?id=770745
2016-09-02 18:56:03 +08:00
Matthias Clasen
bdbe2de57d Document handle-related Wayland api
In particular, note that this API depends on an unstable
Wayland protocol and thus may have to change.
2016-08-29 13:20:44 -04:00
Jonas Ådahl
340b5964dd wayland: Add API for setting an exported as a parent
Add an API that enables an application to, given an exported window
handle, set its own window as a transient of the window associated with
the exported window handle.

https://bugzilla.gnome.org/show_bug.cgi?id=769788
2016-08-29 13:20:44 -04:00
Jonas Ådahl
127d2ac956 wayland: Add API for creating exported window handles
Using the xdg_foreign protocol, expose a way to get handles to windows
that may be shared between processes.

https://bugzilla.gnome.org/show_bug.cgi?id=769788
2016-08-29 13:20:44 -04:00
Olivier Fourdan
9f57fe9960 wayland: add min/max size from xdg-shell v6
Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=764413
2016-08-25 11:04:16 +02:00
Jonas Ådahl
b7964cf5a7 wayland: Implement move_to_rect
Translate move_to_rect parameter into xdg_positioner requests, and use
the generated xdg_positioner to create the popup.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
ceada4adc2 wayland: Port to xdg_shell unstable v6
https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
643f033923 wayland: Move window geometry calculation to helper
We'll use it from more places later.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
d2a80cd235 wayland: Only update the window title if it actually updated
This makes the protocol log less spammy.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
8270699119 wayland: Only sync surface regions once per commit
Only set input, opaque and window geometry regions once per commit.
They are double buffered anyway, so the last one would only take effect
either way; this way reading protocol logs are much more pleasent.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
d2385bec09 wayland: Remove gdk_wayland_display_get_xdg_shell()
Don't expose the xdg_shell struct as it is not yet a stable type that
will stay the same.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
e53d381430 wayland: Get tiled state from gtk_shell instead of xdg_shell
Use our the 'tiled' entry from our new 'state' enum sent via
xdg_surface.configure.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
80dd7566d5 wayland: Fix indentation
https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Matthias Clasen
b8f464e102 wayland: Add some more debug spew 2016-08-25 00:13:13 -04:00
Matthias Clasen
ae720784d9 wayland: Replace g_debug by GDK_NOTE
We have this framework, lets use it.
2016-08-25 00:05:49 -04:00
Carlos Garnacho
87af999b5d wayland: Offer wayland-specific method to set pad actions feedback
The wayland tablet protocol allows notifying the compositor with
descriptions of the actions performed by each tablet element. This
API call allows to hook up in to this wayland-specific feature.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
27f879b835 wayland: Support pad devices in gdk_wayland_device_get_node_path()
We can return the node path on those too, so do that.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
7e961b8bcc wayland: Implement pad event emission
We now send all the set of button/ring/strip/group_mode events.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
cca51b71cb wayland: Create/expose pad devices
These devices are kind of an strange case. Their "master" device is
the keyboard, because they share toplevel focus with it, regardless
of stylus focus. Nonetheless, they are only expected to send the
GdkEventPad* set of events.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
82a46faf41 wayland: Add GdkWaylandDevicePad
This is a subclass of GdkWaylandDevice that implements GdkDevicePad,
all pad features are looked up from the info obtained through the
tablet v2 interface.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
feb09e384c wayland: Implement backbone of pad support
All pad interfaces and features are poked, we just now need
exposing those.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:45 +02:00
Carlos Garnacho
3ac56e60c7 wayland: Add wayland-specific method to retrieve a device node path
This will be useful at least for g-c-c, in order to match libwacom
data with GdkDevices.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:44 +02:00
Carlos Garnacho
942d144d3b gdk: Pass hardware ID on gdk_device_tool_new()
And implement this on wayland, where this information is already obtained.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:44 +02:00
Olivier Fourdan
f9b91197c0 wayland: Use keyboard serial for implicit grab
An xdg-popup requires a serial that the compositor will compare against
its own serial and will dismiss the popup if it doesn't match.

gtk+ uses either a pointer or touch serial for its helper function
_gdk_wayland_seat_get_last_implicit_grab_serial() but if the menu is
triggered before the user has had any pointer or touch interaction with
the client, using a keyboard shortcut, there is neither pointer nor
touch serial available, and gtk+ will use 0 as the default.

As a result, the compositor will instantly dismiss the xdg-popup. In
this case, gtk+ should use the keyboard serial instead.

Track keyboard serial as well and use the keyboard serial as the value
if there is no newer pointer or touch serial available.

https://bugzilla.gnome.org/show_bug.cgi?id=768017
2016-08-19 23:50:14 -04:00
Matthias Clasen
88248e34b1 Remove an outdated comment
It described as TODO what the code right below it already does.
2016-08-19 23:24:08 -04:00
Jonas Ådahl
cc019de6a5 wayland: Postpone processing move_to_rect params until showing
At the time of move_to_rect() is called, not all state may have been set
up on the impl gdk window, causing the position to sometimes be
slightly offset due to drap shadow margins. For now, work around this
by postponing the processing of the move_to_rect() parameters until
showing, when its more likely that all state (such as shadow margin)
has been set correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:52:03 -04:00
Jonas Ådahl
4e0ebd0cdf wayland: Don't traverse transient-ofs when faking root coordinate space
The position of each transient-of will be in fake-root coordinate
space; thus we should not accumulate all the positions making it an
offset; each window is already in fake root coordinate space.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:51 -04:00
Jonas Ådahl
1f7094a3e5 wayland: Use effective toplevel as popup parent
When using the set transient-for as a popup parent, fetch the effective
toplevel instead, otherwise we will position against the wrong
coordinate.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:46 -04:00
Matthias Clasen
a12ee84ec3 wayland: Link against librt
This is required for shm_open.

https://bugzilla.gnome.org/show_bug.cgi?id=769603
2016-08-07 16:11:55 -04:00
Simon McVittie
f65c116d2a Don't apply GDK_HINT_RESIZE_INC to GDK_WINDOW_STATE_TILED windows
This matches the behaviour of Mutter, Metacity and traditional X11
window managers on the window manager side, and is what we want
for at least gnome-terminal. I can't think of any reason why we'd
want incremental resize in any other tiled window.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=760944

https://bugzilla.gnome.org/show_bug.cgi?id=755947
2016-07-25 09:00:01 -04:00
Matthias Clasen
82fd72a477 Opt in to structured logging
Define G_LOG_USE_STRUCTURED, so that all our g_debug, g_warning,
etc calls directly use structured logging and provide source information.
2016-07-22 23:13:20 -04:00
Carlos Garnacho
4a9f17c690 wayland: Fix build
Missing include pointing to tablet-unstable-v1-client-protocol.h,
pays me for not testing on a clean checkout.
2016-07-22 20:58:55 +02:00
Carlos Garnacho
9fe0c1e126 wayland: Use wl_fixed_t on wp_tablet_tool angle arguments
This is an incompatible change in tablet protocol v2.
2016-07-22 19:35:28 +02:00
Carlos Garnacho
536017646e wayland: Update current tablet support to using v2
Only update to using v2 headers/structs. The incompatible changes
to tool events are dealt with in the next commit. Pads aren't handled
in this commit either.
2016-07-22 19:35:09 +02:00
Olivier Fourdan
e032c83822 wayland: remove unneeded statement
seat->pointer_info.focus is already set to NULL 2 lines above, no need to
repeat it there.
2016-07-04 09:46:24 +02:00
Olivier Fourdan
298221bfba wayland: return child only in device_query_state()
On X11, device_query_state() uses XIQueryPointer() which will return a
child window only if the pointer is within an actual child of the given
window.

Wayland backend would return the pointer->focus window independently of
the given window, but that breaks the logic in get_device_state() and
later in gdk_window_get_device_position_double() because the window is
searched based on coordinates from another window without sibling
relationship, breaking gtkmenu sub-menus further down the line.

Fix the Wayland backend to mimic X11's XIQueryPointer() to return a
child only if really a child of the given window.

That's the most sensible thing to do to fix the issue, but the API here
seems to be modeled after the X11 implementation and the description of
gdk_window_get_device_position_double() is not entirely accurate.

https://bugzilla.gnome.org/show_bug.cgi?id=768016
2016-07-04 09:46:18 +02:00
Carlos Garnacho
0d30ad279f wayland: Separate selection buffers and other per-selection atom data
This has most notably impact in selection buffers, because those were
shared across all selection atoms. This turned out wrong on 2 situations:
- Because the selection atom was set at SelectionBuffer creation time, the
  GDK_SELECTION_NOTIFY events generated will have unexpected info if the
  buffer is attempted to be reused for another selection.
- Anytime different selections imply different stored content for the same
  target.

This is better separated into per-selection buffers, so it's not possible
to get collisions if a same target is used across different selections.

https://bugzilla.gnome.org/show_bug.cgi?id=768177
2016-06-30 14:10:26 +02:00
Carlos Garnacho
4b003a75aa wayland: Implement gdk_utf8_to_string_target
The sanitize_utf8() function has been copied from X11 so both
backends behave the same. This allows interaction with older clients
(mainly through Xwayland, and the STRING selection target) that
request non-utf8 text.

https://bugzilla.gnome.org/show_bug.cgi?id=768082
2016-06-30 14:10:26 +02:00
Olivier Fourdan
0eeaa935b9 wayland: do not set PRIMARY selection if focus is lost
If keyboard focus is (already) lost, do not advertise PRIMARY selection.

https://bugzilla.gnome.org/show_bug.cgi?id=767848
2016-06-20 14:13:29 -04:00
Ray Strode
2f3cb31e55 wayland: fall back to shm_open if memfd unavailable
Debian stable currently ships with a 3.16 kernel, so
it doesn't have memfd available.

This commit adds shm_open fall back code for that case
(for now).

https://bugzilla.gnome.org/show_bug.cgi?id=766341
2016-06-16 12:02:51 -04:00
Ray Strode
bb2ca3b94d wayland: fix error handling for memfd_create
We currently use syscall() directly to invoke memfd_create,
since the function isn't available in libc headers yet.

The code, though, mishandles how errors are passed from syscall().
It assumes syscall returns the error code directly (but negative),
when in fact, syscall() uses errno.

Also, the code fails to retry on EINTR.

This commit moves the handling of memfd create to a helper function,
and changes the code to use errno and handle EINTR.

https://bugzilla.gnome.org/show_bug.cgi?id=766341
2016-06-16 12:00:24 -04:00
Timm Bäder
d9a6517d5f wayland: Make sure window titles fit into a wl_buffer
A wl_buffer has a max size of 4096 bytes, of which 8 are needed for the
header and another 4 for the string argument length (in this case), so
make sure the we only save the first 4083 bytes that are still valid
UTF8.

https://bugzilla.gnome.org/show_bug.cgi?id=767241
2016-06-08 15:06:51 +02:00
Olivier Fourdan
85407180cf wayland: add extended state for tiled
xdg-shell allows desktop environments to extend the list of states
within a given range.

Use this possibility to add a new state for tiled so that gtk+ can
benefit from this.

https://bugzilla.gnome.org/show_bug.cgi?id=766860
2016-06-08 14:46:37 +02:00
Matthias Clasen
3d0f76801d wayland: Provide information about scroll devices
The Wayland protocol does not share XI2's wealth of information
about individual devices, but it does provide discriminating
information about the source for scroll events. Pass this on to
the application by creating separate slave devices for these,
and setting them as source device on the scroll events.

These devices can be discriminated by their input-source property:
wheel      - GDK_SOURCE_MOUSE
finger     - GDK_SOURCE_TOUCHPAD
continuous - GDK_SOURCE_TRACKPOINT

https://bugzilla.gnome.org/show_bug.cgi?id=767093

fix up
2016-06-01 14:51:33 -04:00
Matthias Clasen
11e22aadda wayland: Better debug info for scroll axes
Print human readable names for axes and axis sources.
2016-05-31 22:18:08 -04:00
Matthias Clasen
d14305f380 wayland: Survive lack of settings
This can be made to happen eg by setting XDG_DATA_DIRS and
XDG_DATA_HOME to /. Not a useful value, but not a good reason
to crash either.
2016-05-19 07:38:33 -04:00
Olivier Fourdan
0b58c96f06 wayland: Make gdk_wayland_window_get_wl_output() private
There is no need to make it a public API, move it to the private header
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-19 09:48:46 +02:00
Olivier Fourdan
b03784eb97 wayland: Add get_monitor_at_window to Wayland backend
Given that Wayland has no global coordinate, the only way for gdk to
retrieve the monitor a window last entered is to retrieve it from the
GdkWaylandWindow itself.

Implement the backend specific get_monitor_at_window() to return the
monitor that was last entered by the window.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-18 19:07:27 +02:00
Olivier Fourdan
ca77de055b wayland: Add API to retrieve the Wayland output
In Wayland, surfaces get an enter/leave notification each time they
enter or leave an output.

Add an API to GdkWaylandWindow to retrieve the output the window has
last entered.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-18 19:07:27 +02:00
Carlos Garnacho
783c302198 wayland: Avoid spurious crossing events from master touch device
Only generate crossing events on wl_touch.down for the virtual master
device used for touch events, and only whenever this virtual device
actually moves across surfaces. This behavior resembles better what is
expected in X11, where the pointer is warped to the touch position
on XITouchBegin.

This avoids the double emission of leave events when the pointer
emulating touch is lifted, that crossing event will be instead
generated when/if the focus surface changes.

https://bugzilla.gnome.org/show_bug.cgi?id=766314
2016-05-18 12:50:08 +02:00
Matthew Waters
2893526a48 gdk/wayland: use the multi-thread safe wayland API
This is required for proper integration with any other library/application that
may perform wayland API calls and poll() the wayland fd from multiple threads.
Using wl_display_dispatch{_queue}() is thread-safe if not mixed with custom
poll() usage, which GSource/GMainContext does.

Essentially, the problem is that multiple threads polling and reading
the same fd is extremely racy.  Use the wayland provided API for allowing
concurrent access to the wayland display fd.

See the wayland man pages for wl_display_prepare_read(),
wl_display_cancel_read() and wl_display_read_events() for more details.

https://bugzilla.gnome.org/show_bug.cgi?id=763852
2016-05-17 22:58:03 -04:00
Matthias Clasen
e463e09577 wayland: Avoid unitialized memory reads
I didn't pay attention when I replaced g_new0 with g_newa. Oops.
2016-05-12 11:38:46 -04:00
Matthias Clasen
0f476590fb Make gdk_event_get_pointer_emulated public
There is not strong reason to keep the getter private.
At the same time, strip _-prefixes from a few other GdkEvent
APIs. Update all callers.
2016-05-10 15:16:45 -04:00
Christian Hergert
ebb894cd64 wayland: use g_signal_handler_disconnect()
Use of g_signal_handlers_disconnect_by_func() needs to do more work than
necessary to find all the matching handlers. Instead, just hold on to the
signal identifier and remove it directly so we hit the fast path.

Not terribly ground breaking in terms of performance gains, but its done
enough to be worthwhile.

https://bugzilla.gnome.org/show_bug.cgi?id=766049
2016-05-06 11:33:12 +03:00
Matthias Clasen
adc90b9e9d wayland: Small improvements to update_direction
Avoid memory allocation if possible, and use the proper
min/max keycodes.
2016-05-03 23:14:05 -04:00
Matthias Clasen
09aa48b748 wayland: Don't emit direction-changed unless it did
We can easily check this, so lets do it.
2016-05-03 22:52:38 -04:00
Matthias Clasen
3b75cadc41 trivial formatting fixes 2016-05-03 22:36:20 -04:00
Olivier Fourdan
e74ecfe22e wayland: fix up/down mix up in discrete events
The wayland specification for discrete step information for scroll and
other axes reads:

| The discrete value carries the directional information. e.g. a
| value of -2 is two steps towards the negative direction of this axis.

mutter sets a value of 1 for SCROLL_DOWN events and -1 for SCROLL_UP
events.

gdkdevice Wayland backend does the opposite, it translates a positive
discrete value as SCROLL_UP and a negative value as SCROLL_DOWN, which
ends up inverting the scrolling direction.

Fix the logic in gdkdevice Wayland to use a positive value as
SCROLL_DOWN and a negative value as SCROLL_UP so that it matches mutter
and weston logic.

https://bugzilla.gnome.org/show_bug.cgi?id=765907
2016-05-03 11:38:06 +02:00
Matthias Clasen
75e44c50ed wayland: drop a useless list
We were keeping all the event sources in a list, only to remove
them at the end of their life. Not useful.
2016-05-01 13:26:35 -04:00
Matthias Clasen
a829b26de1 wayland: Tag the event source with the acutal display name 2016-05-01 10:52:31 -04:00
Matthias Clasen
55ea6e4dcc wayland: Make gdk_display_get_name work
It should just return the same as gdk_screen_make_display_name.
2016-05-01 10:51:41 -04:00
Matthias Clasen
9026289381 wayland: Port to new monitor api 2016-04-27 23:18:16 -04:00
Daniel Stone
210a747ff0 wayland: Ignore NoSymbol keys
NoSymbol is not a valid GDK symbol (it only has the concept of
VoidSymbol, for some reason, which is neither the same thing nor
produced by any sane keymap). Passing NoSymbol events through to GTK+
apps is unlikely to produce anything useful.

In particular, this meant VTE would scroll to the end of the buffer when
pressing Fn (required for Page Up/Down on Macs), as it was receiving a
keypress that wasn't a modifeir. This does not happen on X11, as the
KEY_FN keycode is above 255, so does not get sent to clients.

https://bugzilla.gnome.org/show_bug.cgi?id=764825
2016-04-27 14:00:30 +01:00
Carlos Garnacho
14967d8d7d wayland: Perform seat grab focus checks on native windows
We don't care about the specific (possibly client-side) window that
requested the focus here, only the toplevel. Fixes mistakenly sent
focus events when the grab happens inside the current focus window.

https://bugzilla.gnome.org/show_bug.cgi?id=762756
2016-04-27 13:29:19 +02:00
Jonas Ådahl
1a4f000f3b gdk/dnd: Don't use default display when getting cursor
Always associate a drag context with a GdkDisplay and use that when
getting a cursor for a given action.

If we don't do this, dragging on a window that doesn't use the default
display will make us use cursors from the wrong display.

https://bugzilla.gnome.org/show_bug.cgi?id=765565
2016-04-26 23:03:24 +08:00
Jonas Ådahl
145b626c2f wayland: Track orphaned dialogs per display
Don't track all orphaned dialogs globally, as mixing them up with each
other would in most cases trigger errors when we try to pass bogus
values to Wayland requests.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -04:00
Jonas Ådahl
cb73becfb4 wayland: Clean up naming of GdkWaylandDisplay pointers
The naming of pointers to GdkWaylandDisplay's were inconsistent.
Running the following commands in gtk+/gdk/wayland illustrate the
inconsistency:

$ grep -r '\<display_wayland\>' *.[ch] | wc -l
195
$ grep -r '\<wayland_display\>' *.[ch] | wc -l
81

This patch renames all occurrences of "wayland_display" to
"display_wayland". This is also consistent with naming in the X11
backend. A couple of whitespace changes were done as well in places
where the rename was already done, that added line breaks to long lines
that stood out.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -04:00
Christian Hergert
724d3be794 wayland: avoid jitter in keyboard repeat
When synthesizing keyboard repeat, we can potentially drift further from
the mark depending on the timing of the frame callback and how long it
took to deliver the event.

This patch attempts to reduce this by tracking from a stable epoch the
time of our next keyboard repeat.

https://bugzilla.gnome.org/show_bug.cgi?id=765567
2016-04-25 18:15:24 -07:00
Emmanuele Bassi
74f4e6e046 wayland: Bind the appropriate OpenGL API
If we want to use OpenGL ES with EGL then we need to bind the API before
creating the EGL context.
2016-04-25 12:29:37 +01:00
Emmanuele Bassi
7d1da94455 wayland: Add debugging notes for EGL context creation 2016-04-25 12:29:37 +01:00
Emmanuele Bassi
d40778f728 wayland: Honour GDK_GL=gles on context creation 2016-04-25 12:29:37 +01:00
Emmanuele Bassi
2849f2fc9a wayland: Implement asking for a GLES context
Wayland uses EGL, which allows us to ask for a GLES context.

https://bugzilla.gnome.org/show_bug.cgi?id=743746
2016-04-25 12:29:37 +01:00
Frediano Ziglio
cf14fea5a8 Save scancode inside GdkEventPrivate
Windows save in hardware_keycode an information which is not so low
level and some application require the hardware scancode.
As Windows provides this information save it in GdkEventPrivate
and provide a function to get this information.
For no Windows system the function return the hardware_keycode instead.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=765259
2016-04-21 22:35:47 -04:00
Rui Matos
deaf664ed2 wayland: Leave existing mods on map_virtual_modifiers
map_virtual_modifiers() is supposed to add the necessary virtual mods
but otherwise leave the mods that are passed in.

https://bugzilla.gnome.org/show_bug.cgi?id=765270
2016-04-19 21:14:20 +02:00
Matthias Clasen
b8a86e6ca4 wayland: Some more debug spew
Print the modifiers and their mapping out as well. This
information is contained in the keymap, but this is a bit
easier to digest.
2016-04-19 12:43:03 -04:00
Matthias Clasen
e7d84898ee wayland: Add debug output for keymaps
Use GDK_DEBUG=input to see your keymap sent over and over again.
Efficiency!
2016-04-19 12:23:51 -04:00
Carlos Garnacho
f7108d4d43 wayland: Improve checks when flushing scroll events
If we get gdk_wayland_seat_flush_frame_event() with no previous event to be
flushed, we fallback into the scroll event checks. However, there's no check
performed there as to whether it really scrolled, so it'd always send a smooth
scroll event with 0/0 deltas in this case.

This should be mostly harmless, but still, we should only end up emitting scroll
events if those really happened.
2016-04-18 14:14:33 +01:00
Carlos Garnacho
bfcd9a2193 wayland: Do not check the pointer focus when receiving wl_pointer.frame
The frame event is also meant to compress wl_pointer.leave events, at this
point the focus surface will be definitely NULL. In the end, wl_pointer.frame
should flush the last composed event despite the pointer focus.

https://bugzilla.gnome.org/show_bug.cgi?id=765065
2016-04-18 14:14:33 +01:00
Matthias Clasen
6664008815 wayland: Make virtual modifier mapping more similar to X
Ignore virtual modifiers that are mapped to Mod1 (as Meta
often is), to avoid interfering with our fix interpretation
of Mod1 as Alt.
2016-04-17 01:50:23 -04:00
Matthias Clasen
5ba8a25d29 wayland: Fix the map_virtual_modifiers implementation
We were not stripping real modifiers out, and thus always
thought there's a conflict when the passed in modifiers
included any real modifiers.
2016-04-16 23:16:12 -04:00
Matthias Clasen
64c2a65cc0 wayland: Implement virtual modifiers
Since Wayland is using libxkbcommon, it inherits X unfortunate
real/virtual modifier distinction, so we have to do the same
gymnastics we do for X to map between the two.

This should fix matching of accelerators using virtual modifiers
(modulo gnome-shell bugs regarding the handling of Super).

https://bugzilla.gnome.org/show_bug.cgi?id=764424
2016-04-15 22:22:48 -04:00
Matthias Clasen
0d64582688 wayland: Keyboard don't have x/y
These axes are not very useful in the first place, but on a
keyboard they just don't make any sense at all.
2016-04-09 17:31:39 -04:00
Matthias Clasen
9044f78751 Move GdkDeviceTool into its own files 2016-04-09 15:48:34 -04:00
Carlos Garnacho
057ae4ace0 wayland: Propagate slider/rotation axes from tools to devices 2016-04-08 17:34:29 +02:00
Carlos Garnacho
6628ffd686 wayland: Check the tablet manager before creating a wp_tablet_seat
This makes things non-crashy if the compositor doesn't provide wp_tablet_manager
2016-04-06 17:29:11 +02:00
Carlos Garnacho
cd1604ae1c wayland: Hook tablets to GdkSeat
Those are now also grabbed togetther with other master pointers,
so everything is able to interoperate on eg. popups triggered by
other devices.
2016-04-06 16:12:13 +02:00
Carlos Garnacho
fb32f11e3d wayland: Translate pen buttons into button events
up/down already take GDK_BUTTON_PRIMARY, we translate BTN_STYLUS(2)
into GDK_BUTTON_MIDDLE/SECONDARY.
2016-04-06 16:12:12 +02:00
Stephen Chandler Paul
4f6bc82052 Wayland: Translate wl_tablet.down/up into button events
These are sent with button=GDK_BUTTON_PRIMARY, axes must be also
included in these events, in addition to motion ones.
2016-04-06 16:12:12 +02:00
Stephen Chandler Paul
0f6be24e28 Wayland: Translate tool axes in motion events
On wayland, such axes are per-tool, we must update device capabilities
on the fly as new tools enter proximity, first the slave device so
it matches the current tool, and then the master device so it looks
the same than the current slave device.
2016-04-06 16:12:12 +02:00
Stephen Chandler Paul
72884a274c Wayland: Implement proximity/crossing/motion event emission on tablets
Each tablet will update its own GdkWaylandPointerData separately. This
commit only adds plain motion event emission so far, no axes are managed
yet.
2016-04-06 16:12:12 +02:00
Stephen Chandler Paul
7cc0850a5a Wayland: Add initial support for drawing tablets
Only the management of tablets and tools is added so far. No tablet events
are yet interpreted.

As it's been the tradition in GTK+, erasers are split into their own device,
whereas the rest of the tools are meant to be routed through the
GDK_SOURCE_PEN device. Both pen/eraser devices are slaves to a master
pointer device, separate to wl_pointer's. This is so each tablet can
maintain its own cursor/positioning accounting.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
2016-04-06 16:12:12 +02:00
Carlos Garnacho
45b4d765c0 wayland: Refactor master pointer data into a separate struct
This will enable multiple "pointers" to have separate data here.
Will come out useful when adding support for tablets, as they
will have a separate cursor for all purposes.
2016-04-06 16:12:12 +02:00
Stephen Chandler Paul
af894af386 gdkcursor-wayland.c: Minor indentation fix
Changed the tabs to spaces

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
2016-04-06 16:12:12 +02:00
Olivier Fourdan
be6784c7ea wayland: Do not resize with the same size
gnome-control-center is calling gtk_window_resize() on configure-event
signals which leads to a busy loop.

Avoids such a busy loop by not re-configuring a window with the same
size, unless this is coming from and xdg-shell configure.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=764374
2016-04-05 18:22:40 +02:00
Matthias Clasen
9bfc8371fe wayland: Remove an unused vfunc 2016-04-03 18:18:17 -04:00
Matthias Clasen
59e40f3d6f wayland: Remove unused field 2016-04-03 18:18:17 -04:00
Carlos Garnacho
2784eacf00 wayland: Avoid NULL slave devices in GdkSeat::get_slaves
Just because we're asked for a capability, it doesn't mean we have
it.
2016-04-01 19:10:36 +02:00
Matthias Clasen
4c698bc824 wayland: Print out more debug info
Print out the subpixel layout and frame rates that the compositor
sends us.
2016-03-31 20:31:00 -04:00
Matthias Clasen
59d8cba482 wayland: Get min/max keycode from xkb keymap
Instead of hardcoding 8/255 here.
2016-03-26 18:48:27 -04:00
Matthias Clasen
1057f249bd wayland: Add debug output for pixel formats
Use GDK_DEBUG=misc to see information about wl_shm pixel formats
supported by the compositor.
2016-03-26 16:08:01 -04:00
Matthias Clasen
c6cdddd68d wayland: Fix up visual implementation
Don't return visuals that don't match the requested depth
and/or visual type.
2016-03-26 14:58:48 -04:00
Matthias Clasen
e48e29db3b wayland: Fully initialize the visual
The pixel details (mask, shift and precision) are supposed to
be filled in for TrueColor visuals.
2016-03-26 10:10:57 -04:00
Christian Hergert
c48bc48dda wayland: avoid dropping surfaces when possible
If the configure-event gives us the same size as we had before,
which is common for animation resizes, then try to keep the
existing buffer around. This saves us a memfd_create() syscall
on every frame.

https://bugzilla.gnome.org/show_bug.cgi?id=763350
2016-03-21 22:03:20 -04:00
Carlos Garnacho
219eedd7c8 wayland: Rename internal functions with misleading naming
Now that GdkWaylandDeviceData is gone, the functions prefixed
"gdk_wayland_device_" and taking a GdkWaylandSeat as first
parameter feel out of place. Renaming those makes it more obvious
that it's seat functions.

https://bugzilla.gnome.org/show_bug.cgi?id=763859
2016-03-21 17:15:59 +01:00
Carlos Garnacho
1597f31eba wayland: Remove GdkWaylandDataDevice typedef
It's no longer used.

https://bugzilla.gnome.org/show_bug.cgi?id=763859
2016-03-21 17:15:59 +01:00
Carlos Garnacho
81f0d23744 wayland: Replace all remaining uses of GdkWaylandDeviceData
And use GdkWaylandSeat in all of those. The variable names have also
been updated.

https://bugzilla.gnome.org/show_bug.cgi?id=763859
2016-03-21 17:15:59 +01:00
Carlos Garnacho
c9f9163544 wayland: Remove GdkWaylandDeviceData pointer in GdkWaylandDevice
It's the same than gdk_device_get_seat() nowadays. Also, rename the
usages of GdkWaylandDeviceData to GdkWaylandSeat in the functions
affected by the removal.

https://bugzilla.gnome.org/show_bug.cgi?id=763859
2016-03-21 17:15:59 +01:00
Matthias Clasen
068d382689 dnd: Hide the drag window when we're done
We were just relying on the drag context finalize() to destroy
the window. But with garbage-collected bindings, that might
not happen as soon as we like, so explicitly hide the window
when the drag ends successfully.

https://bugzilla.gnome.org/show_bug.cgi?id=763659
2016-03-21 11:26:24 -04:00
Matthias Clasen
de4cb363c2 Document gdk_wayland_seat_get_wl_seat 2016-03-20 22:49:33 -04:00
Carlos Garnacho
2923f69d3c gdkdnd: Add private means to commit the drag status
The way gdk_drag_status() may be called multiple times during the
processing of drag and drop events throughout the widget hierarchy
brings some superfluous messaging going in, esp. when it's the last
request the one we want to honor, yet we emit messaging requests on
all.

This is barely appreciable in the X11 backend, but due to the design
of the wayland protocol, quick series of changes like this it have
some self-amplificating consequences which may end up flooding the
connection.

We can delegate this to a late "commit" call, performed within GDK
event management. This way gdk_drag_status() calls may be cached
and only result in windowing messaging once per ::drag-motion or
::drag-data-received event. Emitting the final status will also
avoid spurious action changes on the compositor and the other peer.

https://bugzilla.gnome.org/show_bug.cgi?id=763298
2016-03-14 16:50:36 +01:00
Jonas Ådahl
8fb7f50028 wayland: Add request focus support via gtk_shell
A gtk_surface.present request was added to gtk_surface which takes
timestamp from some input event, and uses that timestamp to figure out
whether the window can be presented or not. If we don't have a
timestamp, we should just give up instead of making up our own,
otherwise we might steal someones focus.

https://bugzilla.gnome.org/show_bug.cgi?id=763037
2016-03-10 12:31:15 +08:00
Jonas Ådahl
ed430dc00a wayland: Add system bell support via gtk_shell
Invoke the system bell by calling the request added to the gtk_shell
protocol.

https://bugzilla.gnome.org/show_bug.cgi?id=763001
2016-03-10 12:31:15 +08:00
Jonas Ådahl
f68cf698fc wayland: Don't invent our own unstable protocol semantics
The gtk_shell protocol used some half baked unstable protocol semantics
that worked by only allowing binding the exact version of the
interface. This hack is a bit too confusing and it makes it impossible
to do any compatible changes without breaking things.

So, instead rename it to include a number in the interface names. This
way we can add requests and events without causing compatibility issues,
and we can later remove requests and events by bumping the number in
the interface names.

https://bugzilla.gnome.org/show_bug.cgi?id=763001
2016-03-10 12:31:15 +08:00