cursor: handle xwayland views for move/resize
This commit is contained in:
parent
7a244092e5
commit
d6823fe3a0
@ -263,30 +263,26 @@ fn handleButton(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the found surface is an xdg toplevel surface, send keyboard
|
// If the target surface has a view, give that view keyboard focus and
|
||||||
// focus to the view.
|
// perhaps enter move/resize mode.
|
||||||
if (c.wlr_surface_is_xdg_surface(wlr_surface)) {
|
if (View.fromWlrSurface(wlr_surface)) |view| {
|
||||||
const wlr_xdg_surface = c.wlr_xdg_surface_from_wlr_surface(wlr_surface);
|
self.seat.focus(view);
|
||||||
if (wlr_xdg_surface.*.role == .WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
|
||||||
const view = util.voidCast(View, wlr_xdg_surface.*.data.?);
|
|
||||||
self.seat.focus(view);
|
|
||||||
|
|
||||||
if (event.state == .WLR_BUTTON_PRESSED and self.pressed_count == 1) {
|
if (event.state == .WLR_BUTTON_PRESSED and self.pressed_count == 1) {
|
||||||
// If the button is pressed and the pointer modifier is
|
// If the button is pressed and the pointer modifier is
|
||||||
// active, enter cursor mode or close view and return.
|
// active, enter cursor mode or close view and return.
|
||||||
const fullscreen = view.current.fullscreen or view.pending.fullscreen;
|
const fullscreen = view.current.fullscreen or view.pending.fullscreen;
|
||||||
if (self.seat.pointer_modifier) {
|
if (self.seat.pointer_modifier) {
|
||||||
switch (event.button) {
|
switch (event.button) {
|
||||||
c.BTN_LEFT => if (!fullscreen) self.enterCursorMode(event, view, .move),
|
c.BTN_LEFT => if (!fullscreen) self.enterCursorMode(event, view, .move),
|
||||||
c.BTN_MIDDLE => view.close(),
|
c.BTN_MIDDLE => view.close(),
|
||||||
c.BTN_RIGHT => if (!fullscreen) self.enterCursorMode(event, view, .resize),
|
c.BTN_RIGHT => if (!fullscreen) self.enterCursorMode(event, view, .resize),
|
||||||
|
|
||||||
// TODO Some mice have additional buttons. These
|
// TODO Some mice have additional buttons. These
|
||||||
// could also be bound to some useful action.
|
// could also be bound to some useful action.
|
||||||
else => {},
|
else => {},
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,23 @@ pub fn getConstraints(self: Self) Constraints {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Find and return the view corresponding to a given wlr_surface, if any
|
||||||
|
pub fn fromWlrSurface(wlr_surface: *c.wlr_surface) ?*Self {
|
||||||
|
if (c.wlr_surface_is_xdg_surface(wlr_surface)) {
|
||||||
|
const wlr_xdg_surface = c.wlr_xdg_surface_from_wlr_surface(wlr_surface);
|
||||||
|
if (wlr_xdg_surface.*.role == .WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
|
return util.voidCast(Self, wlr_xdg_surface.*.data.?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (build_options.xwayland) {
|
||||||
|
if (c.wlr_surface_is_xwayland_surface(wlr_surface)) {
|
||||||
|
const wlr_xwayland_surface = c.wlr_xwayland_surface_from_wlr_surface(wlr_surface);
|
||||||
|
return util.voidCast(Self, wlr_xwayland_surface.*.data.?);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// Called by the impl when the surface is ready to be displayed
|
/// Called by the impl when the surface is ready to be displayed
|
||||||
pub fn map(self: *Self) void {
|
pub fn map(self: *Self) void {
|
||||||
const root = self.output.root;
|
const root = self.output.root;
|
||||||
|
@ -57,8 +57,10 @@ pub fn init(self: *Self, view: *View, wlr_xwayland_surface: *c.wlr_xwayland_surf
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn needsConfigure(self: Self) bool {
|
pub fn needsConfigure(self: Self) bool {
|
||||||
return self.view.current.box.width != self.view.pending.box.width or
|
return self.wlr_xwayland_surface.x != self.view.pending.box.x or
|
||||||
self.view.current.box.height != self.view.pending.box.height;
|
self.wlr_xwayland_surface.y != self.view.pending.box.y or
|
||||||
|
self.wlr_xwayland_surface.width != self.view.pending.box.width or
|
||||||
|
self.wlr_xwayland_surface.height != self.view.pending.box.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tell the client to take a new size
|
/// Tell the client to take a new size
|
||||||
@ -195,7 +197,12 @@ fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
|||||||
|
|
||||||
// See comment in XwaylandView.configure()
|
// See comment in XwaylandView.configure()
|
||||||
if (view.pending_serial != null) {
|
if (view.pending_serial != null) {
|
||||||
view.output.root.notifyConfigured();
|
// If the view is part of the layout, notify the transaction code. If
|
||||||
|
// the view is floating or fullscreen apply the pending state immediately.
|
||||||
view.pending_serial = null;
|
view.pending_serial = null;
|
||||||
|
if (!view.pending.float and !view.pending.fullscreen)
|
||||||
|
view.output.root.notifyConfigured()
|
||||||
|
else
|
||||||
|
view.current = view.pending;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user