From 710e419986b671dbe02021f19e9fe94e0d17ccb3 Mon Sep 17 00:00:00 2001 From: Aylur Date: Wed, 26 Jun 2024 02:20:59 +0200 Subject: feat: widget click through --- gjs/src/astalify.ts | 11 +++++++++++ lua/astal/widget.lua | 5 +++++ src/widget/widget.vala | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/gjs/src/astalify.ts b/gjs/src/astalify.ts index 6c74179..f198f68 100644 --- a/gjs/src/astalify.ts +++ b/gjs/src/astalify.ts @@ -67,6 +67,7 @@ export type Widget = InstanceType & { onDestroy?: (self: Widget) => unknown onDraw?: (self: Widget) => unknown diff --git a/lua/astal/widget.lua b/lua/astal/widget.lua index f38cdb9..d2dadc6 100644 --- a/lua/astal/widget.lua +++ b/lua/astal/widget.lua @@ -259,6 +259,11 @@ Gtk.Widget._attribute.cursor = { set = Astal.widget_set_cursor, } +Gtk.Widget._attribute.click_through = { + get = Astal.widget_get_click_through, + set = Astal.widget_set_click_through, +} + Astal.Box._attribute.children = { get = Astal.Box.get_children, set = Astal.Box.set_children, diff --git a/src/widget/widget.vala b/src/widget/widget.vala index de5ba00..2506bc8 100644 --- a/src/widget/widget.vala +++ b/src/widget/widget.vala @@ -131,4 +131,27 @@ public void widget_set_cursor(Gtk.Widget widget, string cursor) { public string widget_get_cursor(Gtk.Widget widget) { return Cursor.cursors.get(widget); } + +private class ClickThrough { + private static HashTable _click_through; + public static HashTable click_through { + get { + if (_click_through == null) { + _click_through = new HashTable( + (w) => (uint)w, + (a, b) => a == b); + } + return _click_through; + } + } +} + +public void widget_set_click_through(Gtk.Widget widget, bool click_through) { + ClickThrough.click_through.set(widget, click_through); + widget.input_shape_combine_region(click_through ? new Cairo.Region() : null); +} + +public bool widget_get_click_through(Gtk.Widget widget) { + return ClickThrough.click_through.get(widget); +} } -- cgit v1.2.3