1
0
Fork 0
Commit graph

5815 commits

Author SHA1 Message Date
Rui Matos
b281f9566d wayland-surface: Make get_relative_coordinates() accurate for X apps
Using clutter API to transform coordinates is only accurate right
after a clutter layout pass but this function is used e.g. to deliver
pointer motion events which can happen at any time. This isn't a
problem for wayland clients since they don't control their position,
but X clients do and we'd be sending outdated coordinates if a client
is moving a window in response to motion events.

https://bugzilla.gnome.org/show_bug.cgi?id=768039
2016-07-15 14:27:16 +02:00
Rui Matos
5ee0f24ab9 window: Stop updating layers on focus changes
Commit 3a4ae679ea removed the
FOCUSED_WINDOW layer definition but it was already unused for a long
time. There's no layers to update on focus changes.

https://bugzilla.gnome.org/show_bug.cgi?id=768221
2016-07-06 19:11:30 +02:00
Rui Matos
fcc7501eb8 core: Remove META_LAYER_FULLSCREEN
This layer isn't really being used and in fact, it causes
meta_stack_get_default_focus_window() to return a fullscreen window
even if the naturally topmost window in the stack isn't a fullscreen
one.

Note that commit a3bf9b01aa changed how
we choose the default focus window from the MRU to the topmost in the
stack.

https://bugzilla.gnome.org/show_bug.cgi?id=768221
2016-07-06 19:11:30 +02:00
Olivier Fourdan
492854e14d window: Do not try to focus O-R windows in focus-follow-mouse
Doing so would raise a critical warning.

https://bugzilla.gnome.org/show_bug.cgi?id=767997
2016-07-06 09:14:56 +02:00
Luca Bruno
c325a0bebf Fix string format in startup notification to be a gint64
https://bugzilla.gnome.org/show_bug.cgi?id=762407
2016-07-04 22:34:31 +02:00
Owen W. Taylor
b112d98278 Improve handling of tracking the old focused window during restart
When restarting (X compositor only, obviously), we want to keep
the same window focused. There is code that tries to do this by
calling XGetInputFocus() but the previously focused window will
almost certainly not still be focused by the time we get to the
point where we call XGetInputFocus(), and in fact, probably was
no longer correct after the previous window manager exited, so
the net result is that we tend to focus no window on restart.

A better approach is to leave the _NET_ACTIVE_WINDOW property
set on the root window during exit, and if we find it set when
starting, use that to initialize focus.

https://bugzilla.gnome.org/show_bug.cgi?id=766243
2016-06-29 10:22:55 -04:00
Rui Matos
cc6efeb14f MetaSurfaceActorX11: invalidate the stex on video memory purged errors
MetaShapedTexture uses FBOs when mipmapping so we need to cause them
to be recreated.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:50 +02:00
Rui Matos
53993ba4d2 MetaBackground: invalidate contents on video memory purged errors
We use FBOs so we need to cause them to be recreated.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:50 +02:00
Rui Matos
7f6bcea331 compositor: Handle GL video memory purged errors
Emit a signal so that interested parties can recreate their FBOs and
queue a full scene graph redraw to ensure we don't end up showing
graphical artifacts.

This relies on the GL driver supporting the
NV_robustness_video_memory_purge extension and cogl creating a
suitable GL context. For now we only make use of it with the X backend
since the only driver with which this is useful is NVIDIA.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:50 +02:00
Rui Matos
7ed14e0ee8 restart: Make meta_restart() work without a message
In some cases there's no meaningful message to show.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:49 +02:00
Carlos Garnacho
21fd87c4af xwayland: Use CurrentTime on all XConvertSelection calls
The call fetching the targets mistakenly used the timestamp meant
to back up the TIMESTAMP atom (hence, it's the timestamp at which
the selection is *owned* by the compositor, on behalf of a wayland
client).

This timestamp is actually only updated when the compositor gets
to own the selection, so it's a randomly late timestamp to retrieve
the TARGETS atom content, which certain clients might end up
ignoring.

https://bugzilla.gnome.org/show_bug.cgi?id=768007
2016-06-27 11:42:26 +02:00
Rui Matos
1d2bead358 ui/frames: Drop the current grab info on button release
This was added in commit d05b750b8d and
later removed inadvertently in commit
d561b3b18f .

https://bugzilla.gnome.org/show_bug.cgi?id=767969
2016-06-23 18:45:53 +02:00
Florian Müllner
a174c18fb5 frames: "Initialize" frame background
Frames are painted on the frame window according to the GTK+ theme.
Depending on the target's visual, this means either drawing over
a black destination or a fully transparent one. So in cases where
the theme doesn't paint decorations with full opacity, decorations
for windows with an rgba visual look different from those with a
non-rgba visual. Using an rgba visual for all frames independent
from the client's visual can potentially break clients, so our
only option for a consistent appearance is to explicitly initialize
the frame background to black before painting the theme's decoration
on top.

https://bugzilla.gnome.org/show_bug.cgi?id=745060
2016-06-23 16:47:51 +02:00
Florian Müllner
c61dfa71ed frames: Don't clip out "invisible" parts of frames
The GTK+ theme may draw parts of the decorations outside the actual
frame. Since commit f9db65f47f we make sure that the frame is big
enough to account for any overdrawing, however as we still clip the
cairo context to the actual frame before drawing the decorations,
those parts aren't actually painted.
This issue is not very obvious for most frames, as they use a non-rgba
visual where the unpainted parts appear black, which gives the expected
result with many themes once the shape mask is applied (as the mask does
include any overdrawn parts). For frames using an rgba visual however,
unpainted parts are transparent, so any overdrawn decorations are clearly
missing.
Fix this by only clipping out the client area when drawing decorations.

https://bugzilla.gnome.org/show_bug.cgi?id=745060
2016-06-23 16:47:51 +02:00
Florian Müllner
53a9411255 surface-actor: Keep track of ignored damage
We ignore all damage while a surface is frozen and queue a full
update instead once it's thawed. While not super efficient, this
isn't overly bad for the intended case of catching up with any
updates that happened during a compositor effect. However when
extended frame sync is used, surfaces are also frozen while the
client is drawing a frame, in which case the current behavior is
pretty damaging (pun intended), as we end up redrawing the entire
window each frame. To address this, keep track of the actual damage
we ignore and apply it when the surface is thawed.

https://bugzilla.gnome.org/show_bug.cgi?id=767798
2016-06-17 21:39:06 +02:00
Olivier Fourdan
989ec7fc60 wayland: Mark pending moved as moved
The result flag needs to be marked as moved even for pending moves,
otherwise the window's unconstrained_rect doesn't get updated in
meta_window_move_resize_internal() and the anchor grab is wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=764180
2016-06-13 17:31:35 +02:00
Olivier Fourdan
c72efc90cb wayland: Implement force-quit using kill()
The X11 backend uses EWMH's _NET_WM_PID to get the PID of an offending
client and kill its PID to force the client to terminate.

The Wayland backend is using a Wayland protocol error, but if the client
is hung, that will not be sufficient to kill the client.

Retrieve the client PID under Wayland using the Wayland client API
wl_client_get_credentials() and kill() the client the same way the X11
backend does.

https://bugzilla.gnome.org/show_bug.cgi?id=767464
2016-06-10 09:55:19 +02:00
Olivier Fourdan
e7430a4535 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:54:41 +02:00
Rui Matos
2292458f5e wayland/*-shell: UTF-8 validate title, class and app ID strings
The protocol says these must be UTF-8 so let's ensure they are.

https://bugzilla.gnome.org/show_bug.cgi?id=752788
2016-06-07 20:17:39 +02:00
Rui Matos
d62491f46e x11/window-props: Convert WM_NAME and WM_CLASS to UTF-8
gjs throws exceptions on non UTF-8 strings which, in some cases, crash
gnome-shell. ICCCM string properties are defined to be Latin-1 encoded
so we can try to convert them to avoid it.

Note that _NET_WM_NAME is defined to be UTF-8 and we already validate
it in utf8_string_from_results() .

https://bugzilla.gnome.org/show_bug.cgi?id=752788
2016-06-07 20:17:38 +02:00
Rui Matos
8f7a36c53f window: Don't create invalid UTF-8 window description strings
printf string precision counts bytes so we may end up creating invalid
UTF-8 strings here. Instead, use glib's unicode aware methods to clip
the title.

https://bugzilla.gnome.org/show_bug.cgi?id=765535
2016-06-07 20:17:37 +02:00
Florian Müllner
8d7ae52565 stage: Fix function definition 2016-06-02 16:10:42 +02:00
Rui Matos
15300ae72e wayland-outputs: Refactor event sending to ensure we're consistent
This makes us behave the same both on bind and when an output
changes. In particular, we were not sending scale and done events on
output changes. We were also unconditionally sending mode events on
output changes even though these should only be sent if there is an
actual mode change.

https://bugzilla.gnome.org/show_bug.cgi?id=766528
2016-05-20 15:45:25 +02:00
Rui Matos
1141929bc5 backends: Add flags to MetaMonitorMode
And export them in the DBus API since they're useful for
gnome-control-center.

https://bugzilla.gnome.org/show_bug.cgi?id=763832
2016-05-13 18:44:45 +02:00
Rui Matos
bbb83d4cd0 stack: Don't add wayland windows to _NET_CLIENT_LIST
Window->xwindow is None (i.e. 0) for wayland windows and there's no
point in adding them to these X specific properties.

https://bugzilla.gnome.org/show_bug.cgi?id=764844
2016-05-12 20:06:20 +02:00
Rui Matos
c5637c52bd stack: Stack both wayland and X hidden windows below the guard window
Stacking hidden X windows below the guard window is a necessity to
ensure input events aren't delivered to them. Wayland windows don't
need this because the decision to send them input events is done by us
looking at the clutter scene graph.

But, since we don't stack hidden wayland windows along with their X
siblings we lose their relative stack positions while hidden. As
there's no ill side effect to re-stacking hidden wayland windows below
the X guard window we can fix this by just doing it regardless of
window type.

https://bugzilla.gnome.org/show_bug.cgi?id=764844
2016-05-12 20:06:19 +02:00
Marek Chalupa
6cc688d575 wayland: don't send notify when window is being unmanaged
If we try to send notify event (either from surface_state_changed()
or from meta_window_wayland_move_resize_internal()),
we will crash, because we don't have a sufrace anymore.
There's no reason why to resize the window that is being
unmanaged anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=751847
2016-05-12 20:06:11 +02:00
Rui Matos
e160babe3f keybindings: Avoid using unitialized memory and grabbing random keys
meta_parse_accelerator() considers 0 length accelerator strings as
valid, meaning that the keybinding should be disabled. Unfortunately,
it doesn't initialize the MetaKeyCombo so if the caller doesn't
initialize it either, we end up using random values and possibly
grabbing random keys.

https://bugzilla.gnome.org/show_bug.cgi?id=766270
2016-05-12 20:06:02 +02:00
Victor Toso
f8eb05ca6d core: fix build without wayland
introduced by 806f930a16

https://bugzilla.gnome.org/show_bug.cgi?id=766306
2016-05-12 09:33:26 +02:00
Carlos Garnacho
ccf6dcd865 wayland: Ensure tablet objects tear down resources properly
Otherwise the resource is still linked to a wl_list whose storage
has been freed, leading to invalid writes.
2016-05-10 17:45:04 +02:00
Carlos Garnacho
2c13ae2b59 wayland: Remove unused list from MetaWaylandTablet
This object has no concept of focus itself, so the focus_resource_list
is unused.
2016-05-10 17:45:04 +02:00
Matthias Clasen
d4bbdde503 Let gdbus-codegen generate autocleanup definitions
This used to be the hardcoded behavior, but it broke some
other users, so it was made conditional and default off.
2016-05-05 09:24:04 -04:00
Carlos Garnacho
362ab781dd backends: Allow multiple "SW" cursor overlays on the stage
All the upper layers are prepared for multiple onscreen cursors, but
this. All MetaCursorRenderers created would poke the same internal
MetaOverlay in the stage.

This will lead to multiple cursor renderers resorting to the "SW"
rendering paths (as it can be seen with tablet support) to reuse the
same overlay, thus leading to flickering when a different
MetaCursorRenderer takes over the overlay.

Fix this by allowing per-cursor-renderer overlays, their lifetime
is attached to the cursor renderer, so is expected to be tear down
if the relevant device (eg. tablet) disappears.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
2cec7ac596 wayland: Ensure each MetaWaylandSeat gets its MetaWaylandTabletSeat
Those need to be created in advance in order to handle properly the
events, even on lack of requesting clients.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
806f930a16 core: Update tablet cursors
On wayland, tablets have their standalone pointer, which must be updated
on events from the corresponding device.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
0f93ad8b53 wayland: Add methods to update the position of different tools' cursors 2016-05-03 18:17:01 +02:00
Carlos Garnacho
a631010a7a wayland: Implement tool notification
Those must be notified to clients before proximity_in, only if the client
didn't have a resource for this tool previously.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
c17d85e16b wayland: Let MetaWaylandTabletManager process tablet events
meta_wayland_tablet_manager_update()/handle_event() are called before
the MetaWaylandSeat counterparts. If the event comes from a device
managed by MetaWaylandTabletManager, the event will be exclusively handled
by it.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
ec53b5562d wayland: Implement wl_tablet_tool.set_cursor
Each tool has its own MetaCursorRenderer instance, which is created/destroyed
upon proximity, and possibly updated through focus and set_cursor calls in
between.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
521e934cb9 wayland: Implement wl_tablet_tool device event emission
This takes care of the emission of motion/down/up/button, in addition
to the extra distance/pressure/tilt axes.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
edfb8fe19b wayland: Add focus management to MetaWaylandTabletTool
Tools can now switch between surfaces, which implies the emission
of wl_tablet_tool.proximity_in/out events.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
745cb67988 wayland: Initialize the MetaWaylandTabletManager 2016-05-03 18:17:01 +02:00
Carlos Garnacho
d990f873c1 wayland: Add MetaWaylandTabletManager
This struct keeps the server side information for the wl_tablet_manager
global resource. It keeps the clients requesting this interface, and
does keep track of the plugged tablet devices, so
wl_tablet_manager.device_added is emitted on the expected clients.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
0deb069f87 wayland: Add MetaWaylandTabletSeat
This object groups all the tablets/tools pertaining to a given seat.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
ee394a6cd3 wayland: Add MetaWaylandTabletTool
This struct holds the server-side information of a wl_tablet_tool, which
represents an specific tool of an specific tablet, and is unique as such.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
5478accbf2 wayland: Add MetaWaylandTablet
This (very basic at the moment) struct keeps server-side information
for wl_tablet resources.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
bae6903476 protocol: Generate code for the tablet protocol
This is provided by wayland-protocols
2016-05-03 13:05:06 +02:00
Carlos Garnacho
b3eb56bb78 backend: Realize cursor on default MetaCursorRenderer paths
The cursor is realized on x11/native subclasses, but not if a base
MetaCursorRenderer is created.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
5849275b76 wayland: Refactor MetaWaylandSurfaceRoleCursor
Move into a standalone meta-wayland-surface-role-cursor.[ch], and
make generic enough to work for pointe and additional (eg. tablet)
cursors.

Most notably, the sprite is now kept completely internal to the
cursor role, and updates are routed through the given
MetaCursorRenderer (which may be the default one for the pointer,
or something else).

The way cursor updates after cursor surface destruction has also
been reworked, the pointer will just keep track of the last cursor
surface, so older surfaces being destroyed don't trigger pointer
rechecks/updates.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
1acfcbda6c wayland: Add MetaWaylandSurface::destroy signal
There's places where it would be convenient to add listeners to this,
so add the signal. The signal is only emitted once during destruction,
it is convenient for the places where we want notifications at a time
the object is still alive, as opposed to weak refs which notify after
the fact.
2016-05-03 13:05:06 +02:00
Emmanuele Bassi
5f5d8f4091 Drop local g_autoptr definitions for generated code
Sadly, GLib's autoptr cleanup macros cannot be detected by the C
pre-processor, because they generate a function. This means that we are
forced to bump up the dependency on GLib 2.49, in order to build against
a newer version of gdbus-codegen.
2016-05-03 08:54:46 +01:00
Emmanuele Bassi
aeda556af1 Don't re-define auto cleanup symbols
Starting from GLib 2.49, the gdbus-codegen tool automatically generates
the auto cleanup symbols for the GDBus proxy and skeleton interfaces.

Since we don't depend on a specific version of GLib we need to
conditionally generate the auto cleanup symbols in case an older version
of gdbus-codegen is used when building Mutter.

This commit unbreaks the build under GNOME Continuous, which has been
failing with:

usr/include/glib-2.0/glib/gmacros.h:415:43: error: redefinition of 'glib_autoptr_cleanup_Login1Session'
 #define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
                                           ^
[...]
/usr/include/glib-2.0/glib/gmacros.h:415:43: note: previous definition of 'glib_autoptr_cleanup_Login1Session' was here
./meta-dbus-login1.h:82:1: note: in expansion of macro 'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (Login1Session, g_object_unref)
 ^
2016-05-03 07:57:55 +01:00
Jonas Ådahl
a4ba72b0bf wayland/xdg-shell: Restructure file layout a bit
Separate "xdg_surface", "xdg_popup" and "xdg_shell" related functions
into three sections. Prior to this, the "xdg_shell" part was a bit all
over the place.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f318ec9df5 wayland: Move shell surface role fields to the role structs
Don't keep all the role specific fields in MetaWaylandSurface and have
the roles manage the needed fields themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
a89aa1d8cc wayland/wl_shell: Dismiss popup when parent is destroyed
Dismiss the popup when the parent is destroyed, and do this in the
destructor of the parent object. This makes the parent destory listener
unnecessary, since we already handle the parent child unlinking
explicitly in the object destructor.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
61c717abb3 wayland: Let the popup surface explicitly dismiss the popup
Instead of relying on destroy signals attached to the corresponding
role object, let the roles explicitly dismiss the popup when it should
be dismissed.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
229a143eac wayland: Add 'MetaWaylandPopupSurface' bridge between popup and surface
Add a bridge between the MetaWaylandPopup object and the corresponding
popup surface role. This bridge replaces communicating dismissed and
unmapped popup events.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
d9b98bced9 wayland/xdg-shell: Send popup_done if failed to start grab
https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
e68b5f6655 wayland: Simplify popup grabbing API
meta_wayland_popup_grab_create() creates and begins the grab and
meta_wayland_popup_grab_destroy() both ends and destroys the grab.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
19f7e310d9 MetaSurfaceActorWayland: Use weak pointer instead of destroy hook
MetaWaylandSurface is a GObject now, so lets utilize that.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
26815d68f6 MetaSurfaceActorWayland: Only NULL check surface on class vfuncs
The only time the surface pointer (priv->surface) may be NULL is when
the surface is unmanaged but still painting, possibly due to a unmap
animation or the like, so only guard handle this situation in the entry
points that may come from the stage painting.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
bca041b68e MetaWindow: Make buffer_rect and rect share coordinate space
Before this commit, on Wayland, the buffer rect would have the size of
the attached Wayland buffer, no matter the scale. The scale would then
be applied ad-hoc by callers when a sane rectangle was needed. This
commit changes buffer_rect to rather represent the surface rect (i.e.
what is drawn on the stage, including client side shadow). The users of
buffer_rect will no longer need to scale the buffer_rect themself to
get a usable rectangle.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
ca44770f1a wayland: Sync surface actor state in actor role commit handler
This'll also make the actor state already synchronized when shell
surfaces handlers apply their state.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
9028e30b39 wayland: Move out window state application into the roles
A large part of meta_wayland_surface_apply_window_state() was only
relevant for xdg_surface. Make this more obvious by splitting it up,
moving the relevant parts to the relevant roles.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
e66f176c29 wayland: Add get_toplevel() vfunc to the role class
How to find the toplevel surface of a surface depends on the surface
role, so let the roles implement it themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
5e54f322ab wayland: Rename subsurface commit role function
This is to make it obvious it is an implementation of a role class
vfunc.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
23b1b5f57e wayland: Make wl_shell surface role name shorter
MetaWaylandSurfaceRoleWlShellSurface -> MetaWaylandWlShellSurface

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
87555359f5 wayland: Make xdg_shell surface role names shorter
MetaWaylandSurfaceRoleXdgSurface -> MetaWaylandXdgSurface
MetaWaylandSurfaceRoleXdgPopup -> MetaWaylandXdgPopup

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
1088bf476d wayland: Set window type of wl_shell_surface popups to 'dropdown menu'
The wl_shell_surface popups are mostly used in the same way as
xdg_popup, so set the same window type.

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

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f8878ac907 wayland: Let the roles handle their windows being managed
Move xdg_shell specific code from generic Wayland code into the xdg
shell code unit by letting the roles handle the corresponding
MetaWindow being managed.

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

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
c2643ba5ac wayland: Keep wl_shell_surface state during loss of window
It has been common practice (in QT5 for example) to set
wl_shell_surface state at situations where mutter will have destroyed
the MetaWindow. This commit keeps track of the relevant state
separately from MetaWindow, and synchronizes when needed.

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

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
b3ba8e897e wayland: Clean up wl_shell_surface popup management
The wl_surface_shell protocol allows changing the popup parent, so lets
deal with the possibility that it may happen.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
7fd585fe98 wayland: Split out shell surface code from meta-wayland-surface.c
Move xdg_shell related functionality to a new meta-wayland-xdg-shell.c
and wl_shell related functionality to a new meta-wayland-wl-shell.c,
and adapt role object tree.

Common functionality related to the surface being drawn as a
MetaSurfaceActor was moved to a MetaWaylandSurfaceRoleActorSurface role.

The subsurface role GObject is made to inherit the actor surface GObject.

Shell surface hooks (configure, ping, close, popup done) were added to
a MetaWaylandSurfaceRoleShellSurface GObject which inherits the
surface actor role GObject.

The shell surface roles (xdg_surface, xdg_popup, wl_shell_surface) are
made to inherit the shell surface GObject and implement the relevant
API.

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

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Florian Müllner
b6092cf4db Revert "build: Set rpath of standalone executable"
Within the mutter module we use the .la file to link cogl/clutter,
so this isn't actually needed.

This reverts commit 576fe6e16b.
2016-04-28 20:15:48 +02:00
Florian Müllner
576fe6e16b build: Set rpath of standalone executable
We now link to cogl/clutter forks in a private location, so make
sure to point the runtime linker to the correct location.
2016-04-28 19:46:05 +02:00
Rui Matos
1fa540bcb7 Fix the merged build
https://bugzilla.gnome.org/show_bug.cgi?id=760439
2016-04-27 20:37:47 +02:00
Carlos Garnacho
a6cc35e595 wayland: remove pressed button checks from meta_wayland_pointer_can_grab_surface()
Leave these checks up to the callers, the only uses of this function
(indirect, through meta_wayland_seat_get_grab_info) are
[wl_shell|xdg]_surface.move/resize/show_window_menu.

In move/resize it makes sense to check for a button being pressed, because
we must expect a button release event. However for xdg_surface.show_window_menu
we 1) don't strictly need further events and 2) we must account for press+release
event pairs being processed at once in the compositor before the client sees
the former.

That is eg. the case of touchpad 2nd/3rd button tap emulation, multifinger
taps will emit the event pair at once, so when the client manages to request
xdg_surface.show_window_menu, it'll be too late in the compositor side, so the
request is ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=764519
2016-04-25 14:23:01 +02:00
Jonas Ådahl
08ac192b9d wayland: Handle wl_data_device being destroyed while focused
A wl_data_device object may be created while it is being focused,
either because the client destroyed it or because the client was
destroyed. Handle this by early out in focus handler vfuncs the case
where it was destroyed, so that we don't corrupt memory and/or cause
segmentation fault.

https://bugzilla.gnome.org/show_bug.cgi?id=765062
2016-04-25 20:17:24 +08:00
Florian Müllner
ed5c3b39ee monitor-manager: Add get_is_builtin_display_on()
Wrap the existing laptop_display_is_on() method in a public function
that gnome-shell can use to query whether a builtin output is present
and enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=765267
2016-04-21 21:16:16 +02:00
Florian Müllner
b6f11fa8b8 monitor-config: Update laptop heuristics to match GnomeRROutput
gnome-desktop's GnomeRROutput class has heuristics to classify a display
as builtin similar to our own[0]. The two heuristics don't quite match
though, so different core components can end up with a different view
on the current display configuration. Minimize that risk by adding a
couple of rules that bring the two heuristics closer together.

[0] https://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/gnome-rr.c#n1674

https://bugzilla.gnome.org/show_bug.cgi?id=765267
2016-04-21 17:36:22 +02:00
Florian Müllner
ab6c008e3e monitor-manager: Expose output_is_laptop() method
We currently duplicate the heuristics of whether an output is considered
a laptop or not. Avoid this by sharing a small helper method.

https://bugzilla.gnome.org/show_bug.cgi?id=765267
2016-04-21 17:36:22 +02:00
Victor Toso
ff312b6958 fix warning due implicit declaration of function
error: implicit declaration of function
  .x = (int)roundf (priv->current_x - (hot_x * texture_scale)),
            ^

https://bugzilla.gnome.org/show_bug.cgi?id=765252
2016-04-20 09:22:52 +02:00
Rui Matos
e284370013 wayland-keyboard: Notify clients of pending modifier state changes
If we get a key event but still have pending modifier state changes we
need to send a modifiers event right away so that the key event can be
interpreted by clients correctly modified.

This case could happen when mutter/gnome-shell itself consumes the
modifier key press event such as with the overview key which by
default is triggered on super press.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
2016-04-19 18:02:25 +02:00
Rui Matos
0fa9751b31 wayland-keyboard: Include virtual modifiers along with real modifiers
The wayland protocol has enough space to send both virtual and real
modifiers on modifiers events which saves clients the work of
resolving virtual modifiers themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
2016-04-19 18:02:25 +02:00
Rui Matos
82a247ccf5 keybindings: Keep virtual modifier masks around
Besides the resolved real modifier masks, having the virtual masks
around will be useful too.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
2016-04-19 18:02:25 +02:00
Olivier Fourdan
5d6af70bc9 keybindings: Fix keyboard move/resize on Wayland
Rework the code to keep the grab/ungrab logic when running as a Wayland
compositor.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=758076
2016-04-19 09:02:06 +02:00
Florian Müllner
8842bdfb11 Do not skip CoglError parameters
While CoglError is a define to GError, it doesn't follow the convention
of ignoring errors when NULL is passed, but rather treats the error as
fatal :-(
That's clearly unwanted for a compositor, so make sure to always pass
an error parameter where a runtime error is possible (i.e. any CoglError
that is not a malformed blend string).

https://bugzilla.gnome.org/show_bug.cgi?id=765058
2016-04-15 17:22:24 +02:00
Florian Müllner
bdc72dd9d7 Do not try to unref NULL CoglObjects
https://bugzilla.gnome.org/show_bug.cgi?id=765058
2016-04-15 17:21:22 +02:00
Rui Matos
8587f0e80d monitor-config: Handle invalid previous configurations
The previous configuration might not apply because the number of
enabled outputs when trying to apply it might have changed. This isn't
a bug so we shouldn't assert. Instead, we can handle it by falling
back as we would if we didn't have a previous configuration to start
with.

https://bugzilla.gnome.org/show_bug.cgi?id=764286
2016-04-13 18:16:36 +02:00
Cosimo Cecchi
150732a894 theme: set RTL/LTR flags on the style context
https://bugzilla.gnome.org/show_bug.cgi?id=764807
2016-04-09 10:03:27 -07:00
Jasper St. Pierre
75e6029206 stack: Fix 32-bit issues
Since g_array_append_val isn't smart enough to do a proper upcast, we
have to do it manually, lest we get junk.

This fixes various RAISE_ABOVE: window not in stack: 0x8100c8003
warnings that appear on 32-bit systems.
2016-04-08 17:28:26 -07:00
Rui Matos
e017148208 wayland: Make wayland move/resizes be constrained the same as X11
Just like we do for _NET_WM_MOVERESIZE messages on X11, consider
wayland client move/resizes as "frame actions" so that the same
constraints are applied to them, in particular the titlebar visibility
constraint.

https://bugzilla.gnome.org/show_bug.cgi?id=748819
2016-04-06 17:58:18 +02:00
Jonas Ådahl
7173937a7d wayland/cursor: Keep a private use count and reference to active buffer
In order for the native cursor renderer to be able to create a hw
cursor in response to wl_pointer.set_cursor(), keep a private use-count
and reference to the active buffer, stopping it from being released
until it is consumed, replaced, or the surface is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
f44238a72f MetaWaylandSurface: Keep an extra buffer use count for role-less surfaces
Whether a surface needs to keep the committed wl_buffer un-released
depends on what role the surface gets assigned to. For example a cursor
role may need an unreleased shm buffer in order to create a hw cursor from
it.

In order to support this, keep a separate reference and use count to
the buffer on behalf of the in the future assigned role, and release
those references after the surface was assigned a role. A role that
needs its own references and use counts, must in its assign function
make sure to add those.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
10a0114856 wayland: Move buffer use count to MetaWaylandSurface
Each wl_surface.commit with a newly attached buffer should result in
one wl_buffer.release for the attached buffer. For example attaching
the same buffer to two different surfaces must always result in two
wl_buffer.release events being emitted by the server. The client is
responsible for counting the wl_buffer.release events and be sure to
have received as many release events as it has attached and committed
the buffer, before reusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
aa7bc501d5 wayland: Replace buffer destroy wl_signal with a GObject signal
Don't use the libwayland-* utilities when we have our own that do the
same thing.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:02:31 +08:00
Jasper St. Pierre
3a4ae679ea common: Remove META_LAYER_FOCUSED_WINDOW
Usage of this was removed 14 years ago in 25ca0e2. Let's remove the
constant, too.
2016-03-21 13:45:11 -07:00
Jasper St. Pierre
190357c561 surface-actor-x11: Unredirect ARGB32 windows with full opaque regions
We can detect that these windows are already fully opaque, so allow them
to unredirect. Allows unredirecting Totem during video playback, giving
a significant speed boost.
2016-03-21 13:44:44 -07:00
Jonas Ådahl
92c8a51ba6 bell: Fallback to fullscreen flash if no window was passed
We allow to flash without providing a window. In this case we should
flash the whole screen, instead of crashing.

https://bugzilla.gnome.org/show_bug.cgi?id=763858
2016-03-21 11:38:31 +08:00
Carlos Garnacho
3d67bfda14 wayland: Implement support for the x-rootwindow-drop target
This target is set whenever DnD moves towards an area between surfaces.
Although no offer is set and data is actually not read, drag sources
offering this mimetype will be able to behave just like they used to
do in X11.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:02 +01:00
Carlos Garnacho
51e4491a9f wayland: Force an initial focus in meta_wayland_drag_grab_set_focus()
We want some initial processing, even if the current focus didn't change.
This could be for example the case of starting DnD too close to the window
edge and out of it. At the point start_drag() is called, the current
pointer focus is already NULL, so set_focus() would simply bail out here.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:02 +01:00
Carlos Garnacho
82153ff23f wayland: Always send focus() when starting a pointer grab
Even if the focus is NULL, we may want the current grab focus code
to be run.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:01 +01:00
Florian Müllner
9b39325244 display: Fix typo 2016-03-11 12:27:00 +01:00
Florian Müllner
868b3fd01e unit-tests: Fix const compiler warning 2016-03-11 12:26:38 +01:00
Rui Matos
8b801aac77 Handle meta_screen_get_monitor_for_point() returning NULL
On the X11 backend we don't track the pointer position in
priv->current_x/y which remain set to zero. That means we never set
the clutter stage cursor if point 0,0 isn't covered by any monitor
since we return early.

Commit 4bebc5e5fa introduced this to
avoid crashing on the prepare-at handlers when the cursor position
doesn't fall inside any monitor area but we can handle that higher up
in the stack. In that case, the sprite's scale doesn't matter since
the cursor won't be shown anyway so we can skip setting it.

https://bugzilla.gnome.org/show_bug.cgi?id=763159
2016-03-10 16:01:54 +01:00
Rui Matos
c380f2e03f wayland-pointer: Drop a phony signal disconnect
cursor_sprite_prepare_at() is never connected to a MetaCursorTracker
signal.

https://bugzilla.gnome.org/show_bug.cgi?id=763159
2016-03-10 15:58:46 +01:00
Rui Matos
ca1b4382c0 shaped-texture: Invalidate mask texture when main texture changes size
We currently rely only on MetaWindowActor to update the mask
texture. This isn't good enough since we might get asked to use the
mask (e.g. via meta_shaped_texture_get_image() ) after having a new
texture size but before MetaWindowActor decides to update the mask in
which case we might crash since cogl_texture_new_from_sub_texture()
might fail with an early return such as

Cogl-CRITICAL **: cogl_sub_texture_new: assertion 'sub_x + sub_width
<= next_width' failed

https://bugzilla.gnome.org/show_bug.cgi?id=762639
2016-03-10 15:56:41 +01:00
Jonas Ådahl
f6ba3bdfc2 wayland: Add gtk_surface.present to gtk-shell
This commits adds a gtk_surface.present request and its implementation.
The timestamp is assumed to be from some input event that the client
responded to. The timestamps we deal with when managing windows will
usually come from two different clocks: CLOCK_MONOTONIC if they come
from libinput/evdev, or CLOCK_MONOTONIC_COARSE if they come from the
X server.

Luckily these are quite similar, the difference beeing that the X server
timestamps having lower resolution, so we can just pass the timestamps
no matter where they came from and it'll most likely work fine, except
for the race condition described in bug 756272 which might happen here
too until it is properly fixed.

https://bugzilla.gnome.org/show_bug.cgi?id=763295
2016-03-10 12:34:56 +08:00
Jonas Ådahl
99bba9e56c bell: Flash whole window if the window had no frame
CSD X11 clients and Wayland clients don't have a window frame drawn by
the compositor to flash. So instead of flashing the whole screen when
configured to just flash the window, flash just the window region.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
4af908a970 wayland: Add system bell support via gtk_shell
Add a system_bell request to gtk_shell. A client can use this to invoke
the system bell, be it aural, visual or none at all. Currently per
window visual bell support is not implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
417cb2b213 bell: Let the X11 caller deal with the X11 fallback
To support invoking the system bell on Wayland we shouldn't have paths
that fallback to X11. Let the X11 caller deal with the absence of
libcanberra, and change API to not take any X events.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
9f1d1151b7 wayland: Namespace gtk_shell request handlers
https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
fea1ddcd29 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=763284
2016-03-10 12:29:43 +08:00
Carlos Garnacho
3b023ea994 wayland: Start drags from the press position
Using the current position to set the origin x/y of the DnD icon
is wrong, it should still be used in order to move the icon besides
the current pointer position though.

Fixes possible drag-start-x/y property constraint warnings when
starting a drag too close to the window edge, and towards outside
of it.
2016-03-09 18:31:50 +01:00
Carlos Garnacho
f8c70491b9 wayland: Small code cleanup in meta_wayland_drag_grab_set_focus()
There's enough instances of drag_grab->drag_data_source to make it
nicer getting a "source" variable first.
2016-03-09 18:19:23 +01:00
Jonas Ådahl
d4b0c21d06 MetaWaylandPointerConstraint: Maybe enable on window 'raise'
If a MetaWindow's 'appears-focused' state changed to true, but the
window did not have pointer focus, the constraint did not enable. Thus,
make it possible for the user to also click the window to enable it.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:29:22 +08:00
Jonas Ådahl
517078d142 MetaWaylandPointerConstraint: Disable if 'appears-focused' is false
Disable a constraint if the associated MetaWindow's 'appears-focused'
state changed to false.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:27:43 +08:00
Jonas Ådahl
1c94d0e598 MetaWaylandPointerConstraint: Require 'appears-focused' to enable
Instead of relying on the keyboard focus surface, use the
'appears-focused' state of the corresponding MetaWindow to determine if
a constraint should enable or not.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
b04747b174 MetaWaylandPointerConstraint: Unset is_enabled state when disabling
If we don't set the is_disabled state to FALSE when disabling,
re-enabling will fail.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
6396974eae MetaWaylandPointerConstraint: Use own 'appears-focused' signal handler
Instead of having MetaWindowWayland having hooks into pointer
constraints subsystem, have the pointer constraints subsystem listen
for the signal itself and enable/disable itself.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
20908b9c2c MetaWaylandPointerConstraint: Make per surface state a quark
Make the per surface pointer constraint related state (list of
constraints on given surface) a quark managed from the pointer
constraints unit.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
4abfb299e2 MetaWaylandPointerConstraint: Use NULL for infinite region
Instead of having a very large region represent an infinitely large
region, use NULL, and use the calculated input region from the
MetaWaylandSurface if the constraint region was not set.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
62ac9df43d MetaWaylandPointerConstraint: Fix effective region calculation
The when surface->input_region is NULL, it should be interpreted as the
whole surface region. If not, the effective input region is the
intersection of the buffer region and the input region set by
wl_surface.set_input_region. Add
meta_wayland_surface_calculate_input_region() that does this
calculation.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
0882bce989 startup-notification: Ensure provided timestamp is always a 64 bit integer
The libsn API provides its timestamps in the "Time" X11 type, which is
usually is a typedef for "unsigned long". The type of the "timestamp"
parameter of StartupNotificationSequence is a signed 64 bit integer.
When building on an architecture where a "unsigned long" is not 64 bit,
we'd then pass a 32 bit unsigned integer via a va_list where a signed 64
bit integer is expected causing va_arg to read past the passed 32 bit
unsigned integer.

Fix this by ensuring that we always pass the expected type via the
va_list. Also change the internal timestamp type from time_t (which
size is undefined) to gint64, to avoid any potential overflow issues.

https://bugzilla.gnome.org/show_bug.cgi?id=762763
2016-03-07 11:19:08 +08:00
Jonas Ådahl
2d65b485fd tests: Ensure tests run in a nested mutter
Since mutter was changed to be D-Bus activatable, the test cases has not
been working when running from inside a GNOME Wayland session. This
commit makes the test work again by ensuring the tests run in a nested
mutter instance.

https://bugzilla.gnome.org/show_bug.cgi?id=763125
2016-03-07 11:19:08 +08:00
Carlos Garnacho
a94e640b3f xwayland: Fix possible cancellation of wayland data sources
If we receive multiple SelectionRequest events, we'll end up replacing the
former WaylandSelectionData at a time when an async read has been issued.
This will cause the cancellation of the previous operation.

But the wayland_data_read() callback will attempt to just remove the
current wayland data again on error, which will not be the one we're
cancelling, so the new operation will just be cancelled too.

Also, cancellation is no longer warned about. As the wayland selection
has been replaced at this time, we can just return here.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Carlos Garnacho
da28d7a012 wayland: Emit signal on primary selection data source destruction
This is necessary for the X11 side to catch up, and unset the primary
selection ownership on our window that represents the wayland side in
X11 selection.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Carlos Garnacho
169f0e7324 wayland: Emit signal on selection data source destruction
This is necessary for the X11 side to catch up, and unset the selection
ownership on our window that represents the wayland side in X11 selection.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Jonas Ådahl
96927b3415 wayland: Don't access the cursor wl_buffer when updating the sprite
We may have released the wl_buffer already when doing this, which means
we should not try to access the wl_buffer content.

Regarding the cursor texture this is not an issue since we can just use
the texture created in apply_pending_state().

The hw cursor however will only be realized if the surface is already
using the the buffer (surface->using_buffer == true). This will, at the
moment, effectively disable hardware cursors for SHM buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-03 23:26:02 +08:00
Carlos Garnacho
1a3653765c wayland: Close primary selection fd after gtk_primary_selection_source.send
We leak the fd otherwise.
2016-03-01 21:07:56 +01:00
Jonas Ådahl
d340c3a6dd wayland: Don't unset surface->buffer when wl_buffer destroyed
Don't unset the surface->buffer if the associated wl_buffer object is
destroyed. The MetaWaylandBuffer doesn't really only represent a
wl_buffer object, but also the data (texture) created from the given
wl_buffer. Thus, for example destroying a released SHM wl_buffer should
not destroy the MetaWaylandBuffer instance, because the texture may
still be used.

This commit also fixes a race where calc_showing would hide a window
because, at the time of calculation whether it should be showing, the
surface's buffer had been destroyed as described above.

https://bugzilla.gnome.org/show_bug.cgi?id=762716
2016-03-01 13:33:13 +08:00
Carlos Garnacho
43bd057754 wayland: Ensure harder we're dealing with DnD offers/sources
In destroy_data_offer() there is code to ensure compatibility when
dragging from a v3 wl_data_device to a v2 one, it's however not checking
correctly that this is the DnD drag source. The other path should be
used otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=762878
2016-02-29 19:55:55 +01:00
Carlos Garnacho
66be0387ee wayland: Use separate destructor for the gtk_primary_selection_offer
Things don't mix well if we use the same destructor than wl_data_offer,
Use a separate destructor with no DnD paths whatsoever.

https://bugzilla.gnome.org/show_bug.cgi?id=762878
2016-02-29 19:55:55 +01:00
Carlos Garnacho
7c114360d0 wayland: Implement the (so far internal) primary selection protocol
Add an additional MetaWaylandDataSource implementation for primary selection
sources, and methods to set primary selection offers. Primary selection
sets altogether a different channel than the clipboard selection, those don't
cross in any way.

Also, the bridge for the X11 PRIMARY selection atom has been added, which
adds all the necessary handling to translate primary selection both ways
with wayland and X11 applications.

https://bugzilla.gnome.org/show_bug.cgi?id=762560
2016-02-26 19:51:32 +01:00
Carlos Garnacho
c6aad6e735 wayland: Add gtk-primary-selection protocol
This protocol is an internal mirror of the primary selection drafts
being proposed for wayland-protocols. No changes besides prefix/suffix
changes.

https://bugzilla.gnome.org/show_bug.cgi?id=762560
2016-02-26 19:51:32 +01:00
Carlos Garnacho
741dd674f6 backends: rate-filter the emission of MetaBackend::last-device-changed signal
It indirectly triggers expensive operations in gnome-shell
(js/ui/keyboard.js), which turns out too expensive if we happen to operate
the shell simultaneously with 2 devices that will trigger the operations
there.

So just rate limit the signal emission, defer to an idle and just emit
the last device gotten. Worst that will happen is that we may possibly
emit the signal on the same device consecutively.

https://bugzilla.gnome.org/show_bug.cgi?id=753527
2016-02-26 16:19:15 +01:00
Jonas Ådahl
821d737e2c tests: Test scheduling a later MetaLater from a later callback works
The added test tests for the bug fixed by "MetaLater: Invoke later
callbacks queued by earlier ones".

https://bugzilla.gnome.org/show_bug.cgi?id=755605
2016-02-26 17:52:01 +08:00
Jonas Ådahl
35da6a9078 MetaLater: Invoke later callbacks queued by earlier ones
If a MetaLater callback queued another MetaLater with a scheduling
later than the one currently being invoked, make it so that the newly
scheduled callback will actually be invoked.

The fact that it doesn't already do this is a regression from
cd7a968093.

https://bugzilla.gnome.org/show_bug.cgi?id=755605
2016-02-26 17:52:01 +08:00
Jonas Ådahl
00139755ff tests: Add unit tests framework runner
Separate from meta-test-runner which runs metatests testing window
manager operations, a new test program (mutter-unit-tests) is
introduced. This is meant to run unit test like tests on various units
in mutter.

An initial test testing the order of MetaLater callback invokation was
added.

https://bugzilla.gnome.org/show_bug.cgi?id=755605
2016-02-26 17:52:01 +08:00
Jonas Ådahl
ad7e654a8b MetaWaylandPointerConstraint: Don't expose internal function
It was exposed via meta-wayland-pointer-constraints.h for no apparent
reason.
2016-02-25 11:47:17 +08:00
Jonas Ådahl
b01926dbfa MetaWaylandPointerConstraint: Ignore requests on defunct resource
The constraint may be destroyed before the client destroyes the
protocol object, for example if a oneshot constraint was disabled by
alt-tab. Therefore we need to NULL check the constraint in request
handlers and ignore any requests to defunct objects.
2016-02-25 11:32:20 +08:00
Jonas Ådahl
5001aa76d7 MetaWaylandPointerConstraint: Remove redundant typedef 2016-02-25 11:32:20 +08:00
Jonas Ådahl
f1730e488d MetaWaylandPointerConstraint: Remove unused function 2016-02-25 11:32:20 +08:00
Jonas Ådahl
c22bee19e1 Add --nested command line argument
As of "core: start as wayland display server when
XDG_SESSION_TYPE=wayland" it is no longer possible to run a nested
mutter Wayland session on top of another Wayland session. This patch
adds a command line argument to make it possible to force mutter to
start as a nested compositor.

https://bugzilla.gnome.org/show_bug.cgi?id=758658
2016-02-22 17:03:07 +08:00
Carlos Garnacho
3f60a2e48a wayland: Implement gtk-shell v3
Implement the gtk_shell.set_startup_id request, so that the ID is
removed from the sequences list, and feedback updated accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=762268
2016-02-19 17:41:03 +01:00
Carlos Garnacho
3729e592a6 wayland: Update gtk-shell protocol file to v3
Add a gtk_shell.set_startup_id request, so the application can communicate
to the compositor the startup id that it received through the
DESKTOP_STARTUP_ID envvar, or other means.

https://bugzilla.gnome.org/show_bug.cgi?id=762268
2016-02-19 17:41:03 +01:00
Carlos Garnacho
56beedf9f2 core: Refactor startup notification into a separate object
This is kind of in a middle ground at the moment. Even though it
handles sequences not coming from libsn, they're added nowhere at
the moment, we'll rely on the app launch context being in the x11
side at the moment.

Also, even though we do create internal sequence objects, we keep
exposing SnStartupSequences to make gnome-shell happy, we could
consider making this object "public" (and the sequence objects with
it), things stay private at the moment.

https://bugzilla.gnome.org/show_bug.cgi?id=762268
2016-02-19 17:41:03 +01:00
Ray Strode
bed82427c6 wayland: change accessible boolean to use_count counter
Since a buffer can be used by multiple surfaces at once,
we need to release the buffer only after all surfaces
are finished with it.  Currently we track whether or
not to release the buffer based on the accessible boolean.
This commit changes it to a counter to accomodate multiple
users.

Also, each surface needs to know whether not it is done with
the buffer, so this commit adds a buffer_used boolean to the
surface state.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-19 08:57:56 -05:00
Ray Strode
e097bc8353 wayland: get rid of buffer->copied_data boolean
We currently track whether or not a buffer can be released early
by looking at the copied_data boolean on the buffer.  This boolean
is, practically speaking, always set to TRUE for shm buffers and is
always false otherwise.

We can just as easily check if the buffer is a shm buffer to decide
whether or not to do an early release.  That's better from a
theoretical point of view since copied_data assumes a 1-to-1
relationship between surface and buffer, which may not actually hold.

This commit drops copied_data and changes the check to instead see
if the buffer is shm.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-19 08:57:56 -05:00
Olivier Fourdan
4e82a751fb window: check for possible loop in transients
If a broken or naughty application tries set up its windows to create
a loop in the transient relationship, mutter will hang, looping forever
in meta_window_foreach_ancestor()

To avoid looping infinitely at various point in the code, check for a
possible loop when setting the transient relationship and deny the
request to set a window transient for another if that would create a
loop.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759299
2016-02-18 09:03:56 +01:00
Ray Strode
acd50508dc wayland: return from toplevel commit early if no new buffer
meta_wayland_surface_toplevel_commit has a lot of logic to handle
a new buffer getting attached as part of the commit.  None of
that code needs to run if there is no new buffer attached.

This commit short-circuits that case.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-17 16:16:07 -05:00
Jonas Ådahl
9611661154 native: Don't wait for a new input event to wrap the pointer
If we rely on getting back an input event with the warped pointer
coordinates, we might draw a frame with the old coordinates if we warp
during the paint phase. Avoid that by moving the cursor immediately.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
a70a2c3744 MetaPointerConfinementWayland: Support non-rectangular confinement regions
This patch adds support for confinement regions that are more complex
than a single rectangle. It relies on details about cairo regions not
explicitly in the API in order to generate the outer border of the
region.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc47b19c3f wayland: Use the event coordinates when sending pointer motion events
The x/y coordinates of the ClutterInputDevice were not the ones which was
the result of this event but whatever event was queued the last. The
correct coordinates can, however, be found in the event itself, so lets
use those.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc1dd1cee4 MetaBorder: Use float constants and functions instead of double variants
We calculate with floats, so lets use that type throughout.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
495c89401a Implement support for the wp_pointer_constraints protocol
The wp_pointer_constraints protocol is a protocol which enables clients
to manipulate the behavior of the pointer cursor associated with a seat.

Currently available constraints are locking the pointer to a static
position, and confining the pointer to a given region.

Currently locking is fully implemented, and confining is implemented for
rectangular confinement regions.

What else is lacking is less troublesome semantics for enabling the lock
or confinement; currently the only requirement implemented is that the
window that appears focused is the one that may aquire the lock.

This means that a pointer could be 'stolen' by creating a new window that
receives active focus, or when using focus-follows-mouse, a pointer
passes a window that has requested a lock. This semantics can be changed
and the protocol itself allows any semantics as seems fit.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
e2efc85b08 wayland: Make the pending surface state a GObject
Making the pending state an GObject makes it easier to extend it with
additional optional state without putting everything inside one big
struct.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
020ae58fe4 wayland: Add "painting" signal to surface actor
Make MetaWaylandSurface a listener and move output state updating to
the handler function.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
525644059d native: Update to new constrain callback API
https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
f0f638d2bd Move out generic math parts out of the native barrier implementation
In order to reuse some vector math for pointer confinement, move out
those parts to its own file, introducing the types old types
"MetaVector2" and "MetaLine2" outside of meta-barrier-native.c, as well
as introducing MetaBorder which is a line, with a blocking direction.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc8ec2d90d wayland: Add global to surface coordinate helper
https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:47 +08:00
Jonas Ådahl
5b0eabec51 wayland: Implement support for wp_relative_pointer
Add support for sending relative pointer motion deltas to clients who
request such events by creating wp_relative_pointer objects via
wp_relative_pointer_manager.

This currently implements the unstable version 1 from wayland-protocols.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:47 +08:00
Ray Strode
50099c4c10 wayland: use glib function for fetching timestamp
The code currently implements a function, get_time, that
fetches a timestamp.  That duplicates code already in glib,
and the glib implementation is better, anyway, since it doesn't
skew backward when the system clock is changed.

This commit changes the code to use g_get_monotonic_time and
drop the get_time function.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-08 17:01:58 -05:00
Rui Matos
55eef2deb3 cursor-renderer-native: Re-use cogl's gbm device
Instancing a gbm device without initializing EGL with it means that it
won't be able to import wl_drm buffers. Instead, let's re-use cogl's
gbm device which is already properly initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=761557
2016-02-04 18:22:05 +01:00
Florian Müllner
f9db65f47f theme: Take invisible borders required by the theme into account
GTK+ paints some elements like box shadows (which Adwaita likes to (ab)use
for borders) outside the rectangle passed to gtk_render_*. This is not
an issue if our own invisible frame border is big enough, but in case
of non-resizable windows we end up clipping away part of the decoration.
Use the newly added gtk_render_background_get_clip() to make sure we
always use a mask that is large enough to contain all decorations.

https://bugzilla.gnome.org/show_bug.cgi?id=752794
2016-02-04 15:16:26 +01:00
Florian Müllner
a809055470 theme: Update style context hierarchy (again)
GtkWindow actually uses two CSS nodes, 'window' and 'decoration'.
Simulate that by using two separate style contexts for the frame.
2016-02-04 15:13:23 +01:00
Alberts Muktupāvels
247909e161 frames: don't force dark theme to all windows
Use global theme variant only if window does not have _GTK_THEME_VARIANT
property. This allows applications to request default theme variant when
global dark theme is enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=761543
2016-02-04 16:02:21 +02:00
Alberts Muktupāvels
e5ce6192f4 frames: default theme variant now is set as empty string
Related change in GTK+:
https://git.gnome.org/browse/gtk+/commit/?id=8eb261988869608604c78ed90de5579beb4ef2b0

https://bugzilla.gnome.org/show_bug.cgi?id=761543
2016-02-04 15:54:26 +02:00
Ray Strode
7adbb58736 wayland: don't prematurely release EGL buffers
commit 0165cb6974 changed
mutter to release committed shm buffers as soon as they were
uploaded to the GPU.

It also inadvertently changed mutter to prematurely
release EGL buffers (which never get copied, but get used
directly).

This commit corrects that mistake.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-02 11:15:43 -05:00
Ray Strode
0165cb6974 wayland: release buffer after processing commit
When a client is ready for the compositor to read a surface's
shared memory buffer, it tells the compositor via
wl_surface_commit.

From that point forward, the baton is given to the compositor:
it knows it can read the buffer without worring about the client
making changes out from under it.

After the compositor has uploaded the pixel contents to the video
card it is supposed to release the buffer back to the client so that
the client can reuse it for future use.

At the moment, mutter only releases the buffer when a new buffer
is attached.  This is problematic, since it means the client has
to have a second buffer prepared before the compositor gives the
first one back.  Preparing the second buffer potentially involves
copying megabytes of pixel data, so that's suboptimal, and there's
no reason mutter couldn't release the buffer earlier.

This commit changes mutter to release a surface's buffer as soon
as it's done processing the commit request.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-01 14:16:17 -05:00
Rui Matos
3cdcd3e9c1 meta-launcher: Use g_auto* macros
This fixes a couple of minor memory leaks.

https://bugzilla.gnome.org/show_bug.cgi?id=760670
2016-01-25 13:59:53 +01:00
Jasper St. Pierre
6fc51e3723 window-x11: Fix checks for a bounding region input region
When cleaning up the logic in commit c408cf7, I forgot to properly apply
de Morgan's laws to an inverse.

Reported by ricotz on IRC.
2016-01-22 18:28:47 -08:00
Florian Müllner
72d6efc0d5 Shut up some compiler warnings 2016-01-21 23:04:22 +01:00
Florian Müllner
e0ffef06dd theme: Support margins on titlebar title/buttons
GTK+ improved its CSS support, and the default theme started to make
use of it, so we must update our theming code accordingly. Add support
for margins where they make sense.
2016-01-21 23:04:22 +01:00
Florian Müllner
d5b69bcd54 theme: Consider minimum sizes
GTK+ improved its CSS support, and the default theme started to make
use of it, so we must update our theming code accordingly. Start by
supporting min-width/min-height where it makes sense.
2016-01-21 23:04:22 +01:00
Rui Matos
ac8fe2d9b2 cursor-tracker: Port to GdkSeat API 2016-01-21 14:07:50 +01:00
Marek Chalupa
e7a88dc6b2 meta-launcher: don't call g_object_unref() on NULL
g_object_unref() was called no matter what we got for value

https://bugzilla.gnome.org/show_bug.cgi?id=760670
2016-01-21 14:06:41 +01:00
Jonas Ådahl
bcdda506e1 MetaWaylandDataDevice: Don't set surface offset as anchor offset
Since we are using the surface actor to draw the DND icon, the offset
is already accounted for by MetaSurfaceActorWayland, and passing the
surface position offset would effectively double the actual offset,
causing the icon to be misplaced.

This patch always sets the anchor offset to (0, 0) when the icon is a
Wayland surface, and lets the surface actor deal with the offsetting.

https://bugzilla.gnome.org/show_bug.cgi?id=759222
2016-01-19 14:32:34 +01:00
Carlos Garnacho
9b26694bbc wayland: Implement DnD actions as per wl_data_device v3 changes
We now additionally send:
  - wl_data_offer.source_actions
  - wl_data_source.action
  - wl_data_offer.action
  - wl_data_source.dnd_drop_performed
  - wl_data_source.dnd_finished

The protocol changes allow for compositors to implement different policies
when chosing the action, mutter uses this to reimplement the same behavior
that GTK+ traditionally had:

  - Alt/Control/Shift modifiers change the chosen action to
    ask/copy/move respectively
  - Drags with middle button start out as "ask" by default

As mutter now also grabs the keyboard and unsets the window focus for these
purposes, the window focus is restored after the drag operation has
finished.

The Xdnd bridge code is also modified to cope with actions, so mixed
wayland-x11 scenarios are able to convey that information.

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:55:33 +01:00
Carlos Garnacho
f053c09083 data-device: Refactor data source management by the drag grab
Move to a separate meta_wayland_drag_grab_set_source() so we keep
the weak pointer management in a single place.

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
ec9abaf1ef wayland: Add MetaWaylandKeyboardGrab and keyboard grab API
This will be useful during DnD, where mutter is expected to consume
keyboard events for either allowing changes in the selected DnD action,
or misc a11y features like keyboard-driven DnD.

Currently, the vtable contains 2 functions, key() will be used on every
key event we get from Clutter, modifiers() will notify of changes in the
keyboard modifiers (mouse buttons will never be set in the modifier mask)

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
6b88420465 wayland: Add "update" vfunc to MetaWaylandDragDestFuncs
This will be useful when an update is due but no motion event is to be
sent/received (eg. modifier changes during DnD).

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
fc0a834abb wayland: Emit wl_pointer.frame after .enter in pointer resource creation
This place was missing concordance with wl_pointer v5.
2016-01-19 11:51:36 +01:00
Carlos Garnacho
e30010b9f0 wayland: Rename meta_wayland_pointer_send_frame() to broadcast_frame
It's closer to what we mean here. And we can have a send_frame() helper
that does this for a single wl_resource.
2016-01-19 11:50:27 +01:00
Carlos Garnacho
935d76ba04 wayland: Implement wl_pointer.axis_source/axis_stop/axis_frame emission
As per the spec:
- wl_pointer.axis_source determines the current source of
  scroll events.
- wl_pointer.axis_stop determines when there's no further
  scroll events on the given axis.
- wl_pointer.axis_discrete is emitted on "wheel"
  scroll sources, measured in ticks.
- wl_pointer.frame is meant to coalesce events that logically belong
  together, e.g. axis events in this case.

Co-Authored-By: Peter Hutterer <peter.hutterer@who-t.net>

https://bugzilla.gnome.org/show_bug.cgi?id=760637
2016-01-14 19:27:48 +01:00
Sebastian Keller
a7a376ae1f xprops: Null-terminate property reply values
Some of the mutter code using these properties expects them to be
null-terminated whereas xcb does not use null-terminated strings:

http://xcb.freedesktop.org/XcbRationale/

This was in some cases resulting in the WM_CLASS property containing
garbage data which broke application matching, caused the hot-corner and
window-switcher to stop working, or was exposed as text in the UI.

https://bugzilla.gnome.org/show_bug.cgi?id=759658
2016-01-12 16:30:30 +01:00
Rui Matos
5e57af6286 idle-monitor-native: Don't leak user active watches
This fixes an issue analogous to bug 760330 for the X11 backend,
except on this backend we wouldn't crash accessing free'd memory.

Instead we're leaking watches since we steal them from the hash table
which means that when they're removed in
_meta_idle_monitor_watch_fire() they're no longer there and thus
they're never free'd.

https://bugzilla.gnome.org/show_bug.cgi?id=760476
2016-01-11 11:23:54 -05:00
Ray Strode
42b3a34f7b idle-monitor-xsync: fix crash if watch callback removes different watch
Right now the XSync based idle monitoring code, will fetch all active
watches into a list, and then call their watch callbacks one by one
as necessary.  If one watch callback invalidates another watch, the
list will contain free'd memory.

This commit makes sure to consult the hash table after ever call
of a watch callback, to ensure mutter never looks at freed memory.

Fixes crash reported on IRC by Laine Stump with his synergy setup.

https://bugzilla.gnome.org/show_bug.cgi?id=760330
2016-01-11 11:23:39 -05:00
Rui Matos
19d814c887 cursor-renderer-native: Avoid a crash if we fail to allocate a gbm bo
https://bugzilla.gnome.org/show_bug.cgi?id=758613
2016-01-11 14:31:42 +01:00
Florian Müllner
46eb682c83 Revert "window: Remove old tiling code"
This reverts commit 8bded7d497.
2016-01-10 15:16:09 +01:00
Florian Müllner
3aea8d8ce6 Revert "Add "size states" which save window size information"
This reverts commit 2c7ef2269f.
2016-01-10 15:16:09 +01:00
Florian Müllner
40c3c69435 Revert "window: Add new tiling code"
This reverts commit 50e3e3b929.
2016-01-10 15:16:08 +01:00
Florian Müllner
8071e5b149 Revert "frame: Don't allow resizing of edges that are constrained"
This reverts commit 8a481b3e10.
2016-01-10 15:16:06 +01:00
Jasper St. Pierre
8a481b3e10 frame: Don't allow resizing of edges that are constrained
https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:11:15 -08:00
Jasper St. Pierre
50e3e3b929 window: Add new tiling code
The new tiling code, instead of based around "tiling states", is instead
based around constrained edges. This allows us to have windows that have
three constrained edges, but keep one free-floating, e.g. a window tiled
to the left has the left, top, and bottom edges constrained, but the
right edge can be left resizable.

This system also is easily extended to support corner tiling. We also,
using the new "size state" system, also keep normal, tiled, and
maximized sizes independently, allowing the maximize button to bounce
between maximized and tiled states without reverting to normal in
between. Dragging from the top will always restore the normal state,
though.

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:09:30 -08:00
Jasper St. Pierre
2c7ef2269f Add "size states" which save window size information
https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:08:35 -08:00
Jasper St. Pierre
8bded7d497 window: Remove old tiling code
We'll soon replace this with a better scheme

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:08:32 -08:00
Jasper St. Pierre
9ebe3419c3 monitor-manager-xrandr: Don't query legacy properties
This never could have worked -- the Atom name it was querying was a root
window property, not an output property.
2016-01-09 18:06:18 -08:00
Rui Matos
9385c835b8 native: Don't leak DRM plane resources 2016-01-07 19:42:19 +01:00
Carlos Garnacho
efef0c993b native: Implement DRM-based crtc rotation
We can know the rotation modes supported by the driver, so
export these as our supported modes, and ensure these modes
are honored on the CRTC primary plane upon apply_configuration().

It is worth noting however that not all hardware will be
capable of supporting all rotation modes (in fact, most of
them won't). A driver independent solution should be in
place to back up the rotation modes unsupported by the
drivers, so this is still a partial solution.

The cursor renderer has also been changed to default to
software-based rendering anytime the cursor enters a
rotated CRTC. Another solution would be actually rotating
the DRM cursor planes, but then it requires applying rotation on
these per-CRTC, and actually transforming the pointer position by
the output matrix. This brings marginal gains, so we use the
"sw" rendered cursor, which will be transformed together with
the primary plane.

https://bugzilla.gnome.org/show_bug.cgi?id=745079
2016-01-07 17:03:44 +01:00