1
0
Fork 0
Commit graph

924 commits

Author SHA1 Message Date
Jonas Ådahl
33ba06504b MetaWaylandPointerConstraints: Relax enable requirements for Xwayland
Xwayland surfaces are special, because there is no reliable way to
associate a window with its corresponding "application window" (the one
which was given focus). Many games that require pointer warping and
confining pointer grabs may for example create override redirect windows
and make that window receive input even though it will never be the
focus window.

Therefore, the requirements for enabling a constraint for a wl_surface
from Xwayland needs to be relaxed in order. This commit changes
Xwayland wl_surfaces to not require being focused to be enabled; it'll
be enabled as long as any X11 window is the one with focus.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
10c7035a71 MetaWaylandPointerConstraints: Require pointer focus to enable
Require pointer focus to enable, otherwise we can't guarantee it has
entered the surface, as the focus may have been given to a subsurface,
override-redirect or other sub window covering the surface that was
requested to have o pointer constraint.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
e6a20a025d MetaWaylandPointer: Add 'focus-surface-changed' signal
Add a signal that is emitted when the pointer focus surface of the
pointer device changes. This will later be used by the pointer
constraints to maybe enable pointer constraints when a surface receives
pointer focus.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
262b52da50 MetaWaylandPointerConstraints: Handle delayed window surface association
For Xwayland, a newly created wl_surface and X11 Window pair may not be
immediately associated, but Xwayland may still request a pointer
constraint on some of its wl_surface's. Handle the situation by
postponing maybe enabling the constraint until the window and surface
has been associated.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
fccdd00f74 MetaWaylandSurface: Move destroy signal even earlier
Move the MetaWaylandSurface::destroy signal before starting the actual
destruction, in wl_surface_destructor, so that all fields (e.g. surface
role) are intact when the listeners are invoked.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
3a41b0f221 xwayland: Add 'window-associated' signal to role
When the Xwayland wl_surface is created, it may not yet be possible to
associate it with the corresponding X11 Window. Add a signal to the
Xwayland role to communicate with any interested parties.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
e5a359a032 wayland: Make seat devices GObjects
This will make it possible to add signals and other GObject features.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
2016-09-09 10:09:46 +08:00
Jonas Ådahl
0c53677992 wayland/pointer-constraints: Send wl_pointer.frame when locked
We were not sending wl_pointer.frame after
wp_relative_pointer.relative_motion. Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=770994
2016-09-09 10:03:16 +08:00
Jonas Ådahl
640178a94f wayland/cursor-role: Handle premature wl_buffer destruction
If a client would attach a buffer to a surface, commit, destroy the
buffer and then later set the surface as a cursor, there will be no
wl_buffer available to be used by the cursor role. Instead of
dereferencing the non-existing wl_buffer resource, handle this situation
by logging a warning and treating a prematurely destroyd wl_buffer as if
no buffer had been attached.

https://bugzilla.gnome.org/show_bug.cgi?id=770992
2016-09-09 10:02:41 +08:00
Olivier Fourdan
4f58a46217 wayland: add min/max size from xdg-shell v6
Implement min/max size request from xdg-shell-v6 and plug it into the
existing code so that windows with fixed size cannot be tiled/maximized
in Wayland just like in X11.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=770226
2016-09-06 08:54:08 +02:00
Jonas Ådahl
d696fd3021 wayland: Don't handle input events after capability was removed
The seat capability updating is synchronous, but input events are
asynchronous (first queued then emitted). This means we may end up in a
situation where we from libinput first may receive a key event,
immediately followed by a device-removed event. Clutter will first
queue the key event, then remove the device, immediately triggering the
seat capability removal.

Later, when the clutter stage processes the queued events, the
previously queued key event will be processed, eventually making it
into MetaWaylandSeat. Before this patch, MetaWaylandSeat would still
forward the key event to MetaWaylandKeyboard, even though it had
'released' it. Doing this would cause referencing potentially freed
memory, such as the xkb state that was unreferenced when the seat
removed the capability.

In order to avoid processing these lingering events, for now, just drop
them on the floor if the capability has been removed.

Eventually, the event queuing etc needs to be redesigned to work better
when used in a Wayland compositor, but for now at least don't access
freed memory.

https://bugzilla.gnome.org/show_bug.cgi?id=770727
2016-09-02 21:11:08 +08:00
Jonas Ådahl
7a096b8686 wayland/cursor-role: Add back priv variable
Rebase of previous patch that removed the priv variable shouldn't have,
since it was now used by other things. Add it back so it compiles again.
2016-09-01 21:04:13 +08:00
Jonas Ådahl
c7976e0dbc wayland/cursor-role: Increase buffer use count on construction
We may be assigned multiple times, if the surface is assigned to be a
cursor surface multiple times. Each time e.g. wl_pointer.set_cursor is
called, we'll be assigned.

While the role object exists, we'll handle buffer use count even when
we are not actively assigned, thus we should only handle the initial
assignment use count bump when constructing, so that we don't increase
it when reassigned, where the wl_resource may already have been
released.

https://bugzilla.gnome.org/show_bug.cgi?id=770402
2016-09-01 19:39:53 +08:00
Rui Matos
f692c527e7 surface-role-cursor: Send frame callbacks for backend handled cursors
For backend handled cursors, if nothing else changes on the clutter
stage, we end up not sending out frame callbacks since clutter doesn't
draw a new frame.

To fix this, we'll keep cursor surfaces' frame callbacks separate from
other surfaces' and trigger them from the new
MetaCursorRenderer::cursor-painted signal which handles both software
and hardware cursors.

https://bugzilla.gnome.org/show_bug.cgi?id=749913
2016-08-31 20:10:43 +02:00
Olivier Fourdan
1f570d542e wayland: Survive an unsupported buffer size
If cogl fails to create a texture from the client's given buffer,
mutter would raise a fatal error and terminate.

As a result, a broken client might kill gnome-shell/mutter and take the
entire Wayland session with it.

Instead of raising a fatal error in this case, log the cogl error
message and send the client an OOM error, so mutter/gnome-shell can
survive an unsupported buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=770387
2016-08-26 11:16:07 +02:00
Jonas Ådahl
8942e98e1d Revert "window: Make meta_window_has_pointer() per protocol implemented"
Windows from Xwayland still needs to use the Wayland path, but is
represented an MetaWindowX11, thus the abstraction introduced in
"window: Make meta_window_has_pointer() per protocol implemented"
is wrong. Lets turn back time, and reconsider how this can be
abstracted more correctly in the future.

This reverts commit 9fb891d216.
2016-08-26 06:51:19 +08:00
Jonas Ådahl
b6e13c459a wayland/subsurface: Call commit of surface-actor-role on commit
Rely on the actor surface role's commit function for queuing frame
callbacks. This also makes the surface actor state synchronization work
again, which was broken by 'wayland: Sync surface actor state in actor
role commit handler'.

https://bugzilla.gnome.org/show_bug.cgi?id=770131
2016-08-25 12:19:40 +08:00
Jonas Ådahl
43151edece wayland/actor-surface-role: Check for toplevel window
Don't check whether the surface of the role has a window, but whether
the corresponding toplevel surface has a window. This is necessary to
make subsurfaces not always early out.

https://bugzilla.gnome.org/show_bug.cgi?id=770131
2016-08-25 12:19:40 +08:00
Jonas Ådahl
b3f27de710 wayland/subsurface: Return NULL as toplevel if parent has no role
There is nothing stopping a subsurface from commiting its state before
its parents role has been assigned. Thus, we need to handle
meta_wayland_surface_get_toplevel() returning NULL for subsurfaces even
on commit.
2016-08-25 12:19:40 +08:00
Jonas Ådahl
4cf14c41ef wayland: Use correct GObject parent in subsurface role object
The parent of MetaWaylandSurfaceRoleSubsurface is
MetaWaylandSurfaceRoleActorSurface thus use that as the GObject parent.

https://bugzilla.gnome.org/show_bug.cgi?id=770131
2016-08-25 12:19:40 +08:00
Jonas Ådahl
dc03b3aa47 xdg-shell: Don't early out of role commit before calling parent impl
Make sure to always call the parent role commit vfunc, so that they can
handle updating their state properly.

This means other places need to handle the situation where
surface->window is NULL on commit. This may for example happen when the
parent of a modal dialog is unmapped or NULL is attached to a
wl_shell_surface.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
ef3e036b45 wayland/xdg-shell: Port to unstable v6
Port the xdg_shell implementation to use the unstable v6 protocol. This
includes:

 - making xdg_surface a generic base interface for xdg_shell surface
   roles
 - create a xdg_toplevel role replacing the old xdg_surface
 - change the xdg_opup role to be based on xdg_surface
 - make xdg_popup not grab by default
 - add support for xdg_positioner

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
24c3844246 wayland/xdg-shell: Make keyboard focus follow grabbing popup
This is the explicitly intended keyboard focus symantics of xdg-shell
unstable v6. The semantics are undefined in unstable v5.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
f21df37190 wayland: Let shell surface role sync generic window state
Instead of having each final role do the same call, lets just make the
common role object deal with synchronizing window buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
a5efa30f6c wayland: Call assigned() surface role vfunc when re-assigned
This will later be used by xdg-shell to ensure no buffer is attached on
assignment.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
817911d9d3 wayland: Keep track of configured position
Besides the configured dimension, also keep track of the configured
position. This will later be used by popup position feedback.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
a8d86b4876 wayland: Make gtk_shell handle our private window states
Instead of using the "allocated" state ranges of xdg_shell, lets just
use our own gtk_shell by adding a state enum and a configure event.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
cfb3d10e1b MetaWaylandSurface: Add 'configure' signal
Emit a 'configure' signal before configuring the role. This will enable
extensions to send its own configure events before the role is
configured.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
3a75e55cd8 wayland: Move gtk_surface fields out of MetaWaylandSurface
Let the gtk_shell extension unit handle its own state.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
335cd8e74c MetaWaylandSurface: Move 'destroying' field
It is not related to the gtk_surface extension, so move it to other
generic fields.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
c73d3d9d83 wayland: Move out gtk_shell from meta-wayland-surface.c
https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
8833991201 core: Add support for custom window placement rules
Add support for assigning a window a custom window placement rule used
for calculating the initial window position as well as defining how a
window is constrained.

The custom rule is a declarative rule which defines a set of parameters
which the placing algorithm and constrain algorithm uses for
calculating the position of a window. It is meant to be used to
implement positioning of menus and other popup windows created via
Wayland.

A custom placement rule replaces any other placement or constraint
rule.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
9fb891d216 window: Make meta_window_has_pointer() per protocol implemented
https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
3b3f40a1aa MetaWaylandSurface: Allow passing parameters when assigning role
Allow passing parameters (only GObject parameters supported for now) so
that role assignment can affect the paremeters set during construction.

If a role was already assigned when assigning, the passed parameters
are set using g_object_set_valist().

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
2114f2eb9f MetaWaylandSurfaceRole: Set the surface instance on construction
Set the MetaWaylandSurface instance pointer on construction so that all
surface role relevant parameters are initialized when constructed.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
6f8e6864b2 wayland: Add support for the xdg-foreign protocol
This commits adds support for exporting xdg_surface handles via
xdg_exporter and importing them via xdg_importer.

This bumps the required wayland-protocols version to 1.6.

https://bugzilla.gnome.org/show_bug.cgi?id=769786
2016-08-22 21:03:41 +08:00
Jonas Ådahl
aea706230d MetaWaylandSurface: Add 'unmapped' signal
Meant to be used by users of MetaWaylandSurface's that need to know
when the surface was unmapped. So far only emitted by shell surfaces
(surfaces with MetaWindow's).

https://bugzilla.gnome.org/show_bug.cgi?id=769786
2016-08-22 21:03:41 +08:00
Carlos Garnacho
5c9a2c54c4 xwayland: Avoid late errno checks
We do some things when binding to a socket fails (closing the fd,
logging, unlinking files, ...) those might affect errno in some
or other way, so it might no longer be EADDRINUSE even if we later
try to make those non fatal.

It seems better to check errno soon after the failure, and don't
rely on it in any way at a later point. All error paths in
bind_to_abstract_socket() also have early logging, which also might
help figure out better the point of failure when the socket fails
to be created.

https://bugzilla.gnome.org/show_bug.cgi?id=769578
2016-08-06 17:14:52 +02:00
Carlos Garnacho
dd549604e2 xwayland: Fix typo
Check the unix_fd, which is the one just created, the abstract_fd
is already checked above.
2016-08-06 16:42:25 +02:00
Jonas Ådahl
98cd8136ca MetaWindowWayland: Don't set X11 window attributes that'll get ignored
We only use a handful of the attributes set, so lets stop pretending
that things are initialized for a reason. Eventually we should stop
using XWindowAttributes in the generic MetaWindow creation path.

https://bugzilla.gnome.org/show_bug.cgi?id=769070
2016-07-23 10:55:02 +08:00
Florian Müllner
ead09bf6cc wayland: Shut up a compiler warning
If the compiler cannot figure out that the condition for setting
the dev variable is the same as the condition for accessing it,
it will complain about potential uninitialized use.
2016-07-22 23:21:30 +02:00
Carlos Garnacho
c6beb1cfc5 wayland: Emit wp_tablet_pad_group.buttons after focus changes
The buttons grabbed by the compositor might have changed in between,
so just broadcast the button array again.
2016-07-22 13:31:09 +02:00
Carlos Garnacho
b34fe72bb7 wayland: Check serial on wp_tablet_pad.set_feedback
We must lookup the mode switch serial for the group where the button
belongs to. Also, avoid the changes if the client requests setting
the feedback for buttons owned by the compositor.
2016-07-22 13:31:09 +02:00
Carlos Garnacho
18f301cec9 wayland: Export function to tell whether a button belongs to a pad group 2016-07-22 13:31:09 +02:00
Carlos Garnacho
406677e2a0 wayland: Check serial on wp_tablet_pad_strip.set_feedback 2016-07-22 13:31:09 +02:00
Carlos Garnacho
4f25057413 wayland: Check serial on wp_tablet_pad_ring.set_feedback 2016-07-22 13:31:09 +02:00
Carlos Garnacho
2f492c133c wayland: Fix label lookup on >1 strips/rings
We assumed that each group could only have 1 strip and/or ring, because
accounting is performed per group, so we could not assume the real
index for anything above 1. Get rid of this restriction, now that
MetaWaylandTabletPad does its own accounting of rings/strips, alongside
groups.
2016-07-22 13:31:09 +02:00
Carlos Garnacho
138a47b8f9 wayland: Move strips/rings management back to MetaWaylandTabletPad
This is best for 2 reasons:
- It's feels cleaner doing first creation of rings/strips and then
  the group assignment. The other option is making groups iterate
  other all rings/strips and selectively skip those not meant for
  it, which sounds somewhat redundant.
- Some minimal accounting of rings/strips without group restrictions
  is needed for meta_wayland_tablet_pad_get_label().

The rings/strips memory is now owned by MetaWaylandTabletPad instead
of groups, which is sort of meaningless since all are meant to go
at the same time.
2016-07-22 13:31:09 +02:00
Carlos Garnacho
62e4954c96 wayland: Add method to relate a pad strip to its group 2016-07-22 13:31:09 +02:00
Carlos Garnacho
062b696df2 wayland: Add method to relate a pad ring to its group 2016-07-22 13:31:09 +02:00