Re: Third-party dock (C++): how to support AutoHide (Screen Edge) and Global Shortcuts ?

Vlad Zahorodnii <[email protected]> Mon, 21 Oct 2024 12:19:36 +0300
Newsgroups gmane.comp.kde.devel.kwin
Message-ID <[email protected]>
Hi,

On 10/18/24 11:03 PM, Viet Dang wrote:
> Hi,
>
> I'm working on some improvements of my third-party dock (written in 
> C++ here: https://github.com/dangvd/crystal-dock) and have some 
> questions about AutoHide (Screen Edge) and Global Shortcuts support in 
> KWin:
> - AutoHide: I'd like to get my dock to have an AutoHide behaviour like 
> that of a Plasma panel. Is Screen Edge protocol 
> (https://wayland.app/protocols/kde-screen-edge-v1) the right one to 
> use? And if it is, what's the best way to get wl_surface object from 
> my main widget? (I already use layer-shell-qt for my main widget)

You could use the QNativeInterface API to access the wl_surface object. 
See 
https://invent.kde.org/plasma/kwin/-/blob/3740a1b52adc1e5dcaa13320e28bf988e9fb5aec/src/helpers/killer/killer.cpp#L298 
for an example how to do it.

> - Global Shortcuts: how do I support global shortcuts for my dock 
> (e.g. Meta-1 to activate launcher 1 and so on). Is xdg-desktop-portal 
> (https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.GlobalShortcuts.xml) 
> the right one to use?

That, or if you know that the dock will run mostly in Plasma, you could 
use KGlobalAccel to save yourself some time.

Regards,
Vlad