2
* This file is part of unity-qt
4
* Copyright 2010 Canonical Ltd.
7
* - Aurélien Gâteau <aurelien.gateau@canonical.com>
18
#include <QApplication>
20
#include <QDesktopWidget>
21
#include <QHBoxLayout>
26
#include <X11/Xatom.h>
35
QHBoxLayout* m_layout;
39
QDesktopWidget* desktop = QApplication::desktop();
40
const QRect screen = desktop->screenGeometry(q);
41
const QRect available = desktop->availableGeometry(q);
44
Atom atom = XInternAtom(QX11Info::display(), "_NET_WM_STRUT_PARTIAL", False);
49
rect = QRect(screen.left(), available.top(), q->width(), available.height());
52
available.top(), available.bottom(), 0, 0,
57
rect = QRect(screen.left(), screen.top(), screen.width(), q->height());
61
screen.left(), screen.right(), 0, 0
68
XChangeProperty(QX11Info::display(), q->effectiveWinId(), atom,
69
XA_CARDINAL, 32, PropModeReplace,
70
(unsigned char *) &struts, 12);
73
void updateLayoutDirection()
75
QBoxLayout::Direction direction;
78
direction = QApplication::isRightToLeft() ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight;
81
direction = QBoxLayout::TopToBottom;
84
m_layout->setDirection(direction);
90
updateLayoutDirection();
94
Panel::Panel(QWidget* parent)
99
d->m_edge = Panel::TopEdge;
100
d->m_layout = new QHBoxLayout(this);
101
d->m_layout->setMargin(0);
102
d->m_layout->setSpacing(0);
103
setAttribute(Qt::WA_X11NetWmWindowTypeDock);
111
void Panel::setEdge(Panel::Edge edge)
119
Panel::Edge Panel::edge() const
124
void Panel::showEvent(QShowEvent* event)
126
QWidget::showEvent(event);
130
void Panel::addWidget(QWidget* widget)
132
d->m_layout->addWidget(widget);
135
void Panel::addSpacer()
137
d->m_layout->addStretch();