Some X clients create popup or tooltips windows as top level, without
setting them as override redirect or as transient. Since we don't want
to take the focus away from a surface when one of its popup is opened,
check the _NET_WM_WINDOW_TYPE of the X surfaces being mapped and set
them as inactive if it is one of some types.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
To produce the bug, build and run: (you don't need the game data to test)
https://github.com/clintbellanger/flare-engine/
$ mv ~/.config/flare ~/.config/flare.bak
$ ./flare # click 'configure', set full screen mode then click 'ok'
# weston will crash and dump core.
[Pekka: edited the commit message]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
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>
This function is used and clearly designed only for drawing the shadows.
Rename it so that it has name after what it does and also move some
common code into the function.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
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>
We shouldn't do WM-y things on an O-R window, including setting input
focus to it.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=81273
Signed-off-by: Boyan Ding <stu_dby@126.com>
Tested-by: Ryo Munakata <ryomnktml@gmail.com>
Acked-by: Christopher Michael <cp.michael@samsung.com>
XCB and wayland input event handling exists together in xwm, which can
cause problems. weston_wm_handle_button is called via XCB events, while
it calls weston_wm_pick_seat_for_window, which uses info from compositor
(pure wayland). It is also true in setting and removing flags of frames.
Races can happen in between, when resize of moving flag of the frame is
still set while the button has been released, the picked seat will be
NULL in weston_wm_handle_button, causing crash. We can safely ignore
moving or resizing if this happens. The same applies to c06a180d.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=82827
Signed-off-by: Boyan Ding <stu_dby@126.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
When we moved the configure event size to being based on the window
geometry, we changed the coordinates of the configure request to being
frame geometry based. Frame geometry includes titlebar and border, but
not shadow margins.
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The seat picked in weston_wm_window_handle_moveresize can sometimes
be NULL when it is (somehow) triggered with all buttons released.
This patch checks whether the seat is NULL to avoid NULL dereference.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=80837
Signed-off-by: Boyan Ding <stu_dby@126.com>
If X windows are created and destroyed very fast sometimes the WM window
object gets created and destroyed before we get around to handling client
messages. Failing to check that the window is still valid can result in a
segfault.
When Xwayland requests that a wl_surface be created and the X event is
handled before the wayland requests, a surface ID is stored to
window->surface_id and the window is added to the unpaired window list. When
weston_wm_create_surface is called, the window is removed from the list and
window->surface_id is set to zero. If window->surface_id is not zero when
weston_wm_window_destroy is called, the window is assumed to be in the
unpaired window list and wl_list_remove is called. If
weston_wm_window_handle_surface_id is called and the surface has already
been created, the window is not added to the unpaired window list, but
window->surface_id isn't set to zero. When the window is destroyed, removing
the window from the list is attempted anyway and a crash occurs.
This patch stores the surface ID in a temporary variable and only assigns it
to window->surface_id when the window is added to the unpaired window list.
Otherwise window->surface_id is set to zero to maintain its use as a flag
variable.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=80273
Signed-off-by: Tyler Veness <calcmogul@gmail.com>
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.
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.
Make sure we're looking at the right location. The frame could have
received a motion event from a pointer from a different wl_seat, but
under X it looks like our core pointer moved. Move the frame pointer
to the button press location before deciding what to do.
If we're going to move or resize an xwayland surface, we used to just
pick the first seat in the list for doing the move/resize. Ideally we
can map from the XInput device doing the click to the corresponding
weston_seat, but that requires using xcb xinput, which isn't well supported.
Instead, lets use a simple heuristic that just picks the pointer that
most recently delivered a button event to the window in question.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=73807
Set up X windows that are transient for another window as transient
surfaces in shell.c. This keeps the transient windows on top of their
parent as windows are raised, lowered for fullscreened.
https://bugs.freedesktop.org/show_bug.cgi?id=69443
This fixes crashes caused by popup windows that don't have override_redirect
(e.g., menus in VLC and KDE apps).
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Fixes a crash caused by accessing a deleted view in weston_wm_window_schedule_repaint. It can be easily reproduced by switching between menus in Firefox.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
The logic here broke at some point so that we would only update the
input region for non-fullscreen windows. Thus, a fullscreen window would
be stuck with whatever size the most recent non-fullscreen size was.
https://bugs.freedesktop.org/show_bug.cgi?id=69219
The weston_surface structure is split into two structures:
* The weston_surface structure storres everything required for a
client-side or server-side surface. This includes buffers; callbacks;
backend private data; input, damage, and opaque regions; and a few other
bookkeeping bits.
* The weston_view structure represents an entity in the scenegraph and
storres all of the geometry information. This includes clip region,
alpha, position, and the transformation list as well as all of the
temporary information derived from the geometry state. Because a view,
and not a surface, is a scenegraph element, the view is what is placed
in layers and planes.
There are a few things worth noting about the surface/view split:
1. This is *not* a modification to the protocol. It is, instead, a
modification to Weston's internal scenegraph to allow a single surface
to exist in multiple places at a time. Clients are completely unaware
of how many views to a particular surface exist.
2. A view is considered a direct child of a surface and is destroyed when
the surface is destroyed. Because of this, the view.surface pointer is
always valid and non-null.
3. The compositor's surface_list is replaced with a view_list. Due to
subsurfaces, building the view list is a little more complicated than
it used to be and involves building a tree of views on the fly whenever
subsurfaces are used. However, this means that backends can remain
completely subsurface-agnostic.
4. Surfaces and views both keep track of which outputs they are on.
5. The weston_surface structure now has width and height fields. These
are populated when a new buffer is attached before surface.configure
is called. This is because there are many surface-based operations
that really require the width and height and digging through the views
didn't work well.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
We get the child position but never use this information here. Just remove it.
Spotted by Christopher Michael.
Signed-off-by: Stefan Schmidt <s.schmidt@samsung.com>
the unmap event will be followed by the deletion of the weston_surface,
so the shell_surface will also be deleted by the shell. Having removed
the surface_destroy_listener, the surface_destroy callback doesn't
get called, so reset the value of shsurf here.
We used to destroy the frame window and reparent the client window to
wm_window. That means that we lose the destroy_notify event when the
client window is destroyed later, since we don't select for
substructure_notify on wm_window.
Instead of destroying and reparenting, just unmap the frame window.
window->x/y is the coordinate of the top-level surface (whether that's
the frame window or an override-redirect window) and the wayland surface
should be placed there, without the t->margin offset.
The coordinate transformation was broken (worked for first output where
output->x/y was 0,0, broke on all other outputs). We can just use
surface->geometry.x/y directly. We can't use the full transformation,
the best we can do is to move the X window to the geometry.x/y location.
Get rid of the static old_sx/sy hack as well.
We only get configure notify for toplevel (frame or override-redirect window)
and those are the cases where we want to update window->x/y. The way the
code worked, we'd exit immeidately in those cases and window->x/y would
not be updated.