kwin Library API Documentation

mouse.cpp

00001 /*
00002  *
00003  * Copyright (c) 1998 Matthias Ettrich <ettrich@kde.org>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #include <qlabel.h>
00021 #include <qcombobox.h>
00022 #include <qwhatsthis.h>
00023 #include <qlayout.h>
00024 #include <qvgroupbox.h>
00025 #include <qgrid.h>
00026 #include <qsizepolicy.h>
00027 #include <qbitmap.h>
00028 #include <qhgroupbox.h>
00029 #include <qtooltip.h>
00030 
00031 #include <dcopclient.h>
00032 #include <klocale.h>
00033 #include <kapplication.h>
00034 #include <kconfig.h>
00035 #include <kdialog.h>
00036 #include <kglobalsettings.h>
00037 #include <kseparator.h>
00038 
00039 #include <X11/X.h>
00040 #include <X11/Xlib.h>
00041 #include <X11/Xutil.h>
00042 
00043 #include <stdlib.h>
00044 
00045 #include "mouse.h"
00046 #include "mouse.moc"
00047 
00048 
00049 namespace {
00050 
00051 char const * const cnf_Max[] = {
00052   "MaximizeButtonLeftClickCommand",
00053   "MaximizeButtonMiddleClickCommand",
00054   "MaximizeButtonRightClickCommand",
00055 };
00056 
00057 char const * const tbl_Max[] = {
00058   "Maximize",
00059   "Maximize (vertical only)",
00060   "Maximize (horizontal only)",
00061   "" };
00062 
00063 QPixmap maxButtonPixmaps[3];
00064 
00065 void createMaxButtonPixmaps()
00066 {
00067   char const * maxButtonXpms[][3 + 13] = {
00068     {0, 0, 0,
00069     "...............",
00070     ".......#.......",
00071     "......###......",
00072     ".....#####.....",
00073     "..#....#....#..",
00074     ".##....#....##.",
00075     "###############",
00076     ".##....#....##.",
00077     "..#....#....#..",
00078     ".....#####.....",
00079     "......###......",
00080     ".......#.......",
00081     "..............."},
00082     {0, 0, 0,
00083     "...............",
00084     ".......#.......",
00085     "......###......",
00086     ".....#####.....",
00087     ".......#.......",
00088     ".......#.......",
00089     ".......#.......",
00090     ".......#.......",
00091     ".......#.......",
00092     ".....#####.....",
00093     "......###......",
00094     ".......#.......",
00095     "..............."},
00096     {0, 0, 0,
00097     "...............",
00098     "...............",
00099     "...............",
00100     "...............",
00101     "..#.........#..",
00102     ".##.........##.",
00103     "###############",
00104     ".##.........##.",
00105     "..#.........#..",
00106     "...............",
00107     "...............",
00108     "...............",
00109     "..............."},
00110   };
00111 
00112   QString baseColor(". c " + KGlobalSettings::baseColor().name());
00113   QString textColor("# c " + KGlobalSettings::textColor().name());
00114   for (int t = 0; t < 3; ++t)
00115   {
00116     maxButtonXpms[t][0] = "15 13 2 1";
00117     maxButtonXpms[t][1] = baseColor.ascii();
00118     maxButtonXpms[t][2] = textColor.ascii();
00119     maxButtonPixmaps[t] = QPixmap(maxButtonXpms[t]);
00120     maxButtonPixmaps[t].setMask(maxButtonPixmaps[t].createHeuristicMask());
00121   }
00122 }
00123 
00124 } // namespace
00125 
00126 void KActionsConfig::paletteChanged()
00127 {
00128   createMaxButtonPixmaps();
00129   for (int b = 0; b < 3; ++b)
00130     for (int t = 0; t < 3; ++t)
00131       coMax[b]->changeItem(maxButtonPixmaps[t], t);
00132 
00133 }
00134 
00135 KActionsConfig::KActionsConfig (bool _standAlone, KConfig *_config, QWidget * parent, const char *)
00136   : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00137 {
00138   QString strWin1, strWin2, strWin3, strAllKey, strAll1, strAll2, strAll3;
00139   QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint());
00140   QGrid *grid;
00141   QGroupBox *box;
00142   QLabel *label;
00143   QString strMouseButton1, strMouseButton3;
00144   QString txtButton1, txtButton3;
00145   QStringList items;
00146   bool leftHandedMouse = ( KGlobalSettings::mouseSettings().handed == KGlobalSettings::KMouseSettings::LeftHanded);
00147 
00150   QHBoxLayout *hlayout = new QHBoxLayout(layout);
00151 
00152   label = new QLabel(i18n("&Titlebar double-click:"), this);
00153   hlayout->addWidget(label);
00154   QWhatsThis::add( label, i18n("Here you can customize mouse click behavior when double clicking on the"
00155     " titlebar of a window.") );
00156 
00157   QComboBox* combo = new QComboBox(this);
00158   combo->insertItem(i18n("Maximize"));
00159   combo->insertItem(i18n("Maximize (vertical only)"));
00160   combo->insertItem(i18n("Maximize (horizontal only)"));
00161   combo->insertItem(i18n("Minimize"));
00162   combo->insertItem(i18n("Shade"));
00163   combo->insertItem(i18n("Lower"));
00164   combo->insertItem(i18n("On All Desktops"));
00165   combo->insertItem(i18n("Nothing"));
00166   combo->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
00167   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00168   hlayout->addWidget(combo);
00169   coTiDbl = combo;
00170   QWhatsThis::add(combo, i18n("Behavior on <em>double</em> click into the titlebar."));
00171 
00172   label->setBuddy(combo);
00173 
00176   box = new QVGroupBox( i18n("Titlebar && Frame"), this, "Titlebar and Frame");
00177   box->layout()->setMargin(KDialog::marginHint());
00178   box->layout()->setSpacing(KDialog::spacingHint());
00179   layout->addWidget(box);
00180   QWhatsThis::add( box, i18n("Here you can customize mouse click behavior when clicking on the"
00181                              " titlebar or the frame of a window.") );
00182 
00183   grid = new QGrid(4, Qt::Vertical, box);
00184 
00185 
00186   new QLabel(grid); // dummy
00187 
00188   strMouseButton1 = i18n("Left button:");
00189   txtButton1 = i18n("In this row you can customize left click behavior when clicking into"
00190      " the titlebar or the frame.");
00191 
00192   strMouseButton3 = i18n("Right button:");
00193   txtButton3 = i18n("In this row you can customize right click behavior when clicking into"
00194      " the titlebar or the frame." );
00195 
00196   if ( leftHandedMouse )
00197   {
00198      qSwap(strMouseButton1, strMouseButton3);
00199      qSwap(txtButton1, txtButton3);
00200   }
00201 
00202   label = new QLabel(strMouseButton1, grid);
00203   QWhatsThis::add( label, txtButton1);
00204 
00205   label = new QLabel(i18n("Middle button:"), grid);
00206   QWhatsThis::add( label, i18n("In this row you can customize middle click behavior when clicking into"
00207     " the titlebar or the frame.") );
00208 
00209   label = new QLabel(strMouseButton3, grid);
00210   QWhatsThis::add( label, txtButton3);
00211 
00212 
00213   label = new QLabel(i18n("Active"), grid);
00214   label->setAlignment(AlignCenter);
00215   QWhatsThis::add( label, i18n("In this column you can customize mouse clicks into the titlebar"
00216                                " or the frame of an active window.") );
00217 
00218   // Titlebar and frame, active, mouse button 1
00219   combo = new QComboBox(grid);
00220   combo->insertItem(i18n("Raise"));
00221   combo->insertItem(i18n("Lower"));
00222   combo->insertItem(i18n("Operations Menu"));
00223   combo->insertItem(i18n("Toggle Raise & Lower"));
00224   combo->insertItem(i18n("Nothing"));
00225   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00226   coTiAct1 = combo;
00227 
00228   txtButton1 = i18n("Behavior on <em>left</em> click into the titlebar or frame of an "
00229      "<em>active</em> window.");
00230 
00231   txtButton3 = i18n("Behavior on <em>right</em> click into the titlebar or frame of an "
00232      "<em>active</em> window.");
00233 
00234   // Be nice to left handed users
00235   if ( leftHandedMouse ) qSwap(txtButton1, txtButton3);
00236 
00237   QWhatsThis::add(combo, txtButton1);
00238 
00239   // Titlebar and frame, active, mouse button 2
00240 
00241   items << i18n("Raise")
00242         << i18n("Lower")
00243         << i18n("Operations Menu")
00244         << i18n("Toggle Raise & Lower")
00245         << i18n("Nothing")
00246         << i18n("Shade");
00247 
00248   combo = new QComboBox(grid);
00249   combo->insertStringList(items);
00250   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00251   coTiAct2 = combo;
00252   QWhatsThis::add(combo, i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>active</em> window."));
00253 
00254   // Titlebar and frame, active, mouse button 3
00255   combo = new QComboBox(grid);
00256   combo->insertStringList(items);
00257   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00258   coTiAct3 =  combo;
00259   QWhatsThis::add(combo, txtButton3 );
00260 
00261   txtButton1 = i18n("Behavior on <em>left</em> click into the titlebar or frame of an "
00262      "<em>inactive</em> window.");
00263 
00264   txtButton3 = i18n("Behavior on <em>right</em> click into the titlebar or frame of an "
00265      "<em>inactive</em> window.");
00266 
00267   // Be nice to left handed users
00268   if ( leftHandedMouse ) qSwap(txtButton1, txtButton3);
00269 
00270   label = new QLabel(i18n("Inactive"), grid);
00271   label->setAlignment(AlignCenter);
00272   QWhatsThis::add( label, i18n("In this column you can customize mouse clicks into the titlebar"
00273                                " or the frame of an inactive window.") );
00274 
00275   items.clear();
00276   items  << i18n("Activate & Raise")
00277          << i18n("Activate & Lower")
00278          << i18n("Activate")
00279          << i18n("Shade")
00280          << i18n("Operations Menu")
00281          << i18n("Raise")
00282          << i18n("Lower")
00283          << i18n("Nothing");
00284 
00285   combo = new QComboBox(grid);
00286   combo->insertStringList(items);
00287   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00288   coTiInAct1 = combo;
00289   QWhatsThis::add(combo, txtButton1);
00290 
00291   combo = new QComboBox(grid);
00292   combo->insertStringList(items);
00293   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00294   coTiInAct2 = combo;
00295   QWhatsThis::add(combo, i18n("Behavior on <em>middle</em> click into the titlebar or frame of an <em>inactive</em> window."));
00296 
00297   combo = new QComboBox(grid);
00298   combo->insertStringList(items);
00299   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00300   coTiInAct3 = combo;
00301   QWhatsThis::add(combo, txtButton3);
00302 
00305   box = new QHGroupBox(i18n("Maximize Button"), this, "Maximize Button");
00306   box->layout()->setMargin(KDialog::marginHint());
00307   box->layout()->setSpacing(KDialog::spacingHint());
00308   layout->addWidget(box);
00309   QWhatsThis::add( box,
00310     i18n("Here you can customize behavior when clicking on the maximize button.") );
00311 
00312   QString strMouseButton[] = {
00313     i18n("Left button:"),
00314     i18n("Middle button:"),
00315     i18n("Right button:")};
00316 
00317   QString txtButton[] = {
00318     i18n("Behavior on <em>left</em> click onto the maximize button." ),
00319     i18n("Behavior on <em>middle</em> click onto the maximize button." ),
00320     i18n("Behavior on <em>right</em> click onto the maximize button." )};
00321 
00322   if ( leftHandedMouse ) // Be nice to lefties
00323   {
00324      qSwap(strMouseButton[0], strMouseButton[2]);
00325      qSwap(txtButton[0], txtButton[2]);
00326   }
00327 
00328   createMaxButtonPixmaps();
00329   for (int b = 0; b < 3; ++b)
00330   {
00331     if (b != 0) new QWidget(box); // Spacer
00332 
00333     QLabel * label = new QLabel(strMouseButton[b], box);
00334     QWhatsThis::add( label,    txtButton[b] );
00335     label   ->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ));
00336 
00337     coMax[b] = new ToolTipComboBox(box, tbl_Max);
00338     for (int t = 0; t < 3; ++t) coMax[b]->insertItem(maxButtonPixmaps[t]);
00339     connect(coMax[b], SIGNAL(activated(int)), SLOT(changed()));
00340     connect(coMax[b], SIGNAL(activated(int)), coMax[b], SLOT(changed()));
00341     QWhatsThis::add( coMax[b], txtButton[b] );
00342     coMax[b]->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ));
00343   }
00344 
00345   connect(kapp, SIGNAL(kdisplayPaletteChanged()), SLOT(paletteChanged()));
00346 
00349   box = new QVGroupBox(i18n("Inactive Inner Window"), this, "Inactive Inner Window");
00350   box->layout()->setMargin(KDialog::marginHint());
00351   box->layout()->setSpacing(KDialog::spacingHint());
00352   layout->addWidget(box);
00353   QWhatsThis::add( box, i18n("Here you can customize mouse click behavior when clicking on an inactive"
00354                              " inner window ('inner' means: not titlebar, not frame).") );
00355 
00356   grid = new QGrid(3, Qt::Vertical, box);
00357 
00358   strMouseButton1 = i18n("Left button:");
00359   txtButton1 = i18n("In this row you can customize left click behavior when clicking into"
00360      " the titlebar or the frame.");
00361 
00362   strMouseButton3 = i18n("Right button:");
00363   txtButton3 = i18n("In this row you can customize right click behavior when clicking into"
00364      " the titlebar or the frame." );
00365 
00366   if ( leftHandedMouse )
00367   {
00368      qSwap(strMouseButton1, strMouseButton3);
00369      qSwap(txtButton1, txtButton3);
00370   }
00371 
00372   strWin1 = i18n("In this row you can customize left click behavior when clicking into"
00373      " an inactive inner window ('inner' means: not titlebar, not frame).");
00374 
00375   strWin3 = i18n("In this row you can customize right click behavior when clicking into"
00376      " an inactive inner window ('inner' means: not titlebar, not frame).");
00377 
00378   // Be nice to lefties
00379   if ( leftHandedMouse ) qSwap(strWin1, strWin3);
00380 
00381   label = new QLabel(strMouseButton1, grid);
00382   QWhatsThis::add( label, strWin1 );
00383 
00384   label = new QLabel(i18n("Middle button:"), grid);
00385   strWin2 = i18n("In this row you can customize middle click behavior when clicking into"
00386      " an inactive inner window ('inner' means: not titlebar, not frame).");
00387   QWhatsThis::add( label, strWin2 );
00388 
00389   label = new QLabel(strMouseButton3, grid);
00390   QWhatsThis::add( label, strWin3 );
00391 
00392   items.clear();
00393   items   << i18n("Activate, Raise & Pass Click")
00394           << i18n("Activate & Pass Click")
00395           << i18n("Activate")
00396           << i18n("Activate & Raise");
00397 
00398   combo = new QComboBox(grid);
00399   combo->insertStringList(items);
00400   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00401   coWin1 = combo;
00402   QWhatsThis::add( combo, strWin1 );
00403 
00404   combo = new QComboBox(grid);
00405   combo->insertStringList(items);
00406   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00407   coWin2 = combo;
00408   QWhatsThis::add( combo, strWin2 );
00409 
00410   combo = new QComboBox(grid);
00411   combo->insertStringList(items);
00412   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00413   coWin3 = combo;
00414   QWhatsThis::add( combo, strWin3 );
00415 
00416 
00419   box = new QVGroupBox(i18n("Inner Window, Titlebar && Frame"), this, "Inner Window, Titlebar and Frame");
00420   box->layout()->setMargin(KDialog::marginHint());
00421   box->layout()->setSpacing(KDialog::spacingHint());
00422   layout->addWidget(box);
00423   QWhatsThis::add( box, i18n("Here you can customize KDE's behavior when clicking somewhere into"
00424                              " a window while pressing a modifier key."));
00425 
00426   grid = new QGrid(4, Qt::Vertical, box);
00427 
00428   // Labels
00429   label = new QLabel(i18n("Modifier key:"), grid);
00430 
00431   strAllKey = i18n("Here you select whether holding the Meta key or Alt key "
00432     "will allow you to perform the following actions.");
00433   QWhatsThis::add( label, strAllKey );
00434 
00435 
00436   strMouseButton1 = i18n("Modifier key + left button:");
00437   strAll1 = i18n("In this row you can customize left click behavior when clicking into"
00438                  " the titlebar or the frame.");
00439 
00440   strMouseButton3 = i18n("Modifier key + right button:");
00441   strAll3 = i18n("In this row you can customize right click behavior when clicking into"
00442                  " the titlebar or the frame." );
00443 
00444   if ( leftHandedMouse )
00445   {
00446      qSwap(strMouseButton1, strMouseButton3);
00447      qSwap(strAll1, strAll3);
00448   }
00449 
00450   label = new QLabel(strMouseButton1, grid);
00451   QWhatsThis::add( label, strAll1);
00452 
00453   label = new QLabel(i18n("Modifier key + middle button:"), grid);
00454   strAll2 = i18n("Here you can customize KDE's behavior when middle clicking into a window"
00455                  " while pressing the modifier key.");
00456   QWhatsThis::add( label, strAll2 );
00457 
00458   label = new QLabel(strMouseButton3, grid);
00459   QWhatsThis::add( label, strAll3);
00460 
00461   // Combo's
00462   combo = new QComboBox(grid);
00463   combo->insertItem(i18n("Meta"));
00464   combo->insertItem(i18n("Alt"));
00465   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00466   coAllKey = combo;
00467   QWhatsThis::add( combo, strAllKey );
00468 
00469   items.clear();
00470   items << i18n("Move")
00471         << i18n("Activate, Raise and Move")
00472         << i18n("Toggle Raise & Lower")
00473         << i18n("Resize")
00474         << i18n("Raise")
00475         << i18n("Lower")
00476         << i18n("Minimize")
00477         << i18n("Nothing");
00478 
00479   combo = new QComboBox(grid);
00480   combo->insertStringList(items);
00481   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00482   coAll1 = combo;
00483   QWhatsThis::add( combo, strAll1 );
00484 
00485   combo = new QComboBox(grid);
00486   combo->insertStringList(items);
00487   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00488   coAll2 = combo;
00489   QWhatsThis::add( combo, strAll2 );
00490 
00491   combo = new QComboBox(grid);
00492   combo->insertStringList(items);
00493   connect(combo, SIGNAL(activated(int)), SLOT(changed()));
00494   coAll3 =  combo;
00495   QWhatsThis::add( combo, strAll3 );
00496 
00497   layout->addStretch();
00498 
00499   load();
00500 }
00501 
00502 KActionsConfig::~KActionsConfig()
00503 {
00504   if (standAlone)
00505     delete config;
00506 }
00507 
00508 // do NOT change the texts below, they are written to config file
00509 // and are not shown in the GUI
00510 // they have to match the order of items in GUI elements though
00511 const char* const tbl_TiDbl[] = {
00512     "Maximize",
00513     "Maximize (vertical only)",
00514     "Maximize (horizontal only)",
00515     "Minimize",
00516     "Shade",
00517     "Lower",
00518     "OnAllDesktops",
00519     "Nothing",
00520     "" };
00521 
00522 const char* const tbl_TiAc[] = {
00523     "Raise",
00524     "Lower",
00525     "Operations menu",
00526     "Toggle raise and lower",
00527     "Nothing",
00528     "Shade",
00529     "" };
00530 
00531 const char* const tbl_TiInAc[] = {
00532     "Activate and raise",
00533     "Activate and lower",
00534     "Activate",
00535     "Shade",
00536     "Operations menu",
00537     "Raise",
00538     "Lower",
00539     "Nothing",
00540     "" };
00541 
00542 const char* const tbl_Win[] = {
00543     "Activate, raise and pass click",
00544     "Activate and pass click",
00545     "Activate",
00546     "Activate and raise",
00547     "" };
00548 
00549 const char* const tbl_AllKey[] = {
00550     "Meta",
00551     "Alt",
00552     "" };
00553 
00554 const char* const tbl_All[] = {
00555     "Move",
00556     "Activate, raise and move",
00557     "Toggle raise and lower",
00558     "Resize",
00559     "Raise",
00560     "Lower",
00561     "Minimize",
00562     "Nothing",
00563     "" };
00564 
00565 static const char* tbl_num_lookup( const char* const arr[], int pos )
00566 {
00567     for( int i = 0;
00568          arr[ i ][ 0 ] != '\0' && pos >= 0;
00569          ++i )
00570     {
00571         if( pos == 0 )
00572             return arr[ i ];
00573         --pos;
00574     }
00575     abort(); // should never happen this way
00576 }
00577 
00578 static int tbl_txt_lookup( const char* const arr[], const char* txt )
00579 {
00580     int pos = 0;
00581     for( int i = 0;
00582          arr[ i ][ 0 ] != '\0';
00583          ++i )
00584     {
00585         if( qstricmp( txt, arr[ i ] ) == 0 )
00586             return pos;
00587         ++pos;
00588     }
00589     return 0;
00590 }
00591 
00592 void KActionsConfig::setComboText( QComboBox* combo, const char*txt )
00593 {
00594     if( combo == coTiDbl )
00595         combo->setCurrentItem( tbl_txt_lookup( tbl_TiDbl, txt ));
00596     else if( combo == coTiAct1 || combo == coTiAct2 || combo == coTiAct3 )
00597         combo->setCurrentItem( tbl_txt_lookup( tbl_TiAc, txt ));
00598     else if( combo == coTiInAct1 || combo == coTiInAct2 || combo == coTiInAct3 )
00599         combo->setCurrentItem( tbl_txt_lookup( tbl_TiInAc, txt ));
00600     else if( combo == coWin1 || combo == coWin2 || combo == coWin3 )
00601         combo->setCurrentItem( tbl_txt_lookup( tbl_Win, txt ));
00602     else if( combo == coAllKey )
00603         combo->setCurrentItem( tbl_txt_lookup( tbl_AllKey, txt ));
00604     else if( combo == coAll1 || combo == coAll2 || combo == coAll3 )
00605         combo->setCurrentItem( tbl_txt_lookup( tbl_All, txt ));
00606     else if( combo == coMax[0] || combo == coMax[1] || combo == coMax[2] )
00607     {
00608         combo->setCurrentItem( tbl_txt_lookup( tbl_Max, txt ));
00609         static_cast<ToolTipComboBox *>(combo)->changed();
00610     }
00611     else
00612         abort();
00613 }
00614 
00615 const char* KActionsConfig::functionTiDbl( int i )
00616 {
00617     return tbl_num_lookup( tbl_TiDbl, i );
00618 }
00619 
00620 const char* KActionsConfig::functionTiAc( int i )
00621 {
00622     return tbl_num_lookup( tbl_TiAc, i );
00623 }
00624 
00625 const char* KActionsConfig::functionTiInAc( int i )
00626 {
00627     return tbl_num_lookup( tbl_TiInAc, i );
00628 }
00629 
00630 const char* KActionsConfig::functionWin( int i )
00631 {
00632     return tbl_num_lookup( tbl_Win, i );
00633 }
00634 
00635 const char* KActionsConfig::functionAllKey( int i )
00636 {
00637     return tbl_num_lookup( tbl_AllKey, i );
00638 }
00639 
00640 const char* KActionsConfig::functionAll( int i )
00641 {
00642     return tbl_num_lookup( tbl_All, i );
00643 }
00644 
00645 const char* KActionsConfig::functionMax( int i )
00646 {
00647     return tbl_num_lookup( tbl_Max, i );
00648 }
00649 
00650 void KActionsConfig::load()
00651 {
00652   config->setGroup("Windows");
00653   setComboText(coTiDbl, config->readEntry("TitlebarDoubleClickCommand","Shade").ascii());
00654   for (int t = 0; t < 3; ++t)
00655     setComboText(coMax[t],config->readEntry(cnf_Max[t], tbl_Max[t]).ascii());
00656 
00657   config->setGroup( "MouseBindings");
00658   setComboText(coTiAct1,config->readEntry("CommandActiveTitlebar1","Raise").ascii());
00659   setComboText(coTiAct2,config->readEntry("CommandActiveTitlebar2","Lower").ascii());
00660   setComboText(coTiAct3,config->readEntry("CommandActiveTitlebar3","Operations menu").ascii());
00661   setComboText(coTiInAct1,config->readEntry("CommandInactiveTitlebar1","Activate and raise").ascii());
00662   setComboText(coTiInAct2,config->readEntry("CommandInactiveTitlebar2","Activate and lower").ascii());
00663   setComboText(coTiInAct3,config->readEntry("CommandInactiveTitlebar3","Operations menu").ascii());
00664   setComboText(coWin1,config->readEntry("CommandWindow1","Activate, raise and pass click").ascii());
00665   setComboText(coWin2,config->readEntry("CommandWindow2","Activate and pass click").ascii());
00666   setComboText(coWin3,config->readEntry("CommandWindow3","Activate and pass click").ascii());
00667   setComboText(coAllKey,config->readEntry("CommandAllKey","Alt").ascii());
00668   setComboText(coAll1,config->readEntry("CommandAll1","Move").ascii());
00669   setComboText(coAll2,config->readEntry("CommandAll2","Toggle raise and lower").ascii());
00670   setComboText(coAll3,config->readEntry("CommandAll3","Resize").ascii());
00671 }
00672 
00673 void KActionsConfig::save()
00674 {
00675   config->setGroup("Windows");
00676   config->writeEntry("TitlebarDoubleClickCommand", functionTiDbl( coTiDbl->currentItem() ) );
00677   for (int t = 0; t < 3; ++t)
00678     config->writeEntry(cnf_Max[t], functionMax(coMax[t]->currentItem()));
00679 
00680   config->setGroup("MouseBindings");
00681   config->writeEntry("CommandActiveTitlebar1", functionTiAc(coTiAct1->currentItem()));
00682   config->writeEntry("CommandActiveTitlebar2", functionTiAc(coTiAct2->currentItem()));
00683   config->writeEntry("CommandActiveTitlebar3", functionTiAc(coTiAct3->currentItem()));
00684   config->writeEntry("CommandInactiveTitlebar1", functionTiInAc(coTiInAct1->currentItem()));
00685   config->writeEntry("CommandInactiveTitlebar2", functionTiInAc(coTiInAct2->currentItem()));
00686   config->writeEntry("CommandInactiveTitlebar3", functionTiInAc(coTiInAct3->currentItem()));
00687   config->writeEntry("CommandWindow1", functionWin(coWin1->currentItem()));
00688   config->writeEntry("CommandWindow2", functionWin(coWin2->currentItem()));
00689   config->writeEntry("CommandWindow3", functionWin(coWin3->currentItem()));
00690   config->writeEntry("CommandAllKey", functionAllKey(coAllKey->currentItem()));
00691   config->writeEntry("CommandAll1", functionAll(coAll1->currentItem()));
00692   config->writeEntry("CommandAll2", functionAll(coAll2->currentItem()));
00693   config->writeEntry("CommandAll3", functionAll(coAll3->currentItem()));
00694   
00695   if (standAlone)
00696   {
00697     config->sync();
00698     if ( !kapp->dcopClient()->isAttached() )
00699       kapp->dcopClient()->attach();
00700     kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
00701   }
00702 }
00703 
00704 void KActionsConfig::defaults()
00705 {
00706   setComboText(coTiDbl, "Shade");
00707   setComboText(coTiAct1,"Raise");
00708   setComboText(coTiAct2,"Lower");
00709   setComboText(coTiAct3,"Operations menu");
00710   setComboText(coTiInAct1,"Activate and raise");
00711   setComboText(coTiInAct2,"Activate and lower");
00712   setComboText(coTiInAct3,"Operations menu");
00713   setComboText(coWin1,"Activate, raise and pass click");
00714   setComboText(coWin2,"Activate and pass click");
00715   setComboText(coWin3,"Activate and pass click");
00716   setComboText(coAllKey,"Alt");
00717   setComboText (coAll1,"Move");
00718   setComboText(coAll2,"Toggle raise and lower");
00719   setComboText(coAll3,"Resize");
00720   for (int t = 0; t < 3; ++t)
00721     setComboText(coMax[t], tbl_Max[t]);
00722 }
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Nov 4 00:45:27 2005 by doxygen 1.4.0 written by Dimitri van Heesch, © 1997-2003