seat: implement kde idle protocol
This commit is contained in:
parent
aabd85b028
commit
7de2edb623
@ -324,12 +324,14 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, _size: ?u32) !void {
|
||||
fn handleAxis(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is forwarded by the cursor when a pointer emits an axis event,
|
||||
// for example when you move the scroll wheel.
|
||||
const cursor = @fieldParentPtr(Self, "listen_axis", listener.?);
|
||||
const self = @fieldParentPtr(Self, "listen_axis", listener.?);
|
||||
const event = util.voidCast(c.wlr_event_pointer_axis, data.?);
|
||||
|
||||
self.seat.handleActivity();
|
||||
|
||||
// Notify the client with pointer focus of the axis event.
|
||||
c.wlr_seat_pointer_notify_axis(
|
||||
cursor.seat.wlr_seat,
|
||||
self.seat.wlr_seat,
|
||||
event.time_msec,
|
||||
event.orientation,
|
||||
event.delta,
|
||||
@ -344,6 +346,8 @@ fn handleButton(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const self = @fieldParentPtr(Self, "listen_button", listener.?);
|
||||
const event = util.voidCast(c.wlr_event_pointer_button, data.?);
|
||||
|
||||
self.seat.handleActivity();
|
||||
|
||||
if (event.state == .WLR_BUTTON_PRESSED) {
|
||||
self.pressed_count += 1;
|
||||
} else {
|
||||
@ -421,6 +425,8 @@ fn handleMotionAbsolute(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C)
|
||||
const self = @fieldParentPtr(Self, "listen_motion_absolute", listener.?);
|
||||
const event = util.voidCast(c.wlr_event_pointer_motion_absolute, data.?);
|
||||
|
||||
self.seat.handleActivity();
|
||||
|
||||
var lx: f64 = undefined;
|
||||
var ly: f64 = undefined;
|
||||
c.wlr_cursor_absolute_to_layout_coords(self.wlr_cursor, event.device, event.x, event.y, &lx, &ly);
|
||||
@ -434,6 +440,8 @@ fn handleMotion(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const self = @fieldParentPtr(Self, "listen_motion", listener.?);
|
||||
const event = util.voidCast(c.wlr_event_pointer_motion, data.?);
|
||||
|
||||
self.seat.handleActivity();
|
||||
|
||||
Mode.processMotion(self, event.device, event.time_msec, event.delta_x, event.delta_y);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ const default_seat_name = "default";
|
||||
|
||||
server: *Server,
|
||||
|
||||
wlr_idle: *c.wlr_idle,
|
||||
wlr_input_inhibit_manager: *c.wlr_input_inhibit_manager,
|
||||
|
||||
seats: std.TailQueue(Seat),
|
||||
@ -46,9 +47,10 @@ listen_new_input: c.wl_listener,
|
||||
pub fn init(self: *Self, server: *Server) !void {
|
||||
self.server = server;
|
||||
|
||||
// This is automatically freed when the display is destroyed
|
||||
self.wlr_input_inhibit_manager =
|
||||
c.wlr_input_inhibit_manager_create(server.wl_display) orelse return error.OutOfMemory;
|
||||
// These are automatically freed when the display is destroyed
|
||||
self.wlr_idle = c.wlr_idle_create(server.wl_display) orelse return error.OutOfMemory;
|
||||
self.wlr_input_inhibit_manager = c.wlr_input_inhibit_manager_create(server.wl_display) orelse
|
||||
return error.OutOfMemory;
|
||||
|
||||
self.seats = std.TailQueue(Seat).init();
|
||||
|
||||
|
@ -71,9 +71,10 @@ fn handleKey(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is raised when a key is pressed or released.
|
||||
const self = @fieldParentPtr(Self, "listen_key", listener.?);
|
||||
const event = util.voidCast(c.wlr_event_keyboard_key, data.?);
|
||||
|
||||
const wlr_keyboard = self.wlr_keyboard;
|
||||
|
||||
self.seat.handleActivity();
|
||||
|
||||
// Translate libinput keycode -> xkbcommon
|
||||
const keycode = event.keycode + 8;
|
||||
|
||||
|
@ -238,6 +238,10 @@ pub fn focusOutput(self: *Self, output: *Output) void {
|
||||
while (it) |node| : (it = node.next) node.data.sendOutput(.focused);
|
||||
}
|
||||
|
||||
pub fn handleActivity(self: Self) void {
|
||||
c.wlr_idle_notify_activity(self.input_manager.wlr_idle, self.wlr_seat);
|
||||
}
|
||||
|
||||
/// Handle the unmapping of a view, removing it from the focus stack and
|
||||
/// setting the focus if needed.
|
||||
pub fn handleViewUnmap(self: *Self, view: *View) void {
|
||||
|
@ -33,6 +33,7 @@ pub usingnamespace @cImport({
|
||||
@cInclude("wlr/types/wlr_cursor.h");
|
||||
@cInclude("wlr/types/wlr_data_control_v1.h");
|
||||
@cInclude("wlr/types/wlr_data_device.h");
|
||||
@cInclude("wlr/types/wlr_idle.h");
|
||||
@cInclude("wlr/types/wlr_input_device.h");
|
||||
@cInclude("wlr/types/wlr_input_inhibitor.h");
|
||||
@cInclude("wlr/types/wlr_keyboard.h");
|
||||
|
Loading…
Reference in New Issue
Block a user