From a33f4313ab836cce727b94e485ebde7ede2c5e46 Mon Sep 17 00:00:00 2001 From: Karol Szwed Date: Tue, 27 Aug 2002 15:12:14 +0000 Subject: [PATCH] - Removing patch by Diego Iastrubini that attempted to fix the bidi issues in clients by adding an unnecessary 'enable-bidi' checkbox which was never agreed upon on the kwin mailing list. The use of --reverse is sufficient without needing this checkbox. Please discuss largish patches like these first, especially during a feature freeze! (Everyone also seems to forget the kwin-styles in kdeartwork) - Make clients look the same with --reverse instead of the broken state they were in previously. If the button ordering is not to your liking in reverse mode, just change the button positions. (Or send patches for those clients that have not got these features yet). - Clean up popupMenu handling somewhat. - Remove a global static object in keramik. svn path=/trunk/kdebase/kwin/; revision=174079 --- clients/b2/b2client.cpp | 46 +++---- clients/b2/b2client.h | 4 +- clients/default/kdedefault.cpp | 153 ++++++++++------------ clients/default/kdedefault.h | 4 +- clients/icewm/icewm.cpp | 88 +++++-------- clients/icewm/icewm.h | 4 +- clients/kde1/kde1client.cpp | 62 ++++----- clients/keramik/keramik.cpp | 122 ++++++----------- clients/keramik/keramik.h | 14 +- clients/keramik/tiles.h | 17 +-- clients/kstep/nextclient.cpp | 22 +--- clients/kstep/nextclient.h | 4 +- clients/kwmtheme/kwmthemeclient.cpp | 2 +- clients/laptop/laptopclient.cpp | 48 +++---- clients/laptop/laptopclient.h | 4 +- clients/modernsystem/modernsys.cpp | 15 +-- clients/quartz/quartz.cpp | 44 +++---- clients/quartz/quartz.h | 4 +- clients/redmond/redmond.cpp | 73 ++++------- clients/redmond/redmond.h | 4 +- clients/riscos/Manager.cpp | 33 ++--- clients/riscos/Manager.h | 4 +- clients/system/systemclient.cpp | 56 ++++---- clients/web/Web.cpp | 12 +- kcmkwin/kwindecoration/kwindecoration.cpp | 14 +- kcmkwin/kwindecoration/kwindecoration.h | 1 - options.cpp | 7 - options.h | 9 -- workspace.cpp | 2 +- workspace.h | 7 + 30 files changed, 329 insertions(+), 550 deletions(-) diff --git a/clients/b2/b2client.cpp b/clients/b2/b2client.cpp index fff122d4c2..3b69ebaca2 100644 --- a/clients/b2/b2client.cpp +++ b/clients/b2/b2client.cpp @@ -405,37 +405,22 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent, titlebar->setMinimumWidth(16); titlebar->setFixedHeight(20); - QHBoxLayout *titleLayout = new QHBoxLayout(titlebar); - titleLayout->setSpacing(1); + QBoxLayout *titleLayout = new QBoxLayout(titlebar, QBoxLayout::LeftToRight, 0, 1, 0); titleLayout->addSpacing(3); if (options->customButtonPositions()) { - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())){ - addButtons( options->titleButtonsRight(), tips, titlebar, titleLayout ); - titleLayout->addItem(titlebar->captionSpacer); - addButtons( options->titleButtonsLeft(), tips, titlebar, titleLayout ); - } - else{ - addButtons( options->titleButtonsLeft(), tips, titlebar, titleLayout ); - titleLayout->addItem(titlebar->captionSpacer); - addButtons( options->titleButtonsRight(), tips, titlebar, titleLayout ); - } + addButtons( options->titleButtonsLeft(), tips, titlebar, titleLayout ); + titleLayout->addItem(titlebar->captionSpacer); + addButtons( options->titleButtonsRight(), tips, titlebar, titleLayout ); } else { - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())){ - addButtons( "IAX", tips, titlebar, titleLayout ); - titleLayout->addItem(titlebar->captionSpacer); - addButtons( "MSH", tips, titlebar, titleLayout ); - } - else{ - addButtons( "MSH", tips, titlebar, titleLayout ); - titleLayout->addItem(titlebar->captionSpacer); - addButtons( "IAX", tips, titlebar, titleLayout ); - } + addButtons( "MSH", tips, titlebar, titleLayout ); + titleLayout->addItem(titlebar->captionSpacer); + addButtons( "IAX", tips, titlebar, titleLayout ); } titleLayout->addSpacing(3); - + QColor c = options->colorGroup(Options::TitleBar, isActive()). color(QColorGroup::Button); @@ -450,15 +435,13 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent, } void B2Client::addButtons(const QString& s, const QString tips[], - B2Titlebar* tb, QHBoxLayout* titleLayout) + B2Titlebar* tb, QBoxLayout* titleLayout) { - int str_len = s.length(); - if (str_len <= 0) + if (s.length() <= 0) return; for(unsigned int i = 0; i < s.length(); i++) { - switch( (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - ? s[str_len-i-1].latin1():s[i].latin1()) { + switch(s[i].latin1()) { case 'M': // Menu button if (!button[BtnMenu]) { button[BtnMenu] = new B2Button(this, tb, tips[BtnMenu]); @@ -794,9 +777,10 @@ void B2Client::activeChange(bool on) void B2Client::menuButtonPressed() { - QPoint pos = button[BtnMenu]->mapToGlobal(button[BtnMenu]-> - rect().bottomLeft()); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + QPoint menupoint = button[BtnMenu]->mapToGlobal(button[BtnMenu]-> + rect().bottomLeft()); + workspace()->showWindowMenu( menupoint, this ); + button[BtnMenu]->setDown(false); } void B2Client::slotReset() diff --git a/clients/b2/b2client.h b/clients/b2/b2client.h index 0ff6a6477c..bcaac81db8 100644 --- a/clients/b2/b2client.h +++ b/clients/b2/b2client.h @@ -17,7 +17,7 @@ #include "../../kwinbutton.h" class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; class QGridLayout; namespace KWinInternal { @@ -111,7 +111,7 @@ private slots: void maxButtonClicked(); private: void addButtons(const QString& s, const QString tips[], - B2Titlebar* tb, QHBoxLayout* titleLayout); + B2Titlebar* tb, QBoxLayout* titleLayout); void positionButtons(); void calcHiddenButtons(); enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose, diff --git a/clients/default/kdedefault.cpp b/clients/default/kdedefault.cpp index 4e20fcbcc1..f15cee0e50 100644 --- a/clients/default/kdedefault.cpp +++ b/clients/default/kdedefault.cpp @@ -603,18 +603,18 @@ KDEDefaultClient::KDEDefaultClient( Workspace *ws, WId w, QWidget *parent, // No flicker thanks setBackgroundMode( QWidget::NoBackground ); - // Set button pointers to NULL so we can track things - for(int i=0; i < KDEDefaultClient::BtnCount; i++) - button[i] = NULL; + // Set button pointers to NULL so we can track things + for(int i=0; i < KDEDefaultClient::BtnCount; i++) + button[i] = NULL; // Finally, toolWindows look small if ( isTool() ) { - titleHeight = toolTitleHeight; - largeButtons = largeToolButtons; - } - else { - titleHeight = normalTitleHeight; - largeButtons = true; + titleHeight = toolTitleHeight; + largeButtons = largeToolButtons; + } + else { + titleHeight = normalTitleHeight; + largeButtons = true; } // Pack the windowWrapper() window within a grid @@ -624,58 +624,47 @@ KDEDefaultClient::KDEDefaultClient( Workspace *ws, WId w, QWidget *parent, g->addRowSpacing(2, 1); // line under titlebar g->addWidget(windowWrapper(), 3, 1); - // without the next line, unshade flickers - g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + // without the next line, unshade flickers + g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, + QSizePolicy::Expanding ) ); g->setRowStretch(3, 10); // Wrapped window - // Determine the size of the lower grab bar - if ( showGrabBar && (!isTool()) ) - g->addRowSpacing(4, 8); // bottom handles - else - g->addRowSpacing(4, 4); // bottom handles + // Determine the size of the lower grab bar + if ( showGrabBar && (!isTool()) ) + g->addRowSpacing(4, 8); // bottom handles + else + g->addRowSpacing(4, 4); // bottom handles g->addColSpacing(0, 4); g->addColSpacing(2, 4); // Pack the titlebar HBox with items - hb = new QHBoxLayout(); + hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0 ); hb->setResizeMode( QLayout::FreeResize ); g->addLayout ( hb, 1, 1 ); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addClientButtons( options->titleButtonsRight() ); - else addClientButtons( options->titleButtonsLeft() ); - - titlebar = new QSpacerItem( 10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum ); + titlebar = new QSpacerItem( 10, titleHeight, QSizePolicy::Expanding, + QSizePolicy::Minimum ); hb->addItem(titlebar); hb->addSpacing(2); - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addClientButtons( options->titleButtonsLeft(), false ); - else addClientButtons( options->titleButtonsRight(), false ); - } void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) { - if (s.length() > 0){ - unsigned int i = 0; - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - i = s.length() - 1; - //for( ; (i < s.length()) && (i) ;) { // i>=0 - for( ; ( i < s.length()) ;) { // i>=0 + if (s.length() > 0) + for(unsigned int i = 0; i < s.length(); i++) { switch( s[i].latin1() ) { // Menu button case 'M': if (!button[BtnMenu]) { - button[BtnMenu] = new KDEDefaultButton(this, "menu", + button[BtnMenu] = new KDEDefaultButton(this, "menu", largeButtons, isLeft, false, NULL, i18n("Menu")); - connect( button[BtnMenu], SIGNAL(pressed()), + connect( button[BtnMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed()) ); hb->addWidget( button[BtnMenu] ); } @@ -685,10 +674,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) case 'S': if (!button[BtnSticky]) { - button[BtnSticky] = new KDEDefaultButton(this, "sticky", + button[BtnSticky] = new KDEDefaultButton(this, "sticky", largeButtons, isLeft, true, NULL, i18n("Sticky")); button[BtnSticky]->turnOn( isSticky() ); - connect( button[BtnSticky], SIGNAL(clicked()), + connect( button[BtnSticky], SIGNAL(clicked()), this, SLOT(toggleSticky()) ); hb->addWidget( button[BtnSticky] ); } @@ -696,7 +685,7 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) // Help button case 'H': - if( providesContextHelp() && (!button[BtnHelp]) ) + if( providesContextHelp() && (!button[BtnHelp]) ) { button[BtnHelp] = new KDEDefaultButton(this, "help", largeButtons, isLeft, true, question_bits, @@ -711,10 +700,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) case 'I': if ( (!button[BtnIconify]) && isMinimizable()) { - button[BtnIconify] = new KDEDefaultButton(this, "iconify", + button[BtnIconify] = new KDEDefaultButton(this, "iconify", largeButtons, isLeft, true, iconify_bits, i18n("Minimize")); - connect( button[BtnIconify], SIGNAL( clicked()), + connect( button[BtnIconify], SIGNAL( clicked()), this, SLOT(iconify()) ); hb->addWidget( button[BtnIconify] ); } @@ -724,10 +713,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) case 'A': if ( (!button[BtnMax]) && isMaximizable()) { - button[BtnMax] = new KDEDefaultButton(this, "maximize", + button[BtnMax] = new KDEDefaultButton(this, "maximize", largeButtons, isLeft, true, maximize_bits, i18n("Maximize")); - connect( button[BtnMax], SIGNAL( clicked()), + connect( button[BtnMax], SIGNAL( clicked()), this, SLOT(slotMaximize()) ); hb->addWidget( button[BtnMax] ); } @@ -737,10 +726,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) case 'X': if (!button[BtnClose]) { - button[BtnClose] = new KDEDefaultButton(this, "close", + button[BtnClose] = new KDEDefaultButton(this, "close", largeButtons, isLeft, true, close_bits, i18n("Close")); - connect( button[BtnClose], SIGNAL( clicked()), + connect( button[BtnClose], SIGNAL( clicked()), this, SLOT(closeWindow()) ); hb->addWidget( button[BtnClose] ); } @@ -748,18 +737,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) // Spacer item (only for non-tool windows) case '_': - if ( !isTool() ) - hb->addSpacing(2); - } // switch( ... - - // this should be in the for() statment some how.... - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - i--; - else - i++; - - } // for( ... - } // if (s.length().... + if ( !isTool() ) + hb->addSpacing(2); + } + } } @@ -813,7 +794,7 @@ void KDEDefaultClient::resizeEvent( QResizeEvent* e) if ( dx ) { update( width() - dx + 1, 0, dx, height() ); - update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - + update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) ); update( QRect( titlebar->geometry().topRight(), QPoint(width() - 4, titlebar->geometry().bottom()) ) ); @@ -833,12 +814,14 @@ void KDEDefaultClient::captionChange( const QString& ) void KDEDefaultClient::paintEvent( QPaintEvent* ) { - if (!KDEDefault_initialized) - return; + if (!KDEDefault_initialized) + return; + + QColorGroup g; + int offset; + + KPixmap* upperGradient = isActive() ? aUpperGradient : iUpperGradient; - QColorGroup g; - int offset; - KPixmap* upperGradient = isActive() ? aUpperGradient : iUpperGradient; QPainter p(this); // Obtain widget bounds. @@ -850,19 +833,19 @@ void KDEDefaultClient::paintEvent( QPaintEvent* ) int w = r.width(); int h = r.height(); - // Determine where to place the extended left titlebar - int leftFrameStart = (h > 42) ? y+titleHeight+26: y+titleHeight; + // Determine where to place the extended left titlebar + int leftFrameStart = (h > 42) ? y+titleHeight+26: y+titleHeight; - // Determine where to make the titlebar color transition + // Determine where to make the titlebar color transition r = titlebar->geometry(); - int rightOffset = r.x()+r.width()+1; + int rightOffset = r.x()+r.width()+1; // Create a disposable pixmap buffer for the titlebar - // very early before drawing begins so there is no lag - // during painting pixels. + // very early before drawing begins so there is no lag + // during painting pixels. titleBuffer->resize( rightOffset-3, titleHeight+1 ); - // Draw an outer black frame + // Draw an outer black frame p.setPen(Qt::black); p.drawRect(x,y,w,h); @@ -925,14 +908,14 @@ void KDEDefaultClient::paintEvent( QPaintEvent* ) p.drawRect( x+3, y+titleHeight+3, w-6, h-titleHeight-offset-6 ); // Draw the title bar. - r = titlebar->geometry(); + r = titlebar->geometry(); // Obtain titlebar blend colours QColor c1 = options->color(Options::TitleBar, isActive() ); QColor c2 = options->color(Options::Frame, isActive() ); - // Fill with frame color behind RHS buttons - p.fillRect( rightOffset, y+2, x2-rightOffset-1, titleHeight+1, c2); + // Fill with frame color behind RHS buttons + p.fillRect( rightOffset, y+2, x2-rightOffset-1, titleHeight+1, c2); QPainter p2( titleBuffer, this ); @@ -957,20 +940,24 @@ void KDEDefaultClient::paintEvent( QPaintEvent* ) QFontMetrics fm(fnt); int captionWidth = fm.width(caption()); if (caption().isRightToLeft()) - p2.drawTiledPixmap( r.x(), 0, r.width()-captionWidth-4, titleHeight+1, *titlePix ); + p2.drawTiledPixmap( r.x(), 0, r.width()-captionWidth-4, + titleHeight+1, *titlePix ); else - p2.drawTiledPixmap( r.x()+captionWidth+3, 0, r.width()-captionWidth-4, titleHeight+1, *titlePix ); + p2.drawTiledPixmap( r.x()+captionWidth+3, 0, r.width()-captionWidth-4, + titleHeight+1, *titlePix ); } p2.setPen( options->color(Options::Font, isActive()) ); - p2.drawText(r.x(), 1, r.width(), r.height(), - caption().isRightToLeft()?AlignRight:AlignLeft|AlignVCenter, caption() ); + p2.drawText(r.x(), 1, r.width()-1, r.height(), + (caption().isRightToLeft() ? AlignRight : AlignLeft) | AlignVCenter, + caption() ); + + bitBlt( this, 2, 2, titleBuffer ); - bitBlt( this, 2, 2, titleBuffer ); p2.end(); - // Ensure a shaded window has no unpainted areas - p.setPen(c2); + // Ensure a shaded window has no unpainted areas + p.setPen(c2); p.drawLine(x+4, y+titleHeight+4, x2-4, y+titleHeight+4); } @@ -1087,10 +1074,10 @@ Client::MousePosition KDEDefaultClient::mousePosition( const QPoint& p ) const // Make sure the menu button follows double click conventions set in kcontrol void KDEDefaultClient::menuButtonPressed() { - QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-1, - button[BtnMenu]->rect().bottomLeft().y()+2 ); - QPoint pos = button[BtnMenu]->mapToGlobal( menupoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-1, + button[BtnMenu]->rect().bottomLeft().y()+2 ); + workspace()->showWindowMenu( button[BtnMenu]->mapToGlobal( menupoint ), this ); + button[BtnMenu]->setDown(false); } diff --git a/clients/default/kdedefault.h b/clients/default/kdedefault.h index 766d7a598a..e95866405e 100644 --- a/clients/default/kdedefault.h +++ b/clients/default/kdedefault.h @@ -22,7 +22,7 @@ class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; namespace KWinInternal { @@ -109,7 +109,7 @@ class KDEDefaultClient : public KWinInternal::Client int lastButtonWidth; int titleHeight; bool largeButtons; - QHBoxLayout* hb; + QBoxLayout* hb; QSpacerItem* titlebar; }; diff --git a/clients/icewm/icewm.cpp b/clients/icewm/icewm.cpp index ea5612a323..eaade15485 100644 --- a/clients/icewm/icewm.cpp +++ b/clients/icewm/icewm.cpp @@ -70,7 +70,7 @@ QPixmap* frameL [] = {NULL, NULL}; QPixmap* frameR [] = {NULL, NULL}; QPixmap* frameBL[] = {NULL, NULL}; QPixmap* frameB [] = {NULL, NULL}; -QPixmap* frameBR[] = {NULL, NULL}; +QPixmap* frameBR[] = {NULL, NULL}; // Button pixmaps QPixmap* closePix[] = {NULL, NULL}; @@ -177,7 +177,7 @@ ThemeHandler::ThemeHandler(): QObject( NULL ) ThemeHandler::~ThemeHandler() { - if (initialized) + if (initialized) freePixmaps(); delete colorInActiveTitleTextShadow; @@ -241,7 +241,7 @@ void ThemeHandler::readConfig() *titleButtonsRight = options->titleButtonsRight(); // Convert KDE to icewm style buttons - convertButtons( *titleButtonsLeft ); + convertButtons( *titleButtonsLeft ); convertButtons( *titleButtonsRight ); } @@ -368,7 +368,7 @@ void ThemeHandler::initTheme() // Bottom setPixmap( frameBL, "frame", "BL.xpm" ); setPixmap( frameB, "frame", "B.xpm", true ); - setPixmap( frameBR, "frame", "BR.xpm" ); + setPixmap( frameBR, "frame", "BR.xpm" ); // Make sure border sizes are at least reasonable... if (borderSizeX < 0) @@ -553,7 +553,7 @@ void ThemeHandler::setPixmap( QPixmap* p[], QString s1, QString s2, if ( p[Active] ) qWarning("kwin-icewm: setPixmap - should be null (1)\n"); if ( p[InActive] ) - qWarning("kwin-icewm: setPixmap - should be null (2)\n"); + qWarning("kwin-icewm: setPixmap - should be null (2)\n"); p[Active] = new QPixmap( locate("appdata", QString("icewm-themes/") + themeName + s1 + "A" + s2) ); @@ -723,33 +723,30 @@ IceWMClient::IceWMClient( Workspace *ws, WId w, QWidget *parent, const char *nam // Do something IceWM can't do :) if (titleBarOnTop) { - grid->addWidget(windowWrapper(), 2, 1); + grid->addWidget(windowWrapper(), 2, 1); // no shade flicker - grid->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - } + grid->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + } else { // no shade flicker - grid->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + grid->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); grid->addWidget(windowWrapper(), 1, 1); - } + } grid->setRowStretch(1, 10); grid->setRowStretch(2, 10); - grid->setColStretch(1, 10); + grid->setColStretch(1, 10); grid->addRowSpacing(3, borderSizeY); grid->addColSpacing(0, borderSizeX); grid->addColSpacing(2, borderSizeX); // Pack the titlebar with spacers and buttons - hb = new QHBoxLayout(); + hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); hb->setResizeMode( QLayout::FreeResize ); titleSpacerJ = addPixmapSpacer( titleJ ); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows()) ) - addClientButtons( *titleButtonsRight ); - else - addClientButtons( *titleButtonsLeft ); + addClientButtons( *titleButtonsLeft ); titleSpacerL = addPixmapSpacer( titleL ); // Centre titlebar if required. @@ -758,22 +755,15 @@ IceWMClient::IceWMClient( Workspace *ws, WId w, QWidget *parent, const char *nam titleSpacerS = addPixmapSpacer( titleS, spTitleBar, 1 ); titleSpacerP = addPixmapSpacer( titleP ); - titlebar = new QSpacerItem( titleTextWidth(caption()), titleBarHeight, + titlebar = new QSpacerItem( titleTextWidth(caption()), titleBarHeight, QSizePolicy::Preferred, QSizePolicy::Fixed ); hb->addItem(titlebar); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows()) ){ - titleSpacerR = addPixmapSpacer( titleR ); - titleSpacerB = addPixmapSpacer( titleB, QSizePolicy::Expanding, 1 ); - titleSpacerM = addPixmapSpacer( titleM ); - addClientButtons( *titleButtonsLeft ); - } - else{ - titleSpacerM = addPixmapSpacer( titleM ); - titleSpacerB = addPixmapSpacer( titleB, QSizePolicy::Expanding, 1 ); - titleSpacerR = addPixmapSpacer( titleR ); - addClientButtons( *titleButtonsRight ); - } + titleSpacerM = addPixmapSpacer( titleM ); + titleSpacerB = addPixmapSpacer( titleB, QSizePolicy::Expanding, 1 ); + titleSpacerR = addPixmapSpacer( titleR ); + + addClientButtons( *titleButtonsRight ); titleSpacerQ = addPixmapSpacer( titleQ ); @@ -798,31 +788,25 @@ IceWMClient::~IceWMClient() // in the button string 's' void IceWMClient::addClientButtons( const QString& s ) { -/* QString ss = s; - if (QApplication::reverseLayout()) - ss = clientHandler->reverseString( s );*/ - int str_len = s.length(); - - if (str_len > 0) - for(unsigned int i = 0; i < str_len; i++) + if (s.length() > 0) + for(unsigned int i = 0; i < s.length(); i++) { - switch ( (QApplication::reverseLayout() && (!options->reverseBIDIWindows()))? - s[str_len-i-1].latin1():s[i].latin1() ) + switch ( s[i].latin1() ) { case 's': - // Create the menu icons, and render with the current mini-icon + // Create the menu icons, and render with the current mini-icon // if explicitly requested by the theme. if ( validPixmaps(menuButtonPix) && !button[BtnSysMenu]) { if (showMenuButtonIcon) { renderMenuIcons(); - button[BtnSysMenu] = new IceWMButton(this, "menu", - &menuButtonWithIconPix, false, i18n("Menu")); + button[BtnSysMenu] = new IceWMButton(this, "menu", + &menuButtonWithIconPix, false, i18n("Menu")); } else - button[BtnSysMenu] = new IceWMButton(this, "menu", - &menuButtonPix, false, i18n("Menu")); - + button[BtnSysMenu] = new IceWMButton(this, "menu", + &menuButtonPix, false, i18n("Menu")); + connect( button[BtnSysMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed())); hb->addWidget( button[BtnSysMenu] ); @@ -970,7 +954,7 @@ void IceWMClient::resizeEvent( QResizeEvent* e ) Client::resizeEvent( e ); calcHiddenButtons(); - if (isVisibleToTLW()) + if (isVisibleToTLW()) { update(rect()); int dx = 0; @@ -1370,14 +1354,12 @@ Client::MousePosition IceWMClient::mousePosition( const QPoint& p ) const // Make sure the menu button follows double click conventions set in kcontrol void IceWMClient::menuButtonPressed() { - // Animate the menu button when pressed - if (button[BtnSysMenu]) - button[BtnSysMenu]->animateClick(); - QPoint menuPoint ( button[BtnSysMenu]->rect().bottomLeft() ); - // Move to right if menu on rhs, otherwise on left - // and make this depend on windowWrapper(), not button. - QPoint pos = button[BtnSysMenu]->mapToGlobal( menuPoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + QPoint menuPoint ( button[BtnSysMenu]->rect().bottomLeft() ); + + // Move to right if menu on rhs, otherwise on left + // and make this depend on windowWrapper(), not button. + workspace()->showWindowMenu( button[BtnSysMenu]->mapToGlobal(menuPoint), this ); + button[BtnSysMenu]->setDown(false); } diff --git a/clients/icewm/icewm.h b/clients/icewm/icewm.h index df30951761..8181bc79b2 100644 --- a/clients/icewm/icewm.h +++ b/clients/icewm/icewm.h @@ -49,7 +49,7 @@ #include "../../kwinbutton.h" class QLabel; class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; class QGridLayout; namespace KWinInternal { @@ -164,7 +164,7 @@ class IceWMClient : public KWinInternal::Client QSpacerItem* titleSpacerB; QSpacerItem* titleSpacerR; QSpacerItem* titleSpacerQ; - QHBoxLayout* hb; + QBoxLayout* hb; QGridLayout* grid; }; diff --git a/clients/kde1/kde1client.cpp b/clients/kde1/kde1client.cpp index 3c89427108..0c20262e0a 100644 --- a/clients/kde1/kde1client.cpp +++ b/clients/kde1/kde1client.cpp @@ -257,47 +257,31 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name ) button[4] = new ThreeButtonButton( this, 0, i18n("Maximize") ); button[5] = new KWinToolButton( this, 0, i18n("Close") ); - QHBoxLayout* hb = new QHBoxLayout; + QBoxLayout* hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); g->addLayout( hb, 0, 1 ); + hb->addWidget( button[0] ); + hb->addWidget( button[1] ); +// hb->addWidget( button[2] ); + int fh = fontMetrics().lineSpacing(); + titlebar = new QSpacerItem(10, fh, QSizePolicy::Expanding, QSizePolicy::Minimum ); + hb->addItem( titlebar ); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())){ - hb->addWidget( button[5] ); - hb->addWidget( button[4] ); - hb->addWidget( button[3] ); - if ( providesContextHelp() ) { - button[6] = new KWinToolButton( this, 0, i18n("Help") ); - hb->addWidget( button[6] ); // help button - hb->addItem( new QSpacerItem( 5, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - button[6]->setIconSet( isActive() ? *question_mark_pix : *dis_question_mark_pix); - connect( button[6], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) ); - } - button[6] = 0; - hb->addItem( titlebar ); - // hb->addWidget( button[2] ); - hb->addWidget( button[1] ); - hb->addWidget( button[0] ); - } - else{ - hb->addWidget( button[0] ); - hb->addWidget( button[1] ); - // hb->addWidget( button[2] ); - hb->addItem( titlebar ); - button[6] = 0; - if ( providesContextHelp() ) { - button[6] = new KWinToolButton( this, 0, i18n("Help") ); - hb->addWidget( button[6] ); // help button - hb->addItem( new QSpacerItem( 5, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - button[6]->setIconSet( isActive() ? *question_mark_pix : *dis_question_mark_pix); - connect( button[6], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) ); - } - hb->addWidget( button[3] ); - hb->addWidget( button[4] ); - hb->addWidget( button[5] ); + button[6] = 0; + if ( providesContextHelp() ) { + button[6] = new KWinToolButton( this, 0, i18n("Help") ); + hb->addWidget( button[6] ); // help button + hb->addItem( new QSpacerItem( 5, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); + button[6]->setIconSet( isActive() ? *question_mark_pix : *dis_question_mark_pix); + connect( button[6], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) ); } + hb->addWidget( button[3] ); + hb->addWidget( button[4] ); + hb->addWidget( button[5] ); + for ( int i = 0; i < 7; i++) { if ( !button[i] ) continue; @@ -325,8 +309,8 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name ) button[5]->setIconSet(isActive() ? *close_pix : *dis_close_pix); connect( button[5], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) ); -// if ( button[6] ) { -// } + if ( button[6] ) { + } if ( isTransient() ) { @@ -461,12 +445,10 @@ void StdClient::iconChange() */ void StdClient::menuButtonPressed() { - // Animate the click when the menu button is pressed - button[0]->animateClick(); QPoint menupoint ( button[0]->rect().bottomLeft().x()-1, button[0]->rect().bottomLeft().y()+2 ); - QPoint pos = button[0]->mapToGlobal( menupoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + workspace()->showWindowMenu( button[0]->mapToGlobal( menupoint ), this ); + button[0]->setDown(false); } diff --git a/clients/keramik/keramik.cpp b/clients/keramik/keramik.cpp index d08f065d32..247c0bc69a 100644 --- a/clients/keramik/keramik.cpp +++ b/clients/keramik/keramik.cpp @@ -128,7 +128,7 @@ namespace Keramik KeramikHandler *clientHandler = NULL; bool keramik_initialized = false; -} // namespace Keramik +} // namespace Keramik @@ -146,6 +146,8 @@ KeramikHandler::KeramikHandler() settings_cache = NULL; + imageDict = new ImageDict; + // Create the button deco bitmaps buttonDecos[ Menu ] = new QBitmap( 17, 17, menu_bits, true ); buttonDecos[ Sticky ] = new QBitmap( 17, 17, sticky_on_bits, true ); @@ -164,7 +166,7 @@ KeramikHandler::KeramikHandler() if ( QApplication::reverseLayout() ) { for ( int i = 0; i < Help; i++ ) flip( reinterpret_cast(buttonDecos)[i] ); - + for ( int i = Help + 1; i < NumButtonDecos; i++ ) flip( reinterpret_cast(buttonDecos)[i] ); } @@ -186,6 +188,9 @@ KeramikHandler::~KeramikHandler() if ( settings_cache ) delete settings_cache; + + if ( imageDict ) + delete imageDict; } @@ -404,7 +409,7 @@ void KeramikHandler::readConfig() if ( ! settings_cache ) { settings_cache = new SettingsCache; - + if ( options->customButtonPositions() ) { settings_cache->buttonsLeft = options->titleButtonsLeft(); settings_cache->buttonsRight = options->titleButtonsRight(); @@ -412,13 +417,12 @@ void KeramikHandler::readConfig() settings_cache->buttonsLeft = QString( default_left ); settings_cache->buttonsRight = QString( default_right ); } - + settings_cache->aTitleColor = options->color( Options::TitleBar, true ); settings_cache->aTitleBlend = options->color( Options::TitleBlend, true ); settings_cache->iTitleColor = options->color( Options::TitleBar, false ); settings_cache->iTitleBlend = options->color( Options::TitleBlend, false ); settings_cache->buttonColor = options->color( Options::ButtonBg, true ); - settings_cache->reverseBIDIWindows = options->reverseBIDIWindows(); } delete c; @@ -434,14 +438,14 @@ QPixmap *KeramikHandler::composite( QImage *over, QImage *under ) // Clear the destination image Q_UINT32 *data = reinterpret_cast( dest.bits() ); for (int i = 0; i < width * height; i++) - *(data++) = 0; + *(data++) = 0; // Copy the under image (bottom aligned) to the destination image for (int y1 = height - under->height(), y2 = 0; y1 < height; y1++, y2++ ) { register Q_UINT32 *dst = reinterpret_cast( dest.scanLine(y1) ); register Q_UINT32 *src = reinterpret_cast( under->scanLine(y2) ); - + for ( int x = 0; x < width; x++ ) *(dst++) = *(src++); } @@ -457,33 +461,33 @@ QPixmap *KeramikHandler::composite( QImage *over, QImage *under ) if ( a == 0xff ) *dst = *src; - + else if ( a != 0x00 ) *dst = qRgba( Q_UINT8( r1 + (((r2 - r1) * a) >> 8) ), Q_UINT8( g1 + (((g2 - g1) * a) >> 8) ), Q_UINT8( b1 + (((b2 - b1) * a) >> 8) ), 0xff ); - + else if ( qAlpha(*dst) == 0x00 ) *dst = 0; - + src++; dst++; } - + // Compute a 1 bpp mask from the alpha channel QImage alphaMask = dest.createAlphaMask(); dest.setAlphaBuffer( false ); - + // Create the final pixmap QPixmap *pix = new QPixmap( dest ); - + // Set the computed mask for the pixmap if ( ! alphaMask.isNull() ) { QBitmap mask; mask.convertFromImage( alphaMask ); pix->setMask( mask ); - } + } return pix; } @@ -492,11 +496,11 @@ QPixmap *KeramikHandler::composite( QImage *over, QImage *under ) QImage *KeramikHandler::loadImage( const QString &name, const QColor &col ) { if ( col.isValid() ) { - QImage *img = new QImage( qembed_findImage(name).copy() ); + QImage *img = new QImage( qembed_findImage(name)->copy() ); KIconEffect::colorize( *img, col, 1.0 ); return img; } else - return new QImage( qembed_findImage(name).copy() ); + return new QImage( qembed_findImage(name)->copy() ); } @@ -513,9 +517,9 @@ QPixmap *KeramikHandler::loadPixmap( const QString &name, const QColor &col ) void KeramikHandler::reset() { QString buttonsLeft, buttonsRight; - + keramik_initialized = false; - + bool needHardReset = false; bool pixmapsInvalid = false; @@ -531,7 +535,7 @@ void KeramikHandler::reset() { pixmapsInvalid = true; } - + // Check if button positions have changed if ( options->customButtonPositions() ) { buttonsLeft = options->titleButtonsLeft(); @@ -540,16 +544,12 @@ void KeramikHandler::reset() buttonsLeft = QString( default_left ); buttonsRight = QString( default_right ); } - + if ( (settings_cache->buttonsLeft != buttonsLeft) || (settings_cache->buttonsRight != buttonsRight) ) { needHardReset = true; } - // bidi is always a mess.. - if (settings_cache->reverseBIDIWindows != options->reverseBIDIWindows()) - needHardReset = true; - // Update our config cache settings_cache->aTitleColor = options->color( Options::TitleBar, true ); settings_cache->aTitleBlend = options->color( Options::TitleBlend, true ); @@ -558,8 +558,8 @@ void KeramikHandler::reset() settings_cache->buttonColor = options->color( Options::ButtonBg, true ); settings_cache->buttonsLeft = buttonsLeft; settings_cache->buttonsRight = buttonsRight; - settings_cache->reverseBIDIWindows = options->reverseBIDIWindows(); - + + // Do we need to recreate the pixmaps? if ( pixmapsInvalid ) { destroyPixmaps(); @@ -721,31 +721,26 @@ KeramikClient::KeramikClient( Workspace *ws, WId w, QWidget *parent, const char button[i] = NULL; QVBoxLayout *mainLayout = new QVBoxLayout( this ); - QHBoxLayout *titleLayout = new QHBoxLayout(); + QBoxLayout *titleLayout = new QBoxLayout( 0, QBoxLayout::LeftToRight, 0, 0, 0 ); QHBoxLayout *windowLayout = new QHBoxLayout(); largeTitlebar = ( !maximizedVertical() && clientHandler->largeCaptionBubbles() ); largeCaption = ( isActive() && largeTitlebar ); - + int topSpacing = ( largeTitlebar ? 4 : 1 ); topSpacer = new QSpacerItem( 10, topSpacing, QSizePolicy::Expanding, QSizePolicy::Minimum ); mainLayout->addItem( topSpacer ); - + mainLayout->addLayout( titleLayout ); // Titlebar mainLayout->addLayout( windowLayout, 1 ); // Left border + window + right border mainLayout->addSpacing( 8 ); // Bottom grab bar + shadow titleLayout->setSpacing( buttonSpacing ); - + titleLayout->addSpacing( buttonMargin ); // Left button margin - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addButtons( titleLayout, options->customButtonPositions() ? - options->titleButtonsRight() : QString(default_left) ); - else - addButtons( titleLayout, options->customButtonPositions() ? + addButtons( titleLayout, options->customButtonPositions() ? options->titleButtonsLeft() : QString(default_left) ); titlebar = new QSpacerItem( 10, clientHandler->titleBarHeight(largeTitlebar) @@ -753,14 +748,8 @@ KeramikClient::KeramikClient( Workspace *ws, WId w, QWidget *parent, const char titleLayout->addItem( titlebar ); titleLayout->addSpacing( buttonSpacing ); - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addButtons( titleLayout, options->customButtonPositions() ? - options->titleButtonsLeft() : QString(default_right) ); - else - addButtons( titleLayout, options->customButtonPositions() ? + addButtons( titleLayout, options->customButtonPositions() ? options->titleButtonsRight() : QString(default_right) ); - titleLayout->addSpacing( buttonMargin - 1 ); // Right button margin windowLayout->addSpacing( 3 ); // Left border @@ -819,20 +808,17 @@ void KeramikClient::reset() // (i.e. not minimized and on the current desktop) if ( isVisible() ) { repaint( false ); - + for ( int i = 0; i < NumButtons; i++ ) if ( button[i] ) button[i]->repaint( false ); } } -void KeramikClient::addButtons( QHBoxLayout *layout, const QString &s ) +void KeramikClient::addButtons( QBoxLayout *layout, const QString &s ) { - uint i = 0; - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - i = s.length() - 1; - - for( ; ( i < s.length()) ;) { // i>=0 + for ( uint i=0; i < s.length(); i++ ) + { switch ( s[i].latin1() ) { // Menu button @@ -852,7 +838,7 @@ void KeramikClient::addButtons( QHBoxLayout *layout, const QString &s ) layout->addWidget( button[StickyButton] ); } break; - + // Help button case 'H' : if ( !button[HelpButton] && providesContextHelp() ) { @@ -879,7 +865,7 @@ void KeramikClient::addButtons( QHBoxLayout *layout, const QString &s ) layout->addWidget( button[MaxButton] ); } break; - + // Close button case 'X' : if ( !button[CloseButton] ) { @@ -888,18 +874,12 @@ void KeramikClient::addButtons( QHBoxLayout *layout, const QString &s ) layout->addWidget( button[CloseButton] ); } break; - + // Additional spacing case '_' : layout->addSpacing( buttonSpacing ); break; } - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - i--; - else - i++; - } } @@ -1212,26 +1192,10 @@ void KeramikClient::stickyChange( bool on ) void KeramikClient::menuButtonPressed() { - static KeramikClient *tc = 0; - - - if (tc == this) - { - workspace()->clientPopup( this )->hide(); - tc = 0; - } - else - { - QPoint menuPoint ( button[MenuButton]->rect().bottomLeft().x() - 6, - button[MenuButton]->rect().bottomLeft().y() + 3 ); - workspace()->clientPopup( this )->popup( button[MenuButton]->mapToGlobal( menuPoint ) ); - - // Post a fake mouse button release event to the menu button - // to ensure that it's redrawn in its unpressed state - QApplication::postEvent( button[MenuButton], new QMouseEvent( QEvent::MouseButtonRelease, - QPoint(0,0), Qt::LeftButton, Qt::LeftButton ) ); - tc = this; - } + QPoint menuPoint ( button[MenuButton]->rect().bottomLeft().x() - 6, + button[MenuButton]->rect().bottomLeft().y() + 3 ); + workspace()->showWindowMenu( button[MenuButton]->mapToGlobal( menuPoint ), this ); + button[MenuButton]->setDown(false); } diff --git a/clients/keramik/keramik.h b/clients/keramik/keramik.h index 34d62fc2bc..6b3ca52775 100644 --- a/clients/keramik/keramik.h +++ b/clients/keramik/keramik.h @@ -30,17 +30,18 @@ #include "../../client.h" #include "../../kwinbutton.h" -static QDict< QImage > imageDict; - -#include "tiles.h" - - class QSpacerItem; using namespace KWinInternal; namespace Keramik { + typedef QDict ImageDict; + static ImageDict* imageDict = 0; + + #include "tiles.h" + + enum TilePixmap { TitleLeft=0, TitleCenter, TitleRight, CaptionSmallLeft, CaptionSmallCenter, CaptionSmallRight, CaptionLargeLeft, CaptionLargeCenter, CaptionLargeRight, @@ -62,7 +63,6 @@ namespace Keramik { QColor buttonColor; QString buttonsLeft; QString buttonsRight; - bool reverseBIDIWindows; }; class KeramikHandler : public QObject { @@ -152,7 +152,7 @@ namespace Keramik { ~KeramikClient(); private: - void addButtons( QHBoxLayout*, const QString & ); + void addButtons( QBoxLayout*, const QString & ); void updateMask(); void updateCaptionBuffer(); void captionChange( const QString& ); diff --git a/clients/keramik/tiles.h b/clients/keramik/tiles.h index 66728dfa35..889889eec5 100644 --- a/clients/keramik/tiles.h +++ b/clients/keramik/tiles.h @@ -616,12 +616,12 @@ static struct EmbedImage { { 0, 0, 0, 0, 0, 0, 0, 0 } }; -static const QImage& qembed_findImage( const QString& name ) +const QImage* qembed_findImage( const QString& name ) { - - QImage* img = imageDict.find(name); - if ( !img ) { - for (int i=0; embed_image_vec[i].data; i++) { + QImage* img = imageDict->find(name); + if ( !img ) + { + for (int i=0; embed_image_vec[i].data; i++) if ( 0==strcmp(embed_image_vec[i].name, name) ) { img = new QImage((uchar*)embed_image_vec[i].data, embed_image_vec[i].width, @@ -635,13 +635,8 @@ static const QImage& qembed_findImage( const QString& name ) img->setAlphaBuffer(TRUE); break; } - } - if ( !img ) { - static QImage dummy; - return dummy; - } } - return *img; + return img; } #endif diff --git a/clients/kstep/nextclient.cpp b/clients/kstep/nextclient.cpp index b1c75d02b6..7426d5a31c 100644 --- a/clients/kstep/nextclient.cpp +++ b/clients/kstep/nextclient.cpp @@ -273,7 +273,7 @@ NextClient::NextClient( Workspace *ws, WId w, QWidget *parent, connect(options, SIGNAL(resetClients()), this, SLOT(slotReset())); QVBoxLayout *mainLayout = new QVBoxLayout(this); - QHBoxLayout *titleLayout = new QHBoxLayout(); + QBoxLayout *titleLayout = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); QHBoxLayout *windowLayout = new QHBoxLayout(); mainLayout->addLayout(titleLayout); @@ -298,7 +298,7 @@ NextClient::NextClient( Workspace *ws, WId w, QWidget *parent, button is selected in the current button scheme, or (2) null otherwise. */ -void NextClient::initializeButtonsAndTitlebar(QHBoxLayout* titleLayout) +void NextClient::initializeButtonsAndTitlebar(QBoxLayout* titleLayout) { // Null the buttons to begin with (they are not guaranteed to be null). for (int i=0; ireverseBIDIWindows()))? - spec[str_len-i-1].latin1():spec[i].latin1()){ + switch (spec[i].latin1()) { case 'A': if (isMaximizable()) { button[MAXIMIZE_IDX] = @@ -376,7 +370,7 @@ void NextClient::addButtons(QHBoxLayout* titleLayout, const QString& spec) this, SLOT(iconify()) ); } break; - + case 'M': button[MENU_IDX] = new NextButton(this, "menu", NULL, 10, 10, i18n("Menu")); @@ -417,16 +411,14 @@ void NextClient::addButtons(QHBoxLayout* titleLayout, const QString& spec) } } -// Make sure the menu button follows double click conventions set in kcontrol -// (Note: this was almost straight copy and paste from KDEDefaultClient.) void NextClient::menuButtonPressed() { // Probably don't need this null check, but we might as well. if (button[MENU_IDX]) { QPoint menupoint ( button[MENU_IDX]->rect().bottomLeft().x()-1, button[MENU_IDX]->rect().bottomLeft().y()+2 ); - QPoint pos = button[MENU_IDX]->mapToGlobal( menupoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + workspace()->showWindowMenu(button[MENU_IDX]->mapToGlobal(menupoint), this); + button[MENU_IDX]->setDown(false); } } diff --git a/clients/kstep/nextclient.h b/clients/kstep/nextclient.h index 47a4521371..ac0eb147e0 100644 --- a/clients/kstep/nextclient.h +++ b/clients/kstep/nextclient.h @@ -58,8 +58,8 @@ protected slots: void maximizeButtonClicked(); private: - void initializeButtonsAndTitlebar(QHBoxLayout* titleLayout); - void addButtons(QHBoxLayout* titleLayout, const QString& buttons); + void initializeButtonsAndTitlebar(QBoxLayout* titleLayout); + void addButtons(QBoxLayout* titleLayout, const QString& buttons); QSpacerItem* titlebar; diff --git a/clients/kwmtheme/kwmthemeclient.cpp b/clients/kwmtheme/kwmthemeclient.cpp index 53404e4132..f22be97118 100644 --- a/clients/kwmtheme/kwmthemeclient.cpp +++ b/clients/kwmtheme/kwmthemeclient.cpp @@ -263,7 +263,7 @@ KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent, layout->setRowStretch(2, 10); layout->setColStretch(1, 10); - QHBoxLayout* hb = new QHBoxLayout; + QBoxLayout* hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); layout->addLayout( hb, 1, 1 ); KConfig *config = KGlobal::config(); diff --git a/clients/laptop/laptopclient.cpp b/clients/laptop/laptopclient.cpp index 30d366732f..d6e07195de 100644 --- a/clients/laptop/laptopclient.cpp +++ b/clients/laptop/laptopclient.cpp @@ -219,8 +219,8 @@ static void delete_pixmaps() } -LaptopClientButton::LaptopClientButton(int w, int h, Client *parent, - const char *name, const unsigned char *bitmap, +LaptopClientButton::LaptopClientButton(int w, int h, Client *parent, + const char *name, const unsigned char *bitmap, const QString& tip) : KWinButton(parent, name, tip) { @@ -230,7 +230,7 @@ LaptopClientButton::LaptopClientButton(int w, int h, Client *parent, resize(defaultSize); if(bitmap) setBitmap(bitmap); - setBackgroundMode(QWidget::NoBackground); + //setBackgroundMode(QWidget::NoBackground); } QSize LaptopClientButton::sizeHint() const @@ -322,7 +322,7 @@ LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent, if ( isTool() ) th -= 2; - button[BtnClose] = new LaptopClientButton(27, th, this, "close", + button[BtnClose] = new LaptopClientButton(27, th, this, "close", close_bits, i18n("Close")); button[BtnSticky] = new LaptopClientButton(17, th, this, "sticky", NULL, i18n("Sticky")); @@ -347,37 +347,21 @@ LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent, connect( button[BtnIconify], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) ); connect( button[BtnMax], SIGNAL( clicked() ), this, ( SLOT( slotMaximize() ) ) ); - hb = new QHBoxLayout(); + hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); hb->setResizeMode(QLayout::FreeResize); g->addLayout( hb, 1, 1 ); - titlebar = new QSpacerItem(10, th, QSizePolicy::Expanding, QSizePolicy::Minimum); - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())){ - hb->addWidget( button[BtnMax]); - hb->addWidget( button[BtnIconify]); - hb->addWidget( button[BtnSticky]); - if(help){ - hb->addWidget( button[BtnHelp]); - } - hb->addSpacing(1); - hb->addItem(titlebar); - hb->addSpacing(1); - hb->addWidget( button[BtnClose]); + hb->addWidget( button[BtnClose]); + hb->addSpacing(1); + titlebar = new QSpacerItem(10, th, QSizePolicy::Expanding, + QSizePolicy::Minimum); + hb->addItem(titlebar); + hb->addSpacing(1); + if(help){ + hb->addWidget( button[BtnHelp]); } - else{ - hb->addWidget( button[BtnClose]); - hb->addSpacing(1); - hb->addItem(titlebar); - hb->addSpacing(1); - if(help){ - hb->addWidget( button[BtnHelp]); - } - hb->addWidget( button[BtnSticky]); - hb->addWidget( button[BtnIconify]); - hb->addWidget( button[BtnMax]); - } - - + hb->addWidget( button[BtnSticky]); + hb->addWidget( button[BtnIconify]); + hb->addWidget( button[BtnMax]); if ( isTransient() || isTool() ) button[BtnSticky]->hide(); diff --git a/clients/laptop/laptopclient.h b/clients/laptop/laptopclient.h index c6d78a7e26..f23b80b1d7 100644 --- a/clients/laptop/laptopclient.h +++ b/clients/laptop/laptopclient.h @@ -7,7 +7,7 @@ #include "../../kwinbutton.h" class QLabel; class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; namespace KWinInternal { @@ -74,7 +74,7 @@ private: int lastButtonWidth; QSpacerItem* titlebar; bool hiddenItems; - QHBoxLayout* hb; + QBoxLayout* hb; KPixmap activeBuffer; bool bufferDirty; int lastBufferWidth; diff --git a/clients/modernsystem/modernsys.cpp b/clients/modernsystem/modernsys.cpp index d3ccb46c0d..8c9adc3c97 100644 --- a/clients/modernsystem/modernsys.cpp +++ b/clients/modernsystem/modernsys.cpp @@ -294,6 +294,8 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent, const char *name ) : Client( ws, w, parent, name, WResizeNoErase ) { + bool reverse = QApplication::reverseLayout(); + connect(options, SIGNAL(resetClients()), this, SLOT(slotReset())); bool help = providesContextHelp(); @@ -302,12 +304,12 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent, g->setRowStretch(1, 10); g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - g->addColSpacing(0, 2); - g->addColSpacing(2, 2 + handle_width); + g->addColSpacing(0, 2 + (reverse ? handle_width : 0)); + g->addColSpacing(2, 2 + (reverse ? 0 : handle_width)); g->addRowSpacing(2, 2 + handle_width); - QHBoxLayout* hb = new QHBoxLayout(0); + QBoxLayout* hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); hb->setResizeMode(QLayout::FreeResize); titlebar = new QSpacerItem(10, 16, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -325,12 +327,7 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent, connect( button[BtnHelp], SIGNAL(clicked()), this, SLOT( contextHelp() ) ); for (int i = 0; i < (int)button_pattern->length();) { - QChar c; - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - c = (*button_pattern)[button_pattern->length()-i++]; - else - c = (*button_pattern)[i++]; - + QChar c = (*button_pattern)[i++]; if (c == '_') c = '3'; diff --git a/clients/quartz/quartz.cpp b/clients/quartz/quartz.cpp index 704274cb1e..8744a9734c 100644 --- a/clients/quartz/quartz.cpp +++ b/clients/quartz/quartz.cpp @@ -443,22 +443,16 @@ QuartzClient::QuartzClient( Workspace *ws, WId w, QWidget *parent, g->addColSpacing(2, 4); // Pack the titlebar HBox with items - hb = new QHBoxLayout(); + hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); hb->setResizeMode( QLayout::FreeResize ); g->addLayout ( hb, 1, 1 ); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addClientButtons( options->titleButtonsRight() ); - else addClientButtons( options->titleButtonsLeft() ); titlebar = new QSpacerItem( 10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum ); hb->addItem(titlebar); hb->addSpacing(2); - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - addClientButtons( options->titleButtonsLeft(), false ); - else addClientButtons( options->titleButtonsRight(), false ); hb->addSpacing(2); @@ -467,20 +461,18 @@ QuartzClient::QuartzClient( Workspace *ws, WId w, QWidget *parent, void QuartzClient::addClientButtons( const QString& s, bool isLeft ) { - int str_len = s.length(); - if (str_len > 0) + if (s.length() > 0) for(unsigned int i = 0; i < s.length(); i++) { - switch( QApplication::reverseLayout() && (!options->reverseBIDIWindows())? - s[str_len-i-1].latin1():s[i].latin1()) + switch( s[i].latin1() ) { // Menu button case 'M': if (!button[BtnMenu]) { - button[BtnMenu] = new QuartzButton(this, "menu", + button[BtnMenu] = new QuartzButton(this, "menu", largeButtons, isLeft, false, NULL, i18n("Menu")); - connect( button[BtnMenu], SIGNAL(pressed()), + connect( button[BtnMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed()) ); hb->addWidget( button[BtnMenu] ); } @@ -519,7 +511,7 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft ) { button[BtnIconify] = new QuartzButton(this, "iconify", largeButtons, isLeft, true, iconify_bits, i18n("Minimize")); - connect( button[BtnIconify], SIGNAL( clicked()), + connect( button[BtnIconify], SIGNAL( clicked()), this, SLOT(iconify()) ); hb->addWidget( button[BtnIconify] ); } @@ -543,7 +535,7 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft ) { button[BtnClose] = new QuartzButton(this, "close", largeButtons, isLeft, true, close_bits, i18n("Close")); - connect( button[BtnClose], SIGNAL( clicked()), + connect( button[BtnClose], SIGNAL( clicked()), this, SLOT(closeWindow()) ); hb->addWidget( button[BtnClose] ); } @@ -645,7 +637,7 @@ void QuartzClient::paintEvent( QPaintEvent* ) g = options->colorGroup(Options::TitleBar, isActive()); else g = options->colorGroup(Options::Frame, isActive()); - + // Draw outer highlights and lowlights p.setPen( g.light().light(120) ); p.drawLine( x, y, x2-1, y ); @@ -667,7 +659,7 @@ void QuartzClient::paintEvent( QPaintEvent* ) p.drawRect( x+3, y + titleHeight + 3, w-6, h-titleHeight-6 ); // Drawing this extra line removes non-drawn areas when shaded - p.drawLine( x+4, y2-4, x2-4, y2-4); + p.drawLine( x+4, y2-4, x2-4, y2-4); // Highlight top corner p.setPen( g.light().light(160) ); @@ -684,16 +676,14 @@ void QuartzClient::paintEvent( QPaintEvent* ) QColor c1 = options->color(Options::TitleBar, isActive() ).light(130); QColor c2 = options->color(Options::TitleBlend, isActive() ); - // Create a disposable pixmap buffer for the titlebar + // Create a disposable pixmap buffer for the titlebar KPixmap* titleBuffer = new KPixmap; - titleBuffer->resize( w-6, titleHeight ); + titleBuffer->resize( w-6, titleHeight ); QPainter p2( titleBuffer, this ); - int rightoffset = r.x()+r.width()-25-4; // subtract titleBlocks pixmap width and some - /*if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())) - rightoffset = 0; -*/ + int rightoffset = r.x()+r.width()-25-4; // subtract titleBlocks pixmap width and some + p2.fillRect( 0, 0, w, r.height(), c1 ); p2.fillRect( rightoffset, 0, w-rightoffset-6, r.height(), c2 ); @@ -707,8 +697,8 @@ void QuartzClient::paintEvent( QPaintEvent* ) // for toolwindows than the default. QFont fnt = options->font(true); if ( !largeButtons ) - { - fnt.setPointSize( fnt.pointSize() - 3 ); // Shrink font by 3pt + { + fnt.setPointSize( fnt.pointSize() - 3 ); // Shrink font by 3pt fnt.setWeight( QFont::Normal ); // and disable bold } p2.setFont( fnt ); @@ -802,8 +792,8 @@ void QuartzClient::menuButtonPressed() { QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-1, button[BtnMenu]->rect().bottomLeft().y()+2 ); - QPoint pos = button[BtnMenu]->mapToGlobal( menupoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + workspace()->showWindowMenu( button[BtnMenu]->mapToGlobal( menupoint ), this ); + button[BtnMenu]->setDown(false); } diff --git a/clients/quartz/quartz.h b/clients/quartz/quartz.h index 58085cbdcb..7caaa4bff2 100644 --- a/clients/quartz/quartz.h +++ b/clients/quartz/quartz.h @@ -24,7 +24,7 @@ #include "../../kwinbutton.h" class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; namespace KWinInternal { @@ -107,7 +107,7 @@ class QuartzClient : public KWinInternal::Client int lastButtonWidth; int titleHeight; bool largeButtons; - QHBoxLayout* hb; + QBoxLayout* hb; QSpacerItem* titlebar; }; diff --git a/clients/redmond/redmond.cpp b/clients/redmond/redmond.cpp index d9095976cc..a56a56be57 100644 --- a/clients/redmond/redmond.cpp +++ b/clients/redmond/redmond.cpp @@ -412,59 +412,31 @@ GalliumClient::GalliumClient( Workspace *ws, WId w, QWidget *parent, connect( button[BtnMax], SIGNAL( clicked() ), this, SLOT( slotMaximize() )); connect( options, SIGNAL(resetClients()), this, SLOT( slotReset() )); - - // Pack the titleBar hbox with items - hb = new QHBoxLayout(); + // Pack the titleBar hbox with items + hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0); hb->setResizeMode(QLayout::FreeResize); g->addLayout( hb, 1, 1 ); - - if (QApplication::reverseLayout() && (!options->reverseBIDIWindows())){ - hb->addWidget( button[BtnClose] ); - hb->addSpacing(2); - hb->addWidget( button[BtnMax] ); - hb->addWidget( button[BtnIconify] ); - hb->addSpacing(2); + hb->addSpacing(2); + hb->addWidget( button[BtnMenu] ); + titlebar = new QSpacerItem(10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum); + hb->addItem(titlebar); + hb->addSpacing(2); - if( providesContextHelp() ) - { - button[BtnHelp] = new GalliumButton(this, "help", question_bits, false, smallButtons, - i18n("Help")); - connect( button[BtnHelp], SIGNAL( clicked() ), this, SLOT( contextHelp() )); - hb->addWidget( button[BtnHelp] ); - } - else - button[BtnHelp] = NULL; - - titlebar = new QSpacerItem(10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum); - hb->addItem(titlebar); - hb->addSpacing(2); - hb->addWidget( button[BtnMenu] ); - hb->addSpacing(2); + if( providesContextHelp() ) + { + button[BtnHelp] = new GalliumButton(this, "help", question_bits, false, smallButtons, + i18n("Help")); + connect( button[BtnHelp], SIGNAL( clicked() ), this, SLOT( contextHelp() )); + hb->addWidget( button[BtnHelp] ); } - else{ - hb->addSpacing(2); - hb->addWidget( button[BtnMenu] ); - titlebar = new QSpacerItem(10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum); - hb->addItem(titlebar); - hb->addSpacing(2); + else + button[BtnHelp] = NULL; - if( providesContextHelp() ) - { - button[BtnHelp] = new GalliumButton(this, "help", question_bits, false, smallButtons, - i18n("Help")); - hb->addSpacing(2); - connect( button[BtnHelp], SIGNAL( clicked() ), this, SLOT( contextHelp() )); - hb->addWidget( button[BtnHelp] ); - } - else - button[BtnHelp] = NULL; - - hb->addWidget( button[BtnIconify] ); - hb->addWidget( button[BtnMax] ); - hb->addSpacing(2); - hb->addWidget( button[BtnClose] ); - hb->addSpacing(2); - } + hb->addWidget( button[BtnIconify] ); + hb->addWidget( button[BtnMax] ); + hb->addSpacing(2); + hb->addWidget( button[BtnClose] ); + hb->addSpacing(2); // Hide buttons which are not required // We can un-hide them if required later @@ -782,11 +754,10 @@ void GalliumClient::calcHiddenButtons() void GalliumClient::menuButtonPressed() { - // KS - move the menu left by 3 pixels, and down 2 pixels. QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-3, button[BtnMenu]->rect().bottomLeft().y()+2 ); - QPoint pos = button[BtnMenu]->mapToGlobal( menupoint ); - workspace()->showWindowMenu( pos.x(), pos.y(), this ); + workspace()->showWindowMenu( button[BtnMenu]->mapToGlobal( menupoint ), this ); + button[BtnMenu]->setDown(false); } extern "C" diff --git a/clients/redmond/redmond.h b/clients/redmond/redmond.h index 953d77e682..687fc966ee 100644 --- a/clients/redmond/redmond.h +++ b/clients/redmond/redmond.h @@ -24,7 +24,7 @@ #include "../../kwinbutton.h" class QLabel; class QSpacerItem; -class QHBoxLayout; +class QBoxLayout; namespace KWinInternal { @@ -90,7 +90,7 @@ class GalliumClient : public KWinInternal::Client int titleHeight; QSpacerItem* titlebar; bool hiddenItems; - QHBoxLayout* hb; + QBoxLayout* hb; bool smallButtons; }; diff --git a/clients/riscos/Manager.cpp b/clients/riscos/Manager.cpp index c808ba45bf..1a9c562e04 100644 --- a/clients/riscos/Manager.cpp +++ b/clients/riscos/Manager.cpp @@ -596,16 +596,12 @@ Manager::createTitle() QPtrList