mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
abstract away getting a surface from a FocusData and remove popups as...
they aren't ever getting full focus
This commit is contained in:
parent
2e27a5807a
commit
ff196693cd
1 changed files with 12 additions and 16 deletions
28
src/Seat.zig
28
src/Seat.zig
|
|
@ -15,8 +15,14 @@ const server = &@import("main.zig").server;
|
||||||
|
|
||||||
pub const FocusData = union(enum) {
|
pub const FocusData = union(enum) {
|
||||||
view: *View,
|
view: *View,
|
||||||
popup: *Popup,
|
layer_surface: *LayerSurface,
|
||||||
layer_surface: *LayerSurface
|
|
||||||
|
pub fn getSurface(self: FocusData) *wlr.Surface {
|
||||||
|
return switch (self) {
|
||||||
|
.view => |*v| v.*.xdg_toplevel.base.surface,
|
||||||
|
.layer_surface => |*ls| ls.*.wlr_layer_surface.surface,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
wlr_seat: *wlr.Seat,
|
wlr_seat: *wlr.Seat,
|
||||||
|
|
@ -77,11 +83,7 @@ pub fn deinit(self: *Seat) void {
|
||||||
pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
||||||
const surface: ?*wlr.Surface = blk: {
|
const surface: ?*wlr.Surface = blk: {
|
||||||
if (to_focus != null) {
|
if (to_focus != null) {
|
||||||
break :blk switch (to_focus.?) {
|
break :blk to_focus.?.getSurface();
|
||||||
.view => to_focus.?.view.xdg_toplevel.base.surface,
|
|
||||||
.layer_surface => to_focus.?.layer_surface.wlr_layer_surface.surface,
|
|
||||||
.popup => to_focus.?.popup.xdg_popup.base.surface
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
break :blk null;
|
break :blk null;
|
||||||
}
|
}
|
||||||
|
|
@ -93,11 +95,7 @@ pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
||||||
// - current is fullscreen and to focus is content
|
// - current is fullscreen and to focus is content
|
||||||
// - current is fullscreen and layer is bottom or background
|
// - current is fullscreen and layer is bottom or background
|
||||||
if (self.focused_surface) |current_focus| {
|
if (self.focused_surface) |current_focus| {
|
||||||
const current_surface = switch(current_focus) {
|
const current_surface = current_focus.getSurface();
|
||||||
.view => current_focus.view.xdg_toplevel.base.surface,
|
|
||||||
.layer_surface => current_focus.layer_surface.wlr_layer_surface.surface,
|
|
||||||
.popup => current_focus.popup.xdg_popup.base.surface
|
|
||||||
};
|
|
||||||
if (current_surface == surface) return; // Same surface
|
if (current_surface == surface) return; // Same surface
|
||||||
|
|
||||||
if(to_focus != null) {
|
if(to_focus != null) {
|
||||||
|
|
@ -114,12 +112,10 @@ pub fn focusSurface(self: *Seat, to_focus: ?FocusData) void {
|
||||||
},
|
},
|
||||||
.view => |*view| {
|
.view => |*view| {
|
||||||
if(!view.*.fullscreen) return;
|
if(!view.*.fullscreen) return;
|
||||||
},
|
}
|
||||||
else => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
else => {}
|
|
||||||
}
|
}
|
||||||
} else if(current_focus == .view and current_focus.view.fullscreen){
|
} else if(current_focus == .view and current_focus.view.fullscreen){
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue