1
0
Fork 0
Commit graph

125 commits

Author SHA1 Message Date
Carlos Garnacho
5c9a2c54c4 xwayland: Avoid late errno checks
We do some things when binding to a socket fails (closing the fd,
logging, unlinking files, ...) those might affect errno in some
or other way, so it might no longer be EADDRINUSE even if we later
try to make those non fatal.

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

https://bugzilla.gnome.org/show_bug.cgi?id=769578
2016-08-06 17:14:52 +02:00
Carlos Garnacho
dd549604e2 xwayland: Fix typo
Check the unix_fd, which is the one just created, the abstract_fd
is already checked above.
2016-08-06 16:42:25 +02:00
Jonas Ådahl
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
e84f694668 wayland: Don't scale XWayland pointer cursor sprites
We don't have any way of knowing what the intended size of a XWayland
cursor is supposed to be, so lets do what we do with regular XWayland
surfaces and don't scale them. The result is that cursor sprites of
HiDPI aware X11 clients will show correctly, but non-aware clients may
have tiny cursor sprites.

https://bugzilla.gnome.org/show_bug.cgi?id=755099
2015-10-04 14:17:14 +08:00
Rui Matos
69c267b142 xwayland: Fix windows disappearing on reparenting
If the wayland surface isn't available yet when we process the
WL_SURFACE_ID ClientMessage, we schedule a later function to try the
association again after we get a chance to process wayland requests.

This works fine except on cases where the MetaWindow already had a
previous surface attached (i.e. when the xwindow is reparented) since
we only break the existing association on the later function which
means that when processing the old surface's destruction we destroy
the MetaWindow and cancel the pending later function leaving us
without a MetaWindow and an invisible surface.

Fix this by detaching the old surface as soon as possible so that the
MetaWindow survives.

https://bugzilla.gnome.org/show_bug.cgi?id=743339
2015-09-25 19:09:48 +02:00
Florian Müllner
27b37407d0 Don't duplicate declarations from G_DEFINE_TYPE 2015-09-24 03:01:51 +02:00
Jonas Ådahl
83c17134f1 wayland: GObject:ify surface roles
Make a surface roles into objects with vfuncs for things where there
before was a big switch statement. The declaration and definition
boilerplate is hidden behind C macros.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:24:58 +08:00
Jonas Ådahl
dece49b53d wayland: Introduce XWayland surface role
Being a "XWayland window" should be considered equivalent to a role,
even though it is not part of any protocol anywhere. The commit doesn't
have any functional difference, but just makes it clear that an
wl_surface managed by XWayland have the same type of special casing as
surface roles as defined by the Wayland protocol.

As the semantics are more explicit given the role is defined, a comment
explaining why the semantics need to be how they are was added.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:24:58 +08:00
Carlos Garnacho
4fc1811c15 wayland: Add X11/wayland selection interoperation
This piece of code hooks in both wl_data_device and the relevant X
selection events, an X11 Window is set up so it can act as the clipboard
owner when any wayland client owns the selection, reacting to
SelectionRequest events, and returning the data from the wayland client
FD to any X11 requestor through X properties.

In the opposite direction, SelectionNotify messages are received,
which results in the property contents being converted then written
into the wayland requestor's FD.

This code also takes care of the handling incremental transfers through
the INCR property type, reading/writing data chunk by chunk.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-15 17:43:53 +02:00
Ray Strode
eb56e0a3d7 xwayland: plug some leaks in stop function
This commit makes sure the lockfile and display
name are freed in meta_xwayland_stop.

https://bugzilla.gnome.org/show_bug.cgi?id=748380
2015-04-23 13:51:11 -04:00
Ray Strode
8937c32cd5 xwayland: rename lockfile to lock_file
The missing underscore is inconsistent with the
coding style of the surrounding code.

https://bugzilla.gnome.org/show_bug.cgi?id=748380
2015-04-23 13:51:11 -04:00
Ray Strode
a8a5da768a xwayland: don't unlink lock file twice in stop function
The stop function currently manually constructs the lock
filename from the display number and also calls unlink
on the same, already known lock filename from the manager
struct.

This commit gets rid fo the manual construction in favor
of the saved lock filename.

https://bugzilla.gnome.org/show_bug.cgi?id=748380
2015-04-23 13:51:11 -04:00
Ray Strode
33bfcf56ce xwayland: free lockfile in start function on error
Right now we just leak the lockfile.

https://bugzilla.gnome.org/show_bug.cgi?id=748380
2015-04-23 13:51:11 -04:00
Ray Strode
40cccb58a5 xwayland: use out label for cleanup in start function
The start function has a few exit paths that need to
perform clean up of the lock file.

This commit consolidates those exit paths at the end
using an out label and gotos.

https://bugzilla.gnome.org/show_bug.cgi?id=748380
2015-04-23 13:51:11 -04:00
Ray Strode
a5d1f67c34 wayland: try 50 times to create lock file again for login screen
since commit 8c16ac47c1, we started
creating the login screen on display 1024 instead of display 0.

This defeats this logic in try_display:

    display++;
    /* If display is above 50, then something's wrong. Just
     * abort in this case. */
    if (display > 50)

In practice it doesn't matter much since we only have one login
screen in most setups, but we should still fix the bug.

This commit introduces a separate counter to keep try of 50 tries,
rather than assuming "display number == number of tries".

https://bugzilla.gnome.org/show_bug.cgi?id=746545
2015-04-01 10:30:24 -04:00
Jasper St. Pierre
102fa0e373 xwayland: Don't leak the launcher 2015-03-31 11:47:34 -07:00
Jasper St. Pierre
d4e8d97e58 xwayland: Port to GSubprocess 2015-03-27 13:58:56 -07:00
Jasper St. Pierre
a86368dcb1 xwayland: Prevent some boolean confusion
The original code in Weston that this was ported from returned an errno,
not a boolean, so we were inadvertently returning TRUE here during an
error path. Fix that up.
2015-03-27 13:58:56 -07:00
Ray Strode
8c16ac47c1 wayland: don't let the login screen steal :0
In 3.16, GDM keeps a login screen running on vt1.
This login screen starts an Xwayland instance.
Since it's the first X server to start, it gets
the prized :0 display number.

This commit works around that problem, for now,
by having GDM's display number start at 1024.

https://bugzilla.gnome.org/show_bug.cgi?id=746295
2015-03-16 11:08:45 -04:00
Owen W. Taylor
d6624b0a75 Cleanup xwayland/wayland window association from the "unmanage" signal
Windows can be freed at some point after they are unmanaged - because
there is an effect in progress, because a language binding is holding
a reference. Therefore, we need to clean up the later to associate
the xwayland and wayland windows deterministically in an "unamanaged"
handler.

https://bugzilla.gnome.org/show_bug.cgi?id=736694
2014-09-16 10:59:45 -04:00
Owen W. Taylor
9c465a2d5a Do xwayland/wayland window association in a later, not an idle
g_idle_add() makes no guarantee about when it will be run - if Mutter
is busy drawing and blocking glXSwapBuffers() it could happen only
minutes later.  Use meta_later_add (META_LATER_BEFORE_REDRAW) instead -
this will deterministically be run after the Wayland socket is read
from but before the next frame is painted.

https://bugzilla.gnome.org/show_bug.cgi?id=736694
2014-09-16 10:59:45 -04:00
Jasper St. Pierre
9c4908b44a xwayland: Don't crash when the window disappears from under us
If we attach to a MetaWindow that disappears before the idle fires,
we'll notice that we can't associate the window properly again and
try to access data on the MetaWindow struct, which might crash.

Install a weak ref that ties the lifetime of the idle to the lifetime
of the MetaWindow.

It seems every GTK+ app does this for some reason at startup. This
is really unfortunate, since we'll have to create and destroy a new
MetaWindow really quickly.
2014-05-04 15:51:53 -04:00
Jasper St. Pierre
0dd27edb91 xwayland: Remove some unused includes 2014-04-17 16:23:37 -04:00
Jasper St. Pierre
6a44f04b51 xwayland: Stop using UNIX signals for readiness
The latest Xorg / Xwayland has support for -displayfd being used
in conjunction with an explicit display number. Use that to know
when the X server is ready, rather than UNIX signals, because
they're UNIX signals.
2014-04-17 16:23:37 -04:00
Jasper St. Pierre
745134e066 xwayland: Rename sp to something a bit more handy
We also want to create a socketpair for -displayfd instead
of using signals.
2014-04-17 16:23:37 -04:00
Jasper St. Pierre
72b1a2837d xwayland: Clean up display finding code
Split out and make it more manageable.
2014-04-17 16:23:37 -04:00
Jasper St. Pierre
e5ab4f13f1 xwayland: Put the filename in the error message 2014-04-17 16:23:37 -04:00
Jasper St. Pierre
14deeef8a7 xwayland: Use %m instead of explicit strerror 2014-04-17 16:23:37 -04:00
Jasper St. Pierre
62e5faeb0c wayland: Remove the explicit surface commit for Xwayland
It's not needed anymore; we always keep the actor up-to-date.
2014-04-11 23:55:37 -07:00
Bastien Nocera
d53e04f4c8 Name all timeouts and idles
Better names can be used once we make more use of them.

https://bugzilla.gnome.org/show_bug.cgi?id=727979
2014-04-10 18:59:46 +02:00
Rui Matos
feca0fb512 xwayland: Re-sync input focus when associating a surface to a window
When the MetaWindow is created we don't have the surface yet and thus
we can't set input focus to it so we need to try again when we get the
surface.
2014-04-09 11:20:28 +02:00
Jasper St. Pierre
c40868b239 xwayland: Fix rendering
Since we get the ClientMessage after the surface is created, there's
no good way to synchronize the two streams. In this case, what we
need to do is delay the surface commit until after we get the
ClientMessage. Ideally, we'd be using a better surface system overall
where committing the surface didn't depend on what type it is, but
oh well, this is a good short-term hack for now.
2014-04-02 13:24:58 -04:00
Jasper St. Pierre
be02fa1120 xwayland: Switch to the new Xwayland DDX 2014-04-02 13:24:57 -04:00
Jasper St. Pierre
43730f1660 xwayland: Switch to SIGUSR1 to know when the X server has finished init
This is effectively the same, but since we lose the xserver.xml protocol
in the new XWayland DDX, we have to use SIGUSR1 anyway, so might as well
switch over now.
2014-04-02 13:16:10 -04:00
Jasper St. Pierre
4f609dbf5e xwayland: Don't use glib after forking
glib doesn't have any guarantee about working after forking.
We can get away with it, but we're better off just not using it.
2014-04-02 13:04:31 -04:00
Jasper St. Pierre
2a7d12ba14 xwayland: Make failing to exec a fatal error 2014-04-02 13:03:29 -04:00
Jasper St. Pierre
c4c0b5f0ab xwayland: Detect a fail to fork 2014-04-02 13:03:17 -04:00
Jasper St. Pierre
eb5b54dd8b xwayland: Split another part of the initialization sequence out
This will be used from a SIGUSR1 handler.
2014-04-02 11:41:28 -04:00
Jasper St. Pierre
9653b79a35 xwayland: Split a helper out
This will make the next commit, which ports to the new ClientMessage
API, more understandable.
2014-04-02 11:41:28 -04:00
Jasper St. Pierre
e07bd15fc2 xwayland: Make file cosmetically modern
Put a modeline, include "config.h", and shift around the include ordering
2014-04-02 11:41:27 -04:00
Jasper St. Pierre
5cf0740b4e xwayland: Fork the X server ourselves
gspawn just isn't us the fine-grained control we need for starting
processes and leaking file descriptors in.
2014-04-02 11:41:27 -04:00
Jasper St. Pierre
c540ddf59b xwayland: Move display_name into choose_xdisplay 2014-04-02 11:41:27 -04:00
Jasper St. Pierre
a44295599c xwayland: Split out the code that creates the XWayland sockets 2014-04-02 11:41:26 -04:00
Jasper St. Pierre
af272f2685 xwayland: Move global initialization down 2014-04-02 11:41:26 -04:00
Jasper St. Pierre
81d033ec73 xwayland: Use %m instead of manual strerror(errno) 2014-04-02 11:41:26 -04:00
Jasper St. Pierre
3c404c5db3 wayland: Replace make_toplevel / window_unmanaging with set_window
The make_toplevel / window_unmanaging interface has never made
a lot of sense to me. Replace it with set_window, which does
effectively the same thing.

It's still not perfect in the case of XWayland, but I don't think
XWayland will ever make me happy.
2014-04-02 11:41:07 -04:00
Jasper St. Pierre
97ea4e8717 xwayland: Remove some stray logs
These really aren't too helpful.
2014-03-26 12:04:14 -04:00
Jasper St. Pierre
d699b2409a xwayland: Shut up conditionally 2014-03-25 12:54:13 -04:00
Jasper St. Pierre
456e3e2429 xwayland: Punt stdout / stderr to /dev/null
This should really go to the journal, but I'm tired of seeing Xorg
log a bunch of garbage that I don't care about when debugging mutter.
2014-03-25 12:00:38 -04:00
Rui Matos
7484d540cd wayland: Use an array initializer for the X server arguments
This fixes the unitialized array members introduced previously and
should avoid such mistakes again going forward.

https://bugzilla.gnome.org/show_bug.cgi?id=727011
2014-03-25 14:52:57 +01:00
Ray Strode
a55622d924 wayland: drop -logfile argument
It breaks testing wayland with setuid X server.
2014-03-24 14:18:49 -04:00
Jasper St. Pierre
9df8e831be xwayland: Make sure to clear an existing surface if we have one
This fixes an assert fail when redecorating an X11 client.
2014-03-11 10:24:13 -04:00
Giovanni Campagna
45624f2edf MetaWindowActor: survive having no MetaSurfaceActor
We need a MetaWaylandSurface to build a MetaSurfaceActor, but
we don't have one until we get the set_window_xid() call from
XWayland. On the other hand, plugins expect to see the window
actor right from when the window is created, so we need this
empty state.

Based on a patch by Jasper St. Pierre.
2014-02-25 01:22:56 +01:00
Jasper St. Pierre
f0cd9b0687 wayland-surface: Rework construction / destruction yet again
This time, to make way for MetaSurfaceActorEmpty. This also fixes
destroy effects as a side effect. It still has issues if we try
to re-assign an actor that's already toplevel (e.g. somebody
re-popping up a menu that's already being destroyed), but this
will be fixed soon.

The idea here is that MetaWindowActor will do the unparenting of
the surface actor when it itself is destroyed. To prevent bad issues
with picking, we only make the surface actor reactive when it's
toplevel.
2014-02-24 14:46:19 -05:00
Jasper St. Pierre
1783bf20ec Revert "window: Delay the showing of XWayland clients until set_window_id"
This reverts commit 59c8b949ad.
2014-02-24 14:46:19 -05:00
Jasper St. Pierre
f9f2a82e18 xwayland: Don't -retro
This means we see black instead of checkerboard for now when resizing,
but that's better.
2014-02-17 17:57:40 -05:00
Jasper St. Pierre
d694260ad2 xwayland: Fix xwayland
Don't give us a freed pointer here.
2014-02-07 19:28:05 -05:00
Jasper St. Pierre
8566566451 xwayland: Split out the XWayland stuff into its own private struct 2014-02-07 16:21:27 -05:00
Jasper St. Pierre
59c8b949ad window: Delay the showing of XWayland clients until set_window_id
Use our new "surface_mapped" field to delay the showing of XWayland clients
until we have associated together the window's XID and the Wayland surface ID.

This ensures that when we show this window to the compositor, it will properly
use the Wayland surface for rendering, rather than trying to use COMPOSITE and
crash.

https://bugzilla.gnome.org/show_bug.cgi?id=720631
2014-02-01 19:18:01 -05:00
Jasper St. Pierre
1a62ac9276 xwayland: Shuffle some code around 2014-01-31 11:24:02 -05:00
Jasper St. Pierre
9c876722a0 xwayland: Use server protocol wrappers instead of wl_resource_post_event 2014-01-29 10:27:16 -05:00
Jasper St. Pierre
96fc93d744 xwayland: Reindent 2014-01-29 10:23:58 -05:00
Jasper St. Pierre
20545941fa Revert unintentional merge from wip/surface-content to wayland
This reverts a lot of commits.
2014-01-22 09:18:13 -05:00
Jasper St. Pierre
ac32b9ef95 get xwayland working again 2014-01-21 19:06:06 -05:00
Jasper St. Pierre
fd8cc9b7a8 xwayland: Remove outdated code
Now that focus management goes through the central display.c,
we don't need to do this separately. Wayland and X clients
should just behave as one.
2013-12-09 13:57:32 -05:00
Rui Matos
8a3501ffe1 xwayland: Fix a couple of small leaks
https://bugzilla.gnome.org/show_bug.cgi?id=712833
2013-11-21 19:22:26 +01:00
Jasper St. Pierre
a02d734243 window-actor: Move all buffer management and damage correction here
We want ShapedTexture to be a dumb actor that knows how to
pick/paint fairly easily, without any "platform knowledge", so to say...
2013-11-18 21:19:00 -05:00
Giovanni Campagna
a7eaf43e18 wayland: implement resizing and maximization for wayland clients
To properly resize clients, we need to send them configure events
with the size we computed from the constraint system, and
then check if the new size they ask is compatible with
our expectation.

Note that this does not handle interactive resizing yet, it
merely makes the API calls work for wayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=707401
2013-09-16 14:46:34 +02:00
Giovanni Campagna
b5f3238f6f Stop messing with process groups
We can be launched by gnome-session now, which implies gdb must be
attached from outside, and the Ctrl-C problem is gone.

https://bugzilla.gnome.org/show_bug.cgi?id=706421
2013-09-11 16:01:09 +02:00
Giovanni Campagna
168ea64a45 wayland: use symbolic constants for interface version
Replace magic numbers scattered around the code with proper
macros collected in one header file.

https://bugzilla.gnome.org/show_bug.cgi?id=707851
2013-09-10 15:55:11 +02:00
Giovanni Campagna
73ee491281 wayland: fix interface versioning
Add MIN(...) with the interface version actually implemented
to all resource constructor, so that we never risk seeing requests
we don't implement (and consequently segfault)

https://bugzilla.gnome.org/show_bug.cgi?id=707851
2013-09-10 15:54:42 +02:00
Giovanni Campagna
0cceddab75 MetaWayland: install an X io error handler
This way can detect X disconnections correctly, crash with a core
dump and reset the tty.

https://bugzilla.gnome.org/show_bug.cgi?id=706962
2013-08-28 17:21:18 +02:00
Giovanni Campagna
18a21b67c2 wayland: move XWayland support code to its own file
Given that xwayland code is already split in meta-xwayland, it
makes sense to have there the implementation of the private
xserver protocol too.

https://bugzilla.gnome.org/show_bug.cgi?id=705816
2013-08-15 17:42:19 +02:00
Giovanni Campagna
3803fd9511 wayland: don't use fork() and SIGCHLD to spawn processes
It is a very bad idea in a glib program (especially one heavily
using glib child watching facilities, like gnome-shell) to handle
SIGCHLD. While we're there, let's also use g_spawn_async, which
solves some malloc-after-fork problems and makes the code generally
cleaner.

https://bugzilla.gnome.org/show_bug.cgi?id=705816
2013-08-15 17:41:34 +02:00
Robert Bragg
f9a11b3b18 wayland: Adds basic hybrid X + Wayland support
This adds support for running mutter as a hybrid X and Wayland
compositor. It runs a headless XWayland server for X applications
that presents wayland surfaces back to mutter which mutter can then
composite.

This aims to not break Mutter's existing support for the traditional X
compositing model which means a single build of Mutter can be
distributed supporting the traditional model and the new Wayland based
compositing model.

TODO: although building with --disable-wayland has at least been tested,
I still haven't actually verified that running as a traditional
compositor isn't broken currently.

Note: At this point no input is supported

Note: multiple authors have contributed to this patch:
Authored-by: Robert Bragg <robert@linux.intel.com>
Authored-by: Neil Roberts <neil@linux.intel.com>
Authored-by: Rico Tzschichholz.
Authored-by: Giovanni Campagna <gcampagna@src.gnome.org>
2013-08-10 19:13:48 -04:00