mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
set wm strut partial
This commit is contained in:
parent
089c944ac6
commit
5c36c09b54
@ -10,7 +10,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = dde-dock
|
||||
TEMPLATE = app
|
||||
INCLUDEPATH += src/
|
||||
INCLUDEPATH += src/ ../libs/
|
||||
|
||||
|
||||
SOURCES += \
|
||||
src/main.cpp \
|
||||
@ -40,7 +41,8 @@ SOURCES += \
|
||||
src/DBus/dbusmenu.cpp \
|
||||
src/Widgets/apppreviews.cpp \
|
||||
src/Widgets/closebutton.cpp \
|
||||
src/DBus/dbushidestatemanager.cpp
|
||||
src/DBus/dbushidestatemanager.cpp \
|
||||
../libs/xcb_misc.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/abstractdockitem.h \
|
||||
@ -72,13 +74,14 @@ HEADERS += \
|
||||
src/dockconstants.h \
|
||||
src/Widgets/apppreviews.h \
|
||||
src/Widgets/closebutton.h \
|
||||
src/DBus/dbushidestatemanager.h
|
||||
src/DBus/dbushidestatemanager.h \
|
||||
../libs/xcb_misc.h
|
||||
|
||||
RESOURCES += \
|
||||
images.qrc \
|
||||
qss.qrc
|
||||
|
||||
PKGCONFIG += gtk+-2.0 x11 cairo
|
||||
PKGCONFIG += gtk+-2.0 x11 cairo xcb xcb-ewmh
|
||||
CONFIG += c++11 link_pkgconfig
|
||||
|
||||
target.path = /usr/bin/
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <QDebug>
|
||||
#include "mainwidget.h"
|
||||
|
||||
#include "xcb_misc.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -22,5 +24,7 @@ int main(int argc, char *argv[])
|
||||
MainWidget w;
|
||||
w.show();
|
||||
|
||||
XcbMisc::instance()->set_strut_partial(w.winId(), XcbMisc::OrientationBottom, w.height(), w.x(), w.x() + w.width());
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
61
libs/xcb_misc.cpp
Normal file
61
libs/xcb_misc.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include <QDebug>
|
||||
#include <QX11Info>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
|
||||
#include "xcb_misc.h"
|
||||
|
||||
static XcbMisc * _xcb_misc_instance = NULL;
|
||||
|
||||
XcbMisc::XcbMisc()
|
||||
{
|
||||
xcb_intern_atom_cookie_t * cookie = xcb_ewmh_init_atoms(QX11Info::connection(), &m_ewmh_connection);
|
||||
xcb_ewmh_init_atoms_replies(&m_ewmh_connection, cookie, NULL);
|
||||
}
|
||||
|
||||
XcbMisc::~XcbMisc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XcbMisc * XcbMisc::instance()
|
||||
{
|
||||
if (_xcb_misc_instance == NULL) {
|
||||
_xcb_misc_instance = new XcbMisc;
|
||||
}
|
||||
|
||||
return _xcb_misc_instance;
|
||||
}
|
||||
|
||||
void XcbMisc::set_strut_partial(int winId, Orientation orientation, uint strut, uint start, uint end)
|
||||
{
|
||||
xcb_ewmh_wm_strut_partial_t strut_partial;
|
||||
|
||||
switch (orientation) {
|
||||
case OrientationLeft:
|
||||
strut_partial.left = strut;
|
||||
strut_partial.left_start_y = start;
|
||||
strut_partial.left_end_y = end;
|
||||
break;
|
||||
case OrientationRight:
|
||||
strut_partial.right = strut;
|
||||
strut_partial.right_start_y = start;
|
||||
strut_partial.right_end_y = end;
|
||||
break;
|
||||
case OrientationTop:
|
||||
strut_partial.top = strut;
|
||||
strut_partial.top_start_x = start;
|
||||
strut_partial.top_end_x = end;
|
||||
break;
|
||||
case OrientationBottom:
|
||||
strut_partial.bottom = strut;
|
||||
strut_partial.bottom_start_x = start;
|
||||
strut_partial.bottom_end_x = end;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
xcb_ewmh_set_wm_strut_partial(&m_ewmh_connection, winId, strut_partial);
|
||||
}
|
29
libs/xcb_misc.h
Normal file
29
libs/xcb_misc.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef XCB_MISC_H
|
||||
#define XCB_MISC_H
|
||||
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
|
||||
class XcbMisc
|
||||
{
|
||||
|
||||
public:
|
||||
enum Orientation {
|
||||
OrientationLeft,
|
||||
OrientationRight,
|
||||
OrientationTop,
|
||||
OrientationBottom
|
||||
};
|
||||
|
||||
virtual ~XcbMisc();
|
||||
|
||||
static XcbMisc * instance();
|
||||
|
||||
void set_strut_partial(int winId, Orientation orientation, uint strut, uint start, uint end);
|
||||
|
||||
private:
|
||||
XcbMisc();
|
||||
|
||||
xcb_ewmh_connection_t m_ewmh_connection;
|
||||
};
|
||||
|
||||
#endif // XCB_MISC_H
|
Loading…
x
Reference in New Issue
Block a user