Pass single click from GtkWindowHandle to overlaid widget

Hi, I’m trying to get this idea working in order to implement CSD in Electron. A WindowHandle with WindowControls is put into an Overlay alongside the window contents. The intention is to pass single clicks through the handle to the contents. Details apart, I have this POF code that mostly works:

import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk


def activate(app):
    win = Gtk.ApplicationWindow(application=app)
    button = Gtk.Button(label="Click me")
    button.connect("clicked", lambda *_: print("Clicked"))
    ctrls = Gtk.WindowControls(side=Gtk.PackType.END)
    ctrls.set_halign(Gtk.Align.END)
    handle = Gtk.WindowHandle()
    handle.set_valign(Gtk.Align.START)
    handle.set_child(ctrls)
    gesture = Gtk.GestureClick()
    gesture.connect("released", lambda *_: button.emit("clicked"))
    handle.add_controller(gesture)
    over = Gtk.Overlay()
    over.add_overlay(button)
    over.add_overlay(handle)
    win.set_child(over)
    win.show()

app = Gtk.Application()
app.connect("activate", activate)
app.run()

But I’m unable to solve the following problem: when I get a press/release event it might be the only one in a single click sequence or it might be the first one in a double click sequence, since double clicks are claimed by WindowHandle my controller never gets them and it’s not able to tell one situation from the other. At first I thought that handling “stopped” signals instead would help, but at that point my handler doesn’t get the n_press argument. So I’m quite lost at this point.

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.