forked from openkylin/ukui-menu
1.新增带参数启动应用程序功能,2.适配窗管无边框及窗口模糊
This commit is contained in:
parent
8bc2709564
commit
4789475b51
|
@ -37,6 +37,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
UkuiMenu::UkuiMenuApplication menuApplication(&messageProcessor);
|
UkuiMenu::UkuiMenuApplication menuApplication(&messageProcessor);
|
||||||
|
messageProcessor.processMessage(app.instanceId(), SingleApplication::arguments().join(" ").toUtf8());
|
||||||
QObject::connect(&app, &SingleApplication::receivedMessage,
|
QObject::connect(&app, &SingleApplication::receivedMessage,
|
||||||
&messageProcessor, &UkuiMenu::MenuMessageProcessor::processMessage);
|
&messageProcessor, &UkuiMenu::MenuMessageProcessor::processMessage);
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,14 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
|
#include <KWindowEffects>
|
||||||
|
|
||||||
#include <kysdk/applications/waylandhelper.h>
|
// kysdk
|
||||||
#include <kysdk/applications/windowmanager/windowmanager.h>
|
#include <kysdk/applications/windowmanager/windowmanager.h>
|
||||||
|
#include <kysdk/applications/ukuistylehelper/ukui-decoration-manager.h>
|
||||||
|
|
||||||
|
// x11
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#define UKUI_PANEL_SETTING "org.ukui.panel.settings"
|
#define UKUI_PANEL_SETTING "org.ukui.panel.settings"
|
||||||
#define UKUI_PANEL_POSITION_KEY "panelposition"
|
#define UKUI_PANEL_POSITION_KEY "panelposition"
|
||||||
|
@ -36,6 +41,19 @@
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
|
||||||
|
struct MotifWmHints {
|
||||||
|
ulong flags = 0;
|
||||||
|
ulong functions = 0;
|
||||||
|
ulong decorations = 0;
|
||||||
|
long input_mode = 0;
|
||||||
|
ulong status = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
||||||
|
#define MWM_HINTS_DECORATIONS (1L << 1)
|
||||||
|
#define MWM_FUNC_ALL (1L << 0)
|
||||||
|
#define MWM_DECOR_BORDER (1L << 1)
|
||||||
|
|
||||||
void WindowModule::defineModule(const char *uri, int versionMajor, int versionMinor)
|
void WindowModule::defineModule(const char *uri, int versionMajor, int versionMinor)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
@ -90,6 +108,36 @@ void WindowHelper::setWindowAttribute(QWindow *window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowHelper::removeHeaderBar(QWindow *window)
|
||||||
|
{
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QX11Info::isPlatformX11()) {
|
||||||
|
MotifWmHints hints;
|
||||||
|
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||||
|
hints.functions = MWM_FUNC_ALL;
|
||||||
|
hints.decorations = MWM_DECOR_BORDER;
|
||||||
|
|
||||||
|
unsigned long atom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
|
||||||
|
XChangeProperty(QX11Info::display(), window->winId(), atom, atom, 32, XCB_PROP_MODE_REPLACE,
|
||||||
|
(const unsigned char *)&hints, sizeof(MotifWmHints) / sizeof(const unsigned char));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
UKUIDecorationManager::getInstance()->removeHeaderBar(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHelper::windowBlur(QWindow *window, bool enable)
|
||||||
|
{
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//use KWindowEffects
|
||||||
|
KWindowEffects::enableBlurBehind(window->winId(), enable);
|
||||||
|
}
|
||||||
|
|
||||||
//======MenuMainWindow======//
|
//======MenuMainWindow======//
|
||||||
MenuMainWindow::MenuMainWindow(QWindow *parent) : QQuickWindow(parent), m_geometryHelper(new WindowGeometryHelper(this))
|
MenuMainWindow::MenuMainWindow(QWindow *parent) : QQuickWindow(parent), m_geometryHelper(new WindowGeometryHelper(this))
|
||||||
{
|
{
|
||||||
|
@ -334,13 +382,19 @@ void MenuWindow::init()
|
||||||
setResizeMode(SizeRootObjectToView);
|
setResizeMode(SizeRootObjectToView);
|
||||||
setColor("transparent");
|
setColor("transparent");
|
||||||
|
|
||||||
// TODO 使用窗管接口设置无边框
|
// setFlags(Qt::FramelessWindowHint);
|
||||||
setFlags(Qt::FramelessWindowHint);
|
|
||||||
WindowHelper::setWindowAttribute(this);
|
WindowHelper::setWindowAttribute(this);
|
||||||
|
WindowHelper::removeHeaderBar(this);
|
||||||
|
WindowHelper::windowBlur(this, true);
|
||||||
|
|
||||||
// 访问窗口api
|
// 访问窗口api
|
||||||
rootContext()->setContextProperty("mainWindow", this);
|
rootContext()->setContextProperty("mainWindow", this);
|
||||||
connect(this, &QQuickView::activeFocusItemChanged, this, &MenuWindow::onActiveFocusItemChanged);
|
connect(this, &QQuickView::activeFocusItemChanged, this, &MenuWindow::onActiveFocusItemChanged);
|
||||||
|
|
||||||
|
connect(m_geometryHelper, &WindowGeometryHelper::geometryChanged, this, [this] {
|
||||||
|
QEvent event(QEvent::Move);
|
||||||
|
QCoreApplication::sendEvent(this, &event);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuWindow::updateGeometry()
|
void MenuWindow::updateGeometry()
|
||||||
|
|
|
@ -38,6 +38,8 @@ class WindowHelper final
|
||||||
public:
|
public:
|
||||||
static void setWindowGeometry(QWindow *window, const QRect &rect);
|
static void setWindowGeometry(QWindow *window, const QRect &rect);
|
||||||
static void setWindowAttribute(QWindow *window);
|
static void setWindowAttribute(QWindow *window);
|
||||||
|
static void removeHeaderBar(QWindow *window);
|
||||||
|
static void windowBlur(QWindow *window, bool enable);
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowGeometryHelper final : public QObject
|
class WindowGeometryHelper final : public QObject
|
||||||
|
|
Loading…
Reference in New Issue