[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    kwin default window button order.
From:       "Aaron J. Seigo" <aseigo () kde ! org>
Date:       2007-11-14 23:04:35
Message-ID: 200711141604.35821.aseigo () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


hi all ...

something that i've been wanting to see happen for a while is our window 
button order modified a bit. in particular, the defaults would be changed 
to "maximize, minimize, sticky, spacer*2, help, menu" on the left and "close" 
on the right.

the reasons for this layout are:

* close is a destructive action and should therefore be kept away from other 
buttons. we do this in our menus as well.

* the two most important buttons are close and either maximize or minimize 
depending on the user. so they should each have corner positions for easy 
mouse access. i put maximize as the left corner item because it benefits the 
most from this position between maximize and minimize: when maximized the 
window is guaranteed to have a corner position (well, barring panels, etc in 
the way) so maximize is probably the more likely action to benefit.

* in our dialogs we put "go away" buttons on the right (e.g. Ok, Cancel) and 
action buttons to the left (Help, Defaults, etc). we usually put our clear 
buttons on the right in line edits, etc ... this brings the window 
decorations into line with this concept.

attached is a patch that accomplishes this. the patch does four things:

* it changes the defaults to the above

* it introduces two new static methods to KDecorationOptions that return the 
defaults, removing a lot of duplication in the code where the defaults were 
hard coded

* makes the left/right buton default methods in KCommonDecoration 
non-pure-virtual and provides an implementation that returns the defaults as 
defined in KDecorationOptions. this allows window decorations to use the KDE 
defaults, even if they change over time. decos that have good reason for 
different defaults can still override the methods, of course. this change is 
BIC, but SC.

* modifies the karmik, plastik and oxygen decos to use the new defaults. i've 
left the rest as is out of respect for their authors and provenance (e.g. i 
assume the redmond deco should continue to have the typical MS Windows 
ordering)

this is a small thing, but small things make life better. i believe this would 
be worthwhile add to kde4. it was also a nice 15 minute break from plasma 
code ;)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech

["window_button_order.diff" (text/x-diff)]

Index: clients/keramik/keramik.cpp
===================================================================
--- clients/keramik/keramik.cpp	(revision 736818)
+++ clients/keramik/keramik.cpp	(working copy)
@@ -61,10 +61,6 @@
 	const int buttonSpacing    =  4;  // Spacing between the titlebar buttons
 	const int iconSpacing      =  5;  // Spacing between the icon and the text label
 
-	// Default button layout
-	const char default_left[]  = "M";
-	const char default_right[] = "HIAX";
-
 	// Titlebar button bitmaps
 	const unsigned char menu_bits[] = {
 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -929,7 +925,7 @@
 
 	titleLayout->addSpacing( buttonMargin );      // Left button margin
 	addButtons( titleLayout, options()->customButtonPositions() ?
-			options()->titleButtonsLeft() : QString(default_left) );
+			options()->titleButtonsLeft() : KDecorationOptions::defaultTitleButtonsLeft() );
 
 	titlebar = new QSpacerItem( 10, clientHandler->titleBarHeight(largeTitlebar)
 			- topSpacing, QSizePolicy::Expanding, QSizePolicy::Minimum );
@@ -937,7 +933,7 @@
 
 	titleLayout->addSpacing( buttonSpacing );
 	addButtons( titleLayout, options()->customButtonPositions() ?
-				options()->titleButtonsRight() : QString(default_right) );
+				options()->titleButtonsRight() : KDecorationOptions::defaultTitleButtonsRight() \
);  titleLayout->addSpacing( buttonMargin - 1 );  // Right button margin
 
 	windowLayout->addSpacing( leftBorderWidth );                // Left border
Index: clients/plastik/plastikclient.cpp
===================================================================
--- clients/plastik/plastikclient.cpp	(revision 736818)
+++ clients/plastik/plastikclient.cpp	(working copy)
@@ -56,16 +56,6 @@
     return i18n("Plastik");
 }
 
-QString PlastikClient::defaultButtonsLeft() const
-{
-    return "M";
-}
-
-QString PlastikClient::defaultButtonsRight() const
-{
-    return "HIAX";
-}
-
 bool PlastikClient::decorationBehaviour(DecorationBehaviour behaviour) const
 {
     switch (behaviour) {
Index: clients/plastik/plastikclient.h
===================================================================
--- clients/plastik/plastikclient.h	(revision 736818)
+++ clients/plastik/plastikclient.h	(working copy)
@@ -37,8 +37,6 @@
     ~PlastikClient();
 
     virtual QString visibleName() const;
-    virtual QString defaultButtonsLeft() const;
-    virtual QString defaultButtonsRight() const;
     virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
     virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const \
KCommonDecorationButton * = 0) const;  virtual QRegion cornerShape(WindowCorner \
                corner);
Index: clients/oxygen/oxygenclient.cpp
===================================================================
--- clients/oxygen/oxygenclient.cpp	(revision 736818)
+++ clients/oxygen/oxygenclient.cpp	(working copy)
@@ -68,16 +68,6 @@
     return i18n("Oxygen");
 }
 
-QString OxygenClient::defaultButtonsLeft() const
-{
-    return "M";
-}
-
-QString OxygenClient::defaultButtonsRight() const
-{
-    return "HIAX";
-}
-
 void OxygenClient::init()
 {
     KCommonDecoration::init();
Index: clients/oxygen/oxygenclient.h
===================================================================
--- clients/oxygen/oxygenclient.h	(revision 736818)
+++ clients/oxygen/oxygenclient.h	(working copy)
@@ -45,8 +45,6 @@
     virtual ~OxygenClient();
 
     virtual QString visibleName() const;
-    virtual QString defaultButtonsLeft() const;
-    virtual QString defaultButtonsRight() const;
     virtual KCommonDecorationButton *createButton(::ButtonType type);
     virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
     virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const \
                KCommonDecorationButton * = 0) const;
Index: kcmkwin/kwindecoration/kwindecoration.cpp
===================================================================
--- kcmkwin/kwindecoration/kwindecoration.cpp	(revision 736818)
+++ kcmkwin/kwindecoration/kwindecoration.cpp	(working copy)
@@ -472,9 +472,9 @@
 	cbUseCustomButtonPositions->setChecked( customPositions );
 	buttonPositionWidget->setEnabled( customPositions );
 	// Menu and onAllDesktops buttons are default on LHS
-	buttonPositionWidget->setButtonsLeft( conf.readEntry("ButtonsOnLeft", "MS") );
+	buttonPositionWidget->setButtonsLeft( conf.readEntry("ButtonsOnLeft", \
KDecorationOptions::defaultTitleButtonsLeft()) );  // Help, Minimize, Maximize and \
                Close are default on RHS
-	buttonPositionWidget->setButtonsRight( conf.readEntry("ButtonsOnRight", "HIAX") );
+	buttonPositionWidget->setButtonsRight( conf.readEntry("ButtonsOnRight", \
KDecorationOptions::defaultTitleButtonsRight()) );  
         int bsize = conf.readEntry( "BorderSize", (int)BorderNormal );
         if( bsize >= BorderTiny && bsize < BordersCount )
@@ -555,8 +555,8 @@
 //	decorationList->setSelected(
 //		decorationList->findItem( i18n("KDE 2") ), true );  // KDE classic client
 
-	buttonPositionWidget->setButtonsLeft("MS");
-	buttonPositionWidget->setButtonsRight("HIAX");
+	buttonPositionWidget->setButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
 +	buttonPositionWidget->setButtonsRight(KDecorationOptions::defaultTitleButtonsRight());
  
         border_size = BorderNormal;
         checkSupportedBorderSizes();
Index: kcmkwin/kwindecoration/preview.cpp
===================================================================
--- kcmkwin/kwindecoration/preview.cpp	(revision 736818)
+++ kcmkwin/kwindecoration/preview.cpp	(working copy)
@@ -473,8 +473,8 @@
         if (!customTitleButtonsRight.isNull() )
             d->title_buttons_right = customTitleButtonsRight;
     } else {
-        d->title_buttons_left = "MS";
-        d->title_buttons_right = "HIAX";
+        d->title_buttons_left = KDecorationOptions::defaultTitleButtonsLeft();
+        d->title_buttons_right = KDecorationOptions::defaultTitleButtonsRight();
     }
 
     return changed;
Index: lib/kdecoration.cpp
===================================================================
--- lib/kdecoration.cpp	(revision 736818)
+++ lib/kdecoration.cpp	(working copy)
@@ -428,11 +428,21 @@
     return d->title_buttons_left;
 }
 
+QString KDecorationOptions::defaultTitleButtonsLeft()
+{
+    return "AIS__HM";
+}
+
 QString KDecorationOptions::titleButtonsRight() const
 {
     return d->title_buttons_right;
 }
 
+QString KDecorationOptions::defaultTitleButtonsRight()
+{
+    return "X";
+}
+
 bool KDecorationOptions::showTooltips() const
 {
     return d->show_tooltips;
Index: lib/kdecoration.h
===================================================================
--- lib/kdecoration.h	(revision 736818)
+++ lib/kdecoration.h	(working copy)
@@ -238,25 +238,32 @@
     * @li '_' spacer
     *
     * The default ( which is also returned if customButtonPositions returns false )
-    * is "MS".
+    * is "AIS__HM".
     * Unknown buttons in the returned string must be ignored.
     * The changed flags for this setting is SettingButtons.
     */
     QString titleButtonsLeft() const;
     /**
+     * Returns the default left button sequence
+     */
+    static QString defaultTitleButtonsLeft();
+    /**
     * If customButtonPositions() returns true, titleButtonsRight
     * returns which buttons should be on the right side of the titlebar from left
     * to right. Characters in the return string have the same meaning like
     * in titleButtonsLeft().
     *
     * The default ( which is also returned if customButtonPositions returns false )
-    * is "HIAX".
+    * is "X".
     * Unknown buttons in the returned string must be ignored.
     * The changed flags for this setting is SettingButtons.
     */
     QString titleButtonsRight() const;
-
     /**
+     * Returns the default right button sequence.
+     */
+    static QString defaultTitleButtonsRight();
+    /**
     * @returns true if the style should use tooltips for window buttons
     * The changed flags for this setting is SettingTooltips.
     */
Index: lib/kcommondecoration.cpp
===================================================================
--- lib/kcommondecoration.cpp	(revision 736818)
+++ lib/kcommondecoration.cpp	(working copy)
@@ -58,6 +58,16 @@
     delete m_previewWidget;
 }
 
+QString KCommonDecoration::defaultButtonsLeft()
+{
+    return KDecorationOptions::defaultTitleButtonsLeft();
+}
+
+QString KCommonDecoration::defaultButtonsRight()
+{
+    return KDecorationOptions::defaultTitleButtonsRight();
+}
+
 bool KCommonDecoration::decorationBehaviour(DecorationBehaviour behaviour) const
 {
     switch (behaviour) {
Index: lib/kcommondecoration.h
===================================================================
--- lib/kcommondecoration.h	(revision 736818)
+++ lib/kcommondecoration.h	(working copy)
@@ -138,13 +138,13 @@
          * @see KDecoration::titleButtonsLeft()
          * @see KDecoration::titleButtonsRight()
          */
-        virtual QString defaultButtonsLeft() const = 0;
+        virtual QString defaultButtonsLeft();
         /**
          * The default title button order on the left.
          * @see KDecoration::titleButtonsLeft()
          * @see KDecoration::titleButtonsRight()
          */
-        virtual QString defaultButtonsRight() const = 0;
+        virtual QString defaultButtonsRight();
 
         /**
          * This controls whether some specific behaviour should be enabled or not.
Index: lib/kdecoration_p.cpp
===================================================================
--- lib/kdecoration_p.cpp	(revision 736818)
+++ lib/kdecoration_p.cpp	(working copy)
@@ -52,8 +52,8 @@
 
 void KDecorationOptionsPrivate::defaultKWinSettings()
     {
-    title_buttons_left = "MS";
-    title_buttons_right = "HIAX";
+    title_buttons_left = "AIS__HM";
+    title_buttons_right = "X";
     custom_button_positions = false;
     show_tooltips = true;
     border_size = BorderNormal;
@@ -172,13 +172,13 @@
     custom_button_positions = styleConfig.readEntry("CustomButtonPositions", false);
     if (custom_button_positions)
         {
-        title_buttons_left  = styleConfig.readEntry("ButtonsOnLeft", "MS");
-        title_buttons_right = styleConfig.readEntry("ButtonsOnRight", "HIAX");
+        title_buttons_left  = styleConfig.readEntry("ButtonsOnLeft", "AIS__HM");
+        title_buttons_right = styleConfig.readEntry("ButtonsOnRight", "X");
         }
     else
         {
-        title_buttons_left  = "MS";
-        title_buttons_right = "HIAX";
+        title_buttons_left  = "AIS__HM";
+        title_buttons_right = "X";
         }
     if( old_custom_button_positions != custom_button_positions
         || ( custom_button_positions &&


[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic