summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkt <markt>2007-02-23 17:03:01 (GMT)
committermarkt <markt>2007-02-23 17:03:01 (GMT)
commitca7b5ee4a59ea18fd832b11040f63bcc0d8404ab (patch)
tree1ce6639cf743f48e76c4febd37ba8209eb532fa9
parente85569f1df2511f4c5f54b5ea5615b6a80014bcc (diff)
downloadfluxbox_lack-ca7b5ee4a59ea18fd832b11040f63bcc0d8404ab.zip
fluxbox_lack-ca7b5ee4a59ea18fd832b11040f63bcc0d8404ab.tar.bz2
update titlebar buttons on reconfigure
-rw-r--r--ChangeLog3
-rw-r--r--src/WinButton.hh5
-rw-r--r--src/Window.cc107
-rw-r--r--src/Window.hh3
4 files changed, 85 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 37f91ea..4f2648b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0rc3: 2Changes for 1.0rc3:
3*07/02/23:
4 * Update titlebar buttons on reconfigure (Mark)
5 Window.cc/hh
3*07/02/22: 6*07/02/22:
4 * Make systemtray support XEMBED protocol (Mark) 7 * Make systemtray support XEMBED protocol (Mark)
5 Systemtray.cc/hh 8 Systemtray.cc/hh
diff --git a/src/WinButton.hh b/src/WinButton.hh
index d1e57f3..3181278 100644
--- a/src/WinButton.hh
+++ b/src/WinButton.hh
@@ -21,6 +21,9 @@
21 21
22/// $Id$ 22/// $Id$
23 23
24#ifndef WINBUTTON_HH
25#define WINBUTTON_HH
26
24#include "FbTk/Button.hh" 27#include "FbTk/Button.hh"
25#include "FbTk/Observer.hh" 28#include "FbTk/Observer.hh"
26#include "FbTk/FbPixmap.hh" 29#include "FbTk/FbPixmap.hh"
@@ -65,3 +68,5 @@ private:
65 68
66 bool overrode_bg, overrode_pressed; 69 bool overrode_bg, overrode_pressed;
67}; 70};
71
72#endif // WINBUTTON_HH
diff --git a/src/Window.cc b/src/Window.cc
index 9bc4c5a..ba6fe6d 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1098,6 +1098,7 @@ void FluxboxWindow::reconfigure() {
1098 1098
1099 frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); 1099 frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
1100 1100
1101 updateButtons();
1101 frame().reconfigure(); 1102 frame().reconfigure();
1102 1103
1103 menu().reconfigure(); 1104 menu().reconfigure();
@@ -3911,25 +3912,16 @@ void FluxboxWindow::setupWindow() {
3911 typedef RefCount<Command> CommandRef; 3912 typedef RefCount<Command> CommandRef;
3912 typedef SimpleCommand<FluxboxWindow> WindowCmd; 3913 typedef SimpleCommand<FluxboxWindow> WindowCmd;
3913 3914
3914 CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify));
3915 CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeFull));
3916 CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical));
3917 CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal));
3918 CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close));
3919 CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade)); 3915 CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade));
3920 CommandRef shade_on_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOn)); 3916 CommandRef shade_on_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOn));
3921 CommandRef shade_off_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOff)); 3917 CommandRef shade_off_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOff));
3922 CommandRef next_tab_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient)); 3918 CommandRef next_tab_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient));
3923 CommandRef prev_tab_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient)); 3919 CommandRef prev_tab_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient));
3924 CommandRef raise_cmd(new WindowCmd(*this, &FluxboxWindow::raise));
3925 CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower)); 3920 CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower));
3926 CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus)); 3921 CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus));
3927 CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick)); 3922 CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick));
3928 CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu)); 3923 CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu));
3929 3924
3930 // clear old buttons from frame
3931 frame().removeAllButtons();
3932
3933 typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource; 3925 typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource;
3934 3926
3935 string titlebar_name[2]; 3927 string titlebar_name[2];
@@ -3983,12 +3975,85 @@ void FluxboxWindow::setupWindow() {
3983 screen().addManagedResource(titlebar_side[i]); 3975 screen().addManagedResource(titlebar_side[i]);
3984 } 3976 }
3985 3977
3978 updateButtons();
3979
3980 // setup titlebar
3981 frame().setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1
3982 frame().setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
3983 frame().setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
3984 frame().setOnClickTitlebar(lower_cmd, 2); // on release with button 2
3985
3986 int reverse = 0;
3987 if (screen().getScrollReverse())
3988 reverse = 1;
3989
3990 if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) {
3991 frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll
3992 frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction
3993 } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) {
3994 frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab
3995 frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab
3996 }
3997
3998 frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
3999
4000 // end setup frame
4001
4002}
4003
4004void FluxboxWindow::updateButtons() {
4005 string titlebar_name[2];
4006 titlebar_name[0] = screen().name() + ".titlebar.left";
4007 titlebar_name[1] = screen().name() + ".titlebar.right";
4008
4009 typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource;
4010 WinButtonsResource *titlebar_side[2];
4011 ResourceManager &rm = screen().resourceManager();
4012
4013 bool need_update = false;
4014 // get resource for titlebar
4015 for (int i=0; i < 2; ++i) {
4016 titlebar_side[i] = dynamic_cast<WinButtonsResource *>(
4017 rm.findResource( titlebar_name[i] ) );
4018
4019 // check if we need to update our buttons
4020 size_t new_size = (*titlebar_side[i])->size();
4021 if (new_size != m_titlebar_buttons[i].size() || need_update)
4022 need_update = true;
4023 else {
4024 for (int j=0; j < new_size && !need_update; j++) {
4025 if ((*(*titlebar_side[i]))[j] != m_titlebar_buttons[i][j])
4026 need_update = true;
4027 }
4028 }
4029
4030 }
4031
4032 if (!need_update)
4033 return;
3986 4034
4035 // clear old buttons from frame
4036 frame().removeAllButtons();
3987 4037
4038 using namespace FbTk;
4039 typedef RefCount<Command> CommandRef;
4040 typedef SimpleCommand<FluxboxWindow> WindowCmd;
4041
4042 CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify));
4043 CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeFull));
4044 CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical));
4045 CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal));
4046 CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close));
4047 CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade));
4048 CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick));
4049 CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu));
4050
4051 WinButtonTheme &winbutton_theme = screen().winButtonTheme();
3988 4052
3989 for (size_t c = 0; c < 2 ; c++) { 4053 for (size_t c = 0; c < 2 ; c++) {
3990 // get titlebar configuration for current side 4054 // get titlebar configuration for current side
3991 const vector<WinButton::Type> &dir = *(*titlebar_side[c]); 4055 const vector<WinButton::Type> &dir = *(*titlebar_side[c]);
4056 m_titlebar_buttons[c] = dir;
3992 4057
3993 for (size_t i=0; i < dir.size(); ++i) { 4058 for (size_t i=0; i < dir.size(); ++i) {
3994 //create new buttons 4059 //create new buttons
@@ -4069,32 +4134,8 @@ void FluxboxWindow::setupWindow() {
4069 } // end for c 4134 } // end for c
4070 4135
4071 frame().reconfigure(); 4136 frame().reconfigure();
4072
4073 // setup titlebar
4074 frame().setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1
4075 frame().setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
4076 frame().setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
4077 frame().setOnClickTitlebar(lower_cmd, 2); // on release with button 2
4078
4079 int reverse = 0;
4080 if (screen().getScrollReverse())
4081 reverse = 1;
4082
4083 if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) {
4084 frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll
4085 frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction
4086 } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) {
4087 frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab
4088 frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab
4089 }
4090
4091 frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
4092
4093 // end setup frame
4094
4095} 4137}
4096 4138
4097
4098/** 4139/**
4099 * reconfigTheme: must be called after frame is reconfigured 4140 * reconfigTheme: must be called after frame is reconfigured
4100 * Client windows need to be made the same size and location as 4141 * Client windows need to be made the same size and location as
diff --git a/src/Window.hh b/src/Window.hh
index 2cec115..4e5956f 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -32,6 +32,7 @@
32#include "FbTk/EventHandler.hh" 32#include "FbTk/EventHandler.hh"
33#include "FbTk/XLayerItem.hh" 33#include "FbTk/XLayerItem.hh"
34#include "FbWinFrame.hh" 34#include "FbWinFrame.hh"
35#include "WinButton.hh"
35 36
36#include <X11/Xlib.h> 37#include <X11/Xlib.h>
37#include <X11/Xutil.h> 38#include <X11/Xutil.h>
@@ -443,6 +444,7 @@ private:
443 static const int PropBlackboxAttributesElements = 8; 444 static const int PropBlackboxAttributesElements = 8;
444 445
445 void setupWindow(); 446 void setupWindow();
447 void updateButtons();
446 448
447 void init(); 449 void init();
448 /// applies a shape mask to the window if it has one 450 /// applies a shape mask to the window if it has one
@@ -543,6 +545,7 @@ private:
543 maximize, close, menu, sticky, shade, tab, enabled; 545 maximize, close, menu, sticky, shade, tab, enabled;
544 } decorations; 546 } decorations;
545 547
548 std::vector<WinButton::Type> m_titlebar_buttons[2];
546 bool m_toggled_decos; 549 bool m_toggled_decos;
547 550
548 struct _functions { 551 struct _functions {