///| Pure-MoonBit Wayland compositor host wiring WaylandServer, lib/wm, Breeze SSD, SceneGraph, and SoftwareRenderer. ///| pub(all) struct HostWindow { id : UInt64 mut title : String mut app_id : String mut geometry : @scene.Rect mut focused : Bool mut maximized : Bool mut fullscreen : Bool mut surface : @scene.ShmBufferSnapshot? /// A size change still to be sent to the client (coalesced while dragging a divider). mut cfg_dirty : Bool } ///| A client popup (xdg_popup): menus, combo lists, tooltips. pub(all) struct HostPopup { id : UInt64 parent : UInt64 /// Position relative to the parent's content origin. rx : Int ry : Int w : Int h : Int mut surface : @scene.ShmBufferSnapshot? } ///| pub(all) struct MoonPlasmaCompositor { /// Open popups, oldest first (the last is topmost). popups : Array[HostPopup] server : @wayland.WaylandServer wm : @wm.WmState theme : @scene.ThemeTokens output_w : Int output_h : Int work_area : @wm.Rect windows : Map[UInt64, HostWindow] damage : @scene.DamageTracker shell : @shell.DesktopShell mut ptr_x : Double mut ptr_y : Double mut ptr_win : UInt64? /// Divider being dragged between tiled windows. mut split_drag : @wm.SplitHandle? /// True while a button press was forwarded to a client (so its release is too). mut press_fwd : Bool mut kbd_win : UInt64? mut mods : UInt /// A Super key is down and nothing else was pressed since: releasing it opens the launcher. mut super_solo : Bool mut layout_mode : @wm.LayoutMode } ///| pub fn MoonPlasmaCompositor::new( socket_path : String, theme : @scene.ThemeTokens, output_w : Int, output_h : Int, ) -> MoonPlasmaCompositor? { ignore(@font.install()) // Adwaita Mono; keeps the bitmap font if it's missing let server = match @wayland.WaylandServer::listen(socket_path, output_w, output_h) { Some(s) => s None => return None } let wm = @wm.WmState::new( inner_gap=8, outer_gap=8, titlebar_h=32, border_w=2, ) let out_rect : @wm.Rect = { x: 0, y: 0, w: output_w, h: output_h } let work_area = @wm.compute_work_area( out_rect, excl_top=32, // room for the server-side title bar drawn above each client excl_bottom=theme.panel_height, ) let shell = @shell.DesktopShell::new(socket_path) shell.set_output(theme, output_w, output_h) Some({ server, wm, theme, output_w, output_h, work_area, windows: {}, damage: @scene.DamageTracker::new(), shell, ptr_x: 0.0, ptr_y: 0.0, popups: [], ptr_win: None, split_drag: None, press_fwd: false, kbd_win: None, mods: 0U, super_solo: false, layout_mode: @wm.LayoutMode::Tiling, }) } ///| pub fn MoonPlasmaCompositor::close(self : MoonPlasmaCompositor) -> Unit { self.shell.shutdown() self.server.close() } ///| fn MoonPlasmaCompositor::apply_actions( self : MoonPlasmaCompositor, actions : Array[@wm.WmAction], ) -> Unit { for act in actions { match act { @wm.WmAction::SetGeometry(wid, r) => match self.windows.get(wid) { Some(win) => { win.geometry = @scene.Rect::new(r.x, r.y, r.w, r.h) if self.split_drag is Some(_) { // Dragging: send one configure per frame, not one per mouse event. win.cfg_dirty = true } else { win.cfg_dirty = false self.server.send_toplevel_configure( wid, r.w, r.h, win.focused, win.maximized, win.fullscreen, ) } self.damage.mark_full() } None => () } @wm.WmAction::Focus(wid) => { for id, w in self.windows { w.focused = id == wid } self.set_kbd_focus(Some(wid)) self.damage.mark_full() } @wm.WmAction::Raise(_) => self.damage.mark_full() @wm.WmAction::Close(wid) => self.server.send_toplevel_close(wid) @wm.WmAction::SetMaximized(wid, m) => match self.windows.get(wid) { Some(win) => win.maximized = m None => () } @wm.WmAction::SetFullscreen(wid, f) => match self.windows.get(wid) { Some(win) => win.fullscreen = f None => () } } } } ///| Send the size changes coalesced during a divider drag. fn MoonPlasmaCompositor::flush_configures(self : MoonPlasmaCompositor) -> Unit { for wid, win in self.windows { if win.cfg_dirty { win.cfg_dirty = false self.server.send_toplevel_configure( wid, win.geometry.w, win.geometry.h, win.focused, win.maximized, win.fullscreen, ) } } } ///| pub fn MoonPlasmaCompositor::step(self : MoonPlasmaCompositor) -> Unit { self.flush_configures() let events = self.server.poll_events() for ev in events { match ev { @wayland.CompositorEvent::ToplevelOpened(wid, app_id, title, min_w, min_h) => { let win : HostWindow = { id: wid, title, app_id, geometry: @scene.Rect::new(100, 100, 640, 480), focused: true, maximized: false, fullscreen: false, surface: None, cfg_dirty: false, } self.windows.set(wid, win) let rec : @wm.WindowRecord = { id: wid, app_id, title, geometry: { x: 100, y: 100, w: 640, h: 480 }, floating_geometry: { x: 100, y: 100, w: 640, h: 480 }, min_size: { w: min_w, h: min_h }, max_size: None, focused: true, maximized: false, fullscreen: false, minimized: false, is_floating: false, workspace: 0U, can_move: true, can_resize: true, can_maximize: true, can_minimize: true, can_fullscreen: true, } let actions = self.wm.open_window(rec, self.work_area) self.apply_actions(actions) } @wayland.CompositorEvent::ToplevelUpdated(wid, app_id, title) => match self.windows.get(wid) { Some(win) => { if app_id.length() > 0 { win.app_id = app_id } if title.length() > 0 { win.title = title } self.damage.mark_full() } None => () } @wayland.CompositorEvent::ToplevelCommitted(wid, snap) => match self.windows.get(wid) { Some(win) => { match snap { Some(s) => { win.surface = Some(s) self.damage.mark_rect(win.geometry) } None => () } } None => () } @wayland.CompositorEvent::PopupOpened(wid, parent, rx, ry, w, h) => { self.popups.push({ id: wid, parent, rx, ry, w, h, surface: None }) self.set_kbd_focus(Some(wid)) } @wayland.CompositorEvent::PopupCommitted(wid, snap) => for p in self.popups { if p.id == wid { match snap { Some(_) => p.surface = snap None => () } self.damage.mark_full() } } @wayland.CompositorEvent::PopupClosed(wid) => self.close_popup(wid) @wayland.CompositorEvent::ToplevelClosed(wid) => { self.close_popup(wid) ignore(self.windows.remove(wid)) if self.ptr_win == Some(wid) { self.ptr_win = None } if self.kbd_win == Some(wid) { self.kbd_win = None } let actions = self.wm.close_window(wid, self.work_area) self.apply_actions(actions) } @wayland.CompositorEvent::ToplevelMaximizeRequest(wid, m) => { let actions = self.wm.handle_request( wid, @wm.WindowRequest::Maximize(m), self.work_area, ) self.apply_actions(actions) } @wayland.CompositorEvent::ToplevelFullscreenRequest(wid, f) => { let actions = self.wm.handle_request( wid, @wm.WindowRequest::Fullscreen(f), self.work_area, ) self.apply_actions(actions) } @wayland.CompositorEvent::ToplevelMinimizeRequest(wid, m) => { let actions = self.wm.handle_request( wid, @wm.WindowRequest::Minimize(m), self.work_area, ) self.apply_actions(actions) } @wayland.CompositorEvent::ToplevelMoveRequest(_) => () } } } ///| pub fn MoonPlasmaCompositor::set_layout_mode( self : MoonPlasmaCompositor, mode : @wm.LayoutMode, ) -> Unit { self.layout_mode = mode let actions = self.wm.set_layout_mode(mode, self.work_area) self.apply_actions(actions) } ///| pub fn MoonPlasmaCompositor::compose_frame( self : MoonPlasmaCompositor, ) -> @renderer.Pixmap { self.flush_configures() let scene = @scene.SceneGraph::new(self.output_w, self.output_h) let order = self.wm.stacking_order() for wid in order { match self.windows.get(wid) { Some(win) => { let (insets, deco_ops) = @scene.build_breeze_decoration( win.title, win.app_id, win.focused, win.fullscreen, win.geometry.w + 4, win.geometry.h + 34, self.theme, ) scene.windows.push({ id: win.id, title: win.title, app_id: win.app_id, focused: win.focused, fullscreen: win.fullscreen, geometry: win.geometry, deco_insets: insets, deco_ops, surface: win.surface, }) } None => () } } for p in self.popups { match p.surface { Some(snap) => scene.popups.push((self.popup_rect(p), snap)) None => () } } self.shell.layout_sel = match self.layout_mode { @wm.LayoutMode::Tiling => 0 @wm.LayoutMode::Monocle => 1 @wm.LayoutMode::Floating => 2 } // The task list shows every window, minimized ones too (so they can be restored). let wins : Array[@shell.WinInfo] = [] for wid in order { match self.windows.get(wid) { Some(win) => wins.push({ id: win.id, title: if win.title.length() > 0 { win.title } else { win.app_id }, focused: win.focused, minimized: false, }) None => () } } for id, r in self.wm.windows { if r.minimized { match self.windows.get(id) { Some(win) => wins.push({ id, title: if win.title.length() > 0 { win.title } else { win.app_id }, focused: false, minimized: true, }) None => () } } } self.shell.windows = wins // The window list the `windows` interface serves to wasm widgets (task-bar order). let entries : Array[@wasm.WindowEntry] = [] for w in wins { match self.windows.get(w.id) { Some(win) => entries.push({ id: w.id, title: w.title, app_id: win.app_id, focused: w.focused }) None => () } } self.shell.win_list = entries let (bg_ops, panel_ops) = self.shell.render(self.output_w, self.output_h, self.theme) self.run_shell_actions() scene.background_ops = bg_ops scene.panel_ops = panel_ops ignore(self.damage.take_damage(self.output_w, self.output_h)) @renderer.render_scene(scene) } ///| /// Compose the current desktop GUI frame and present it onto a wasi-gfx /// `SurfaceFrameBufferContext`. pub fn MoonPlasmaCompositor::present_to_gfx( self : MoonPlasmaCompositor, ctx : @gfx.SurfaceFrameBufferContext, ) -> @renderer.Pixmap { let pixmap = self.compose_frame() @gfx.present_pixmap(ctx, pixmap) pixmap } ///| /// Process pending wasi-gfx surface input events (pointer clicks for focus). pub fn MoonPlasmaCompositor::handle_gfx_events( self : MoonPlasmaCompositor, surface : @gfx.Surface, ) -> Unit { let downs = surface.drain_pointer_down() for ev in downs { let px = ev.x.to_int() let py = ev.y.to_int() let order = self.wm.stacking_order() // Top-most window hit-test (iterate reverse Z-order). let mut i = order.length() - 1 while i >= 0 { let wid = order[i] match self.windows.get(wid) { Some(win) => if px >= win.geometry.x && px < win.geometry.x + win.geometry.w && py >= win.geometry.y - 32 && py < win.geometry.y + win.geometry.h { self.apply_actions([ @wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid), ]) break } None => () } i = i - 1 } } } ///| Content origin of a window or popup. fn MoonPlasmaCompositor::origin_of(self : MoonPlasmaCompositor, wid : UInt64) -> (Int, Int) { match self.windows.get(wid) { Some(win) => (win.geometry.x, win.geometry.y) None => { for p in self.popups { if p.id == wid { let r = self.popup_rect(p) return (r.x, r.y) } } (0, 0) } } } ///| Absolute rectangle of a popup, nudged to stay on screen. fn MoonPlasmaCompositor::popup_rect(self : MoonPlasmaCompositor, p : HostPopup) -> @scene.Rect { let (w, h) = match p.surface { Some(s) => (s.width, s.height) None => (p.w, p.h) } let (bx, by) = self.origin_of_parent(p) let x = bx + p.rx let y = by + p.ry let x = if x + w > self.output_w { self.output_w - w } else { x } let y = if y + h > self.output_h { self.output_h - h } else { y } @scene.Rect::new(if x < 0 { 0 } else { x }, if y < 0 { 0 } else { y }, w, h) } ///| fn MoonPlasmaCompositor::origin_of_parent(self : MoonPlasmaCompositor, p : HostPopup) -> (Int, Int) { if p.parent == p.id { (0, 0) } else { self.origin_of(p.parent) } } ///| Top-most popup under (x, y). fn MoonPlasmaCompositor::popup_at(self : MoonPlasmaCompositor, x : Int, y : Int) -> HostPopup? { let mut i = self.popups.length() - 1 while i >= 0 { let p = self.popups[i] let r = self.popup_rect(p) if p.surface is Some(_) && x >= r.x && x < r.x + r.w && y >= r.y && y < r.y + r.h { return Some(p) } i = i - 1 } None } ///| The toplevel a popup chain hangs off (for returning keyboard focus). fn MoonPlasmaCompositor::popup_root(self : MoonPlasmaCompositor, wid : UInt64) -> UInt64? { let mut cur = wid let mut n = 0 while n < 16 { if self.windows.contains(cur) { return Some(cur) } let mut next : UInt64? = None for p in self.popups { if p.id == cur { next = Some(p.parent) } } match next { Some(x) => cur = x None => return None } n = n + 1 } None } ///| Forget a popup (and any popups hanging off it); give keyboard focus back to its window. fn MoonPlasmaCompositor::close_popup(self : MoonPlasmaCompositor, wid : UInt64) -> Unit { let mut found = false for p in self.popups { if p.id == wid { found = true } } if !found { return } let root = self.popup_root(wid) let keep = self.popups.filter(p => p.id != wid) self.popups.clear() for p in keep { self.popups.push(p) } self.damage.mark_full() if self.ptr_win == Some(wid) { self.ptr_win = None } if self.kbd_win == Some(wid) { self.kbd_win = None match self.popups.last() { Some(top) => self.set_kbd_focus(Some(top.id)) None => self.set_kbd_focus(root) } } } ///| Send pointer enter/motion for a popup under the pointer. fn MoonPlasmaCompositor::pointer_into_popup(self : MoonPlasmaCompositor, p : HostPopup, time_ms : UInt, motion : Bool) -> Unit { let r = self.popup_rect(p) let lx = self.ptr_x - r.x.to_double() let ly = self.ptr_y - r.y.to_double() if self.ptr_win != Some(p.id) { self.leave_pointer() self.ptr_win = Some(p.id) self.server.pointer_enter(p.id, lx, ly) } if motion { self.server.pointer_motion(p.id, time_ms, lx, ly) } } ///| Move keyboard focus (wl_keyboard leave/enter + current modifiers). fn MoonPlasmaCompositor::set_kbd_focus(self : MoonPlasmaCompositor, wid : UInt64?) -> Unit { if self.kbd_win == wid { return } match self.kbd_win { Some(old) => self.server.keyboard_leave(old) None => () } self.kbd_win = wid match wid { Some(w) => { self.server.keyboard_enter(w) self.server.keyboard_modifiers(w, self.mods, 0U, 0U, 0U) } None => () } } ///| Top-most window under (x, y): (id, in client area). The titlebar counts as the window but not the client. fn MoonPlasmaCompositor::window_at(self : MoonPlasmaCompositor, x : Int, y : Int) -> (UInt64, Bool)? { let order = self.wm.stacking_order() let mut i = order.length() - 1 while i >= 0 { match self.windows.get(order[i]) { Some(win) => { let g = win.geometry if x >= g.x && x < g.x + g.w && y >= g.y && y < g.y + g.h { return Some((win.id, true)) } if x >= g.x - 2 && x < g.x + g.w + 2 && y >= g.y - 32 && y < g.y { return Some((win.id, false)) } } None => () } i = i - 1 } None } ///| Title-bar button under (x, y) for window `wid`: 1 minimize, 2 maximize, 3 close, 0 none. /// Mirrors the layout in `build_breeze_decoration` (18px buttons, 8px apart, 10px from the right edge). fn MoonPlasmaCompositor::title_button_at( self : MoonPlasmaCompositor, wid : UInt64, x : Int, y : Int, ) -> Int { match self.windows.get(wid) { None => 0 Some(win) => { let g = win.geometry let outer_w = g.w + 4 let lx = x - (g.x - 2) let ly = y - (g.y - 32) let size = 18 let by = (32 - size) / 2 if ly < by - 3 || ly >= by + size + 3 { return 0 } let close_x = outer_w - 10 - size let max_x = close_x - 8 - size let min_x = max_x - 8 - size if lx >= close_x - 3 && lx < close_x + size + 3 { 3 } else if lx >= max_x - 3 && lx < max_x + size + 3 { 2 } else if lx >= min_x - 3 && lx < min_x + size + 3 { 1 } else { 0 } } } } ///| Activate the title-bar button `btn` of window `wid`. fn MoonPlasmaCompositor::press_title_button( self : MoonPlasmaCompositor, wid : UInt64, btn : Int, ) -> Unit { self.leave_pointer() let req = match btn { 1 => @wm.WindowRequest::Minimize(true) 2 => { let maxed = match self.wm.windows.get(wid) { Some(r) => r.maximized None => false } @wm.WindowRequest::Maximize(!maxed) } _ => @wm.WindowRequest::Close } self.apply_actions(self.wm.handle_request(wid, req, self.work_area)) if btn == 1 { // Hand focus to the top-most remaining window. let order = self.wm.stacking_order() if order.length() > 0 { let top = order[order.length() - 1] self.apply_actions([@wm.WmAction::Focus(top), @wm.WmAction::Raise(top)]) } else { self.set_kbd_focus(None) } } self.damage.mark_full() } ///| Restore a minimized window (or focus a visible one) from its task-bar pill. fn MoonPlasmaCompositor::activate_task(self : MoonPlasmaCompositor, wid : UInt64) -> Unit { let minimized = match self.wm.windows.get(wid) { Some(r) => r.minimized None => return } if minimized { self.apply_actions( self.wm.handle_request(wid, @wm.WindowRequest::Minimize(false), self.work_area), ) } self.apply_actions([@wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid)]) } ///| Carry out what panel modules asked for: focus a window, switch layout. fn MoonPlasmaCompositor::run_shell_actions(self : MoonPlasmaCompositor) -> Unit { for a in self.shell.take_actions() { match a { @shell.ShellAction::FocusWindow(wid) => self.activate_task(wid) @shell.ShellAction::SetLayout(m) => match m { 0 => self.set_layout_mode(@wm.LayoutMode::Tiling) 1 => self.set_layout_mode(@wm.LayoutMode::Monocle) 2 => self.set_layout_mode(@wm.LayoutMode::Floating) _ => () } } } } ///| Tiling divider under (x, y), with a few pixels of slack either side. fn MoonPlasmaCompositor::handle_at( self : MoonPlasmaCompositor, x : Int, y : Int, ) -> @wm.SplitHandle? { let slop = 3 for h in self.wm.split_handles(self.work_area) { let r = h.rect // Title bars sit 32px above the windows, so the hit area reaches up over them. let hit = if h.horizontal { x >= r.x - slop && x < r.x + r.w + slop && y >= r.y - 32 && y < r.y + r.h } else { y >= r.y - slop && y < r.y + r.h + slop && x >= r.x && x < r.x + r.w } if hit { return Some(h) } } None } ///| fn MoonPlasmaCompositor::leave_pointer(self : MoonPlasmaCompositor) -> Unit { match self.ptr_win { Some(w) => { self.server.pointer_leave(w) self.ptr_win = None } None => () } } ///| evdev keycode -> the key name lib/launcher understands (US layout). fn key_name(code : UInt, shift : Bool) -> String { let rows = [ (16U, "qwertyuiop"), (30U, "asdfghjkl"), (44U, "zxcvbnm"), (2U, "1234567890"), ] for r in rows { let (first, chars) = r if code >= first && code < first + chars.length().reinterpret_as_uint() { let c = Int::unsafe_to_char(chars[(code - first).reinterpret_as_int()].to_int()) return if shift && c >= 'a' && c <= 'z' { Int::unsafe_to_char(c.to_int() - 32).to_string() } else { c.to_string() } } } match code { 1U => "Escape" 14U => "Backspace" 28U => "Enter" 57U => " " 12U => "-" 52U => "." 53U => "/" _ => "" } } ///| Route host input: shell (launcher) first, then the window under the pointer /// / the keyboard-focused window. pub fn MoonPlasmaCompositor::handle_input( self : MoonPlasmaCompositor, ev : @nested.InputEvent, time_ms : UInt, ) -> Unit { match ev { PointerMove(x, y) => { self.ptr_x = x self.ptr_y = y let xi = x.to_int() let yi = y.to_int() match self.popup_at(xi, yi) { Some(p) => { self.pointer_into_popup(p, time_ms, true) return } None => () } if self.shell.inspecting() { self.leave_pointer() let id = match self.shell.component_at(xi, yi) { "" => match self.window_at(xi, yi) { Some((_, true)) => "window-surface" Some((_, false)) => "window-decoration" None => "desktop" } sid => sid } self.shell.set_hover(id, xi, yi) return } if self.shell.pointer_move(xi, yi) || self.shell.hit(xi, yi) { self.leave_pointer() return } match self.split_drag { Some(h) => { self.apply_actions(self.wm.drag_split(h, xi, yi, self.work_area)) return } None => () } if self.handle_at(xi, yi) is Some(_) { self.leave_pointer() return } match self.split_drag { Some(h) => { self.apply_actions(self.wm.drag_split(h, xi, yi, self.work_area)) return } None => () } if self.handle_at(xi, yi) is Some(_) { self.leave_pointer() return } match self.window_at(xi, yi) { Some((wid, true)) => match self.windows.get(wid) { Some(win) => { let lx = x - win.geometry.x.to_double() let ly = y - win.geometry.y.to_double() if self.ptr_win != Some(wid) { self.leave_pointer() self.ptr_win = Some(wid) self.server.pointer_enter(wid, lx, ly) } self.server.pointer_motion(wid, time_ms, lx, ly) } None => () } _ => self.leave_pointer() } } Scroll(v) => { // ~10 units per wheel notch -> 3 lines. let lines = if v > 0.0 { (v / 10.0).to_int() + 1 } else { (v / 10.0).to_int() - 1 } ignore(self.shell.scroll_inspector(lines)) } PointerButton(button, pressed) => { let xi = self.ptr_x.to_int() let yi = self.ptr_y.to_int() match self.popup_at(xi, yi) { Some(p) => { self.pointer_into_popup(p, time_ms, false) if pressed { self.press_fwd = true self.server.pointer_button(p.id, time_ms, button, true) } else if self.press_fwd { self.press_fwd = false self.server.pointer_button(p.id, time_ms, button, false) } return } None => () } if pressed && self.popups.length() > 0 { // A click outside the open popups dismisses them (the click is swallowed). let mut i = self.popups.length() - 1 while i >= 0 { self.server.popup_done(self.popups[i].id) i = i - 1 } return } if !pressed && self.shell.pointer_up() { self.run_shell_actions() return } if !pressed && self.split_drag is Some(_) { self.split_drag = None return } // Right button over a swappable panel widget opens its alternatives menu. if button == 273U && pressed && self.shell.right_click(xi, yi) { return } if pressed { self.super_solo = false if button != 273U && self.shell.pointer_down(xi, yi) { self.run_shell_actions() return } match self.window_at(xi, yi) { Some((wid, false)) => { let btn = self.title_button_at(wid, xi, yi) if btn != 0 { self.press_title_button(wid, btn) return } } _ => () } match self.handle_at(xi, yi) { Some(h) => { self.split_drag = Some(h) self.leave_pointer() return } None => () } match self.handle_at(xi, yi) { Some(h) => { self.split_drag = Some(h) self.leave_pointer() return } None => () } if self.window_at(xi, yi) is None && self.shell.desk_press(xi, yi) { self.leave_pointer() return } match self.window_at(xi, yi) { Some((wid, _)) => { self.apply_actions([ @wm.WmAction::Focus(wid), @wm.WmAction::Raise(wid), ]) } None => () } } match self.ptr_win { Some(w) => if pressed { self.press_fwd = true self.server.pointer_button(w, time_ms, button, pressed) } else if self.press_fwd { self.press_fwd = false self.server.pointer_button(w, time_ms, button, pressed) } None => () } } Key(code, pressed) => if code == 125U || code == 126U { // Super (left/right): a bare tap toggles the launcher search; never reaches clients. if pressed { self.super_solo = true } else if self.super_solo { self.super_solo = false if !self.shell.inspecting() { self.shell.toggle_launcher() } } } else if self.shell.inspecting() { self.super_solo = false // Escape leaves inspect mode; other keys are not forwarded while inspecting. if code == 1U && pressed { self.shell.set_inspecting(false) } } else if self.shell.popup_open() { self.super_solo = false if pressed { let name = key_name(code, (self.mods & 1U) != 0U) if name.length() > 0 { self.shell.key_down(name) } } } else { self.super_solo = false match self.kbd_win { Some(w) => self.server.keyboard_key(w, time_ms, code, pressed) None => () } } Modifiers(dep, lat, lock, group) => { self.mods = dep match self.kbd_win { Some(w) => self.server.keyboard_modifiers(w, dep, lat, lock, group) None => () } } } } ///| Cursor shape (wp_cursor_shape_v1 value) for the current pointer position: shell UI /// decides over the launcher; a client window decides inside its client area; otherwise default. pub fn MoonPlasmaCompositor::desired_cursor(self : MoonPlasmaCompositor) -> UInt { let shell_shape = self.shell.cursor_at(self.ptr_x.to_int(), self.ptr_y.to_int()) if shell_shape != 0U { return shell_shape } let handle = match self.split_drag { Some(h) => Some(h) None => self.handle_at(self.ptr_x.to_int(), self.ptr_y.to_int()) } match handle { Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize None => () } let handle = match self.split_drag { Some(h) => Some(h) None => self.handle_at(self.ptr_x.to_int(), self.ptr_y.to_int()) } match handle { Some(h) => return if h.horizontal { 26U } else { 27U } // ew-resize / ns-resize None => () } if self.ptr_win is None && self.shell.desk_hit(self.ptr_x.to_int(), self.ptr_y.to_int()) && self.window_at(self.ptr_x.to_int(), self.ptr_y.to_int()) is None { return 4U // the desktop card can be dragged } match self.ptr_win { Some(w) => self.server.client_cursor_shape(w) None => 1U } }