Add focus to my single window
This commit is contained in:
parent
bad5007670
commit
9d64ca0124
5 changed files with 92 additions and 16 deletions
28
src/Seat.zig
28
src/Seat.zig
|
|
@ -8,12 +8,15 @@ context: *Context,
|
|||
|
||||
seat_v1: *river.SeatV1,
|
||||
|
||||
hovered: ?*Window,
|
||||
|
||||
link: wl.list.Link,
|
||||
|
||||
pub fn init(seat: *Seat, context: *Context, river_seat_v1: *river.SeatV1) void {
|
||||
seat.* = .{
|
||||
.context = context,
|
||||
.seat_v1 = river_seat_v1,
|
||||
.hovered = null,
|
||||
.link = undefined, // Handled by the wl.list
|
||||
};
|
||||
|
||||
|
|
@ -23,8 +26,17 @@ pub fn init(seat: *Seat, context: *Context, river_seat_v1: *river.SeatV1) void {
|
|||
fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: *Seat) void {
|
||||
assert(seat.seat_v1 == river_seat_v1);
|
||||
switch (event) {
|
||||
.wl_seat => |ev| {
|
||||
log.debug("initializing new river_ouput_v1 corresponding to wl_seat: {d}", .{ev.name});
|
||||
.removed => {
|
||||
river_seat_v1.destroy();
|
||||
seat.context.allocator.destroy(seat);
|
||||
},
|
||||
.wl_seat => {
|
||||
// log.debug("initializing new river_seat_v1 corresponding to wl_seat: {d}", .{ev.name});
|
||||
},
|
||||
.pointer_enter => |ev| {
|
||||
const window_v1 = ev.window orelse return;
|
||||
const window: *Window = @ptrCast(@alignCast(window_v1.getUserData()));
|
||||
seat.hovered = window;
|
||||
},
|
||||
else => |ev| {
|
||||
log.debug("unhandled event: {s}", .{@tagName(ev)});
|
||||
|
|
@ -32,6 +44,17 @@ fn seatListener(river_seat_v1: *river.SeatV1, event: river.SeatV1.Event, seat: *
|
|||
}
|
||||
}
|
||||
|
||||
pub fn manage(seat: *Seat) void {
|
||||
if (seat.hovered) |window| {
|
||||
seat.seat_v1.focusWindow(window.window_v1);
|
||||
seat.hovered = null;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(seat: *Seat) void {
|
||||
_ = seat;
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
|
||||
|
|
@ -40,5 +63,6 @@ const wl = wayland.client.wl;
|
|||
const river = wayland.client.river;
|
||||
|
||||
const Context = @import("main.zig").Context;
|
||||
const Window = @import("Window.zig");
|
||||
|
||||
const log = std.log.scoped(.Seat);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue