Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow layer click-through #245

Merged
merged 7 commits into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/widgets/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=3.0';
import GLib from 'gi://GLib?version=2.0';
import Gdk from 'gi://Gdk?version=3.0';
import Cairo from 'gi://cairo?version=1.0';
import Service, { kebabify, Props, BindableProps, Binding } from '../service.js';
import { registerGObject } from '../gobject.js';
import { interval } from '../utils.js';
Expand Down Expand Up @@ -83,6 +84,7 @@ export type BaseProps<Self extends Gtk.Widget, Props> = {
} & BindableProps<Props & {
class_name?: string
class_names?: string[]
click_through?: boolean
css?: string
hpack?: Align
vpack?: Align
Expand Down Expand Up @@ -217,6 +219,7 @@ export default function AgsWidget<
'cursor': ['string', 'rw'],
'is-destroyed': ['boolean', 'r'],
'attribute': ['jsobject', 'rw'],
'click-through': ['boolean', 'rw'],

// FIXME: deprecated
'properties': ['jsobject', 'w'],
Expand Down Expand Up @@ -492,5 +495,16 @@ export default function AgsWidget<

return x > 0 && x < w && y > 0 && y < h;
}

get click_through() { return !!this._get('click-through'); }
set click_through(clickThrough: boolean) {
if (this.click_through === clickThrough)
return;

const value = clickThrough ? new Cairo.Region : null;
this.input_shape_combine_region(value);
this._set('click-through', value);
this.notify('click-through');
}
};
}