forked from quickshell/quickshell
service/tray!: redesign menus / dbusmenu and add native menu support
Reworks dbusmenu menus to be displayable with a system context menu. Breaks the entire DBusMenu api.
This commit is contained in:
parent
c31bbea837
commit
ec362637b8
18 changed files with 898 additions and 191 deletions
|
@ -50,7 +50,9 @@ endfunction()
|
|||
|
||||
# -----
|
||||
|
||||
qt_add_library(quickshell-wayland STATIC)
|
||||
qt_add_library(quickshell-wayland STATIC
|
||||
platformmenu.cpp
|
||||
)
|
||||
|
||||
# required to make sure the constructor is linked
|
||||
add_library(quickshell-wayland-init OBJECT init.cpp)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <qtenvironmentvariables.h>
|
||||
|
||||
#include "../core/plugin.hpp"
|
||||
#include "platformmenu.hpp"
|
||||
|
||||
#ifdef QS_WAYLAND_WLR_LAYERSHELL
|
||||
#include "wlr_layershell.hpp"
|
||||
|
@ -26,6 +27,8 @@ class WaylandPlugin: public QuickshellPlugin {
|
|||
return isWayland;
|
||||
}
|
||||
|
||||
void init() override { installPlatformMenuHook(); }
|
||||
|
||||
void registerTypes() override {
|
||||
#ifdef QS_WAYLAND_WLR_LAYERSHELL
|
||||
qmlRegisterType<WaylandPanelInterface>("Quickshell._WaylandOverlay", 1, 0, "PanelWindow");
|
||||
|
|
32
src/wayland/platformmenu.cpp
Normal file
32
src/wayland/platformmenu.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "platformmenu.hpp"
|
||||
|
||||
#include <private/qwayland-xdg-shell.h>
|
||||
#include <qmargins.h>
|
||||
#include <qwindow.h>
|
||||
|
||||
#include "../core/platformmenu.hpp"
|
||||
|
||||
using namespace qs::menu::platform;
|
||||
using namespace QtWayland;
|
||||
|
||||
// fixes positioning of submenus when hitting screen edges
|
||||
void platformMenuHook(PlatformMenuQMenu* menu) {
|
||||
auto* window = menu->windowHandle();
|
||||
|
||||
auto constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_flip_x
|
||||
| QtWayland::xdg_positioner::constraint_adjustment_flip_y;
|
||||
|
||||
window->setProperty("_q_waylandPopupConstraintAdjustment", constraintAdjustment);
|
||||
|
||||
if (auto* containingMenu = menu->containingMenu) {
|
||||
auto geom = containingMenu->actionGeometry(menu->menuAction());
|
||||
|
||||
// use the first action to find the offsets relative to the containing window
|
||||
auto baseGeom = containingMenu->actionGeometry(containingMenu->actions().first());
|
||||
geom += QMargins(0, baseGeom.top(), 0, baseGeom.top());
|
||||
|
||||
window->setProperty("_q_waylandPopupAnchorRect", geom);
|
||||
}
|
||||
}
|
||||
|
||||
void installPlatformMenuHook() { PlatformMenuEntry::registerCreationHook(&platformMenuHook); }
|
3
src/wayland/platformmenu.hpp
Normal file
3
src/wayland/platformmenu.hpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void installPlatformMenuHook();
|
Loading…
Add table
Add a link
Reference in a new issue