build: update to wlroots 0.19
This commit is contained in:
		| @ -14,6 +14,7 @@ packages: | ||||
|   - xcb-util-wm-dev | ||||
|   - pixman-dev | ||||
|   - libevdev-dev | ||||
|   - wayland-dev | ||||
|   - wayland-protocols | ||||
|   - xwayland-dev | ||||
|   - meson | ||||
| @ -23,18 +24,11 @@ packages: | ||||
|   - xz | ||||
| sources: | ||||
|   - https://codeberg.org/river/river | ||||
|   - https://gitlab.freedesktop.org/wayland/wayland.git | ||||
|   - https://gitlab.freedesktop.org/wlroots/wlroots.git | ||||
| tasks: | ||||
|   - install_deps: | | ||||
|       cd wayland | ||||
|       git checkout 1.23.0 | ||||
|       meson setup build -Ddocumentation=false -Dtests=false --prefix /usr | ||||
|       sudo ninja -C build install | ||||
|       cd .. | ||||
|  | ||||
|       cd wlroots | ||||
|       git checkout 0.18.0 | ||||
|       git checkout 0.19.0 | ||||
|       meson setup build --auto-features=enabled -Drenderers=gles2 \ | ||||
|             -Dcolor-management=disabled -Dlibliftoff=disabled \ | ||||
|             -Dexamples=false -Dwerror=false -Db_ndebug=false \ | ||||
|  | ||||
| @ -21,18 +21,11 @@ packages: | ||||
|   - xz | ||||
| sources: | ||||
|   - https://codeberg.org/river/river | ||||
|   - https://gitlab.freedesktop.org/wayland/wayland.git | ||||
|   - https://gitlab.freedesktop.org/wlroots/wlroots.git | ||||
| tasks: | ||||
|   - install_deps: | | ||||
|       cd wayland | ||||
|       git checkout 1.23.0 | ||||
|       meson setup build -Ddocumentation=false -Dtests=false --prefix /usr | ||||
|       sudo ninja -C build install | ||||
|       cd .. | ||||
|  | ||||
|       cd wlroots | ||||
|       git checkout 0.18.0 | ||||
|       git checkout 0.19.0 | ||||
|       meson setup build --auto-features=enabled -Drenderers=gles2 \ | ||||
|             -Dcolor-management=disabled -Dlibliftoff=disabled \ | ||||
|             -Dexamples=false -Dwerror=false -Db_ndebug=false \ | ||||
|  | ||||
| @ -7,6 +7,7 @@ packages: | ||||
|   - devel/meson | ||||
|   - devel/pkgconf | ||||
|   - graphics/mesa-libs | ||||
|   - graphics/wayland | ||||
|   - graphics/wayland-protocols | ||||
|   - misc/hwdata | ||||
|   - x11/libX11 | ||||
| @ -26,19 +27,13 @@ packages: | ||||
|   - wget | ||||
| sources: | ||||
|   - https://codeberg.org/river/river | ||||
|   - https://gitlab.freedesktop.org/wayland/wayland.git | ||||
|   - https://gitlab.freedesktop.org/wlroots/wlroots.git | ||||
| tasks: | ||||
|   - install_deps: | | ||||
|       cd wayland | ||||
|       git checkout 1.23.0 | ||||
|       meson setup build -Ddocumentation=false -Dtests=false --prefix /usr | ||||
|       sudo ninja -C build install | ||||
|       cd .. | ||||
|  | ||||
|       cd wlroots | ||||
|       git checkout 0.18.0 | ||||
|       git checkout 0.19.0 | ||||
|       meson setup build --auto-features=enabled -Drenderers=gles2 \ | ||||
|             -Dallocators=gbm \ | ||||
|             -Dcolor-management=disabled -Dlibliftoff=disabled \ | ||||
|             -Dexamples=false -Dwerror=false -Db_ndebug=false \ | ||||
|             -Dxcb-errors=disabled --prefix /usr | ||||
|  | ||||
| @ -60,7 +60,7 @@ distribution. | ||||
| - [zig](https://ziglang.org/download/) 0.14 | ||||
| - wayland | ||||
| - wayland-protocols | ||||
| - [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.18 | ||||
| - [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.19 | ||||
| - xkbcommon | ||||
| - libevdev | ||||
| - pixman | ||||
|  | ||||
| @ -142,7 +142,7 @@ pub fn build(b: *Build) !void { | ||||
|     // exposed to the wlroots module for @cImport() to work. This seems to be | ||||
|     // the best way to do so with the current std.Build API. | ||||
|     wlroots.resolved_target = target; | ||||
|     wlroots.linkSystemLibrary("wlroots-0.18", .{}); | ||||
|     wlroots.linkSystemLibrary("wlroots-0.19", .{}); | ||||
|  | ||||
|     const flags = b.createModule(.{ .root_source_file = b.path("common/flags.zig") }); | ||||
|     const globber = b.createModule(.{ .root_source_file = b.path("common/globber.zig") }); | ||||
| @ -163,7 +163,7 @@ pub fn build(b: *Build) !void { | ||||
|         river.linkSystemLibrary("libevdev"); | ||||
|         river.linkSystemLibrary("libinput"); | ||||
|         river.linkSystemLibrary("wayland-server"); | ||||
|         river.linkSystemLibrary("wlroots-0.18"); | ||||
|         river.linkSystemLibrary("wlroots-0.19"); | ||||
|         river.linkSystemLibrary("xkbcommon"); | ||||
|         river.linkSystemLibrary("pixman-1"); | ||||
|  | ||||
|  | ||||
| @ -17,8 +17,8 @@ | ||||
|             .hash = "wayland-0.3.0-lQa1kjPIAQDmhGYpY-zxiRzQJFHQ2VqhJkQLbKKdt5wl", | ||||
|         }, | ||||
|         .wlroots = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-wlroots/archive/v0.18.2.tar.gz", | ||||
|             .hash = "wlroots-0.18.2-jmOlchnIAwBq45_cxU1V3OWErxxJjQZlc9PyJfR-l3uk", | ||||
|             .url = "https://codeberg.org/ifreund/zig-wlroots/archive/v0.19.1.tar.gz", | ||||
|             .hash = "wlroots-0.19.1-jmOlcs7dAwCajnVWlQZIc-ySYjRlbLxy0F5FvTQqYA3P", | ||||
|         }, | ||||
|         .xkbcommon = .{ | ||||
|             .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz", | ||||
|  | ||||
| @ -84,7 +84,7 @@ fn handleRequest(control_v1: *zriver.ControlV1, request: zriver.ControlV1.Reques | ||||
|             }; | ||||
|         }, | ||||
|         .run_command => |run_command| { | ||||
|             const seat: *Seat = @ptrFromInt(wlr.Seat.Client.fromWlSeat(run_command.seat).?.seat.data); | ||||
|             const seat: *Seat = @alignCast(@ptrCast(wlr.Seat.Client.fromWlSeat(run_command.seat).?.seat.data)); | ||||
|  | ||||
|             const callback = zriver.CommandCallbackV1.create( | ||||
|                 control_v1.getClient(), | ||||
|  | ||||
| @ -255,6 +255,30 @@ pub fn init(cursor: *Cursor, seat: *Seat) !void { | ||||
| } | ||||
|  | ||||
| pub fn deinit(cursor: *Cursor) void { | ||||
|     cursor.axis.link.remove(); | ||||
|     cursor.button.link.remove(); | ||||
|     cursor.frame.link.remove(); | ||||
|     cursor.motion_absolute.link.remove(); | ||||
|     cursor.motion.link.remove(); | ||||
|     cursor.swipe_begin.link.remove(); | ||||
|     cursor.swipe_update.link.remove(); | ||||
|     cursor.swipe_end.link.remove(); | ||||
|     cursor.pinch_begin.link.remove(); | ||||
|     cursor.pinch_update.link.remove(); | ||||
|     cursor.pinch_end.link.remove(); | ||||
|     cursor.request_set_cursor.link.remove(); | ||||
|  | ||||
|     cursor.touch_down.link.remove(); | ||||
|     cursor.touch_motion.link.remove(); | ||||
|     cursor.touch_up.link.remove(); | ||||
|     cursor.touch_cancel.link.remove(); | ||||
|     cursor.touch_frame.link.remove(); | ||||
|  | ||||
|     cursor.tablet_tool_axis.link.remove(); | ||||
|     cursor.tablet_tool_proximity.link.remove(); | ||||
|     cursor.tablet_tool_tip.link.remove(); | ||||
|     cursor.tablet_tool_button.link.remove(); | ||||
|  | ||||
|     cursor.hide_cursor_timer.remove(); | ||||
|     cursor.xcursor_manager.destroy(); | ||||
|     cursor.wlr_cursor.destroy(); | ||||
| @ -338,7 +362,7 @@ fn clearFocus(cursor: *Cursor) void { | ||||
| /// Axis event is a scroll wheel or similiar | ||||
| fn handleAxis(listener: *wl.Listener(*wlr.Pointer.event.Axis), event: *wlr.Pointer.event.Axis) void { | ||||
|     const cursor: *Cursor = @fieldParentPtr("axis", listener); | ||||
|     const device: *InputDevice = @ptrFromInt(event.device.data); | ||||
|     const device: *InputDevice = @alignCast(@ptrCast(event.device.data)); | ||||
|  | ||||
|     cursor.seat.handleActivity(); | ||||
|     cursor.unhide(); | ||||
| @ -458,7 +482,7 @@ fn updateKeyboardFocus(cursor: Cursor, result: Root.AtResult) void { | ||||
| /// Requires a call to Root.applyPending() | ||||
| fn updateOutputFocus(cursor: Cursor, lx: f64, ly: f64) void { | ||||
|     if (server.root.output_layout.outputAt(lx, ly)) |wlr_output| { | ||||
|         const output: *Output = @ptrFromInt(wlr_output.data); | ||||
|         const output: *Output = @alignCast(@ptrCast(wlr_output.data)); | ||||
|         cursor.seat.focusOutput(output); | ||||
|     } | ||||
| } | ||||
| @ -635,7 +659,7 @@ fn handleTabletToolAxis( | ||||
|     _: *wl.Listener(*wlr.Tablet.event.Axis), | ||||
|     event: *wlr.Tablet.event.Axis, | ||||
| ) void { | ||||
|     const device: *InputDevice = @ptrFromInt(event.device.data); | ||||
|     const device: *InputDevice = @alignCast(@ptrCast(event.device.data)); | ||||
|     const tablet: *Tablet = @fieldParentPtr("device", device); | ||||
|  | ||||
|     device.seat.handleActivity(); | ||||
| @ -649,7 +673,7 @@ fn handleTabletToolProximity( | ||||
|     _: *wl.Listener(*wlr.Tablet.event.Proximity), | ||||
|     event: *wlr.Tablet.event.Proximity, | ||||
| ) void { | ||||
|     const device: *InputDevice = @ptrFromInt(event.device.data); | ||||
|     const device: *InputDevice = @alignCast(@ptrCast(event.device.data)); | ||||
|     const tablet: *Tablet = @fieldParentPtr("device", device); | ||||
|  | ||||
|     device.seat.handleActivity(); | ||||
| @ -663,7 +687,7 @@ fn handleTabletToolTip( | ||||
|     _: *wl.Listener(*wlr.Tablet.event.Tip), | ||||
|     event: *wlr.Tablet.event.Tip, | ||||
| ) void { | ||||
|     const device: *InputDevice = @ptrFromInt(event.device.data); | ||||
|     const device: *InputDevice = @alignCast(@ptrCast(event.device.data)); | ||||
|     const tablet: *Tablet = @fieldParentPtr("device", device); | ||||
|  | ||||
|     device.seat.handleActivity(); | ||||
| @ -677,7 +701,7 @@ fn handleTabletToolButton( | ||||
|     _: *wl.Listener(*wlr.Tablet.event.Button), | ||||
|     event: *wlr.Tablet.event.Button, | ||||
| ) void { | ||||
|     const device: *InputDevice = @ptrFromInt(event.device.data); | ||||
|     const device: *InputDevice = @alignCast(@ptrCast(event.device.data)); | ||||
|     const tablet: *Tablet = @fieldParentPtr("device", device); | ||||
|  | ||||
|     device.seat.handleActivity(); | ||||
| @ -1255,7 +1279,7 @@ fn warp(cursor: *Cursor) void { | ||||
|     }; | ||||
|     if (!output_layout_box.containsPoint(cursor.wlr_cursor.x, cursor.wlr_cursor.y) or | ||||
|         (usable_layout_box.containsPoint(cursor.wlr_cursor.x, cursor.wlr_cursor.y) and | ||||
|             !target_box.containsPoint(cursor.wlr_cursor.x, cursor.wlr_cursor.y))) | ||||
|         !target_box.containsPoint(cursor.wlr_cursor.x, cursor.wlr_cursor.y))) | ||||
|     { | ||||
|         const lx: f64 = @floatFromInt(target_box.x + @divTrunc(target_box.width, 2)); | ||||
|         const ly: f64 = @floatFromInt(target_box.y + @divTrunc(target_box.height, 2)); | ||||
| @ -1268,7 +1292,7 @@ fn warp(cursor: *Cursor) void { | ||||
| fn updateDragIcons(cursor: *Cursor) void { | ||||
|     var it = server.root.drag_icons.children.iterator(.forward); | ||||
|     while (it.next()) |node| { | ||||
|         const icon = @as(*DragIcon, @ptrFromInt(node.data)); | ||||
|         const icon: *DragIcon = @alignCast(@ptrCast(node.data)); | ||||
|  | ||||
|         if (icon.wlr_drag_icon.drag.seat == cursor.seat.wlr_seat) { | ||||
|             icon.updatePosition(cursor); | ||||
|  | ||||
| @ -42,7 +42,7 @@ pub fn create(wlr_drag_icon: *wlr.Drag.Icon, cursor: *Cursor) error{OutOfMemory} | ||||
|         .wlr_drag_icon = wlr_drag_icon, | ||||
|         .scene_drag_icon = scene_drag_icon, | ||||
|     }; | ||||
|     scene_drag_icon.node.data = @intFromPtr(drag_icon); | ||||
|     scene_drag_icon.node.data = drag_icon; | ||||
|  | ||||
|     drag_icon.updatePosition(cursor); | ||||
|  | ||||
|  | ||||
| @ -89,7 +89,7 @@ fn handleForeignActivate( | ||||
| ) void { | ||||
|     const handle: *ForeignToplevelHandle = @fieldParentPtr("foreign_activate", listener); | ||||
|     const view: *View = @fieldParentPtr("foreign_toplevel_handle", handle); | ||||
|     const seat: *Seat = @ptrFromInt(event.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(event.seat.data)); | ||||
|  | ||||
|     seat.focus(view); | ||||
|     server.root.applyPending(); | ||||
|  | ||||
| @ -86,7 +86,7 @@ pub fn init(device: *InputDevice, seat: *Seat, wlr_device: *wlr.InputDevice) !vo | ||||
|         .link = undefined, | ||||
|     }; | ||||
|  | ||||
|     wlr_device.data = @intFromPtr(device); | ||||
|     wlr_device.data = device; | ||||
|  | ||||
|     wlr_device.events.destroy.add(&device.destroy); | ||||
|  | ||||
| @ -117,7 +117,7 @@ pub fn deinit(device: *InputDevice) void { | ||||
|         device.seat.updateCapabilities(); | ||||
|     } | ||||
|  | ||||
|     device.wlr_device.data = 0; | ||||
|     device.wlr_device.data = null; | ||||
|  | ||||
|     device.* = undefined; | ||||
| } | ||||
|  | ||||
| @ -185,7 +185,7 @@ fn handleNewVirtualKeyboard( | ||||
|     _: *wl.Listener(*wlr.VirtualKeyboardV1), | ||||
|     virtual_keyboard: *wlr.VirtualKeyboardV1, | ||||
| ) void { | ||||
|     const seat: *Seat = @ptrFromInt(virtual_keyboard.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(virtual_keyboard.seat.data)); | ||||
|     seat.addDevice(&virtual_keyboard.keyboard.base); | ||||
| } | ||||
|  | ||||
| @ -200,7 +200,7 @@ fn handleNewConstraint( | ||||
| } | ||||
|  | ||||
| fn handleNewInputMethod(_: *wl.Listener(*wlr.InputMethodV2), input_method: *wlr.InputMethodV2) void { | ||||
|     const seat: *Seat = @ptrFromInt(input_method.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(input_method.seat.data)); | ||||
|  | ||||
|     log.debug("new input method on seat {s}", .{seat.wlr_seat.name}); | ||||
|  | ||||
|  | ||||
| @ -96,7 +96,7 @@ pub fn init(keyboard: *Keyboard, seat: *Seat, wlr_device: *wlr.InputDevice) !voi | ||||
|     errdefer keyboard.device.deinit(); | ||||
|  | ||||
|     const wlr_keyboard = keyboard.device.wlr_device.toKeyboard(); | ||||
|     wlr_keyboard.data = @intFromPtr(keyboard); | ||||
|     wlr_keyboard.data = keyboard; | ||||
|  | ||||
|     // wlroots will log a more detailed error if this fails. | ||||
|     if (!wlr_keyboard.setKeymap(server.config.keymap)) return error.OutOfMemory; | ||||
|  | ||||
| @ -43,7 +43,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit) | ||||
| new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup), | ||||
|  | ||||
| pub fn create(wlr_layer_surface: *wlr.LayerSurfaceV1) error{OutOfMemory}!void { | ||||
|     const output: *Output = @ptrFromInt(wlr_layer_surface.output.?.data); | ||||
|     const output: *Output = @alignCast(@ptrCast(wlr_layer_surface.output.?.data)); | ||||
|     const layer_surface = try util.gpa.create(LayerSurface); | ||||
|     errdefer util.gpa.destroy(layer_surface); | ||||
|  | ||||
| @ -59,7 +59,7 @@ pub fn create(wlr_layer_surface: *wlr.LayerSurfaceV1) error{OutOfMemory}!void { | ||||
|     try SceneNodeData.attach(&layer_surface.scene_layer_surface.tree.node, .{ .layer_surface = layer_surface }); | ||||
|     try SceneNodeData.attach(&layer_surface.popup_tree.node, .{ .layer_surface = layer_surface }); | ||||
|  | ||||
|     wlr_layer_surface.surface.data = @intFromPtr(&layer_surface.scene_layer_surface.tree.node); | ||||
|     wlr_layer_surface.surface.data = &layer_surface.scene_layer_surface.tree.node; | ||||
|  | ||||
|     wlr_layer_surface.events.destroy.add(&layer_surface.destroy); | ||||
|     wlr_layer_surface.surface.events.map.add(&layer_surface.map); | ||||
| @ -88,7 +88,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfa | ||||
|     layer_surface.popup_tree.node.destroy(); | ||||
|  | ||||
|     // The wlr_surface may outlive the wlr_layer_surface so we must clean up the user data. | ||||
|     layer_surface.wlr_layer_surface.surface.data = 0; | ||||
|     layer_surface.wlr_layer_surface.surface.data = null; | ||||
|  | ||||
|     util.gpa.destroy(layer_surface); | ||||
| } | ||||
| @ -156,7 +156,7 @@ fn handleKeyboardInteractiveExclusive(output: *Output, consider: ?*LayerSurface) | ||||
|         var it = tree.children.iterator(.reverse); | ||||
|         while (it.next()) |node| { | ||||
|             assert(node.type == .tree); | ||||
|             if (@as(?*SceneNodeData, @ptrFromInt(node.data))) |node_data| { | ||||
|             if (@as(?*SceneNodeData, @alignCast(@ptrCast(node.data)))) |node_data| { | ||||
|                 const layer_surface = node_data.data.layer_surface; | ||||
|                 const wlr_layer_surface = layer_surface.wlr_layer_surface; | ||||
|                 if (wlr_layer_surface.surface.mapped and | ||||
|  | ||||
| @ -68,7 +68,7 @@ fn handleRequest( | ||||
|         .get_layout => |req| { | ||||
|             // Ignore if the output is inert | ||||
|             const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return; | ||||
|             const output: *Output = @ptrFromInt(wlr_output.data); | ||||
|             const output: *Output = @alignCast(@ptrCast(wlr_output.data)); | ||||
|  | ||||
|             log.debug("bind layout '{s}' on output '{s}'", .{ req.namespace, output.wlr_output.name }); | ||||
|  | ||||
|  | ||||
| @ -266,7 +266,7 @@ pub fn updateLockSurfaceSize(manager: *LockManager, output: *Output) void { | ||||
|  | ||||
|     var it = lock.surfaces.iterator(.forward); | ||||
|     while (it.next()) |wlr_lock_surface| { | ||||
|         const lock_surface: *LockSurface = @ptrFromInt(wlr_lock_surface.data); | ||||
|         const lock_surface: *LockSurface = @alignCast(@ptrCast(wlr_lock_surface.data)); | ||||
|         if (output == lock_surface.getOutput()) { | ||||
|             lock_surface.configure(); | ||||
|         } | ||||
|  | ||||
| @ -44,7 +44,7 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLoc | ||||
|         .wlr_lock_surface = wlr_lock_surface, | ||||
|         .lock = lock, | ||||
|     }; | ||||
|     wlr_lock_surface.data = @intFromPtr(lock_surface); | ||||
|     wlr_lock_surface.data = lock_surface; | ||||
|  | ||||
|     const output = lock_surface.getOutput(); | ||||
|     const tree = try output.locked_content.createSceneSubsurfaceTree(wlr_lock_surface.surface); | ||||
| @ -52,7 +52,7 @@ pub fn create(wlr_lock_surface: *wlr.SessionLockSurfaceV1, lock: *wlr.SessionLoc | ||||
|  | ||||
|     try SceneNodeData.attach(&tree.node, .{ .lock_surface = lock_surface }); | ||||
|  | ||||
|     wlr_lock_surface.surface.data = @intFromPtr(&tree.node); | ||||
|     wlr_lock_surface.surface.data = &tree.node; | ||||
|  | ||||
|     wlr_lock_surface.surface.events.map.add(&lock_surface.map); | ||||
|     wlr_lock_surface.events.destroy.add(&lock_surface.surface_destroy); | ||||
| @ -65,7 +65,7 @@ pub fn destroy(lock_surface: *LockSurface) void { | ||||
|         var surface_it = lock_surface.lock.surfaces.iterator(.forward); | ||||
|         const new_focus: Seat.FocusTarget = while (surface_it.next()) |surface| { | ||||
|             if (surface != lock_surface.wlr_lock_surface) | ||||
|                 break .{ .lock_surface = @ptrFromInt(surface.data) }; | ||||
|                 break .{ .lock_surface = @alignCast(@ptrCast(surface.data)) }; | ||||
|         } else .none; | ||||
|  | ||||
|         var seat_it = server.input_manager.seats.first; | ||||
| @ -86,13 +86,13 @@ pub fn destroy(lock_surface: *LockSurface) void { | ||||
|     lock_surface.surface_destroy.link.remove(); | ||||
|  | ||||
|     // The wlr_surface may outlive the wlr_lock_surface so we must clean up the user data. | ||||
|     lock_surface.wlr_lock_surface.surface.data = 0; | ||||
|     lock_surface.wlr_lock_surface.surface.data = null; | ||||
|  | ||||
|     util.gpa.destroy(lock_surface); | ||||
| } | ||||
|  | ||||
| pub fn getOutput(lock_surface: *LockSurface) *Output { | ||||
|     return @ptrFromInt(lock_surface.wlr_lock_surface.output.data); | ||||
|     return @alignCast(@ptrCast(lock_surface.wlr_lock_surface.output.data)); | ||||
| } | ||||
|  | ||||
| pub fn configure(lock_surface: *LockSurface) void { | ||||
|  | ||||
| @ -125,10 +125,6 @@ lock_render_state: enum { | ||||
|     lock_surface, | ||||
| } = .blanked, | ||||
|  | ||||
| /// Set to true if a gamma control client makes a set gamma request. | ||||
| /// This request is handled while rendering the next frame in handleFrame(). | ||||
| gamma_dirty: bool = false, | ||||
|  | ||||
| /// The state of the output that is directly acted upon/modified through user input. | ||||
| /// | ||||
| /// Pending state will be copied to the inflight state and communicated to clients | ||||
| @ -295,7 +291,7 @@ pub fn create(wlr_output: *wlr.Output) !void { | ||||
|         }, | ||||
|         .status = undefined, | ||||
|     }; | ||||
|     wlr_output.data = @intFromPtr(output); | ||||
|     wlr_output.data = output; | ||||
|  | ||||
|     output.pending.focus_stack.init(); | ||||
|     output.pending.wm_stack.init(); | ||||
| @ -364,7 +360,7 @@ fn sendLayerConfigures( | ||||
|         var it = tree.children.safeIterator(.forward); | ||||
|         while (it.next()) |node| { | ||||
|             assert(node.type == .tree); | ||||
|             if (@as(?*SceneNodeData, @ptrFromInt(node.data))) |node_data| { | ||||
|             if (@as(?*SceneNodeData, @alignCast(@ptrCast(node.data)))) |node_data| { | ||||
|                 const layer_surface = node_data.data.layer_surface; | ||||
|  | ||||
|                 if (!layer_surface.wlr_layer_surface.initialized) continue; | ||||
| @ -433,7 +429,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void { | ||||
|  | ||||
|     if (output.layout_namespace) |namespace| util.gpa.free(namespace); | ||||
|  | ||||
|     output.wlr_output.data = 0; | ||||
|     output.wlr_output.data = null; | ||||
|  | ||||
|     util.gpa.destroy(output); | ||||
|  | ||||
| @ -480,7 +476,6 @@ pub fn applyState(output: *Output, state: *wlr.Output.State) error{CommitFailed} | ||||
|  | ||||
| fn handleEnableDisable(output: *Output) void { | ||||
|     output.updateLockRenderStateOnEnableDisable(); | ||||
|     output.gamma_dirty = true; | ||||
|  | ||||
|     if (output.wlr_output.enabled) { | ||||
|         // Add the output to root.active_outputs and the output layout if it has not | ||||
| @ -532,7 +527,6 @@ fn handleFrame(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void { | ||||
|  | ||||
|     // TODO this should probably be retried on failure | ||||
|     output.renderAndCommit(scene_output) catch |err| switch (err) { | ||||
|         error.OutOfMemory => log.err("out of memory", .{}), | ||||
|         error.CommitFailed => log.err("output commit failed for {s}", .{output.wlr_output.name}), | ||||
|     }; | ||||
|  | ||||
| @ -541,34 +535,13 @@ fn handleFrame(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void { | ||||
| } | ||||
|  | ||||
| fn renderAndCommit(output: *Output, scene_output: *wlr.SceneOutput) !void { | ||||
|     // TODO(wlroots): replace this with wlr_scene_output_needs_frame() | ||||
|     if (!output.wlr_output.needs_frame and !output.gamma_dirty and | ||||
|         !scene_output.pending_commit_damage.notEmpty()) | ||||
|     { | ||||
|         return; | ||||
|     } | ||||
|     if (!scene_output.needsFrame()) return; | ||||
|  | ||||
|     var state = wlr.Output.State.init(); | ||||
|     defer state.finish(); | ||||
|  | ||||
|     if (!scene_output.buildState(&state, null)) return error.CommitFailed; | ||||
|  | ||||
|     if (output.gamma_dirty) { | ||||
|         const control = server.root.gamma_control_manager.getControl(output.wlr_output); | ||||
|         if (!wlr.GammaControlV1.apply(control, &state)) return error.OutOfMemory; | ||||
|  | ||||
|         // TODO(wlroots): remove this isHeadless() workaround after upstream fix is available | ||||
|         // in a release: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4868 | ||||
|         if (!output.wlr_output.testState(&state) or output.wlr_output.isHeadless()) { | ||||
|             wlr.GammaControlV1.sendFailedAndDestroy(control); | ||||
|             state.clearGammaLut(); | ||||
|             // If the backend does not support gamma LUTs it will reject any | ||||
|             // state with the gamma LUT committed bit set even if the state | ||||
|             // has a null LUT. The wayland backend for example has this behavior. | ||||
|             state.committed.gamma_lut = false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (output.current.fullscreen) |fullscreen| { | ||||
|         if (fullscreen.allowTearing()) { | ||||
|             state.tearing_page_flip = true; | ||||
| @ -583,8 +556,6 @@ fn renderAndCommit(output: *Output, scene_output: *wlr.SceneOutput) !void { | ||||
|  | ||||
|     if (!output.wlr_output.commitState(&state)) return error.CommitFailed; | ||||
|  | ||||
|     output.gamma_dirty = false; | ||||
|  | ||||
|     if (server.lock_manager.state == .locked or | ||||
|         (server.lock_manager.state == .waiting_for_lock_surfaces and output.locked_content.node.enabled) or | ||||
|         server.lock_manager.state == .waiting_for_blank) | ||||
|  | ||||
| @ -47,7 +47,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit) | ||||
| node_destroy: wl.Listener(void) = wl.Listener(void).init(handleNodeDestroy), | ||||
|  | ||||
| pub fn create(wlr_constraint: *wlr.PointerConstraintV1) error{OutOfMemory}!void { | ||||
|     const seat: *Seat = @ptrFromInt(wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(wlr_constraint.seat.data)); | ||||
|  | ||||
|     const constraint = try util.gpa.create(PointerConstraint); | ||||
|     errdefer util.gpa.destroy(constraint); | ||||
| @ -55,7 +55,7 @@ pub fn create(wlr_constraint: *wlr.PointerConstraintV1) error{OutOfMemory}!void | ||||
|     constraint.* = .{ | ||||
|         .wlr_constraint = wlr_constraint, | ||||
|     }; | ||||
|     wlr_constraint.data = @intFromPtr(constraint); | ||||
|     wlr_constraint.data = constraint; | ||||
|  | ||||
|     wlr_constraint.events.destroy.add(&constraint.destroy); | ||||
|     wlr_constraint.surface.events.commit.add(&constraint.commit); | ||||
| @ -70,7 +70,7 @@ pub fn create(wlr_constraint: *wlr.PointerConstraintV1) error{OutOfMemory}!void | ||||
| } | ||||
|  | ||||
| pub fn maybeActivate(constraint: *PointerConstraint) void { | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     assert(seat.cursor.constraint == constraint); | ||||
|  | ||||
| @ -102,7 +102,7 @@ pub fn maybeActivate(constraint: *PointerConstraint) void { | ||||
|  | ||||
| /// Called when the cursor position or content in the scene graph changes | ||||
| pub fn updateState(constraint: *PointerConstraint) void { | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     constraint.maybeActivate(); | ||||
|  | ||||
| @ -154,7 +154,7 @@ pub fn confine(constraint: *PointerConstraint, dx: *f64, dy: *f64) void { | ||||
| } | ||||
|  | ||||
| pub fn deactivate(constraint: *PointerConstraint) void { | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     assert(seat.cursor.constraint == constraint); | ||||
|     assert(constraint.state == .active); | ||||
| @ -167,7 +167,7 @@ pub fn deactivate(constraint: *PointerConstraint) void { | ||||
| } | ||||
|  | ||||
| fn warpToHintIfSet(constraint: *PointerConstraint) void { | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     if (constraint.wlr_constraint.current.cursor_hint.enabled) { | ||||
|         var lx: i32 = undefined; | ||||
| @ -190,7 +190,7 @@ fn handleNodeDestroy(listener: *wl.Listener(void)) void { | ||||
|  | ||||
| fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), _: *wlr.PointerConstraintV1) void { | ||||
|     const constraint: *PointerConstraint = @fieldParentPtr("destroy", listener); | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     if (constraint.state == .active) { | ||||
|         // We can't simply call deactivate() here as it calls sendDeactivated(), | ||||
| @ -215,7 +215,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), _: *wlr.Point | ||||
| // the surface changes. | ||||
| fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void { | ||||
|     const constraint: *PointerConstraint = @fieldParentPtr("commit", listener); | ||||
|     const seat: *Seat = @ptrFromInt(constraint.wlr_constraint.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data)); | ||||
|  | ||||
|     switch (constraint.state) { | ||||
|         .active => |state| { | ||||
|  | ||||
| @ -97,8 +97,6 @@ power_manager_set_mode: wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode) = | ||||
|     wl.Listener(*wlr.OutputPowerManagerV1.event.SetMode).init(handlePowerManagerSetMode), | ||||
|  | ||||
| gamma_control_manager: *wlr.GammaControlManagerV1, | ||||
| gamma_control_set_gamma: wl.Listener(*wlr.GammaControlManagerV1.event.SetGamma) = | ||||
|     wl.Listener(*wlr.GammaControlManagerV1.event.SetGamma).init(handleSetGamma), | ||||
|  | ||||
| /// A list of all outputs | ||||
| all_outputs: wl.list.Head(Output, .all_link), | ||||
| @ -123,6 +121,9 @@ pub fn init(root: *Root) !void { | ||||
|     const scene = try wlr.Scene.create(); | ||||
|     errdefer scene.tree.node.destroy(); | ||||
|  | ||||
|     const gamma_control_manager = try wlr.GammaControlManagerV1.create(server.wl_server); | ||||
|     scene.setGammaControlManagerV1(gamma_control_manager); | ||||
|  | ||||
|     const interactive_content = try scene.tree.createSceneTree(); | ||||
|     const drag_icons = try scene.tree.createSceneTree(); | ||||
|     const hidden_tree = try scene.tree.createSceneTree(); | ||||
| @ -163,11 +164,11 @@ pub fn init(root: *Root) !void { | ||||
|         .all_outputs = undefined, | ||||
|         .active_outputs = undefined, | ||||
|  | ||||
|         .presentation = try wlr.Presentation.create(server.wl_server, server.backend), | ||||
|         .presentation = try wlr.Presentation.create(server.wl_server, server.backend, 2), | ||||
|         .xdg_output_manager = try wlr.XdgOutputManagerV1.create(server.wl_server, output_layout), | ||||
|         .output_manager = try wlr.OutputManagerV1.create(server.wl_server), | ||||
|         .power_manager = try wlr.OutputPowerManagerV1.create(server.wl_server), | ||||
|         .gamma_control_manager = try wlr.GammaControlManagerV1.create(server.wl_server), | ||||
|         .gamma_control_manager = gamma_control_manager, | ||||
|         .transaction_timeout = transaction_timeout, | ||||
|     }; | ||||
|     root.hidden.pending.focus_stack.init(); | ||||
| @ -187,10 +188,14 @@ pub fn init(root: *Root) !void { | ||||
|     root.output_manager.events.@"test".add(&root.manager_test); | ||||
|     root.output_layout.events.change.add(&root.layout_change); | ||||
|     root.power_manager.events.set_mode.add(&root.power_manager_set_mode); | ||||
|     root.gamma_control_manager.events.set_gamma.add(&root.gamma_control_set_gamma); | ||||
| } | ||||
|  | ||||
| pub fn deinit(root: *Root) void { | ||||
|     root.manager_apply.link.remove(); | ||||
|     root.manager_test.link.remove(); | ||||
|     root.layout_change.link.remove(); | ||||
|     root.power_manager_set_mode.link.remove(); | ||||
|  | ||||
|     root.output_layout.destroy(); | ||||
|     root.transaction_timeout.remove(); | ||||
| } | ||||
| @ -323,7 +328,7 @@ pub fn deactivateOutput(root: *Root, output: *Output) void { | ||||
|         var it = tree.children.safeIterator(.forward); | ||||
|         while (it.next()) |scene_node| { | ||||
|             assert(scene_node.type == .tree); | ||||
|             if (@as(?*SceneNodeData, @ptrFromInt(scene_node.data))) |node_data| { | ||||
|             if (@as(?*SceneNodeData, @alignCast(@ptrCast(scene_node.data)))) |node_data| { | ||||
|                 node_data.data.layer_surface.wlr_layer_surface.destroy(); | ||||
|             } | ||||
|         } | ||||
| @ -795,7 +800,7 @@ fn processOutputConfig( | ||||
|     var it = config.heads.iterator(.forward); | ||||
|     while (it.next()) |head| { | ||||
|         const wlr_output = head.state.output; | ||||
|         const output: *Output = @ptrFromInt(wlr_output.data); | ||||
|         const output: *Output = @alignCast(@ptrCast(wlr_output.data)); | ||||
|  | ||||
|         var proposed_state = wlr.Output.State.init(); | ||||
|         head.state.apply(&proposed_state); | ||||
| @ -834,7 +839,7 @@ fn handlePowerManagerSetMode( | ||||
|     event: *wlr.OutputPowerManagerV1.event.SetMode, | ||||
| ) void { | ||||
|     // The output may have been destroyed, in which case there is nothing to do | ||||
|     const output = @as(?*Output, @ptrFromInt(event.output.data)) orelse return; | ||||
|     const output: *Output = @alignCast(@ptrCast(event.output.data orelse return)); | ||||
|  | ||||
|     std.log.debug("client requested dpms {s} for output {s}", .{ | ||||
|         @tagName(event.mode), | ||||
| @ -864,18 +869,4 @@ fn handlePowerManagerSetMode( | ||||
|     } | ||||
|  | ||||
|     output.updateLockRenderStateOnEnableDisable(); | ||||
|     output.gamma_dirty = true; | ||||
| } | ||||
|  | ||||
| fn handleSetGamma( | ||||
|     _: *wl.Listener(*wlr.GammaControlManagerV1.event.SetGamma), | ||||
|     event: *wlr.GammaControlManagerV1.event.SetGamma, | ||||
| ) void { | ||||
|     // The output may have been destroyed, in which case there is nothing to do | ||||
|     const output = @as(?*Output, @ptrFromInt(event.output.data)) orelse return; | ||||
|  | ||||
|     std.log.debug("client requested to set gamma", .{}); | ||||
|  | ||||
|     output.gamma_dirty = true; | ||||
|     output.wlr_output.scheduleFrame(); | ||||
| } | ||||
|  | ||||
| @ -46,7 +46,7 @@ pub fn attach(node: *wlr.SceneNode, data: Data) error{OutOfMemory}!void { | ||||
|         .node = node, | ||||
|         .data = data, | ||||
|     }; | ||||
|     node.data = @intFromPtr(scene_node_data); | ||||
|     node.data = scene_node_data; | ||||
|  | ||||
|     node.events.destroy.add(&scene_node_data.destroy); | ||||
| } | ||||
| @ -54,7 +54,7 @@ pub fn attach(node: *wlr.SceneNode, data: Data) error{OutOfMemory}!void { | ||||
| pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData { | ||||
|     var n = node; | ||||
|     while (true) { | ||||
|         if (@as(?*SceneNodeData, @ptrFromInt(n.data))) |scene_node_data| { | ||||
|         if (@as(?*SceneNodeData, @alignCast(@ptrCast(n.data)))) |scene_node_data| { | ||||
|             return scene_node_data; | ||||
|         } | ||||
|         if (n.parent) |parent_tree| { | ||||
| @ -66,7 +66,7 @@ pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData { | ||||
| } | ||||
|  | ||||
| pub fn fromSurface(surface: *wlr.Surface) ?*SceneNodeData { | ||||
|     if (@as(?*wlr.SceneNode, @ptrFromInt(surface.getRootSurface().data))) |node| { | ||||
|     if (@as(?*wlr.SceneNode, @alignCast(@ptrCast(surface.getRootSurface().data)))) |node| { | ||||
|         return fromNode(node); | ||||
|     } | ||||
|     return null; | ||||
| @ -76,7 +76,7 @@ fn handleDestroy(listener: *wl.Listener(void)) void { | ||||
|     const scene_node_data: *SceneNodeData = @fieldParentPtr("destroy", listener); | ||||
|  | ||||
|     scene_node_data.destroy.link.remove(); | ||||
|     scene_node_data.node.data = 0; | ||||
|     scene_node_data.node.data = null; | ||||
|  | ||||
|     util.gpa.destroy(scene_node_data); | ||||
| } | ||||
|  | ||||
| @ -122,7 +122,7 @@ pub fn init(seat: *Seat, name: [*:0]const u8) !void { | ||||
|         .mapping_repeat_timer = mapping_repeat_timer, | ||||
|         .keyboard_group = try wlr.KeyboardGroup.create(), | ||||
|     }; | ||||
|     seat.wlr_seat.data = @intFromPtr(seat); | ||||
|     seat.wlr_seat.data = seat; | ||||
|  | ||||
|     try seat.cursor.init(seat); | ||||
|     seat.relay.init(); | ||||
| @ -284,7 +284,7 @@ pub fn setFocusRaw(seat: *Seat, new_focus: FocusTarget) void { | ||||
|             if (seat.cursor.constraint) |constraint| { | ||||
|                 assert(constraint.wlr_constraint == wlr_constraint); | ||||
|             } else { | ||||
|                 seat.cursor.constraint = @ptrFromInt(wlr_constraint.data); | ||||
|                 seat.cursor.constraint = @alignCast(@ptrCast(wlr_constraint.data)); | ||||
|                 assert(seat.cursor.constraint != null); | ||||
|             } | ||||
|         } | ||||
| @ -312,7 +312,7 @@ pub fn keyboardEnterOrLeave(seat: *Seat, target_surface: ?*wlr.Surface) void { | ||||
|  | ||||
| fn keyboardNotifyEnter(seat: *Seat, wlr_surface: *wlr.Surface) void { | ||||
|     if (seat.wlr_seat.getKeyboard()) |wlr_keyboard| { | ||||
|         const keyboard: *Keyboard = @ptrFromInt(wlr_keyboard.data); | ||||
|         const keyboard: *Keyboard = @alignCast(@ptrCast(wlr_keyboard.data)); | ||||
|  | ||||
|         var keycodes: std.BoundedArray(u32, Keyboard.Pressed.capacity) = .{}; | ||||
|         for (keyboard.pressed.keys.constSlice()) |item| { | ||||
|  | ||||
| @ -233,6 +233,8 @@ pub fn deinit(server: *Server) void { | ||||
|  | ||||
|     server.wl_server.destroyClients(); | ||||
|  | ||||
|     server.input_manager.new_input.link.remove(); | ||||
|     server.root.new_output.link.remove(); | ||||
|     server.backend.destroy(); | ||||
|  | ||||
|     // The scene graph needs to be destroyed after the backend but before the renderer | ||||
| @ -499,7 +501,7 @@ fn handleRequestSetCursorShape( | ||||
|     _: *wl.Listener(*wlr.CursorShapeManagerV1.event.RequestSetShape), | ||||
|     event: *wlr.CursorShapeManagerV1.event.RequestSetShape, | ||||
| ) void { | ||||
|     const seat: *Seat = @ptrFromInt(event.seat_client.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(event.seat_client.seat.data)); | ||||
|  | ||||
|     if (event.tablet_tool) |wp_tool| { | ||||
|         assert(event.device_type == .tablet_tool); | ||||
|  | ||||
| @ -69,7 +69,7 @@ fn handleRequest( | ||||
|         .get_river_output_status => |req| { | ||||
|             // ignore if the output is inert | ||||
|             const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return; | ||||
|             const output: *Output = @ptrFromInt(wlr_output.data); | ||||
|             const output: *Output = @alignCast(@ptrCast(wlr_output.data)); | ||||
|  | ||||
|             const resource = zriver.OutputStatusV1.create( | ||||
|                 status_manager_v1.getClient(), | ||||
| @ -86,7 +86,7 @@ fn handleRequest( | ||||
|         .get_river_seat_status => |req| { | ||||
|             // ignore if the seat is inert | ||||
|             const wlr_seat = wlr.Seat.Client.fromWlSeat(req.seat) orelse return; | ||||
|             const seat: *Seat = @ptrFromInt(wlr_seat.seat.data); | ||||
|             const seat: *Seat = @alignCast(@ptrCast(wlr_seat.seat.data)); | ||||
|  | ||||
|             const node = util.gpa.create(std.SinglyLinkedList(SeatStatus).Node) catch { | ||||
|                 status_manager_v1.getClient().postNoMemory(); | ||||
|  | ||||
| @ -59,7 +59,7 @@ set_cursor: wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor) = | ||||
|     wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor).init(handleSetCursor), | ||||
|  | ||||
| pub fn get(wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) error{OutOfMemory}!*TabletTool { | ||||
|     if (@as(?*TabletTool, @ptrFromInt(wlr_tool.data))) |tool| { | ||||
|     if (@as(?*TabletTool, @alignCast(@ptrCast(wlr_tool.data)))) |tool| { | ||||
|         return tool; | ||||
|     } else { | ||||
|         return TabletTool.create(wlr_seat, wlr_tool); | ||||
| @ -81,7 +81,7 @@ fn create(wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) error{OutOfMemory}!*Ta | ||||
|         .wlr_cursor = wlr_cursor, | ||||
|     }; | ||||
|  | ||||
|     wlr_tool.data = @intFromPtr(tool); | ||||
|     wlr_tool.data = tool; | ||||
|  | ||||
|     wlr_tool.events.destroy.add(&tool.destroy); | ||||
|     tool.wp_tool.events.set_cursor.add(&tool.set_cursor); | ||||
| @ -92,7 +92,7 @@ fn create(wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) error{OutOfMemory}!*Ta | ||||
| fn handleDestroy(listener: *wl.Listener(*wlr.TabletTool), _: *wlr.TabletTool) void { | ||||
|     const tool: *TabletTool = @fieldParentPtr("destroy", listener); | ||||
|  | ||||
|     tool.wp_tool.wlr_tool.data = 0; | ||||
|     tool.wp_tool.wlr_tool.data = null; | ||||
|  | ||||
|     tool.wlr_cursor.destroy(); | ||||
|  | ||||
|  | ||||
| @ -43,7 +43,7 @@ destroy: wl.Listener(*wlr.TextInputV3) = | ||||
|     wl.Listener(*wlr.TextInputV3).init(handleDestroy), | ||||
|  | ||||
| pub fn create(wlr_text_input: *wlr.TextInputV3) !void { | ||||
|     const seat: *Seat = @ptrFromInt(wlr_text_input.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(wlr_text_input.seat.data)); | ||||
|  | ||||
|     const text_input = try util.gpa.create(TextInput); | ||||
|  | ||||
| @ -64,7 +64,7 @@ pub fn create(wlr_text_input: *wlr.TextInputV3) !void { | ||||
|  | ||||
| fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { | ||||
|     const text_input: *TextInput = @fieldParentPtr("enable", listener); | ||||
|     const seat: *Seat = @ptrFromInt(text_input.wlr_text_input.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data)); | ||||
|  | ||||
|     if (text_input.wlr_text_input.focused_surface == null) { | ||||
|         log.err("client requested to enable text input without focus, ignoring request", .{}); | ||||
| @ -91,7 +91,7 @@ fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v | ||||
|  | ||||
| fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { | ||||
|     const text_input: *TextInput = @fieldParentPtr("commit", listener); | ||||
|     const seat: *Seat = @ptrFromInt(text_input.wlr_text_input.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data)); | ||||
|  | ||||
|     if (seat.relay.text_input != text_input) { | ||||
|         log.err("inactive text input tried to commit an update, client bug?", .{}); | ||||
| @ -105,7 +105,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v | ||||
|  | ||||
| fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { | ||||
|     const text_input: *TextInput = @fieldParentPtr("disable", listener); | ||||
|     const seat: *Seat = @ptrFromInt(text_input.wlr_text_input.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data)); | ||||
|  | ||||
|     if (seat.relay.text_input == text_input) { | ||||
|         seat.relay.disableTextInput(); | ||||
| @ -114,7 +114,7 @@ fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) | ||||
|  | ||||
| fn handleDestroy(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { | ||||
|     const text_input: *TextInput = @fieldParentPtr("destroy", listener); | ||||
|     const seat: *Seat = @ptrFromInt(text_input.wlr_text_input.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data)); | ||||
|  | ||||
|     if (seat.relay.text_input == text_input) { | ||||
|         seat.relay.disableTextInput(); | ||||
|  | ||||
| @ -34,7 +34,7 @@ request_mode: wl.Listener(*wlr.XdgToplevelDecorationV1) = | ||||
|     wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleRequestMode), | ||||
|  | ||||
| pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void { | ||||
|     const toplevel: *XdgToplevel = @ptrFromInt(wlr_decoration.toplevel.base.data); | ||||
|     const toplevel: *XdgToplevel = @alignCast(@ptrCast(wlr_decoration.toplevel.base.data)); | ||||
|  | ||||
|     toplevel.decoration = .{ .wlr_decoration = wlr_decoration }; | ||||
|     const decoration = &toplevel.decoration.?; | ||||
| @ -48,7 +48,7 @@ pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void { | ||||
| } | ||||
|  | ||||
| pub fn deinit(decoration: *XdgDecoration) void { | ||||
|     const toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data); | ||||
|     const toplevel: *XdgToplevel = @alignCast(@ptrCast(decoration.wlr_decoration.toplevel.base.data)); | ||||
|  | ||||
|     decoration.destroy.link.remove(); | ||||
|     decoration.request_mode.link.remove(); | ||||
| @ -72,7 +72,7 @@ fn handleRequestMode( | ||||
| ) void { | ||||
|     const decoration: *XdgDecoration = @fieldParentPtr("request_mode", listener); | ||||
|  | ||||
|     const toplevel: *XdgToplevel = @ptrFromInt(decoration.wlr_decoration.toplevel.base.data); | ||||
|     const toplevel: *XdgToplevel = @alignCast(@ptrCast(decoration.wlr_decoration.toplevel.base.data)); | ||||
|     const view = toplevel.view; | ||||
|  | ||||
|     const ssd = server.config.rules.ssd.match(toplevel.view) orelse | ||||
|  | ||||
| @ -100,8 +100,8 @@ pub fn create(wlr_toplevel: *wlr.XdgToplevel) error{OutOfMemory}!void { | ||||
|  | ||||
|     toplevel.view = view; | ||||
|  | ||||
|     wlr_toplevel.base.data = @intFromPtr(toplevel); | ||||
|     wlr_toplevel.base.surface.data = @intFromPtr(&view.tree.node); | ||||
|     wlr_toplevel.base.data = toplevel; | ||||
|     wlr_toplevel.base.surface.data = &view.tree.node; | ||||
|  | ||||
|     // Add listeners that are active over the toplevel's entire lifetime | ||||
|     wlr_toplevel.events.destroy.add(&toplevel.destroy); | ||||
| @ -216,7 +216,7 @@ fn handleDestroy(listener: *wl.Listener(void)) void { | ||||
|     toplevel.new_popup.link.remove(); | ||||
|  | ||||
|     // The wlr_surface may outlive the wlr_xdg_toplevel so we must clean up the user data. | ||||
|     toplevel.wlr_toplevel.base.surface.data = 0; | ||||
|     toplevel.wlr_toplevel.base.surface.data = null; | ||||
|  | ||||
|     const view = toplevel.view; | ||||
|     view.impl = .none; | ||||
| @ -235,7 +235,7 @@ fn handleMap(listener: *wl.Listener(void)) void { | ||||
|     toplevel.wlr_toplevel.events.set_title.add(&toplevel.set_title); | ||||
|     toplevel.wlr_toplevel.events.set_app_id.add(&toplevel.set_app_id); | ||||
|  | ||||
|     toplevel.wlr_toplevel.base.getGeometry(&toplevel.geometry); | ||||
|     toplevel.geometry = toplevel.wlr_toplevel.base.geometry; | ||||
|  | ||||
|     view.pending.box = .{ | ||||
|         .x = 0, | ||||
| @ -338,7 +338,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void { | ||||
|     switch (toplevel.configure_state) { | ||||
|         .idle, .committed, .timed_out => { | ||||
|             const old_geometry = toplevel.geometry; | ||||
|             toplevel.wlr_toplevel.base.getGeometry(&toplevel.geometry); | ||||
|             toplevel.geometry = toplevel.wlr_toplevel.base.geometry; | ||||
|  | ||||
|             const size_changed = toplevel.geometry.width != old_geometry.width or | ||||
|                 toplevel.geometry.height != old_geometry.height; | ||||
| @ -381,7 +381,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void { | ||||
|         // stashed buffer from when the transaction started. | ||||
|         .inflight => view.sendFrameDone(), | ||||
|         .acked, .timed_out_acked => { | ||||
|             toplevel.wlr_toplevel.base.getGeometry(&toplevel.geometry); | ||||
|             toplevel.geometry = toplevel.wlr_toplevel.base.geometry; | ||||
|  | ||||
|             if (view.inflight.resizing) { | ||||
|                 view.resizeUpdatePosition(toplevel.geometry.width, toplevel.geometry.height); | ||||
| @ -423,7 +423,7 @@ fn handleRequestMove( | ||||
|     event: *wlr.XdgToplevel.event.Move, | ||||
| ) void { | ||||
|     const toplevel: *XdgToplevel = @fieldParentPtr("request_move", listener); | ||||
|     const seat: *Seat = @ptrFromInt(event.seat.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(event.seat.seat.data)); | ||||
|     const view = toplevel.view; | ||||
|  | ||||
|     if (view.pending.fullscreen) return; | ||||
| @ -446,7 +446,7 @@ fn handleRequestMove( | ||||
|  | ||||
| fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), event: *wlr.XdgToplevel.event.Resize) void { | ||||
|     const toplevel: *XdgToplevel = @fieldParentPtr("request_resize", listener); | ||||
|     const seat: *Seat = @ptrFromInt(event.seat.seat.data); | ||||
|     const seat: *Seat = @alignCast(@ptrCast(event.seat.seat.data)); | ||||
|     const view = toplevel.view; | ||||
|  | ||||
|     if (view.pending.fullscreen) return; | ||||
|  | ||||
| @ -120,7 +120,7 @@ fn mapImpl(override_redirect: *XwaylandOverrideRedirect) error{OutOfMemory}!void | ||||
|         .override_redirect = override_redirect, | ||||
|     }); | ||||
|  | ||||
|     surface.data = @intFromPtr(&override_redirect.surface_tree.?.node); | ||||
|     surface.data = &override_redirect.surface_tree.?.node; | ||||
|  | ||||
|     override_redirect.surface_tree.?.node.setPosition( | ||||
|         override_redirect.xwayland_surface.x, | ||||
| @ -159,7 +159,7 @@ fn handleUnmap(listener: *wl.Listener(void)) void { | ||||
|  | ||||
|     override_redirect.set_geometry.link.remove(); | ||||
|  | ||||
|     override_redirect.xwayland_surface.surface.?.data = 0; | ||||
|     override_redirect.xwayland_surface.surface.?.data = null; | ||||
|     override_redirect.surface_tree.?.node.destroy(); | ||||
|     override_redirect.surface_tree = null; | ||||
|  | ||||
|  | ||||
| @ -164,7 +164,7 @@ pub fn handleMap(listener: *wl.Listener(void)) void { | ||||
|  | ||||
|     const xwayland_surface = xwayland_view.xwayland_surface; | ||||
|     const surface = xwayland_surface.surface.?; | ||||
|     surface.data = @intFromPtr(&view.tree.node); | ||||
|     surface.data = &view.tree.node; | ||||
|  | ||||
|     // Add listeners that are only active while mapped | ||||
|     xwayland_surface.events.set_title.add(&xwayland_view.set_title); | ||||
| @ -215,7 +215,7 @@ pub fn handleMap(listener: *wl.Listener(void)) void { | ||||
| fn handleUnmap(listener: *wl.Listener(void)) void { | ||||
|     const xwayland_view: *XwaylandView = @fieldParentPtr("unmap", listener); | ||||
|  | ||||
|     xwayland_view.xwayland_surface.surface.?.data = 0; | ||||
|     xwayland_view.xwayland_surface.surface.?.data = null; | ||||
|  | ||||
|     // Remove listeners that are only active while mapped | ||||
|     xwayland_view.set_title.link.remove(); | ||||
|  | ||||
| @ -109,7 +109,7 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output { | ||||
|                 .previous => link.prev.?, | ||||
|             }; | ||||
|         } | ||||
|         return @as(*Output, @fieldParentPtr("active_link", link)); | ||||
|         return @fieldParentPtr("active_link", link); | ||||
|     } else if (std.meta.stringToEnum(wlr.OutputLayout.Direction, str)) |direction| { // Spacial direction | ||||
|         var focus_box: wlr.Box = undefined; | ||||
|         server.root.output_layout.getBox(seat.focused_output.?.wlr_output, &focus_box); | ||||
| @ -121,7 +121,7 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output { | ||||
|             @floatFromInt(focus_box.x + @divTrunc(focus_box.width, 2)), | ||||
|             @floatFromInt(focus_box.y + @divTrunc(focus_box.height, 2)), | ||||
|         ) orelse return null; | ||||
|         return @as(*Output, @ptrFromInt(wlr_output.data)); | ||||
|         return @alignCast(@ptrCast(wlr_output.data)); | ||||
|     } else { | ||||
|         // Check if an output matches by name | ||||
|         var it = server.root.active_outputs.iterator(.forward); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user