Commit graph

217 commits

Author SHA1 Message Date
Giulio Camuffo 7a8d67dedf shell: fix positioning of maximized surfaces with a custom geometry 2015-01-27 15:27:39 -08:00
Pekka Paalanen b502654b9f compositor: Implement JSON-timeline logging
Logging is activated and deactivated with the debug key binding 't'.
When activated, it creates a new log file, where it records the events.
The log file contains events and detailed object information entries in
JSON format, and is meant to be parsed in sequence from beginning to the
end.

The emitted events are mostly related to the output repaint cycle, like
when repaint begins, is submitted to GPU, and when it completes on a
vblank. This is recorded per-output. Also some per-surface events are
recorded, including when surface damage is flushed.

To reduce the log size, events refer to objects like outputs and
surfaces by id numbers. Detailed object information is emitted only as
needed: on the first object occurrence, and afterwards only if
weston_timeline_object::force_refresh asks for it.

The detailed information for surfaces includes the string returned by
weston_surface::get_label. Therefore it is important to set
weston_timeline_object::force_refresh = 1 whenever the string would
change, so that the new details get recorded.

A rudimentary parser and SVG generator can be found at:
https://github.com/ppaalanen/wesgr

The timeline logs can answer questions including:
- How does the compositor repaint cycle work timing-wise?
- When was the vblank deadline missed?
- What is the latency from surface commit to showing the new content on
  screen?
- How long does it take to process the scenegraph?

v2: weston_surface::get_description renamed to get_label.
v3: reafctor a bit into fprint_quoted_string().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-12-08 15:02:56 +02:00
Pekka Paalanen 8274d901f1 compositor: add weston_surface_set_label_func()
When printing out logs from Weston's actions, mainly for debugging, it
can be very difficult to identify the different surfaces.  Inspecting
the configure function pointer is not useful, as the configure functions
may live in modules.

Add vfunc get_label to weston_surface, which will produce a short,
human-readable description of the surface, which allows identifying it
better, rather than just looking at the surface size, for instance.

Set the label function from most parts of Weston, to identify cursors and
drag icons, and panels, backgrounds, screensavers and lock surfaces, and
the desktop shell's application surfaces.

v2: renamed 'description' to 'label', so we get
	weston_surface_set_label_func().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-12-08 14:20:20 +02:00
Pekka Paalanen a4bac9e0e0 desktop-shell: don't crash input-panel if no kbd focus
If a keyboard exists but it has no current focus, yet something asks the
input-panel to come up, we would crash here. Check that there is a focus
before attempting to use it.

Maybe there should not even exist a case where input-panel tries to come
up without a keyboard focus, but I am not sure there is no race where it
could happen.

In any case, this fix was brought up by the ivi-shell work, where I
suppose you can somehow hit it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Tanibata, Nobuhiko <ntanibata@jp.adit-jv.com>
2014-11-24 13:47:32 +02:00
Marek Chalupa e9fe467453 xwayland: fix fullscreening
set_fullscreen has been sending configure before changing the state
and xwayland windows added border to the fullscreen size.

This fixes the bug:
https://bugs.freedesktop.org/show_bug.cgi?id=83502

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Ryo Munakata <ryomnktml@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-21 15:14:55 +02:00
Derek Foreman 6ae7bc982f compositor: Refactor weston_output_mode_switch()
This breaks weston_output_mode_switch() into 3 functions:
weston_output_mode_set_native()
weston_output_mode_switch_to_temporary()
weston_output_mode_switch_to_native()

Differences from previous behaviour:
SET_NATIVE didn't set current_scale (now it does)
SET_TEMPORARY could set mode and scale independently - now it can't.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-05 13:15:13 +02:00
Pekka Paalanen 50b6747903 compositor: send error for surface role resets
With the more accurate definition of wl_surface roles in Wayland,
enforce the restriction: a role is always set permanently, and
attempting to change it is a protocol error.

This patch is based on Jasper's patch:
http://lists.freedesktop.org/archives/wayland-devel/2014-August/016811.html

The difference in this patch compared to his are:

- send role errors on the interface whose request triggers it, not on
  wl_surface

- an interface could have several requests assigning different roles,
  cannot use wl_interface as the unique key; use an arbitary string
  instead

- ensure in window-manager.c that create_shell_surface() ->
  create_common_surface() is never called with surface->configure set,
  to avoid compositor abort

- use wl_resource_post_no_memory() where appropriate instead of
  hand-rolling it with wl_resource_post_error()

Ideally we would not add weston_surface::role_name field, but use
weston_surface::configure. At the moment this is not possible though,
because at least shell.c uses several different roles with the same
configure function. Drag'n'drop uses two configure functions for the
same role. The configure hook is also reset in several places,
which is not good for role tracking.

This patch overlooks the wl_surface roles assigned in privileged
extensions: screensaver, panel, background, lock, input panel.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-10-08 13:16:30 +03:00
Pekka Paalanen e972b27f34 shell: don't crash on create_common_surface() failure
Noticed while reading code, that create_common_surface() may return
NULL, and callers of its direct callers check for NULL, but the
intermediate function in between would crash.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-10-01 14:58:46 +03:00
Derek Foreman 69c6273f28 shell: fix weston_output_mode_switch() usage
Calling weston_output_mode_switch() with WESTON_MODE_SWITCH_RESTORE_NATIVE
will result in the mode being set "back" to the passed in mode - so the
passed mode should be the native mode.

Additionally, weston_output_mode_switch() should be called when
output->original_mode is non-NULL (which indicates we had a temporary
mode set).  The comparison to current_mode results in a lot of
log chatter.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-22 14:38:13 +03:00
Derek Foreman 4b1a0a1d07 cosmetic: update comments that refer to weston_surface_update_transform()
weston_surface_update_transform() no longer exists, except in comments.

Fix that.

[Pekka Paalanen: don't lose the full comment in compositor-drm.c.]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-11 11:52:56 +03:00
Marek Chalupa 8b771af986 xdg-shell: fix maximizing in multi-head setup
Set the right position of maximized window. Up until now we ignored
output's "position" and were using only the working area
of output which is in output-relative coordinates. This led to
showing the maximized window always on the first output.

This, along with the previous patch, fixes
https://bugs.freedesktop.org/show_bug.cgi?id=82967

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-10 16:33:13 +03:00
Marek Chalupa bfbb64bb75 xdg-shell: update shsurf->output when maximizing
shsurf->output is the output that user expects the shell surface
is on. When maximizing, we don't have any explicit setting of the output
like in the case of fullscreening, so set the output to the one that
the surface is currently on. In the case that the surface is not mapped yet,
(if it ever happens) use the same heuristics as for fullscreening.

This fixes the size sent with configure event, when maximizing a window.
The size is now picked up by the correct output, but the maximized
window position is still wrong. [Pekka Paalanen]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82967
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-10 16:26:00 +03:00
Pekka Paalanen 974c094060 fix asprintf warnings
Fix recently introduced compiler warnings:

desktop-shell/shell.c: In function 'shell_configuration':
desktop-shell/shell.c:588:10: warning: ignoring return value of
'asprintf', declared with attribute warn_unused_result [-Wunused-result]

src/screenshooter.c: In function ‘screenshooter_binding’:
src/screenshooter.c:291:10: warning: ignoring return value of
‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]

src/text-backend.c: In function ‘text_backend_configuration’:
src/text-backend.c:944:10: warning: ignoring return value of ‘asprintf’,
declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-05 14:45:09 +03:00
Marek Chalupa 052917aa2a xdg-shell: handle clients launched in fullscreen
When client is lauched in fullscreen, it is placed on the
first output, because it is not mapped and
shell_surface_set_output() therefore sets default output.

Since we have no better way how to position newly created windows,
(http://lists.freedesktop.org/archives/wayland-devel/2014-May/thread.html#14568)
set the output to the one that has currently focus. Priority has
the touch focus, then pointer and then keyboard focus.

This fixes bug
https://bugs.freedesktop.org/show_bug.cgi?id=69780

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-05 12:10:12 +03:00
Derek Foreman 362656bfa3 touch-input: Don't dereference NULL pointer during full screen fade
If a full screen program is fading out and a touch start happens, it
will result in a NULL pointer dereference when weston_touch_set_focus
tries to derefernce view->surface->resource.

Instead, this patch sets the focus to NULL, which should be the
same as if the program was destroyed during the touch anyway.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=78706
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-05 10:32:09 +03:00
Jonny Lamb 76cf1feb3b desktop-shell: implement touch popup grabs
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-04 13:34:57 +03:00
Pekka Paalanen 2e62e4ad71 shell: quit weston, if weston-desktop-shell dies early
If weston-desktop-shell dies soon after launch, or maybe cannot be
executed at all, let weston exit rather than letting the user stare at a
black screen.

But, do not exit weston, if weston-desktop-shell dies later, as the user
may already have apps open, and those apps would likely still function
correctly. This gives the user the opportunity to save his work and
close the apps properly.

This should make one class of "I see only black screen" failures obvious.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
2014-09-01 10:18:59 +03:00
Pekka Paalanen 826dc14ec4 shell: fix race on desktop-shell exit
The desktop shell plugin registers both a wl_client destroy signal
listener, and a sigchld handler, when launching weston-desktop-shell.
However, nothing guarantees in which order do the wl_client destructor
and the sigchld handler run.

Luckily, the sigchld handler cannot interrupt any code, because we
handle the signal via signalfd, which means it is handled like any event
in the compositor's main event loop.

Still, shell.c has a race, that when lost, can cause a crash, as
described in bug #82957.

If the sigchld handler happens to run first, it will try to launch a new
weston-desktop-shell without removing the destroy listener from the old
wl_client first. This leads to list corruption, that may cause a crash
when the old wl_client gets destroyed.

Simply removing the destroy listener in the sigchld handler is not
enough, because respawning sets shell->child.client pointer, and if
the wl_client destructor runs after, it will reset it to NULL.

OTOH, the wl_client destroy handler cannot reset shell->child.process,
because that would cause the sigchld handler in weston core to not find
the process tracker anymore, and report that an unknown process exited.

Turns out, that to make everything work, we would need to wait for both
the wl_client destructor and the sigchld handler to have run, before
respawn. This gets tricky.

Instead, solve the problem by removing shell->child.process. Use the new
weston_client_start() which automatically creates and manages the struct
weston_process. The shell does not need to know about the process exit,
it only needs to know about the client disconnect. Weston-desktop-shell
will never attempt to reconnect, and it would not work even if it did,
so disconnect is equivalent to weston-desktop-shell exiting.

This should permanently solve the race for weston-desktop-shell.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82957
Cc: Boyan Ding <stu_dby@126.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2014-08-28 10:15:38 +03:00
Arnaud Vrac 4263119d02 desktop-shell: fix invalid memory access when shell execution fails
In this case wl_client_add_destroy_listener() was called with a NULL
client, which is invalid.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-27 16:57:55 +03:00
Ondřej Majerech ae9c4fc39f desktop-shell: Replace magic constants with named ones
Signed-off-by: Ondřej Majerech <majerech.o@gmail.com>
Reviewed-by: Nils Chr. Brause <nilschrbrause@gmail.com>
2014-08-27 16:03:49 +03:00
Derek Foreman c7210434d4 tests: allow running make check without make install
desktop shell and weston keyboard both refer to themselves prefixed by
LIBEXECDIR, however this is only valid once installed.  make check will
currently either fail or run pre-existing versions.

This patch adds a way to override that location by setting the env var
WESTON_BUILD_DIR - which is then set by the test env script so make check
will test the versions in the build directory regardless of whether they're
installed or not.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-22 17:47:33 +03:00
Pekka Paalanen 71182aed84 xdg-shell: bump experimental protocol version
The experimental versioning has not been updated when it was supposed
to. Let's try to be better at it now, as xdg-shell is close to have its
first stable version.

Bump the version now to bring the world into the same exact version.

There may be some protocol changes still coming, but we try to land them
before 1.6 gets out. Those changes will bump the experimental version
again as needed.

When 1.6.0 is released, the experimental version will no longer be
bumped, and no incompatible protocol changes will be made. Xdg-shell.xml
file will move to Wayland in 1.7.0, drop the experimental versioning,
and become stable.

Cc: Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-21 17:47:20 +03:00
Jonny Lamb d73c694afd desktop-shell: use panel location to calculate correct sizes and ranges
Now the client can let us know where the panel is using
desktop_shell.set_panel_position, we can correctly calculate where to
put new views and how big maximized views should be.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-20 17:06:57 +03:00
Jonny Lamb 765760dc71 desktop-shell: add set_panel_position to help place views onscreen
Panels are always assumed to be on the top edge of the output. If this
is not the case views will be placed under the panel, wherever it is,
and maximize doesn't use the correct space allocated for views.

By telling the server on which edge the panel is located, it can
correctly calculate where to put new views and how big maximized views
should be.

[Pekka Paalanen: the user of this protocol so far is Maynard.]

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-20 17:06:19 +03:00
Jonas Ådahl 61917c84e3 shell: Update focused surface pointer coordinates in popup grab
The commit 'input: Send leave and enter pair when the surface moves
under the cursor' introduced focused surface local pointer coordinates
to keep track of if a surface had been moved or transformed in a way
that the pointer posititon relative to that surface would change.
Update these coordinates also for the popup grab as otherwise every
pointer motion during a popup grab results in leave and then enter
events.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-18 15:36:39 +03:00
Jonny Lamb f322f8efea desktop-shell: add close-animation config option for destroying surfaces
At the moment when surfaces are destroyed they are faded out but let's
make it configurable!

Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-18 13:27:11 +03:00
Jasper St. Pierre 666bc9234a desktop-shell: Add a missing return; in an error path 2014-08-08 14:59:48 -07:00
Jasper St. Pierre c91408f3fb Don't bother destroying resources after sending an error
An error makes the client exit, which cleans up the resources anyway.

Note (Jason Ekstrand):
This is safe for two reasons.  First, we should be handling object
destruction nicely anyway.  Second, in each of these cases, the resources
don't have any implementation or destruction set so it has absolutely no
effect on the rest of weston whether we destroy it now or later.
2014-08-08 14:57:17 -07:00
Jonny Lamb e84ab4ef4d desktop-shell: don't assume there's a pointer when mapping a popup 2014-08-07 16:23:10 +03:00
Giulio Camuffo 412e6a59eb compositor: keep track of the weston_layer a weston_view is in
This introduces a new struct, weston_layer_entry, which is now used
in place of wl_list to keep the link for the layer list in weston_view
and the head of the list in weston_layer.
weston_layer_entry also has a weston_layer*, which points to the layer
the view is in or, in the case the entry it's the head of the list, to
the layer itself.
2014-07-23 12:34:33 -07:00
Jasper St. Pierre ccf48fb4f9 shell: Replace set_margin with set_window_geometry
Currently, there is a fun flicker when toggling maximization or
fullscreen on a window in mutter or more sophisicated compositors
and WMs.

What happens is that the client want so go maximized, so we
calculate the size that we want the window to resize to (640x480),
and then add on its margins to find the buffer size (+10 = 660x500),
and then send out a configure event for that size. The client
renders to that size, realizes that it's maximized, and then
says "oh hey, my margins are actually 0 now!", and so the compositor
has to send out another configure event.

In order to fix this, make the the configure request correspond to
the window geometry we'd like the window to be at. At the same time,
replace set_margin with set_window_geometry, where we specify a rect
rather than a border around the window.
2014-07-17 13:59:01 -07:00
Jasper St. Pierre bd65e50875 Interpret the size in the configure event as window geometry
The size of the configure event has always been specified as in window
geometry coordinates, but it was never implemented this way.
2014-07-17 13:58:45 -07:00
Boyan Ding 32abdbbad9 shell: fix segfault in fullscreen binding
Commit 9aa8ce69 forgot to set shsurf->fullscreen_output in
fullscreen_binding(), causing segfault when fullscreening using key
bindings. This patch fixes that.

https://bugs.freedesktop.org/show_bug.cgi?id=79828
Signed-off-by: Boyan Ding <stu_dby@126.com>
2014-06-25 19:59:26 -07:00
Emilio Pozuelo Monfort 5872b6821b desktop-shell: Don't assume there is a pointer when resizing
Fixes a crash on touch devices without a pointer, when touching
the window frame of a client.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2014-06-23 13:41:30 -07:00
Jonny Lamb 7e7d485164 desktop-shell: make background applications less dark 2014-06-18 17:14:40 -07:00
Emilio Pozuelo Monfort 5905ebcc33 exposay: fix crash when navigating with the keyboard
Commit a7592019 introduced an optimization that caused some
exposay struct members to not be properly initialized, particularly
cur_output, leading to crashes in some circumstances (e.g. pressing
the down arrow key after going to exposay).

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2014-06-18 17:14:40 -07:00
Jasper St. Pierre 81ff075bf4 xdg-shell: Add show_window_menu request 2014-05-23 09:43:17 -07:00
Jasper St. Pierre 851799e791 shell: Make margin double-buffered state that's applied on commit 2014-05-12 23:34:05 -07:00
Jasper St. Pierre 9aa8ce6985 shell: Don't use the helper methods in xdg_shell implementations
With most of the code in send_configure_for_surface, the helper
methods don't give us that much benefit, so stop using them. We
can't kill them off, as they're part of the shell interface and
used by the WM.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre 6458ec3410 shell: Centralize management of sending configure requests
Currently, there's a giant bug in how xdg-shell state management
is done. If a client calls set_fullscreen and then set_maximized,
it will get two configure events:

  => set_fullscreen
  <= configure(800, 600, [STATE_FULLSCREEN])

  => set_maximized
  <= configure(800, 560, [STATE_FULLSCREEN, STATE_MAXIMIZED])

Since fullscreen takes precedence over maximized, the client will
render full-screen at 800x600 first, and then 800x560 next. As
a result, the surface gets the wrong size.

This is because the code that sends out configure requests is
"immediate" -- when an app calls set_maximized, we immediately
send out the configure event that would have happened if we
transitioned immediately into maximized mode.

In wl_shell, this is correct behavior. However, in xdg-shell,
this is wrong. State needs to be more carefully managed in
xdg-shell, as states aren't exclusive.

Pull all the code that sends out configure events out and send
them centrally, based on Weston's on surface state management.
This should work with both wl_shell and xdg_shell's strategies.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre 973d7879e3 xdg-shell: Turn "activated" into a state
This drops two events, and makes new window decorations race-free with
an attach in-flight.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre 5befdda84f xdg-shell: Turn the resizing heuristics into an explicit state
Currently, there's a race condition. When resizing from the left, and
a client attaches a buffer after the resize ends, you suddenly see the
buffer jump to the right, because the resize ended while multiple
attaches were in-flight. Making resize a state can fix this, as the
server can now know exactly when the resize ended, and whether a commit
was before or after that place.

We don't implement the correct tracking in this commit; that's left as
an exercise to the reader.

Additionally, clients like terminals might want to display resize popups
to display the number of cells when in a resize. They can use the hint
here to figure out whether they are resizing.
2014-05-12 23:34:05 -07:00
Jasper St. Pierre ab2c108137 xdg-shell: Rework the state system
The states system, so far, has been a complicated mix of weird APIs
that solved a real race condition, but have been particularly ugly
for both compositors and clients to implement.
2014-05-12 23:33:59 -07:00
Jasper St. Pierre c815d62b85 xdg-shell: Rename set_transient_for to set_parent
It's a confusing name that comes from the ICCCM. The ICCCM is best
forgotten about.

With the addition of the potential new "transient" role meaning a
parent-relative toplevel like a long-lived popup, used for e.g.
tooltips, the set_transient_for name will become even more confusing.
2014-05-13 00:35:30 -04:00
Kristian Høgsberg c991513483 desktop-shell: Damage the black view when we remove it
We should be using weston_view_unmap() here, or maybe just destroying the
black view, but let's do a minimal, safe fix for the 1.5 release.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=78501
2014-05-09 16:24:07 -07:00
Ander Conselvan de Oliveira 6d43f045e3 shell: Don't allow maximized surfaces to be moved with touch
Moving a maximized surface with the pointer is already not possible,
so make the behavior with touch consistent.

https://bugs.freedesktop.org/show_bug.cgi?id=78208
2014-05-09 13:33:36 -07:00
Ander Conselvan de Oliveira 6e56ab41d9 shell: Fix crash when restoring focus state during workspace change
The check to avoid calling weston_keyboard_set_focus() for a seat that
didn't have a keyboard in restore_focus_state() was cheking the wrong
seat (the one from the previous loop). That caused a crash when
switching workspaces if there was an extra seat that didn't have a
keyboard.

https://bugs.freedesktop.org/show_bug.cgi?id=78349
2014-05-09 12:51:28 -07:00
Ander Conselvan de Oliveira 9c6217e6dc shell: Fix artifacts caused by workspace change animation
Views that extend past the bottom of the output are still visible after
the workspace animation ends but before its layer is hidden. When the
layer was hidden, nothing would cause those regions to be repainted,
leading to artifacts.

https://bugs.freedesktop.org/show_bug.cgi?id=78363
2014-05-09 12:49:54 -07:00
Kristian Høgsberg 4779241516 xwayland: Fix fullscreen mode
With xdg_shell wl_shell starting to diverge in how they work, there's
less shared code in set_fullscreen().  The problem is that the xwayland
window manager calls into set_fulscreen() which now doesn't complete
the fullscreen transition.  Add shell_interface_set_fullscreen() for
the shell interface set_fullscreen hook to use.

https://bugs.freedesktop.org/show_bug.cgi?id=78230
2014-05-04 13:47:06 -07:00
Jasper St. Pierre ac985be8ce compositor: Remove the edges parameter from send_configure
send_configure was originally modelled after
wl_shell_surface::send_configure, which takes these arguments. However,
the X WM and xdg_surface::configure variants don't use these arguments.

We already store the resize edges for a surface while it's being
resized, so just use the saved state in the wl_shell_surface variant.
2014-04-30 20:53:15 -07:00
Kristian Høgsberg 6d50b0f2a1 desktop-shell: Remove output_move listener on shutdown
https://bugs.freedesktop.org/show_bug.cgi?id=78138
2014-04-30 20:46:25 -07:00
Kristian Høgsberg e5c1ae9368 xwayland: Set decoration margin for xwayland windows 2014-04-30 16:28:41 -07:00
Kristian Høgsberg a4b620e7e7 desktop-shell: Further consolidate move/resize grab checks
This moves the check for shsurf->grabbed into surface_move() and
surface_resize(), which are shared with the xwayland code.  This prevents
trying to resize or move an xwayland window with multiple pointers.
2014-04-30 16:05:49 -07:00
Kristian Høgsberg e0b9d5be84 xwayland: Make resizing work again
9c376b54ea fixed the crash when a client goes
away during a resize grab.  The shsurf->resource is set to NULL in that
case and we were trying to send out events to a NULL resource.  However,
xwayland shell surfaces are created by the xwayland module and don't have a
resource.  We use a different function pointer for sending the configure
events that handle the events inside xwayland instead of sending protocol
events.

To fix all this, we just move the check for a NULL resource into the
functions that we use for sending configure events for wl_shell and
xdg_shell.
2014-04-30 13:45:53 -07:00
Xiong Zhang 62899f5124 shell.c: Set dirty for visible views on destroyed output
The geometry for visible views will keep unchanged,
weston_view_set_position() doesn't mark these views
as dirty. So there is no chance for them to reassign output, then
these views will disappear.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=72946

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2014-04-30 10:59:30 -07:00
Ander Conselvan de Oliveira ef6a7e46eb shell: Don't map surfaces of type SHELL_SURFACE_NONE
When commit 07926d90 factored out the code that chooses in which layer
a surface is added to, it changed the behavior for surfaces with no
type. Instead of not adding it to any layer, the surface is added to
the current workspace.

This patch restores the old behavior.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77527
2014-04-30 09:09:32 -07:00
Jason Ekstrand 024177cecb desktop-shell: Properly handle seat hotplugging
Previously, desktop-shell would only create its internal shell_seat object
for each seat available when the desktop-shell module is loaded.  This is a
problem any time seats are created dynamically.  In particular, the Wayland
and RDP backends create seats on an as-needed basis and they weren't
getting picked up proprely by desktop-shell.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77649
2014-04-29 16:49:59 -07:00
Kristian Høgsberg 3434b33b19 desktop-shell: Remove unused variables 2014-04-29 16:38:23 -07:00
Emilio Pozuelo Monfort 9e7c7598aa desktop-shell: Properly handle lowered fullscreen surfaces
lower_fullscreen_surface() was removing fullscreen surfaces from
the fullscreen layer and inserting them in the normal workspace
layer. However, those fullscreen surfaces were never put back in
the fullscreen layer, causing bugs such as unrelated surfaces
being drawn between a fullscreen surface and its black view.

Change the lower_fullscreen_surface() logic so that it lowers
fullscreen surfaces to the workspace layer *and* hides the
black views. Make this reversible by re-configuring the lowered
fullscreen surface: when it is re-configured, the black view
will be shown again and the surface will be restacked in the
fullscreen layer.

https://bugs.freedesktop.org/show_bug.cgi?id=73575
https://bugs.freedesktop.org/show_bug.cgi?id=74221
https://bugs.freedesktop.org/show_bug.cgi?id=74222
2014-04-29 16:33:56 -07:00
Kristian Høgsberg ae356aef58 desktop-shell: Keep windows on screen when moving
We add a primitive constraining function to at least prevent users from
moving the window up under the panel.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=73421
2014-04-29 16:03:58 -07:00
Kristian Høgsberg 6110d07777 desktop-shell: Raise new windows over fullscreen apps
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74219
2014-04-29 15:15:45 -07:00
Kristian Høgsberg 74071e056a desktop-shell: End popup when starting a touch shell grab
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77345
2014-04-29 15:01:16 -07:00
Kristian Høgsberg 7b83ae433f desktop-shell: Reject resize if we're already grabbed
This rejects resizing a window that's currently being moved.  This can
be done using a touch screen and a pointer or just two seats.
2014-04-29 14:50:25 -07:00
Kristian Høgsberg d0b40ed451 desktop-shell: Reject window move in common_surface_move()
We move the check for shsurf->grabbed from surface_move() and
surface_touch_move() up top common_surface_move()
2014-04-29 14:47:46 -07:00
Ander Conselvan de Oliveira 9c376b54ea shell: Fix crash when a client is destroyed during the resize grab
If a client exists during a resize grab, the resource for the shell
surface being resized is destroyed. The shell surface is not destroyed
immediately, however, because of the window close animation. In that
case, the compositor would crash trying to send configure events to
the surface being resized, since it would pass a NULL pointer to
wl_resource_post_event().

The code for the resize grab was already able to handle the surface
going away, so expand it to also handle the resource going away and
fix the crash.

https://bugs.freedesktop.org/show_bug.cgi?id=77344
2014-04-29 13:33:29 -07:00
Ander Conselvan de Oliveira 15f9a26bb1 shell: Fix memory leaks caused by the window close animation
In order to do the window close animation, a reference for a destroyed
surface is kept. However, the reference count was also increased for
unmapped surfaces, in which case the animation wouldn't run. Since the
reference count was decremented in the animation done function, it would
never be decreased for unmapped surfaces, causing them to not be
released.

The close animation also changed how shell surfaces are released. The
destroy function for its resource was changed to not deallocate the
surface, and instead keep it around until the animation finishes and
the weston surface is destroyed. The destruction should happen in the
destroy listener for the weston surface, but it wouldn't destroy the
shell surface in the case the resource was still valid, assuming that
it would be freed in the resource destroy function.
2014-04-29 13:33:26 -07:00
Jonas Ådahl 1679f232e5 libinput: Forward frame events to clients
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77353

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-04-21 16:03:28 -07:00
Manuel Bachmann 5082ad6b28 shell: display the input panel on the active output
We now dynamically move the input panel (i.e. virtual
keyboard) surface to the output containing the currently
focused surface.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=71015

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
2014-04-21 14:34:15 -07:00
Ander Conselvan de Oliveira 75c373c76c shell: Destroy a previous input panel animation when showing it again
It is possible that an input panel will be shown quickly, hidden and
shown again, before the animation for the first appeareance finished.
In that case, another animation would be created and the effect of the
two combined could cause the panel to not appear in the screen.

This patch fixes this by keeping a reference to the previous animation
and deleting it when a new one is created.
2014-04-16 22:33:48 -07:00
Jason Ekstrand 9e9512f017 desktop-shell: Get rid of get_shell_client
We now carry the shell_client around with each shell_surface.  This is much
more reliable than tacitly assuming that there is only one wl_shell or
xdg_shell instance bound to a particular wl_client.  In particular, weston
would crash when a client bound to both wl_shell and xdg_shell even if it
only ever used one of them.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-04-16 22:29:01 -07:00
Ander Conselvan de Oliveira 304996d182 shell: Fix view repositioning logic for output move and destroy
Previously, the repositioning logic would iterate the compositor's list
of layers and move the views on those layers. However, that failed in
two different ways: it didn't cover hidden workspaces and crashed when
the display was locked.

This patch changes the logic to explicit iterate over all the layers
owned by the shell. The iteration is done through a helper function,
shell_for_each_layer().

https://bugs.freedesktop.org/show_bug.cgi?id=76859
https://bugs.freedesktop.org/show_bug.cgi?id=77290
2014-04-11 10:05:19 -07:00
Ander Conselvan de Oliveira 641796c31a shell: Keep shsurf->fullscreen_output set after unset_fullscreen()
When a fullscreen surface gets the maximized state, the function
reset_surface_type() is called and that causes unset_fullscreen() to be
called. That function would set the value of shsurf->fullscreen_output
to NULL. However, since the surface still has the fullscreen state, it
will be configured as a fullscreen surface again, and an attempt to
access that field would cause the compositor to crash.

Fix the crash by keeping the value of fullscreen_output around after
unset_fullscreen(). This is safe since the value is only used when a
surface has the fullscreen state and is replaced on a new request to
make the surface fullscreen.

https://bugs.freedesktop.org/show_bug.cgi?id=76867
2014-04-10 10:20:54 -07:00
Ander Conselvan de Oliveira facc0ccf06 shell: Damage below child surfaces on move to different workspace
When moving from a surface from visible workspace to an invisible one
via a popup menu, the area below the menu wouldn't be repainted.

https://bugs.freedesktop.org/show_bug.cgi?id=76973
2014-04-10 10:06:22 -07:00
Ander Conselvan de Oliveira 4e20e9b847 shell: Disarm the screensaver timeout timer on terminate_screensaver()
The timer was left running after the screensaver was terminated. When
it triggered, a fade out that would in turn cause the screen to be
locked was started. Since that could happen without the compositor
emitting the idle signal, there would be no wake signal to make the
shell show the lock screen, so the system was left unresponsive
until the idle signal actually triggered.

https://bugs.freedesktop.org/show_bug.cgi?id=70923
2014-04-10 10:02:35 -07:00
Neil Roberts b4a91708e3 Reset the keyboard focus on all seats when the compositor is locked
Before commit 2f5faff7f9 when the compositor is locked it would
reset the keyboard focus on all of the seats as part of pushing the
focus_state. This was removed because it now always keeps track of the
focus_state in the workspace instead of waiting until the state is
pushed. However this had the side effect that the active surface would
retain focus when the compositor is locked. This patch just makes it
explicitly set the keyboard focus to NULL on all of the seats when
locking. This will be restored based on the workspace's state when
unlocking.

https://bugs.freedesktop.org/show_bug.cgi?id=73905
2014-04-10 09:40:28 -07:00
Neil Roberts 4237f50e11 Reset focus on unknown seats when restoring focus state
The focus_state list on a workspace only contains entries for seats
which have a keyboard focus on that workspace. For workspaces that
have no surfaces the list will be empty. That means that when a
workspace with no surfaces is switched to it would previously leave
the keyboard focus unaffected and you could still type in the surface
on the old workspace.

This patch makes it instead reset the keyboard focus to NULL for seats
without a focus_state. It does this by temporarily stealing the
compositor's list of seats while it iterates the focus_states. After
all of the focus states have been processed any seats remaining in
this temporary list have their focus reset.

https://bugs.freedesktop.org/show_bug.cgi?id=73905
2014-04-10 09:32:09 -07:00
Ander Conselvan de Oliveira e5a1aee694 shell: Allow unresponsive surfaces to be moved again
Commit c85f1d45 caused the move of an unresponsive surface to be no
longer possible, since the grabbed flag would prevent the move grab
to start while the busy grab was still active.
2014-04-09 10:44:32 -07:00
Kristian Høgsberg f0ce581b92 desktop-shell: Activate surface on right click too
This raises the surface to the top on right click as well, which fixes
pop stacking.

https://bugs.freedesktop.org/show_bug.cgi?id=74831
2014-04-07 11:52:17 -07:00
Bryan Cain a46b946cb3 shell: Fix segfault from trying to access a destroyed popup shell surface
The shell_destroy_shell_surface function only set the backing resource to
NULL, leaving an unusable surface in the popup_grab list until the surface's
fading animation finished and it could be freed. This caused a segfault if
the shell tried to forcibly break the grab during that time interval due to
the compositor losing the keyboard focus.

https://bugs.freedesktop.org/show_bug.cgi?id=77072
2014-04-06 22:47:26 -07:00
Giulio Camuffo c6ab3d52f5 compositor: let the shells create the screenshooter 2014-04-02 11:39:19 -07:00
Manuel Bachmann 805d2f536a shell: position input panel layer above fullscreen layer
When a client calls the input panel (weston-keyboard e.g.)
and then goes fullscreen, the panel will not be hidden
anymore.

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
2014-04-02 10:35:26 -07:00
Manuel Bachmann c1ae2e817e compositor: use Mod-Tab to show/raise minimized surfaces
Temporarily show minimized surfaces when switching between
surfaces with the keyboard. If the final selected one was
minimized, it will be restored.

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
2014-04-02 10:27:27 -07:00
Manuel Bachmann 50c87dbd95 compositor: implement xdg_surface_set_minimized()
We now handle the client-side xdg_surface_set_minimized()
call, and eventually hide the target surface by moving it
to a dedicated layer.

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
2014-04-02 10:27:13 -07:00
Pekka Paalanen 952b6c8004 compositor: reorganize struct weston_buffer_viewport
Queueing in the Presentation extension requires splitting the viewport
state into buffer state and surface state. To conveniently allow
assigning only one, the other, or both, reorganize the
weston_buffer_viewport structure.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-04-01 16:46:40 -07:00
Jasper St. Pierre fe9671e30e shell: Correct error message when we already have an xdg surface
It was referencing get_shell_surface, which is absolutely wrong.
2014-03-25 10:59:20 -07:00
Kristian Høgsberg b033c5e1d0 shell: Only animate window closing for mapped windows
https://bugs.freedesktop.org/show_bug.cgi?id=76415
2014-03-20 14:49:07 -07:00
Kristian Høgsberg 160fe75b32 shell: Animate window closing
This provides an example of keeping a weston_surface alive after the client
destroys it.  We install a destroy listener for the resource, so that we'll
be notifified when the client destroys it.  Then we increase the weston_surface
refcount so that we keep the surface and initiate an animation.  When
the animation finishes we can finally destroy the surface.
2014-03-19 16:51:53 -07:00
Kristian Høgsberg c7680b09dd xdg-shell: Bump unstable version to 3 2014-02-19 10:14:46 -08:00
Kristian Høgsberg 283bf373a1 shell: Consolidate state changes into xdg_surface_change_state
This makes xdg_surface_change state the canonical place for changing
surface state and moves much of the duplicated code into one place.
2014-02-19 09:50:40 -08:00
Jasper St. Pierre 8c6aa45f97 xdg-shell: Replace the set_* atrocity with a new approach
Rather than require that the client implement two methods for every state,
simply have one global request, change_state, and one global event,
request_change_state.
2014-02-19 09:50:40 -08:00
Jasper St. Pierre b223a72147 xdg-shell: Rename focused_set / focused_unset to activated / deactivated
To try and make the distinction between this event and keyboard focus.
2014-02-18 16:39:01 -08:00
Jasper St. Pierre 63a9c336f3 Reorder the xdg_shell implementations to fit the spec'd order 2014-02-18 19:20:17 -05:00
Emilio Pozuelo Monfort a75920190e exposay: avoid needlessly activating the active view
Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2014-02-18 14:07:08 -08:00
Emilio Pozuelo Monfort f942b73a1c exposay: don't crash if a view goes away
When a view was destroyed while we were on exposay, we didn't
remove it from the list of views, and so when leaving exposay
we were trying to animate (and sometimes activate) a
non-existent view, causing a crash.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
2014-02-18 14:04:39 -08:00
Emilio Pozuelo Monfort 3b6e68e2c1 exposay: arrange views per-output
https://bugs.freedesktop.org/show_bug.cgi?id=73173
2014-02-18 14:04:24 -08:00
Kristian Høgsberg dd62abafa1 shell: Use the per-client responsiveness tracking for wl_shell as well 2014-02-12 21:29:11 -08:00
Kristian Høgsberg e11ef64534 compositor: Drop core ping_handler callout
This was always a little iffy.  At least it could have been a signal,
but we now have focus signal, so lets just use that.  We lose
the ability to detect unresponsive clients at key event time, but we
could add that back by adding a key_signal.
2014-02-11 16:35:22 -08:00
Kristian Høgsberg 239902b323 client: Fix shell unstable version check
Use a static assert to catch mismatch between implementation and
interface version.  Fix window.c to not use XDG_SHELL_VERSION_CURRENT,
which will fail to catch version mismatches.  The implementation version
must updated manually when the implementation is updated to use the new
interface.
2014-02-11 16:22:10 -08:00
Kristian Høgsberg 2bff94e057 xdg-shell: Move "ping" and "pong" to xdg_shell, not xdg_surface
Responsivenes is a per-client thing so we move the ping/pong functionality
to xdg_shell.  Having this per-window was carries over from the EWMH
protocol, where the WM has no other way to do this.  In wayland, the
compositor can directly ping the client that owns the surface.
2014-02-11 16:22:10 -08:00
Jasper St. Pierre 7407345446 xdg-shell: Add set_margin request
This is used to figure out the size of "invisible" decorations, which we'll
use to better know the visible extents of the surface, which we can use for
constraining, titlebars, and more.
2014-02-06 13:05:03 -08:00