The props array contained offsets to struct members. It is convenient
for writing static const arrays as you only store a constant offset and
compute the pointer later. However, the array was not static to begin
with, the atoms are not build time constants. We can as well just store
the pointer directly in the array.
Entries that did not use the offset had bogus offsets, producing
pointers to arbitrary fields. They are changed to have a NULL pointer.
If the code unintentionally used the pointer, it will now explode rather
than corrupt memory.
Also explain the use of the #defined constants and #undef them when they
get out of scope. This clearly documents that they are just a convenient
hack to avoid lots of special cases in the function.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
The legacy fullscreen state needs to be detected at MapRequest time,
because that is when the X11 client has alredy set up the initial window
state.
Doing it at xserver_map_shell_surface() meant that it would be done as a
response to Xwayland creating the wl_surface and XWM receiving the
WL_SURFACE_ID ClientMessage, whichever came later. At that point the X11
client might still be setting things up in theory, though in practice
most of the X11 communication has already happened when
xserver_map_shell_surface() gets called.
The real reason for this is to clean up xserver_map_shell_surface() from
everything that would affect drawing the decorations. This patch is one
part of that clean-up.
The weston_output_weak_ref logic is not put into compositor.h, because
there are no other users for it at this time. We need to protect against
the output going away.
A side-effect of this patch is that saved_width and saved_height will
now get overwritten also for legacy fullscreen windows. Previously, they
were left to zero as far as I could tell.
NOTE: This stops override-redirect legacy fullscreen windows from being
detected as fullscreen. MapRequest processing does not happen for OR
windows. These windows get detected as type XWAYLAND instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Add WM debug prints on map, decoration drawing and geometry setting.
These help see the sequence and timing of operations, when debugging
Xwayland window management glitches.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Helps debugging initial placement problems.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Helps debugging X11 window positioning issues.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Just to keep it hidden so far... A lot of the plumbing necessary to
handle x11->wayland drag and drop is missing, and the current
partial handling gets in the middle for X11 drag-and-drop itself
to work.
The approach is well directed, but needs some further work, till
then, just keep our fake drag-and-drop target hidden. This allows
drag-and-drop to work between X11 clients in Xwayland, and avoids
a crash with (currently unhandled) wl_resource-less data sources.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=94218
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
The X11 lock file was somewhat opaque. Into a sized array of 16
characters, we previously read 11 bytes. 61beda653b fixed the parsing of
this input to ensure that we only considered the first 10 bytes: this
has the effect of culling a LF byte at the end of the string.
This commit more explicitly NULLs the entire string before reading, and
trims trailing LF characters only.
It also adds some documentation by way of resizing pid, an explicit size
check on snprintf's return, and comments.
Verified manually that it emits lock files with a trailing \n, as Xorg
does. Also verified manually that it ignores misformatted lock files,
but accepts either \n or \0 in the trailing position.
Related Mutter issue: https://bugzilla.gnome.org/show_bug.cgi?id=774613
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Starting an xterm with no input device led to a crash
because weston_wm_pick_seat() was returning garbage and
weston_wm_selection_init() was trying to use the garbage.
Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Patch 139fcabe7c "xwayland: Improve error
checking for strtol call" caused a regression in the X11 unix socket
lock file parsing. Before that patch, only the first 10 characters were
considered for parsing. After the patch, the newline as the 11th
character caused strtol() to stop parsing at the 10th character which
was then considered an error as not the whole input was consumed.
The effect of the regression was that no X11 lock files were ever deemed
stale, hence stale lock files were never removed. Up till now, I have
accumulated 37 lock files, and Weston complaining for each of them on
every start it cannot parse them.
Fix this by terminating the string at the expected newline character.
Also, it looks like 'pid' was being used uninitialized, risking strtol()
reading past the end of the array. This patch fixes that too.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
compositor.h already helpfully defines WL_HIDE_DEPRECATED for us, so we
don't get warnings about wl_buffer (in particular) being deprecated when
we have wayland-server headers defining it as deprecated, and then
wayland-client headers using the type.
Move it to be before all our other includes, so we actually make use of
it.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
This silences two warnings:
clients/window.c:2450:20: warning: implicit conversion from enumeration
type 'enum wl_pointer_button_state' to different enumeration type 'enum
frame_button_state' [-Wenum-conversion]
button, state);
^~~~~
clients/window.c:2453:15: warning: implicit conversion from enumeration
type 'enum wl_pointer_button_state' to different enumeration type 'enum
frame_button_state' [-Wenum-conversion]
button, state);
^~~~~
Warning produced by Clang 3.8.
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
This updates the error checking for the strtol() call in xwayland's
create_lockfile to match other cases. C.f. cbc05378 and other recent
patches.
A notable difference here is that the existing error checking was
verifying that exactly 10 digits were being read from the lock file,
but the fact that it's 10 digits is just an implementation detail for
how we're writing it. The pid could be a shorter number of digits, and
would just be space-padded on the left.
This change allows the file to contain any number of digits, but it
can't be blank, all of the digits must be numeric, and the resulting
number must be within the accepted range.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.
This change is an expansion of f6051cbab8
to cover the remaining strtol() calls in Weston, where the routine is
being used to read fds and pids - which are always expressed in base-10.
It also changes the calls in config-parser, used by
weston_config_section_get_int(), which in turn is being used to read
scales, sizes, times, rates, and delays; these are all expressed in
base-10 numbers only.
The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line. Also, by making the code
consistent with other usages of strtol, it may make it possible to
factor out the common code in the future.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This patch follows a similar approach taken to detach the backends from
weston. But instead of passing a configuration struct when loading the
plugin, we use the plugin API registry to register an API, and to get it
in the compositor side. This API allows to spawn the Xwayland process
in the compositor side, and to deal with signal handling. A new
function is added in compositor.c to load and init the xwayland.so
plugin.
Also make sure to re-arm the SIGUSR1 when the X server quits.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
[Pekka: moved xwayland/weston-xwayland.c -> compositor/xwayland.c]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This is the start of separating weston-the-compositor source files from
libweston source files.
This is moving all the files related to the 'weston' binary. Also the
CMS and systemd plugins are moved.
xwayland plugin is not moved, because it will be turned into a
libweston feature.
To avoid breaking the build, #includes for weston.h are fixed to use
compositor/weston.h. This serves as a reminder that such files may need
further attention: moving to the right directory, or maybe using the
proper -I flags instead.
v2: Move also screen-share.c, and add a note about weston-launch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
The config can now be retrieved with a new function defined in weston.h,
wet_get_config(weston_compositor*).
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
They belong in the compositor rather than libweston since they
set signals handlers, and a library should not do that behind its
user's back. Besides, they were using functions in main.c already
so they were not usable by other compositors.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
weston maintains a copy of the most recently selected "thing" - it picks
the first available type when it copies, and saves that one only.
When an application quits weston will make the saved selection active.
When xwm sees the selection set it will check if any of the offered types
are text. If no text type is offered it will clear the selection.
weston then interprets this in the same way as an application exiting and
causing the selection to be unset, and we get caught in a live lock with
both weston and xwayland consuming as much cpu as they can.
The simple fix is to just remove the test for text presence.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
The wrapped weston_data_source struct has new fields which were left
uninitialized, so its access is unreliable.
The data source in xwayland/dnd.c should be eventually setting the
drag-and-drop actions, but it is a lot more incomplete than that
(read: completely), so falls out of the scope of this patch.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
The xwm used to automatically send to Xwayland the position of X windows
when that changed, using the x,y of the primary view of the surface.
This works fine for the desktop shell but less so for others.
This patch adds a 'send_position' vfunc to the weston_shell_client that
the shell will call when it wants to let Xwayland know what the position
of a window is.
The logic used by the desktop-shell for that is exactly the same the xwm
used to have.
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
Patch updated to remove dead lines as suggested by Daniel Stone
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
The xwm gets a primary view for a X window using the get_primary_view
vfunc of the shell_interface struct. Storing it is dangerous though
because it doesn't listen for its destruction so it may end up using the
old stored view pointer after that view was freed, or after the primary
view for that window was changed to another one.
Fetch the primary view just before using it every time and try to not
abuse this 'primary view' concept which may map badly to some shells:
iterate over all the views instead when it makes sense.
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
xwayland source is checked, so it dispatches twice on any event.
If the other turn has no events to dispatch, we flush the connection
redundantly
v2. do not flood logs with 'unhandled event' messages
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
- opening braces are on the same line as the if statement
- opening braces are not on the same line as the function name
- space between for/while/if and opening parenthesis
Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
When we get a focus in event from an X window which is not the one
we last set as the active window, reset the focus.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
An earlier patch made surface_resize() and surface_move() take pointers
instead of seats, this updates the weston_shell_interface resize and move to
match.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This reverts commit d3553c721c.
weston_wm_write_property() takes the ownership of the reply it gets as
a parameter, and will eventually free it later in writable_callback.
This change introduced a double-free when Xwayland programs triggered a
copy to the clipboard, leading to a Weston crash.
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
dump_property allows reply to be NULL. Calling it unconditionally will
ensure user knows where the selection failed.
Also refactor code a bit.
Suggested by Marek Chalupa
The man pages indicate this routine can return NULL on certain error
conditions.
Suggested by Marek Chalupa
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Removed duplicate definitions of the container_of() macro and
refactored sources to use the single implementation.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Enable all hints by default. This fixes the "Maximize" button in apps that
don't set any hints - e.g., xclock or Firefox. (There's still a problem, though:
"decorate" is sometimes treated as a boolean, sometimes as a bitmask.)
Handle MWM_DECOR_ALL correctly. It looks like it's supposed to invert the values
of the rest of the flags.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-By: Giulio Camuffo <giuliocamuffo@gmail.com>
If windows are created and quickly destroyed it's possible that they'll be
on the unpaired window list at the time of surface creation. The surface
destroy listener for that surface isn't properly freed and a crash happens
some time later.
This patch removes the window from the unpaired list during unmap, so we
should never get to the destroy handler with a surface destroy listener set.
Just in case there's another path to that failure, I've also removed the
surface destroy listener in the destory handler.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Jasper St. Pierre <jstpierre@mecheye.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This lets us verify that all callers are actually testing for a
successful hash lookup at compile time.
All current users of hash_table_lookup are converted to the new
wm_lookup_window() and the appropriate success check is added.
This fixes any call sites that used to assume a successful return
and dereference a NULL pointer.
This closes http://bugs.freedesktop.org/show_bug.cgi?id=83994
The xwayland test has been failing because weston crashes due to
a hash lookup failure and a subsequent dereference of the returned
NULL pointer.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>