Make function names camelCase
This conforms with the zig style guidelines: https://ziglang.org/documentation/master/#Style-Guide
This commit is contained in:
parent
46fe1baa96
commit
aaecef8c5c
@ -55,28 +55,28 @@ pub const Cursor = struct {
|
||||
|
||||
.listen_motion = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_motion,
|
||||
.notify = handleMotion,
|
||||
},
|
||||
.listen_motion_absolute = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_motion_absolute,
|
||||
.notify = handleMotionAbsolute,
|
||||
},
|
||||
.listen_button = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_button,
|
||||
.notify = handleButton,
|
||||
},
|
||||
.listen_axis = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_axis,
|
||||
.notify = handleAxis,
|
||||
},
|
||||
.listen_frame = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_frame,
|
||||
.notify = handleFrame,
|
||||
},
|
||||
|
||||
.listen_request_set_cursor = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_request_set_cursor,
|
||||
.notify = handleRequestSetCursor,
|
||||
},
|
||||
|
||||
.mode = CursorMode.Passthrough,
|
||||
@ -112,7 +112,7 @@ pub const Cursor = struct {
|
||||
c.wl_signal_add(&self.seat.wlr_seat.events.request_set_cursor, &self.listen_request_set_cursor);
|
||||
}
|
||||
|
||||
fn process_move(self: *Self, time: u32) void {
|
||||
fn processMove(self: *Self, time: u32) void {
|
||||
// Move the grabbed view to the new position.
|
||||
// TODO: log on null
|
||||
if (self.grabbed_view) |view| {
|
||||
@ -121,7 +121,7 @@ pub const Cursor = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn process_resize(self: *Self, time: u32) void {
|
||||
fn processsResize(self: *Self, time: u32) void {
|
||||
// Resizing the grabbed view can be a little bit complicated, because we
|
||||
// could be resizing from any corner or edge. This not only resizes the view
|
||||
// on one or two axes, but can also move the view if you resize from the top
|
||||
@ -170,13 +170,13 @@ pub const Cursor = struct {
|
||||
);
|
||||
}
|
||||
|
||||
fn process_motion(self: *Self, time: u32) void {
|
||||
fn processMotion(self: *Self, time: u32) void {
|
||||
// If the mode is non-passthrough, delegate to those functions.
|
||||
if (self.mode == CursorMode.Move) {
|
||||
self.process_move(time);
|
||||
self.processMove(time);
|
||||
return;
|
||||
} else if (self.mode == CursorMode.Resize) {
|
||||
self.process_resize(time);
|
||||
self.processsResize(time);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ pub const Cursor = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_motion(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleMotion(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is forwarded by the cursor when a pointer emits a _relative_
|
||||
// pointer motion event (i.e. a delta)
|
||||
const cursor = @fieldParentPtr(Cursor, "listen_motion", listener.?);
|
||||
@ -239,10 +239,10 @@ pub const Cursor = struct {
|
||||
// generated the event. You can pass NULL for the device if you want to move
|
||||
// the cursor around without any input.
|
||||
c.wlr_cursor_move(cursor.wlr_cursor, event.device, event.delta_x, event.delta_y);
|
||||
cursor.process_motion(event.time_msec);
|
||||
cursor.processMotion(event.time_msec);
|
||||
}
|
||||
|
||||
fn handle_motion_absolute(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleMotionAbsolute(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is forwarded by the cursor when a pointer emits an _absolute_
|
||||
// motion event, from 0..1 on each axis. This happens, for example, when
|
||||
// wlroots is running under a Wayland window rather than KMS+DRM, and you
|
||||
@ -255,10 +255,10 @@ pub const Cursor = struct {
|
||||
@alignCast(@alignOf(*c.wlr_event_pointer_motion_absolute), data),
|
||||
);
|
||||
c.wlr_cursor_warp_absolute(cursor.wlr_cursor, event.device, event.x, event.y);
|
||||
cursor.process_motion(event.time_msec);
|
||||
cursor.processMotion(event.time_msec);
|
||||
}
|
||||
|
||||
fn handle_button(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleButton(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is forwarded by the cursor when a pointer emits a button
|
||||
// event.
|
||||
const cursor = @fieldParentPtr(Cursor, "listen_button", listener.?);
|
||||
@ -297,7 +297,7 @@ pub const Cursor = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_axis(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) 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(Cursor, "listen_axis", listener.?);
|
||||
@ -317,7 +317,7 @@ pub const Cursor = struct {
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_frame(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleFrame(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is forwarded by the cursor when a pointer emits an frame
|
||||
// event. Frame events are sent after regular pointer events to group
|
||||
// multiple events together. For instance, two axis events may happen at the
|
||||
@ -327,7 +327,7 @@ pub const Cursor = struct {
|
||||
c.wlr_seat_pointer_notify_frame(cursor.seat.wlr_seat);
|
||||
}
|
||||
|
||||
fn handle_request_set_cursor(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleRequestSetCursor(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is rasied by the seat when a client provides a cursor image
|
||||
const cursor = @fieldParentPtr(Cursor, "listen_request_set_cursor", listener.?);
|
||||
const event = @ptrCast(
|
||||
|
@ -44,14 +44,14 @@ pub const Keyboard = struct {
|
||||
c.wlr_keyboard_set_repeat_info(self.wlr_keyboard, 25, 600);
|
||||
|
||||
// Setup listeners for keyboard events
|
||||
self.listen_modifiers.notify = handle_modifiers;
|
||||
self.listen_modifiers.notify = handleModifiers;
|
||||
c.wl_signal_add(&self.wlr_keyboard.events.modifiers, &self.listen_modifiers);
|
||||
|
||||
self.listen_key.notify = handle_key;
|
||||
self.listen_key.notify = handleKey;
|
||||
c.wl_signal_add(&self.wlr_keyboard.events.key, &self.listen_key);
|
||||
}
|
||||
|
||||
fn handle_modifiers(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleModifiers(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is raised when a modifier key, such as shift or alt, is
|
||||
// pressed. We simply communicate this to the client. */
|
||||
const keyboard = @fieldParentPtr(Keyboard, "listen_modifiers", listener.?);
|
||||
@ -69,7 +69,7 @@ pub const Keyboard = struct {
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_key(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleKey(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is raised when a key is pressed or released.
|
||||
const keyboard = @fieldParentPtr(Keyboard, "listen_key", listener.?);
|
||||
const event = @ptrCast(
|
||||
|
@ -39,7 +39,7 @@ pub const Output = struct {
|
||||
self.wlr_output = wlr_output;
|
||||
|
||||
// Sets up a listener for the frame notify event.
|
||||
self.listen_frame.notify = handle_frame;
|
||||
self.listen_frame.notify = handleFrame;
|
||||
c.wl_signal_add(&wlr_output.events.frame, &self.listen_frame);
|
||||
|
||||
// Add the new output to the layout. The add_auto function arranges outputs
|
||||
@ -54,7 +54,7 @@ pub const Output = struct {
|
||||
c.wlr_output_create_global(wlr_output);
|
||||
}
|
||||
|
||||
fn handle_frame(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleFrame(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This function is called every time an output is ready to display a frame,
|
||||
// generally at the output's refresh rate (e.g. 60Hz).
|
||||
const output = @fieldParentPtr(Output, "listen_frame", listener.?);
|
||||
@ -94,7 +94,7 @@ pub const Output = struct {
|
||||
};
|
||||
// This calls our render_surface function for each surface among the
|
||||
// xdg_surface's toplevel and popups.
|
||||
c.wlr_xdg_surface_for_each_surface(view.wlr_xdg_surface, render_surface, &rdata);
|
||||
c.wlr_xdg_surface_for_each_surface(view.wlr_xdg_surface, renderSurface, &rdata);
|
||||
}
|
||||
|
||||
// Hardware cursors are rendered by the GPU on a separate plane, and can be
|
||||
@ -112,7 +112,7 @@ pub const Output = struct {
|
||||
_ = c.wlr_output_commit(output.wlr_output);
|
||||
}
|
||||
|
||||
fn render_surface(opt_surface: ?*c.wlr_surface, sx: c_int, sy: c_int, data: ?*c_void) callconv(.C) void {
|
||||
fn renderSurface(opt_surface: ?*c.wlr_surface, sx: c_int, sy: c_int, data: ?*c_void) callconv(.C) void {
|
||||
// wlroots says this will never be null
|
||||
const surface = opt_surface.?;
|
||||
// This function is called for every surface that needs to be rendered.
|
||||
|
12
src/seat.zig
12
src/seat.zig
@ -24,7 +24,7 @@ pub const Seat = struct {
|
||||
.wlr_seat = undefined,
|
||||
.listen_new_input = c.wl_listener{
|
||||
.link = undefined,
|
||||
.notify = handle_new_input,
|
||||
.notify = handleNewInput,
|
||||
},
|
||||
.cursor = undefined,
|
||||
.keyboards = std.TailQueue(Keyboard).init(),
|
||||
@ -46,7 +46,7 @@ pub const Seat = struct {
|
||||
c.wl_signal_add(&self.server.wlr_backend.events.new_input, &self.listen_new_input);
|
||||
}
|
||||
|
||||
fn add_keyboard(self: *Self, device: *c.wlr_input_device) !void {
|
||||
fn addKeyboard(self: *Self, device: *c.wlr_input_device) !void {
|
||||
c.wlr_seat_set_keyboard(self.wlr_seat, device);
|
||||
|
||||
const node = try self.keyboards.allocateNode(self.server.allocator);
|
||||
@ -54,7 +54,7 @@ pub const Seat = struct {
|
||||
self.keyboards.append(node);
|
||||
}
|
||||
|
||||
fn add_pointer(self: *Self, device: *c.struct_wlr_input_device) void {
|
||||
fn addPointer(self: *Self, device: *c.struct_wlr_input_device) void {
|
||||
// We don't do anything special with pointers. All of our pointer handling
|
||||
// is proxied through wlr_cursor. On another compositor, you might take this
|
||||
// opportunity to do libinput configuration on the device to set
|
||||
@ -62,14 +62,14 @@ pub const Seat = struct {
|
||||
c.wlr_cursor_attach_input_device(self.cursor.wlr_cursor, device);
|
||||
}
|
||||
|
||||
fn handle_new_input(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleNewInput(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// This event is raised by the backend when a new input device becomes available.
|
||||
const seat = @fieldParentPtr(Seat, "listen_new_input", listener.?);
|
||||
const device = @ptrCast(*c.wlr_input_device, @alignCast(@alignOf(*c.wlr_input_device), data));
|
||||
|
||||
switch (device.type) {
|
||||
.WLR_INPUT_DEVICE_KEYBOARD => seat.add_keyboard(device) catch unreachable,
|
||||
.WLR_INPUT_DEVICE_POINTER => seat.add_pointer(device),
|
||||
.WLR_INPUT_DEVICE_KEYBOARD => seat.addKeyboard(device) catch unreachable,
|
||||
.WLR_INPUT_DEVICE_POINTER => seat.addPointer(device),
|
||||
else => {},
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ pub const Server = struct {
|
||||
pub fn desktop_view_at(self: *Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) ?*View {
|
||||
var it = self.views.last;
|
||||
while (it) |node| : (it = node.prev) {
|
||||
if (node.data.is_at(lx, ly, surface, sx, sy)) {
|
||||
if (node.data.isAt(lx, ly, surface, sx, sy)) {
|
||||
return &node.data;
|
||||
}
|
||||
}
|
||||
|
18
src/view.zig
18
src/view.zig
@ -27,13 +27,13 @@ pub const View = struct {
|
||||
self.x = 0;
|
||||
self.y = 0;
|
||||
|
||||
self.listen_map.notify = handle_map;
|
||||
self.listen_map.notify = handleMap;
|
||||
c.wl_signal_add(&self.wlr_xdg_surface.events.map, &self.listen_map);
|
||||
|
||||
self.listen_unmap.notify = handle_unmap;
|
||||
self.listen_unmap.notify = handleUnmap;
|
||||
c.wl_signal_add(&self.wlr_xdg_surface.events.unmap, &self.listen_unmap);
|
||||
|
||||
self.listen_destroy.notify = handle_destroy;
|
||||
self.listen_destroy.notify = handleDestroy;
|
||||
c.wl_signal_add(&self.wlr_xdg_surface.events.destroy, &self.listen_destroy);
|
||||
|
||||
// const toplevel = xdg_surface.unnamed_160.toplevel;
|
||||
@ -41,19 +41,19 @@ pub const View = struct {
|
||||
// c.wl_signal_add(&toplevel.events.request_resize, &view.request_resize);
|
||||
}
|
||||
|
||||
fn handle_map(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleMap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// Called when the surface is mapped, or ready to display on-screen.
|
||||
const view = @fieldParentPtr(View, "listen_map", listener.?);
|
||||
view.mapped = true;
|
||||
view.focus(view.wlr_xdg_surface.surface);
|
||||
}
|
||||
|
||||
fn handle_unmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const view = @fieldParentPtr(View, "listen_unmap", listener.?);
|
||||
view.mapped = false;
|
||||
}
|
||||
|
||||
fn handle_destroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
const view = @fieldParentPtr(View, "listen_destroy", listener.?);
|
||||
const server = view.server;
|
||||
|
||||
@ -68,11 +68,11 @@ pub const View = struct {
|
||||
server.views.destroyNode(target, server.allocator);
|
||||
}
|
||||
|
||||
// fn xdg_toplevel_request_move(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// fn xdgToplevelRequestMove(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// // ignore for now
|
||||
// }
|
||||
|
||||
// fn xdg_toplevel_request_resize(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// fn xdgToplevelRequestResize(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||
// // ignore for now
|
||||
// }
|
||||
|
||||
@ -122,7 +122,7 @@ pub const View = struct {
|
||||
);
|
||||
}
|
||||
|
||||
fn is_at(self: *Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) bool {
|
||||
fn isAt(self: *Self, lx: f64, ly: f64, surface: *?*c.wlr_surface, sx: *f64, sy: *f64) bool {
|
||||
// XDG toplevels may have nested surfaces, such as popup windows for context
|
||||
// menus or tooltips. This function tests if any of those are underneath the
|
||||
// coordinates lx and ly (in output Layout Coordinates). If so, it sets the
|
||||
|
Loading…
Reference in New Issue
Block a user