diff --git a/client.cpp b/client.cpp index b1c941dd5a..c4455e45d3 100644 --- a/client.cpp +++ b/client.cpp @@ -946,7 +946,7 @@ void Client::mouseMoveEvent( QMouseEvent * e) if ( !moveResizeMode ) { QPoint p( e->pos() - moveOffset ); - if ( (QABS( p.x()) >= 4) || (QABS( p.y() ) >= 4 )) { + if (p.manhattanLength() >= 6) { moveResizeMode = TRUE; Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart ); grabMouse( cursor() ); // to keep the right cursor @@ -1501,7 +1501,7 @@ void Client::setShade( bool s ) clearWFlags( WNorthWestGravity ); resize ( s ); windowWrapper()->show(); - activateLayout(); + activateLayout(); repaint(); if ( isActive() ) workspace()->requestFocus( this ); diff --git a/clients/riscos/Button.cpp b/clients/riscos/Button.cpp index f4beb60c41..2f6bdd8121 100644 --- a/clients/riscos/Button.cpp +++ b/clients/riscos/Button.cpp @@ -20,24 +20,18 @@ Boston, MA 02111-1307, USA. */ -#include -#include - -#include "../../options.h" - #include "Button.h" -#include "Manager.h" #include "Static.h" namespace RiscOS { -Button::Button(QWidget * parent, Manager * client, SymbolType t) +Button::Button(QWidget * parent, SymbolType t) : QWidget (parent, "Button", WRepaintNoErase | WPaintUnclipped), - client_ (client), type_ (t), align_ (Left), - down_ (false) + down_ (false), + active_ (false) { setFixedSize(19, 20); } @@ -50,9 +44,26 @@ Button::~Button() void Button::updateDisplay() { - setBackgroundPixmap(Static::instance()->button(type_, client_->isActive(), down_)); + setBackgroundPixmap( + Static::instance()->button(type_, active_, down_) + ); + repaint(true); } + + void +Button::setType(SymbolType t) +{ + type_ = t; + updateDisplay(); +} + + void +Button::setActive(bool b) +{ + active_ = b; + updateDisplay(); +} } // End namespace diff --git a/clients/riscos/Button.h b/clients/riscos/Button.h index 739a8c4e74..a64c2f28c2 100644 --- a/clients/riscos/Button.h +++ b/clients/riscos/Button.h @@ -23,42 +23,45 @@ #ifndef RISC_OS_BUTTON_H #define RISC_OS_BUTTON_H -#include - #include "Static.h" +#include namespace RiscOS { -class Manager; - class Button : public QWidget { + Q_OBJECT + public: enum Alignment { Left, Right }; - Button(QWidget * parent, Manager * client, SymbolType); + enum SymbolType; + + Button(QWidget * parent, SymbolType); virtual ~Button(); void updateDisplay(); void setAlign(Alignment a) { align_ = a; updateDisplay(); } - void setType(SymbolType t) { type_ = t; updateDisplay(); } + void setType(SymbolType t); + + void setActive(bool); protected: - Manager * client() { return client_; } + bool active() const { return active_; } void mousePressEvent(QMouseEvent *) { down_ = true; updateDisplay(); } void mouseReleaseEvent(QMouseEvent *) { down_ = false; updateDisplay(); } private: - Manager * client_; SymbolType type_; Alignment align_; bool down_; + bool active_; }; } // End namespace diff --git a/clients/riscos/CloseButton.cpp b/clients/riscos/CloseButton.cpp index c8cdd656fe..5076134bcb 100644 --- a/clients/riscos/CloseButton.cpp +++ b/clients/riscos/CloseButton.cpp @@ -21,14 +21,12 @@ */ #include "CloseButton.h" -#include "Manager.h" -#include "Static.h" namespace RiscOS { -CloseButton::CloseButton(QWidget * parent, Manager * client) - : Button(parent, client, Close) +CloseButton::CloseButton(QWidget * parent) + : Button(parent, Close) { } @@ -43,16 +41,16 @@ CloseButton::mouseReleaseEvent(QMouseEvent * e) switch (e->button()) { case RightButton: - client()->closeWindow(); + emit(closeClient()); break; case MidButton: - client()->closeWindow(); + emit(closeClient()); break; case LeftButton: default: - client()->closeWindow(); + emit(closeClient()); break; } } diff --git a/clients/riscos/CloseButton.h b/clients/riscos/CloseButton.h index 4c066fe5b2..31fc7641cf 100644 --- a/clients/riscos/CloseButton.h +++ b/clients/riscos/CloseButton.h @@ -28,13 +28,17 @@ namespace RiscOS { -class Manager; - class CloseButton : public Button { + Q_OBJECT + public: - CloseButton(QWidget * parent, Manager * client); + CloseButton(QWidget * parent); + + signals: + + void closeClient(); protected: diff --git a/clients/riscos/IconifyButton.cpp b/clients/riscos/IconifyButton.cpp index 69b6817f1e..85c907e140 100644 --- a/clients/riscos/IconifyButton.cpp +++ b/clients/riscos/IconifyButton.cpp @@ -21,14 +21,12 @@ */ #include "IconifyButton.h" -#include "Manager.h" -#include "Static.h" namespace RiscOS { -IconifyButton::IconifyButton(QWidget * parent, Manager * client) - : Button(parent, client, Iconify) +IconifyButton::IconifyButton(QWidget * parent) + : Button(parent, Iconify) { } @@ -43,16 +41,16 @@ IconifyButton::mouseReleaseEvent(QMouseEvent * e) switch (e->button()) { case RightButton: - client()->iconify(); + emit(iconifyClient()); break; case MidButton: - client()->iconify(); + emit(iconifyClient()); break; case LeftButton: default: - client()->iconify(); + emit(iconifyClient()); break; } diff --git a/clients/riscos/IconifyButton.h b/clients/riscos/IconifyButton.h index f2ea323edf..ad6880d610 100644 --- a/clients/riscos/IconifyButton.h +++ b/clients/riscos/IconifyButton.h @@ -28,14 +28,17 @@ namespace RiscOS { -class Manager; - - class IconifyButton : public Button { + Q_OBJECT + public: - IconifyButton(QWidget * parent, Manager * client); + IconifyButton(QWidget * parent); + + signals: + + void iconifyClient(); protected: diff --git a/clients/riscos/LowerButton.cpp b/clients/riscos/LowerButton.cpp index f38833e939..159e7075d9 100644 --- a/clients/riscos/LowerButton.cpp +++ b/clients/riscos/LowerButton.cpp @@ -20,17 +20,13 @@ Boston, MA 02111-1307, USA. */ -#include "../../workspace.h" - #include "LowerButton.h" -#include "Manager.h" -#include "Static.h" namespace RiscOS { -LowerButton::LowerButton(QWidget * parent, Manager * client) - : Button(parent, client, Lower) +LowerButton::LowerButton(QWidget * parent) + : Button(parent, Lower) { } @@ -45,13 +41,12 @@ LowerButton::mouseReleaseEvent(QMouseEvent * e) switch (e->button()) { default: - client()->workspace()->lowerClient(client()); + emit(lowerClient()); break; } } - } // End namespace; // vim:ts=2:sw=2:tw=78 diff --git a/clients/riscos/LowerButton.h b/clients/riscos/LowerButton.h index da04fed961..7c6d9f0403 100644 --- a/clients/riscos/LowerButton.h +++ b/clients/riscos/LowerButton.h @@ -28,13 +28,17 @@ namespace RiscOS { -class Manager; - class LowerButton : public Button { + Q_OBJECT + public: - LowerButton(QWidget * parent, Manager * client); + LowerButton(QWidget * parent); + + signals: + + void lowerClient(); protected: diff --git a/clients/riscos/Makefile.am b/clients/riscos/Makefile.am index 3ff7bc6a8f..f4302d4270 100644 --- a/clients/riscos/Makefile.am +++ b/clients/riscos/Makefile.am @@ -38,5 +38,6 @@ lnk_DATA = riscos.desktop EXTRA_DIST = $(lnk_DATA) -libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic +libkwinriscos_la_LIBADD = $(LIB_QT) ../../kwin.la +libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic -no-undefined diff --git a/clients/riscos/Manager.cpp b/clients/riscos/Manager.cpp index 183efedaf5..6c998573d2 100644 --- a/clients/riscos/Manager.cpp +++ b/clients/riscos/Manager.cpp @@ -50,30 +50,14 @@ Manager::Manager( ) : Client(workSpace, id, parent, name) { - Static::instance(); - setBackgroundMode(NoBackground); connect(options, SIGNAL(resetClients()), this, SLOT(slotReset())); - titleBar_ = new TitleBar(this, this); + titleBar_ = new TitleBar(this); resizeBar_ = new ResizeBar(this, this); - // Border Window Border - QHBoxLayout * windowLayout = new QHBoxLayout(0, "windowLayout"); - windowLayout->addSpacing(1); - windowLayout->addWidget(windowWrapper(), 1); - windowLayout->addSpacing(1); - - // Titlebar (has own single pixel border) - // Window - // Resize bar (has own single pixel border) - QVBoxLayout * mainLayout = new QVBoxLayout(this, 0, 0, "mainLayout"); - mainLayout->addWidget(titleBar_); - mainLayout->addLayout(windowLayout, 1); - mainLayout->addWidget(resizeBar_); - - updateDisplay(); + activateLayout(); } Manager::~Manager() @@ -84,8 +68,7 @@ Manager::~Manager() Manager::slotReset() { Static::instance()->update(); - titleBar_->updateDisplay(); - resizeBar_->updateDisplay(); + _updateDisplay(); } void @@ -98,46 +81,23 @@ Manager::captionChange(const QString &) Manager::paletteChange(const QPalette &) { Static::instance()->update(); - titleBar_->updateDisplay(); + _updateDisplay(); } void -Manager::activeChange(bool) +Manager::activeChange(bool b) { - titleBar_->updateDisplay(); - resizeBar_->updateDisplay(); + titleBar_->setActive(b); } void Manager::maximizeChange(bool b) { - titleBar_->updateMaximise(b); + emit(maximiseChanged(b)); } void -Manager::maximizeAndRaise() -{ - maximize(MaximizeFull); - workspace()->raiseClient(this); - workspace()->requestFocus(this); -} - - void -Manager::maximizeVertically() -{ - maximize(MaximizeVertical); - workspace()->raiseClient(this); - workspace()->requestFocus(this); -} - - void -Manager::maximizeNoRaise() -{ - maximize(MaximizeFull); -} - - void -Manager::updateDisplay() +Manager::_updateDisplay() { titleBar_->updateDisplay(); resizeBar_->updateDisplay(); @@ -173,31 +133,54 @@ Manager::paintEvent(QPaintEvent * e) } } - void -Manager::mouseMoveEvent(QMouseEvent * e) + Client::MousePosition +Manager::mousePosition(const QPoint & p) const { - if ((e->pos().x() == 0) || (e->pos().y() == 0)) - return; - - Client::mouseMoveEvent(e); + if (titleBar_->rect().contains(p)) + return Client::Center; + else + return Client::Nowhere; } void -Manager::mousePressEvent(QMouseEvent * e) +Manager::lower() { - if ((e->pos().x() == 0) || (e->pos().y() == 0)) - return; - - Client::mousePressEvent(e); + workspace()->lowerClient(this); } void -Manager::mouseReleaseEvent(QMouseEvent * e) +Manager::raise() { - if ((e->pos().x() == 0) || (e->pos().y() == 0)) - return; + workspace()->raiseClient(this); +} - Client::mouseReleaseEvent(e); + void +Manager::vMax() +{ + maximize(MaximizeVertical); +} + + void +Manager::resizeEvent(QResizeEvent * e) +{ + Client::resizeEvent(e); + _updateLayout(); +} + + void +Manager::_updateLayout() +{ + titleBar_ -> setGeometry(0, 0, width(), 20); + windowWrapper() -> setGeometry(1, 20, width() - 2, height() - 30); + resizeBar_ -> setGeometry(0, height() - 10, width(), 10); + + _updateDisplay(); +} + + void +Manager::activateLayout() +{ + _updateLayout(); } } // End namespace diff --git a/clients/riscos/Manager.h b/clients/riscos/Manager.h index 4df8c5d5d7..499e528eea 100644 --- a/clients/riscos/Manager.h +++ b/clients/riscos/Manager.h @@ -35,35 +35,44 @@ class Manager : public Client { Q_OBJECT + friend class TitleText; + public: Manager(Workspace *, WId, QWidget * parent = 0, const char * name = 0); ~Manager(); - void maximizeVertically(); - void maximizeAndRaise(); - void maximizeNoRaise(); - void setShade(bool); - void updateDisplay(); + signals: + + void maximiseChanged(bool); + + public slots: + + void lower(); + void raise(); + void vMax(); protected: + Client::MousePosition mousePosition(const QPoint &) const; void paletteChange(const QPalette &); void activeChange(bool); void maximizeChange(bool); void paintEvent(QPaintEvent *); - void mouseMoveEvent(QMouseEvent *); - void mousePressEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); - + void resizeEvent(QResizeEvent *); + void activateLayout(); + protected slots: void captionChange(const QString &); void slotReset(); private: + + void _updateDisplay(); + void _updateLayout(); TitleBar * titleBar_; ResizeBar * resizeBar_; diff --git a/clients/riscos/MaximiseButton.cpp b/clients/riscos/MaximiseButton.cpp index ff29ed37fc..f1890fefe7 100644 --- a/clients/riscos/MaximiseButton.cpp +++ b/clients/riscos/MaximiseButton.cpp @@ -21,14 +21,12 @@ */ #include "MaximiseButton.h" -#include "Static.h" -#include "Manager.h" namespace RiscOS { -MaximiseButton::MaximiseButton(QWidget * parent, Manager * client) - : Button(parent, client, Max) +MaximiseButton::MaximiseButton(QWidget * parent) + : Button(parent, Max) { } @@ -50,16 +48,17 @@ MaximiseButton::mouseReleaseEvent(QMouseEvent * e) switch (e->button()) { case RightButton: - client()->maximizeNoRaise(); + emit(maximiseClient()); break; case MidButton: - client()->maximizeVertically(); + emit(vMaxClient()); break; case LeftButton: default: - client()->maximizeAndRaise(); + emit(raiseClient()); + emit(maximiseClient()); break; } } diff --git a/clients/riscos/MaximiseButton.h b/clients/riscos/MaximiseButton.h index 9566307ece..a23c8ec4df 100644 --- a/clients/riscos/MaximiseButton.h +++ b/clients/riscos/MaximiseButton.h @@ -23,23 +23,29 @@ #ifndef RISC_OS_MAXIMISE_BUTTON_H #define RISC_OS_MAXIMISE_BUTTON_H -#include - #include "Button.h" namespace RiscOS { -class Manager; - class MaximiseButton : public Button { + Q_OBJECT + public: - MaximiseButton(QWidget * parent, Manager * client); + MaximiseButton(QWidget * parent); + + public slots: void setOn(bool); + signals: + + void maximiseClient(); + void raiseClient(); + void vMaxClient(); + protected: void mouseReleaseEvent(QMouseEvent *); diff --git a/clients/riscos/README b/clients/riscos/README index cb9e4c5da9..04ebd85d4e 100644 --- a/clients/riscos/README +++ b/clients/riscos/README @@ -84,4 +84,7 @@ in the lower right corner of the window (actually inside the window). To emulate this would mean covering part of the window with the decorations, which is not acceptable. RISC OS gets away with it by making sure that there is a vertical scrollbar visible at all times, which is just stupid. +It's also an impossibility with X11, as the window manager does not know +anything about scrollbars - they belong to the application, so don't ask +me to implement it. diff --git a/clients/riscos/ResizeBar.cpp b/clients/riscos/ResizeBar.cpp index 5bc60d3dd2..44c4138a12 100644 --- a/clients/riscos/ResizeBar.cpp +++ b/clients/riscos/ResizeBar.cpp @@ -36,7 +36,6 @@ ResizeBar::ResizeBar(QWidget * parent, Manager * client) client_ (client) { setBackgroundMode(NoBackground); - setFixedHeight(10); left_ = new ResizeSide(this, client_, ResizeSide::Left); mid_ = new ResizeMid(this, client_); diff --git a/clients/riscos/TitleBar.cpp b/clients/riscos/TitleBar.cpp index 4f6c610e6d..e135a25593 100644 --- a/clients/riscos/TitleBar.cpp +++ b/clients/riscos/TitleBar.cpp @@ -33,18 +33,16 @@ namespace RiscOS { -TitleBar::TitleBar(QWidget * parent, Manager * client) - : QWidget(parent), - client_(client) +TitleBar::TitleBar(Manager * client) + : QWidget(client) { setBackgroundMode(NoBackground); - setFixedHeight(20); - lower_ = new LowerButton (this, client_); - close_ = new CloseButton (this, client_); - text_ = new TitleText (this, client_); - iconify_ = new IconifyButton (this, client_); - maximise_ = new MaximiseButton (this, client_); + lower_ = new LowerButton (this); + close_ = new CloseButton (this); + text_ = new TitleText (this, client); + iconify_ = new IconifyButton (this); + maximise_ = new MaximiseButton (this); lower_ ->setAlign(Button::Left); close_ ->setAlign(Button::Left); @@ -60,6 +58,14 @@ TitleBar::TitleBar(QWidget * parent, Manager * client) layout->addWidget(text_, 1); layout->addWidget(iconify_); layout->addWidget(maximise_); + + connect(lower_, SIGNAL(lowerClient()), client, SLOT(lower())); + connect(close_, SIGNAL(closeClient()), client, SLOT(closeWindow())); + connect(iconify_, SIGNAL(iconifyClient()), client, SLOT(iconify())); + connect(maximise_, SIGNAL(maximiseClient()), client, SLOT(maximize())); + connect(maximise_, SIGNAL(vMaxClient()), client, SLOT(vMax())); + connect(maximise_, SIGNAL(raiseClient()), client, SLOT(raise())); + connect(client, SIGNAL(maximiseChanged(bool)), maximise_, SLOT(setOn(bool))); } void @@ -72,12 +78,6 @@ TitleBar::updateDisplay() maximise_ ->updateDisplay(); } - void -TitleBar::updateMaximise(bool b) -{ - maximise_->setOn(b); -} - void TitleBar::updateText() { @@ -89,7 +89,7 @@ TitleBar::~TitleBar() } void -TitleBar::resizeEvent(QResizeEvent * e) +TitleBar::resizeEvent(QResizeEvent *) { int sizeProblem = 0; @@ -128,8 +128,16 @@ TitleBar::resizeEvent(QResizeEvent * e) close_ ->show(); break; } +} - QWidget::resizeEvent(e); + void +TitleBar::setActive(bool b) +{ + lower_->setActive(b); + close_->setActive(b); + text_->setActive(b); + iconify_->setActive(b); + maximise_->setActive(b); } } // End namespace diff --git a/clients/riscos/TitleBar.h b/clients/riscos/TitleBar.h index 17dc0600fe..2e26656d1f 100644 --- a/clients/riscos/TitleBar.h +++ b/clients/riscos/TitleBar.h @@ -39,13 +39,15 @@ class TitleBar : public QWidget { public: - TitleBar(QWidget * parent, Manager * client); + TitleBar(Manager * client); virtual ~TitleBar(); void updateDisplay(); void updateText(); void updateMaximise(bool); + void setActive(bool); + protected: void resizeEvent(QResizeEvent *); @@ -59,8 +61,6 @@ class TitleBar : public QWidget IconifyButton * iconify_; MaximiseButton * maximise_; - - Manager * client_; }; } // End namespace diff --git a/clients/riscos/TitleText.cpp b/clients/riscos/TitleText.cpp index a39f146b18..07a42d5972 100644 --- a/clients/riscos/TitleText.cpp +++ b/clients/riscos/TitleText.cpp @@ -34,25 +34,33 @@ namespace RiscOS TitleText::TitleText(QWidget * parent, Manager * client) : DBWidget(parent, "TitleText"), - client_(client) + client_(client), + active_(false) { - setFixedHeight(20); } TitleText::~TitleText() { } + void +TitleText::setActive(bool b) +{ + active_ = b; + updateDisplay(); +} + void TitleText::updatePixmap() { QPainter p(&buf()); - p.drawPixmap(0, 0, Static::instance()->titleTextLeft(client_->isActive())); - p.drawPixmap(width() - 3, 0, Static::instance()->titleTextRight(client_->isActive())); - p.drawTiledPixmap(3, 0, width() - 6, 20, Static::instance()->titleTextMid(client_->isActive())); + Static * s = Static::instance(); - p.setPen(options->color(Options::Font, client_->isActive())); + p.drawPixmap(0, 0, s->titleTextLeft(active_)); + p.drawPixmap(width() - 3, 0, s->titleTextRight(active_)); + p.drawTiledPixmap(3, 0, width() - 6, 20, s->titleTextMid(active_)); + p.setPen(options->color(Options::Font, active_)); p.setFont(options->font()); p.drawText(4, 0, width() - 8, 18, AlignCenter, client_->caption()); } @@ -60,50 +68,25 @@ TitleText::updatePixmap() void TitleText::mousePressEvent(QMouseEvent * e) { - switch (e->button()) { - - case MidButton: - clientPosToMousePos_ = e->globalPos() - client_->pos(); - break; - - case LeftButton: - clientPosToMousePos_ = e->globalPos() - client_->pos(); - client_->workspace()->raiseClient(client_); - client_->workspace()->requestFocus(client_); - break; - - case RightButton: - client_->workspace()->clientPopup(client_)->popup(e->globalPos()); - break; - - default: - break; - } + client_->mousePressEvent(e); } void -TitleText::mouseReleaseEvent(QMouseEvent *) +TitleText::mouseReleaseEvent(QMouseEvent * e) { - // Anything to do ? + client_->mouseReleaseEvent(e); } void TitleText::mouseMoveEvent(QMouseEvent * e) { - // Need to be a little clever here. - - QPoint adjustedForCursor = e->globalPos() - clientPosToMousePos_; - - QPoint adjustedForSnap = - client_->workspace()->adjustClientPosition(client_, adjustedForCursor); - - client_->move(adjustedForSnap); + client_->mouseMoveEvent(e); } void -TitleText::mouseDoubleClickEvent(QMouseEvent *) +TitleText::mouseDoubleClickEvent(QMouseEvent * e) { - client_->setShade(!client_->isShade()); + client_->mouseDoubleClickEvent(e); } } // End namespace diff --git a/clients/riscos/TitleText.h b/clients/riscos/TitleText.h index db3e8d477a..72606af6bc 100644 --- a/clients/riscos/TitleText.h +++ b/clients/riscos/TitleText.h @@ -40,6 +40,8 @@ class TitleText : public DBWidget TitleText(QWidget * parent, Manager * client); virtual ~TitleText(); + void setActive(bool); + protected: void updatePixmap(); @@ -52,8 +54,7 @@ class TitleText : public DBWidget private: Manager * client_; - - QPoint clientPosToMousePos_; + bool active_; }; } // End namespace