From f2ed85555bf1042aa50b9c2704ea3da225c5890d Mon Sep 17 00:00:00 2001 From: Marko Mattila Date: Sat, 28 Feb 2009 01:22:26 +0200 Subject: [PATCH] - removed more unused classes from qlwm and renamed toolbar to homedesktop (nice name:) - Going to sleep now. Night folks:) --- qlwm/{toolbar.cpp => homedesktop.cpp} | 14 +-- qlwm/{toolbar.h => homedesktop.h} | 6 -- qlwm/qapp.cpp | 1 - qlwm/qapp.h | 8 +- qlwm/qlwm.pro | 26 ++--- qlwm/rubber.cpp | 127 ---------------------- qlwm/rubber.h | 30 ------ qlwm/xwindow.cpp | 145 ++++++-------------------- qlwm/xwindow.h | 4 +- 9 files changed, 44 insertions(+), 317 deletions(-) rename qlwm/{toolbar.cpp => homedesktop.cpp} (91%) rename qlwm/{toolbar.h => homedesktop.h} (83%) delete mode 100644 qlwm/rubber.cpp delete mode 100644 qlwm/rubber.h diff --git a/qlwm/toolbar.cpp b/qlwm/homedesktop.cpp similarity index 91% rename from qlwm/toolbar.cpp rename to qlwm/homedesktop.cpp index 9a97f9d..f5299d3 100644 --- a/qlwm/toolbar.cpp +++ b/qlwm/homedesktop.cpp @@ -8,13 +8,8 @@ #include "defs.h" #include "qapp.h" -#include "toolbar.h" +#include "homedesktop.h" #include "defaults.h" -#include "pager.h" -#include "winlist.h" -#include "menu.h" -#include "procbar.h" -#include "apbar.h" #include #include @@ -50,12 +45,7 @@ qtablet::Pager * HomeDesktop::getPager() const return home->pager(); } -/* -qtablet::Pager * HomeDesktop::getProcbar() const -{ - return home->pager(); -} -*/ + qtablet::Home * HomeDesktop::getHome() const { return home; diff --git a/qlwm/toolbar.h b/qlwm/homedesktop.h similarity index 83% rename from qlwm/toolbar.h rename to qlwm/homedesktop.h index be55865..a5e7453 100644 --- a/qlwm/toolbar.h +++ b/qlwm/homedesktop.h @@ -5,11 +5,6 @@ #include #include -class pager; -class winlist; -class procbar; -class menu; -class apbar; class QBoxLayout; @@ -29,7 +24,6 @@ class HomeDesktop: public QWidget HomeDesktop( QWidget * parent = 0 ); public: qtablet::Pager * getPager() const; - //qtablet::Pager * getProcbar() const; qtablet::Home * getHome() const; public slots: diff --git a/qlwm/qapp.cpp b/qlwm/qapp.cpp index 286ed1c..3c769c8 100644 --- a/qlwm/qapp.cpp +++ b/qlwm/qapp.cpp @@ -11,7 +11,6 @@ #include "defs.h" #include "conf.h" #include "defaults.h" -#include "toolbar.h" #include "qapp.h" #include diff --git a/qlwm/qapp.h b/qlwm/qapp.h index 5402546..a8c051b 100644 --- a/qlwm/qapp.h +++ b/qlwm/qapp.h @@ -3,14 +3,8 @@ #ifndef QAPP_H #define QAPP_H -#include "toolbar.h" -#include "pager.h" -#include "winlist.h" -#include "menu.h" -#include "procbar.h" -#include "apbar.h" +#include "homedesktop.h" #include "winfo.h" -#include "rubber.h" #include "xwindow.h" extern QList clients; // client list diff --git a/qlwm/qlwm.pro b/qlwm/qlwm.pro index a022836..fb33f8a 100644 --- a/qlwm/qlwm.pro +++ b/qlwm/qlwm.pro @@ -17,28 +17,18 @@ DESTDIR += $$BUILDDIR/qlwm/bin HEADERS += conf.h \ defaults.h \ defs.h \ - eventnames.h \ - #menu.h \ - #pager.h \ - #procbar.h \ - qapp.h \ - rubber.h \ - toolbar.h \ + eventnames.h \ + qapp.h \ + homedesktop.h \ wborder.h \ - winfo.h \ - #winlist.h \ + winfo.h \ xwindow.h SOURCES += defaults.cpp \ - main.cpp \ - #menu.cpp \ - #pager.cpp \ - #procbar.cpp \ - qapp.cpp \ - rubber.cpp \ - toolbar.cpp \ + main.cpp \ + qapp.cpp \ + homedesktop.cpp \ wborder.cpp \ - winfo.cpp \ - #winlist.cpp \ + winfo.cpp \ xwindow.cpp diff --git a/qlwm/rubber.cpp b/qlwm/rubber.cpp deleted file mode 100644 index 316c381..0000000 --- a/qlwm/rubber.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* -* File : rubber.cpp -* Written by: alinden@gmx.de -* Copyright : GPL -* -* Creates the rubberbanding for move and resize -*/ - -#include "defs.h" -#include "defaults.h" -#include "qapp.h" -#include "rubber.h" - -rubber::rubber(QWidget *parent) : QLabel(parent) // move -{ - mpos = TRUE; - init(); -} - -rubber::rubber(int basew, int baseh, int incw, int inch, QWidget *parent) : QLabel(parent) // resize -{ - base_w = basew; - base_h = baseh; - inc_w = incw; - inc_h = inch; - mpos = FALSE; - init(); -} - -void rubber::init(void) -{ - drawn = FALSE; - - setFrameStyle(QFrame::Box|QFrame::Plain); - setLineWidth(1); - setGeometry(QApplication::desktop()->width()/2-50, QApplication::desktop()->height()/2, 100, defaults::tb_height); - - XGCValues gv; - - gv.function = GXxor; - gv.subwindow_mode = IncludeInferiors; - gv.foreground = WhitePixel(QX11Info::display(), QX11Info::appScreen()); - gv.background = BlackPixel(QX11Info::display(), QX11Info::appScreen()); - gv.line_width = 1; - gc_thin = XCreateGC(QX11Info::display(), QX11Info::appRootWindow(), - GCForeground|GCBackground|GCFunction|GCLineWidth|GCSubwindowMode, &gv); - - gv.line_width = 2; - gc_thick = XCreateGC(QX11Info::display(), QX11Info::appRootWindow(), - GCForeground|GCBackground|GCFunction|GCLineWidth|GCSubwindowMode, &gv); - setFont(defaults::toolbarfont); -} - -void rubber::drawframe(void) -{ - XDrawRectangle(QX11Info::display(), QX11Info::appRootWindow(), gc_thick, px, py, pw, ph); - XDrawSegments(QX11Info::display(), QX11Info::appRootWindow(), gc_thin, segs, 4); -} - -void rubber::draw(int x, int y, int w, int h) -{ - if(drawn && old_x == x && old_y == y && old_w == w && old_h == h) // no changes - return; - - old_x = x; old_y = y; - old_w = w; old_h = h; - - if(drawn) // remove old frame - drawframe(); - - QString txt; - if(mpos) - txt.sprintf(" x:%d y:%d ", x+(qapp::adesk*QApplication::desktop()->width()), y); - else - { - if(inc_w > 1 || inc_h > 1) - { - int i = 1; - int j = 1; - - if(inc_w > 1) - i = (w-base_w)/inc_w; - - if(inc_h > 1) - j = (h-base_h)/inc_h; - - txt.sprintf(" c:%d r:%d ", i, j); - } - else - txt.sprintf(" w:%d h:%d ", w, h); - } - - if(! drawn) - { - XGrabServer(QX11Info::display()); - show(); - XSync(QX11Info::display(), FALSE); - qapp::mrb = TRUE; - drawn = TRUE; - } - setText(txt); - update(); - - // draw frame - - int xl = w/3; - int yl = h/3; - segs[0].x1 = x; segs[0].x2 = x+w; segs[0].y1 = segs[0].y2 = y+yl; - segs[1].x1 = x; segs[1].x2 = x+w; segs[1].y1 = segs[1].y2 = y+2*yl; - segs[2].x1 = segs[2].x2 = x+xl; segs[2].y1 = y; segs[2].y2 = y+h; - segs[3].x1 = segs[3].x2 = x+2*xl; segs[3].y1 = y; segs[3].y2 = y+h; - px = x; py = y; pw = w; ph = h; - - drawframe(); -} - -rubber::~rubber(void) -{ - if(drawn) - drawframe(); - - qapp::mrb = FALSE; - - XUngrabServer(QX11Info::display()); - XFreeGC(QX11Info::display(), gc_thin); - XFreeGC(QX11Info::display(), gc_thick); -} diff --git a/qlwm/rubber.h b/qlwm/rubber.h deleted file mode 100644 index 445b7b1..0000000 --- a/qlwm/rubber.h +++ /dev/null @@ -1,30 +0,0 @@ -/* rubber.h */ - -#ifndef RUBBER_H -#define RUBBER_H -#include - -class rubber : public QLabel -{ - bool mpos; // show move position - int px,py,pw,ph; // frame - XSegment segs[4]; // lines - GC gc_thin,gc_thick; - bool drawn; - int base_w,base_h; // XWMNormalHints - int inc_w, inc_h; // XWMNormalHints - int old_x,old_y,old_w,old_h; - - void drawframe(void); - -public: - // upper constructor used for move - // lower constructor used for resize - - rubber(QWidget *parent=0); - rubber(int basew, int baseh, int incw, int inch, QWidget *parent=0); - void init(void); - void draw(int x, int y, int w, int h); // draw frame - ~rubber(void); -}; -#endif diff --git a/qlwm/xwindow.cpp b/qlwm/xwindow.cpp index ce03dee..af136fa 100644 --- a/qlwm/xwindow.cpp +++ b/qlwm/xwindow.cpp @@ -10,14 +10,13 @@ #include "defaults.h" #include "qapp.h" #include "winfo.h" -#include "toolbar.h" +#include "homedesktop.h" #include xwindow::xwindow(Window w, QWidget *parent) : QWidget(parent) { dt = QApplication::desktop(); maxstate = 0; - mrb = NULL; clientid = w; actpal = TRUE; urgpal = FALSE; @@ -530,23 +529,18 @@ void xwindow::s_maximize(void) void xwindow::press_move(QMouseEvent *event) { - if(mrb != NULL) - return; - + // TODO: This code isn't used in QTablet so check if + // it needs to be removed mousepos = event->pos()+midmove->pos(); // offset - midmove->grabMouse(QCursor(Qt::SizeAllCursor)); - mrb = new rubber(0); + midmove->grabMouse(QCursor(Qt::SizeAllCursor)); move_move(event); // draw frame } void xwindow::release_move(QMouseEvent *event) { + //TODO: Check if this code is needed. Q_UNUSED( event ); - if(mrb == NULL) - return; - - delete mrb; - mrb = NULL; + midmove->releaseMouse(); //move(event->globalPos()-mousepos); maxstate = 0; @@ -559,33 +553,24 @@ void xwindow::release_move(QMouseEvent *event) void xwindow::move_move(QMouseEvent *event) { + Q_UNUSED( event ); + // TODO: Check if this code is needed // We don't allow moving the windows around return; - if(mrb == NULL) - return; - - QPoint p = event->globalPos()-mousepos; - mrb->draw(p.x(), p.y(), width(), height()); + } void xwindow::press_leftresize(QMouseEvent *event) { - if(mrb != NULL) - return; - - mousepos = event->globalPos(); - lbdr->leftframe->grabMouse(QCursor(Qt::SizeAllCursor)); - mrb = new rubber(base_w, base_h, inc_w, inc_h, 0); - move_leftresize(event); // draw frame + Q_UNUSED( event ); + // TODO: Check if this code is needed + } void xwindow::release_leftresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - delete mrb; - mrb = NULL; + // TODO: Check if this code is needed + Q_UNUSED( event ); lbdr->leftframe->releaseMouse(); QPoint dpos = event->globalPos()-mousepos; int resw = width()-dpos.x(); @@ -607,110 +592,44 @@ void xwindow::release_leftresize(QMouseEvent *event) void xwindow::move_leftresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - QPoint dpos = event->globalPos()-mousepos; - int resw = width()-dpos.x(); - int resh = height()+dpos.y(); - - getsize(&resw, &resh); - int resx = x()-resw+width(); - - if(resx+min_w > x()+width()) - resx = x()+width()-min_w; - - mrb->draw(resx, y(), resw, resh); + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::press_rightresize(QMouseEvent *event) { - if(mrb != NULL) - return; - - mousepos = event->globalPos(); - lbdr->rightframe->grabMouse(QCursor(Qt::SizeAllCursor)); - mrb = new rubber(base_w, base_h, inc_w, inc_h, 0); - move_rightresize(event); // draw frame + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::release_rightresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - delete mrb; - mrb = NULL; - lbdr->rightframe->releaseMouse(); - QPoint dpos = event->globalPos()-mousepos; - int resw = width()+dpos.x(); - int resh = height()+dpos.y(); - - getsize(&resw, &resh); - resize_client(x(), y(), resw, resh); - maxstate = 0; - raise(); - - if(tstate && ! qapp::is_curdesk(this)) - tstate = FALSE; + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::move_rightresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - QPoint dpos = event->globalPos()-mousepos; - int resw = width()+dpos.x(); - int resh = height()+dpos.y(); - - getsize(&resw, &resh); - mrb->draw(x(), y(), resw, resh); + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::press_midresize(QMouseEvent *event) { - if(mrb != NULL) - return; - - mousepos = event->globalPos(); - lbdr->midframe->grabMouse(QCursor(Qt::SizeAllCursor)); - mrb = new rubber(base_w, base_h, inc_w, inc_h, 0); - move_midresize(event); // draw frame + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::release_midresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - delete mrb; - mrb = NULL; - lbdr->midframe->releaseMouse(); - QPoint dpos = event->globalPos()-mousepos; - int resh = height()+dpos.y(); - int resw = width(); - - getsize(&resw, &resh); - resize_client(x(), y(), resw, resh); - maxstate = 0; - raise(); - - if(tstate && ! qapp::is_curdesk(this)) - tstate = FALSE; + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::move_midresize(QMouseEvent *event) { - if(mrb == NULL) - return; - - QPoint dpos = event->globalPos()-mousepos; - int resh = height()+dpos.y(); - int resw = width(); - - getsize(&resw, &resh); - mrb->draw(x(), y(), resw, resh); + // TODO: Check if this code is needed + Q_UNUSED( event ); } void xwindow::show_info(void) @@ -870,7 +789,7 @@ void xwindow::seturgent(void) void xwindow::raise() { - if(mrb != NULL || qapp::winf->get_client() != NULL || (! qapp::smode && (pflags & qapp::StayOnBottom))) + if( qapp::winf->get_client() != NULL || (! qapp::smode && (pflags & qapp::StayOnBottom))) return; #ifdef DEBUGMSG @@ -1117,7 +1036,7 @@ void xwindow::stopautofocus(void) void xwindow::startautofocus(void) // start autofocus timer { - if(! defaults::autofocustime || mrb != NULL) + if(! defaults::autofocustime ) return; // do not raise if another window appears within this window @@ -1406,7 +1325,7 @@ void xwindow::set_pflags(int tflags) logmsg << "rebuilding window frame (WId:" << winId() << ")\n"; #endif qDebug() << "rebuilding window frame"; - delete mrb; + delete midmove; delete ubdr; delete lbdr; @@ -1705,7 +1624,7 @@ xwindow::~xwindow(void) HomeDesktop::instance()->getPager()->removeWindow(this->winId()); delete [] cmapwins; - delete mrb; + if(qapp::winf->get_client() == this) qapp::winf->release_cancel(); diff --git a/qlwm/xwindow.h b/qlwm/xwindow.h index 5c24955..bab1128 100644 --- a/qlwm/xwindow.h +++ b/qlwm/xwindow.h @@ -5,7 +5,6 @@ #define XWINDOW_H #include "wborder.h" -#include "rubber.h" #include #include #include @@ -25,8 +24,7 @@ class xwindow : public QWidget int scx, scy, scw, sch; // normal geometry in screenmode int tcx, tcy, tcw, tch; // normal geometry in tilemode char maxstate; // maximized state 1=toolbar,2=screen - QPoint mousepos; // mouse position at button press - rubber *mrb; // move/resize rubberband + QPoint mousepos; // mouse position at button press bool actpal; // set to active colors bool urgpal; // set to urgent colors QTimer *focustimer; // autofocus timer