Add XWayland support

With Cage becoming more popular since its mention on Phoronix and
therefore getting more use-cases than just my own project, add XWayland
support. The refactoring of 2cf40f7 makes this much easier. Note that
this is a no-cost addition for those of us not using XWayland as it is a
compile-time option that needs to be explicitly enabled by adding
`-Dxwayland=true` to your meson command.
This commit is contained in:
Jente Hidskes 2018-12-31 17:24:21 +01:00
parent 48f8f69556
commit a34c726a1c
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
10 changed files with 213 additions and 3 deletions

22
seat.c
View file

@ -6,6 +6,8 @@
* See the LICENSE file accompanying this file.
*/
#include "config.h"
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/backend.h>
@ -14,15 +16,15 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
#if CAGE_HAS_XWAYLAND
#include <wlr/xwayland.h>
#endif
#include "output.h"
#include "seat.h"
#include "server.h"
#include "view.h"
#define DEFAULT_XCURSOR "left_ptr"
#define XCURSOR_SIZE 24
static inline bool
have_dialogs_open(struct cg_server *server)
{
@ -52,6 +54,13 @@ view_at(struct cg_view *view, double lx, double ly,
view_sx, view_sy,
&_sx, &_sy);
break;
#ifdef CAGE_HAS_XWAYLAND
case CAGE_XWAYLAND_VIEW:
_surface = wlr_surface_surface_at(view->wlr_surface,
view_sx, view_sy,
&_sx, &_sy);
break;
#endif
default:
wlr_log(WLR_ERROR, "Unrecognized view type: %d", view->type);
}
@ -501,6 +510,13 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view)
return;
}
#if CAGE_HAS_XWAYLAND
if (view->type == CAGE_XWAYLAND_VIEW &&
!wlr_xwayland_or_surface_wants_focus(view->xwayland_surface)) {
return;
}
#endif
if (prev_view) {
view_activate(prev_view, false);
}