fix menus for "extra" things, like remember, so that they will be
added back if the menu is rebuilt.
This commit is contained in:
parent
ace3e2e629
commit
1741ac072d
9 changed files with 229 additions and 175 deletions
7
BUGS
7
BUGS
|
@ -2,9 +2,6 @@ Known bugs and missing features that will be fixed in future version:
|
|||
|
||||
BUGS:
|
||||
|
||||
* Remember menu sometimes isn't present in window menu. Probably need
|
||||
to add a signal for menu reconfigures (Screen::setupWindowActions)
|
||||
|
||||
* Window handle is invisible sometimes.
|
||||
|
||||
* KDE support needs attention (e.g. klipper).
|
||||
|
@ -75,6 +72,10 @@ Fixed bugs (or not-our-fault bugs):
|
|||
highest numbered screen.
|
||||
=> Fixed, moved alpha setting into MenuTheme rather than static value
|
||||
|
||||
* Remember menu sometimes isn't present in window menu. Probably need
|
||||
to add a signal for menu reconfigures (Screen::setupWindowActions)
|
||||
=> Fixed, added "ExtraMenus" for windows that get added whenever it
|
||||
is rebuilt.
|
||||
|
||||
------------------------------
|
||||
Core dumps and notes
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 0.9.5:
|
||||
*03/07/20:
|
||||
* Fix disappearing Remember menu, plus titles of sub-window menus
|
||||
-> can now use addExtraMenus for windows in extensions (Simon)
|
||||
Menu.hh/cc Window.hh/cc Screen.hh/cc Remember.cc
|
||||
* Fix crash with toolbarmode = OFF, and put toolbar menu back into
|
||||
screen's configure menu (Simon)
|
||||
Screen.hh/cc ToolbarHandler.cc
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Menu.cc,v 1.29 2003/07/19 03:59:56 rathnor Exp $
|
||||
// $Id: Menu.cc,v 1.30 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
//use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -557,6 +557,8 @@ void Menu::update() {
|
|||
|
||||
|
||||
void Menu::show() {
|
||||
if (m_need_update)
|
||||
update();
|
||||
menu.window.showSubwindows();
|
||||
menu.window.show();
|
||||
//!! TODO, this should probably be done explicit if one don't want to raise
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Menu.hh,v 1.19 2003/07/19 03:59:56 rathnor Exp $
|
||||
// $Id: Menu.hh,v 1.20 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
#ifndef FBTK_MENU_HH
|
||||
#define FBTK_MENU_HH
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
int remove(unsigned int item);
|
||||
/// remove all items
|
||||
void removeAll();
|
||||
inline void setInternalMenu() { internal_menu = true; }
|
||||
inline void setInternalMenu(bool val = true) { internal_menu = val; }
|
||||
inline void setAlignment(Alignment a) { m_alignment = a; }
|
||||
inline void setTorn() { torn = true; }
|
||||
inline void removeParent() { if (internal_menu) m_parent = 0; }
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
inline void setTitleVisibility(bool b) { title_vis = b; }
|
||||
inline void setTitleVisibility(bool b) { title_vis = b; m_need_update = true; }
|
||||
inline void setMovable(bool b) { movable = b; }
|
||||
inline void setHideTree(bool h) { hide_tree = h; }
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Remember.cc,v 1.27 2003/07/10 13:23:09 rathnor Exp $
|
||||
// $Id: Remember.cc,v 1.28 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
#include "Remember.hh"
|
||||
#include "ClientPattern.hh"
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
Remember::Attribute m_attrib;
|
||||
};
|
||||
|
||||
FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win) {
|
||||
FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win, bool enabled) {
|
||||
// each fluxboxwindow has its own windowmenu
|
||||
// so we also create a remember menu just for it...
|
||||
BScreen &screen = win.screen();
|
||||
|
@ -101,7 +101,16 @@ FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win) {
|
|||
screen.screenNumber(),
|
||||
screen.imageControl(),
|
||||
*screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()));
|
||||
menu->disableTitle();
|
||||
|
||||
// if enabled, then we want this to be a unavailable menu
|
||||
if (!enabled) {
|
||||
FbTk::MenuItem *item = new FbTk::MenuItem("unavailable");
|
||||
item->setEnabled(false);
|
||||
menu->insert(item);
|
||||
menu->update();
|
||||
return menu;
|
||||
}
|
||||
|
||||
// TODO: nls
|
||||
menu->insert(new RememberMenuItem("Workspace", remember, win,
|
||||
Remember::REM_WORKSPACE));
|
||||
|
@ -676,28 +685,13 @@ void Remember::setupFrame(FluxboxWindow &win) {
|
|||
|
||||
// we don't touch the window if it is a transient
|
||||
// of something else
|
||||
int menupos = win.menu().numberOfItems()-2;
|
||||
if (menupos < -1)
|
||||
menupos = -1;
|
||||
|
||||
if (winclient.transientFor()) {
|
||||
// still put something in the menu so people don't get confused
|
||||
// so, we add a disabled item...
|
||||
// TODO: nls
|
||||
FbTk::MenuItem *item = new FbTk::MenuItem("Remember...");
|
||||
item->setEnabled(false);
|
||||
win.menu().insert(item, menupos);
|
||||
win.menu().update();
|
||||
return;
|
||||
}
|
||||
|
||||
// add the menu, this -2 is somewhat dodgy... :-/
|
||||
// All windows get the remember menu.
|
||||
// TODO: nls
|
||||
win.menu().insert("Remember...",
|
||||
createRememberMenu(*this, win),
|
||||
menupos);
|
||||
win.menu().reconfigure();
|
||||
win.addExtraMenu("Remember...", createRememberMenu(*this, win, (winclient.transientFor() == 0)));
|
||||
|
||||
if (winclient.transientFor())
|
||||
return;
|
||||
|
||||
Application *app = find(winclient);
|
||||
if (app == 0)
|
||||
|
|
126
src/Screen.cc
126
src/Screen.cc
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Screen.cc,v 1.205 2003/07/20 02:45:57 rathnor Exp $
|
||||
// $Id: Screen.cc,v 1.206 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
|
||||
#include "Screen.hh"
|
||||
|
@ -35,7 +35,6 @@
|
|||
#include "StringUtil.hh"
|
||||
#include "Netizen.hh"
|
||||
#include "Directory.hh"
|
||||
#include "WinButton.hh"
|
||||
#include "SimpleCommand.hh"
|
||||
#include "FbWinFrameTheme.hh"
|
||||
#include "MenuTheme.hh"
|
||||
|
@ -1069,7 +1068,6 @@ FluxboxWindow *BScreen::createWindow(Window client) {
|
|||
focused_list.push_back(&win->winClient());
|
||||
|
||||
if (new_win) {
|
||||
setupWindowActions(*win);
|
||||
Fluxbox::instance()->attachSignals(*win);
|
||||
}
|
||||
|
||||
|
@ -1107,7 +1105,6 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) {
|
|||
// WinClient already exists).
|
||||
|
||||
Fluxbox::instance()->saveWindowSearch(client.window(), win);
|
||||
setupWindowActions(*win);
|
||||
Fluxbox::instance()->attachSignals(*win);
|
||||
// winclient actions should have been setup when the WinClient was created
|
||||
if (win->workspaceNumber() == currentWorkspaceID() || win->isStuck()) {
|
||||
|
@ -1116,127 +1113,6 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) {
|
|||
return win;
|
||||
}
|
||||
|
||||
void BScreen::setupWindowActions(FluxboxWindow &win) {
|
||||
|
||||
FbWinFrame &frame = win.frame();
|
||||
|
||||
|
||||
typedef FbTk::RefCount<FbTk::Command> CommandRef;
|
||||
|
||||
using namespace FbTk;
|
||||
typedef RefCount<Command> CommandRef;
|
||||
typedef SimpleCommand<FluxboxWindow> WindowCmd;
|
||||
|
||||
CommandRef iconify_cmd(new WindowCmd(win, &FluxboxWindow::iconify));
|
||||
CommandRef maximize_cmd(new WindowCmd(win, &FluxboxWindow::maximize));
|
||||
CommandRef maximize_vert_cmd(new WindowCmd(win, &FluxboxWindow::maximizeVertical));
|
||||
CommandRef maximize_horiz_cmd(new WindowCmd(win, &FluxboxWindow::maximizeHorizontal));
|
||||
CommandRef close_cmd(new WindowCmd(win, &FluxboxWindow::close));
|
||||
CommandRef shade_cmd(new WindowCmd(win, &FluxboxWindow::shade));
|
||||
CommandRef raise_cmd(new WindowCmd(win, &FluxboxWindow::raise));
|
||||
CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::lower));
|
||||
CommandRef raise_and_focus_cmd(new WindowCmd(win, &FluxboxWindow::raiseAndFocus));
|
||||
CommandRef stick_cmd(new WindowCmd(win, &FluxboxWindow::stick));
|
||||
CommandRef show_menu_cmd(new WindowCmd(win, &FluxboxWindow::popupMenu));
|
||||
|
||||
// clear old buttons from frame
|
||||
frame.removeAllButtons();
|
||||
//!! TODO: fix this ugly hack
|
||||
// get titlebar configuration
|
||||
const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
|
||||
for (char c=0; c<2; c++) {
|
||||
for (size_t i=0; i< dir->size(); ++i) {
|
||||
//create new buttons
|
||||
FbTk::Button *newbutton = 0;
|
||||
if (win.isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) {
|
||||
newbutton = new WinButton(win, *m_winbutton_theme.get(),
|
||||
WinButton::MINIMIZE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
newbutton->setOnClick(iconify_cmd);
|
||||
|
||||
} else if (win.isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) {
|
||||
newbutton = new WinButton(win, *m_winbutton_theme.get(),
|
||||
WinButton::MAXIMIZE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
|
||||
newbutton->setOnClick(maximize_cmd, 1);
|
||||
newbutton->setOnClick(maximize_horiz_cmd, 3);
|
||||
newbutton->setOnClick(maximize_vert_cmd, 2);
|
||||
|
||||
} else if (win.isClosable() && (*dir)[i] == Fluxbox::CLOSE) {
|
||||
newbutton = new WinButton(win, *m_winbutton_theme.get(),
|
||||
WinButton::CLOSE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
|
||||
newbutton->setOnClick(close_cmd);
|
||||
#ifdef DEBUG
|
||||
cerr<<__FILE__<<": Creating close button"<<endl;
|
||||
#endif // DEBUG
|
||||
} else if ((*dir)[i] == Fluxbox::STICK) {
|
||||
WinButton *winbtn = new WinButton(win, *m_winbutton_theme.get(),
|
||||
WinButton::STICK,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
win.stateSig().attach(winbtn);
|
||||
winbtn->setOnClick(stick_cmd);
|
||||
newbutton = winbtn;
|
||||
} else if ((*dir)[i] == Fluxbox::SHADE) {
|
||||
WinButton *winbtn = new WinButton(win, *m_winbutton_theme.get(),
|
||||
WinButton::SHADE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
winbtn->setOnClick(shade_cmd);
|
||||
}
|
||||
|
||||
if (newbutton != 0) {
|
||||
newbutton->show();
|
||||
if (c == 0)
|
||||
frame.addLeftButton(newbutton);
|
||||
else
|
||||
frame.addRightButton(newbutton);
|
||||
}
|
||||
} //end for i
|
||||
dir = &Fluxbox::instance()->getTitlebarRight();
|
||||
} // end for c
|
||||
|
||||
frame.reconfigure();
|
||||
|
||||
// setup titlebar
|
||||
frame.setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1
|
||||
frame.setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
|
||||
frame.setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
|
||||
frame.setOnClickTitlebar(lower_cmd, 2); // on release with button 2
|
||||
frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
|
||||
// setup menu
|
||||
FbTk::Menu &menu = win.menu();
|
||||
menu.removeAll(); // clear old items
|
||||
menu.disableTitle(); // not titlebar
|
||||
|
||||
// set new menu items
|
||||
menu.insert("Shade", shade_cmd);
|
||||
menu.insert("Stick", stick_cmd);
|
||||
menu.insert("Maximize", maximize_cmd);
|
||||
menu.insert("Maximize Vertical", maximize_vert_cmd);
|
||||
menu.insert("Maximize Horizontal", maximize_horiz_cmd);
|
||||
menu.insert("Iconify", iconify_cmd);
|
||||
menu.insert("Raise", raise_cmd);
|
||||
menu.insert("Lower", lower_cmd);
|
||||
menu.insert("Layer...", &win.layermenu());
|
||||
CommandRef next_client_cmd(new WindowCmd(win, &FluxboxWindow::nextClient));
|
||||
CommandRef prev_client_cmd(new WindowCmd(win, &FluxboxWindow::prevClient));
|
||||
menu.insert("Next Client", next_client_cmd);
|
||||
menu.insert("Prev Client", prev_client_cmd);
|
||||
|
||||
menu.insert("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯");
|
||||
menu.insert("Close", close_cmd);
|
||||
|
||||
menu.reconfigure(); // update graphics
|
||||
|
||||
}
|
||||
|
||||
Strut *BScreen::requestStrut(int left, int right, int top, int bottom) {
|
||||
Strut *str = new Strut(left, right, top, bottom);
|
||||
m_strutlist.push_back(str);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Screen.hh,v 1.115 2003/07/20 02:45:57 rathnor Exp $
|
||||
// $Id: Screen.hh,v 1.116 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
#ifndef SCREEN_HH
|
||||
#define SCREEN_HH
|
||||
|
@ -193,6 +193,9 @@ public:
|
|||
inline MenuTheme *menuTheme() { return m_menutheme.get(); }
|
||||
inline const MenuTheme *menuTheme() const { return m_menutheme.get(); }
|
||||
inline const RootTheme &rootTheme() const { return *m_root_theme.get(); }
|
||||
inline WinButtonTheme &winButtonTheme() { return *m_winbutton_theme.get(); }
|
||||
inline const WinButtonTheme &winButtonTheme() const { return *m_winbutton_theme.get(); }
|
||||
|
||||
FbRootWindow &rootWindow() { return m_root_window; }
|
||||
const FbRootWindow &rootWindow() const { return m_root_window; }
|
||||
|
||||
|
@ -311,8 +314,8 @@ public:
|
|||
void updateAvailableWorkspaceArea();
|
||||
|
||||
// for extras to add menus. These menus must be marked
|
||||
// internal for their safety, and the extension must
|
||||
// delete and remove the menu itself
|
||||
// internal for their safety, and __the extension__ must
|
||||
// delete and remove the menu itself (opposite to Window)
|
||||
void addConfigMenu(const char *label, FbTk::Menu &menu);
|
||||
void removeConfigMenu(FbTk::Menu &menu);
|
||||
|
||||
|
|
191
src/Window.cc
191
src/Window.cc
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Window.cc,v 1.205 2003/07/19 11:55:49 rathnor Exp $
|
||||
// $Id: Window.cc,v 1.206 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
#include "Window.hh"
|
||||
|
||||
|
@ -41,6 +41,8 @@
|
|||
#include "Workspace.hh"
|
||||
#include "LayerMenu.hh"
|
||||
#include "FbWinFrame.hh"
|
||||
#include "WinButton.hh"
|
||||
#include "WinButtonTheme.hh"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -234,12 +236,6 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
|
|||
m_screen(scr),
|
||||
m_timer(this),
|
||||
display(0),
|
||||
m_layermenu(new LayerMenu<FluxboxWindow>(*scr.menuTheme(),
|
||||
scr.screenNumber(),
|
||||
scr.imageControl(),
|
||||
*scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
|
||||
this,
|
||||
false)),
|
||||
m_windowmenu(*scr.menuTheme(), scr.screenNumber(), scr.imageControl()),
|
||||
m_old_decoration(DECOR_NORMAL),
|
||||
m_client(&client),
|
||||
|
@ -295,6 +291,18 @@ FluxboxWindow::~FluxboxWindow() {
|
|||
}
|
||||
}
|
||||
|
||||
// deal with extra menus
|
||||
ExtraMenus::iterator mit = m_extramenus.begin();
|
||||
ExtraMenus::iterator mit_end = m_extramenus.end();
|
||||
for (; mit != mit_end; ++mit) {
|
||||
// we set them to NOT internal so that they will be deleted when the
|
||||
// menu is cleaned up. We can't delete them here because they are
|
||||
// still in the menu
|
||||
// (They need to be internal for most of the time so that if we
|
||||
// rebuild the menu, then they won't be removed.
|
||||
mit->second->setInternalMenu(false);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl;
|
||||
#endif // DEBUG
|
||||
|
@ -302,10 +310,6 @@ FluxboxWindow::~FluxboxWindow() {
|
|||
|
||||
|
||||
void FluxboxWindow::init() {
|
||||
// so parent menu don't kill us
|
||||
m_layermenu->setInternalMenu();
|
||||
m_layermenu->disableTitle();
|
||||
|
||||
m_attaching_tab = 0;
|
||||
|
||||
assert(m_client);
|
||||
|
@ -518,7 +522,17 @@ void FluxboxWindow::init() {
|
|||
}
|
||||
|
||||
setState(m_current_state);
|
||||
frame().reconfigure();
|
||||
|
||||
addExtraMenu("Layer...",
|
||||
new LayerMenu<FluxboxWindow>(*screen().menuTheme(),
|
||||
screen().screenNumber(),
|
||||
screen().imageControl(),
|
||||
*screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
|
||||
this,
|
||||
false));
|
||||
// the layermenu will get deleted as an extra menu
|
||||
// don't call setupWindow here as the addExtraMenu call should
|
||||
|
||||
sendConfigureNotify();
|
||||
// no focus default
|
||||
setFocusFlag(false);
|
||||
|
@ -2169,7 +2183,7 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
|
|||
getWMProtocols();
|
||||
//!!TODO check this area
|
||||
// reset window actions
|
||||
screen().setupWindowActions(*this);
|
||||
setupWindow();
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -3304,3 +3318,154 @@ void FluxboxWindow::sendConfigureNotify(bool send_to_netizens) {
|
|||
} // end for
|
||||
}
|
||||
|
||||
void FluxboxWindow::addExtraMenu(const char *label, FbTk::Menu *menu) {
|
||||
menu->setInternalMenu();
|
||||
menu->disableTitle();
|
||||
m_extramenus.push_back(std::make_pair(label, menu));
|
||||
|
||||
setupWindow();
|
||||
}
|
||||
|
||||
void FluxboxWindow::removeExtraMenu(FbTk::Menu *menu) {
|
||||
ExtraMenus::iterator it = m_extramenus.begin();
|
||||
ExtraMenus::iterator it_end = m_extramenus.end();
|
||||
for (; it != it_end; ++it) {
|
||||
if (it->second == menu) {
|
||||
m_extramenus.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
setupWindow();
|
||||
}
|
||||
|
||||
|
||||
void FluxboxWindow::setupWindow() {
|
||||
// sets up our window
|
||||
// we allow both to be done at once to share the commands
|
||||
|
||||
FbWinFrame &frame = *m_frame.get();
|
||||
WinButtonTheme &winbutton_theme = screen().winButtonTheme();
|
||||
|
||||
typedef FbTk::RefCount<FbTk::Command> CommandRef;
|
||||
|
||||
using namespace FbTk;
|
||||
typedef RefCount<Command> CommandRef;
|
||||
typedef SimpleCommand<FluxboxWindow> WindowCmd;
|
||||
|
||||
CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify));
|
||||
CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximize));
|
||||
CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical));
|
||||
CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal));
|
||||
CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close));
|
||||
CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade));
|
||||
CommandRef raise_cmd(new WindowCmd(*this, &FluxboxWindow::raise));
|
||||
CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower));
|
||||
CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus));
|
||||
CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick));
|
||||
CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu));
|
||||
|
||||
// clear old buttons from frame
|
||||
frame.removeAllButtons();
|
||||
//!! TODO: fix this ugly hack
|
||||
// get titlebar configuration
|
||||
const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
|
||||
for (char c=0; c<2; c++) {
|
||||
for (size_t i=0; i< dir->size(); ++i) {
|
||||
//create new buttons
|
||||
FbTk::Button *newbutton = 0;
|
||||
if (isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) {
|
||||
newbutton = new WinButton(*this, winbutton_theme,
|
||||
WinButton::MINIMIZE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
newbutton->setOnClick(iconify_cmd);
|
||||
|
||||
} else if (isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) {
|
||||
newbutton = new WinButton(*this, winbutton_theme,
|
||||
WinButton::MAXIMIZE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
|
||||
newbutton->setOnClick(maximize_cmd, 1);
|
||||
newbutton->setOnClick(maximize_horiz_cmd, 3);
|
||||
newbutton->setOnClick(maximize_vert_cmd, 2);
|
||||
|
||||
} else if (isClosable() && (*dir)[i] == Fluxbox::CLOSE) {
|
||||
newbutton = new WinButton(*this, winbutton_theme,
|
||||
WinButton::CLOSE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
|
||||
newbutton->setOnClick(close_cmd);
|
||||
#ifdef DEBUG
|
||||
cerr<<__FILE__<<": Creating close button"<<endl;
|
||||
#endif // DEBUG
|
||||
} else if ((*dir)[i] == Fluxbox::STICK) {
|
||||
WinButton *winbtn = new WinButton(*this, winbutton_theme,
|
||||
WinButton::STICK,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
stateSig().attach(winbtn);
|
||||
winbtn->setOnClick(stick_cmd);
|
||||
newbutton = winbtn;
|
||||
} else if ((*dir)[i] == Fluxbox::SHADE) {
|
||||
WinButton *winbtn = new WinButton(*this, winbutton_theme,
|
||||
WinButton::SHADE,
|
||||
frame.titlebar(),
|
||||
0, 0, 10, 10);
|
||||
winbtn->setOnClick(shade_cmd);
|
||||
}
|
||||
|
||||
if (newbutton != 0) {
|
||||
newbutton->show();
|
||||
if (c == 0)
|
||||
frame.addLeftButton(newbutton);
|
||||
else
|
||||
frame.addRightButton(newbutton);
|
||||
}
|
||||
} //end for i
|
||||
dir = &Fluxbox::instance()->getTitlebarRight();
|
||||
} // end for c
|
||||
|
||||
frame.reconfigure();
|
||||
|
||||
// setup titlebar
|
||||
frame.setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1
|
||||
frame.setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
|
||||
frame.setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
|
||||
frame.setOnClickTitlebar(lower_cmd, 2); // on release with button 2
|
||||
frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
|
||||
|
||||
// end setup frame
|
||||
|
||||
// setup menu
|
||||
FbTk::Menu &menu = m_windowmenu;
|
||||
menu.removeAll(); // clear old items
|
||||
menu.disableTitle(); // not titlebar
|
||||
|
||||
// set new menu items
|
||||
menu.insert("Shade", shade_cmd);
|
||||
menu.insert("Stick", stick_cmd);
|
||||
menu.insert("Maximize", maximize_cmd);
|
||||
menu.insert("Maximize Vertical", maximize_vert_cmd);
|
||||
menu.insert("Maximize Horizontal", maximize_horiz_cmd);
|
||||
menu.insert("Iconify", iconify_cmd);
|
||||
menu.insert("Raise", raise_cmd);
|
||||
menu.insert("Lower", lower_cmd);
|
||||
CommandRef next_client_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient));
|
||||
CommandRef prev_client_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient));
|
||||
menu.insert("Next Client", next_client_cmd);
|
||||
menu.insert("Prev Client", prev_client_cmd);
|
||||
|
||||
ExtraMenus::iterator it = m_extramenus.begin();
|
||||
ExtraMenus::iterator it_end = m_extramenus.end();
|
||||
for (; it != it_end; ++it) {
|
||||
it->second->disableTitle(); // be sure there is no title
|
||||
menu.insert(it->first, it->second);
|
||||
}
|
||||
|
||||
menu.insert("¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯");
|
||||
menu.insert("Close", close_cmd);
|
||||
|
||||
menu.reconfigure(); // update graphics
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Window.hh,v 1.84 2003/07/17 17:56:28 rathnor Exp $
|
||||
// $Id: Window.hh,v 1.85 2003/07/20 08:12:36 rathnor Exp $
|
||||
|
||||
#ifndef WINDOW_HH
|
||||
#define WINDOW_HH
|
||||
|
@ -198,6 +198,8 @@ public:
|
|||
void moveToLayer(int layernum);
|
||||
|
||||
void reconfigure();
|
||||
void setupWindow();
|
||||
|
||||
void installColormap(bool);
|
||||
void restore(WinClient *client, bool remap);
|
||||
void restore(bool remap);
|
||||
|
@ -288,8 +290,17 @@ public:
|
|||
FbTk::Menu &menu() { return m_windowmenu; }
|
||||
const FbTk::Menu &menu() const { return m_windowmenu; }
|
||||
|
||||
FbTk::Menu &layermenu() { return *m_layermenu.get(); }
|
||||
const FbTk::Menu &layermenu() const { return *m_layermenu.get(); }
|
||||
// this should perhaps be a refcount??
|
||||
typedef std::list<std::pair<const char *, FbTk::Menu *> > ExtraMenus;
|
||||
|
||||
// for extras to add menus.
|
||||
// These menus will be marked internal,
|
||||
// and deleted when the window dies (as opposed to Screen
|
||||
void addExtraMenu(const char *label, FbTk::Menu *menu);
|
||||
void removeExtraMenu(FbTk::Menu *menu);
|
||||
|
||||
ExtraMenus &extraMenus() { return m_extramenus; }
|
||||
const ExtraMenus &extraMenus() const { return m_extramenus; }
|
||||
|
||||
const FbTk::FbWindow &parent() const { return m_parent; }
|
||||
FbTk::FbWindow &parent() { return m_parent; }
|
||||
|
@ -403,10 +414,8 @@ private:
|
|||
Display *display; /// display connection
|
||||
BlackboxAttributes m_blackbox_attrib;
|
||||
|
||||
std::auto_ptr<FbTk::Menu> m_layermenu;
|
||||
FbTk::Menu m_windowmenu;
|
||||
|
||||
|
||||
timeval m_last_focus_time;
|
||||
|
||||
int m_button_grab_x, m_button_grab_y; // handles last button press event for move
|
||||
|
@ -451,6 +460,7 @@ private:
|
|||
|
||||
FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window")
|
||||
|
||||
ExtraMenus m_extramenus;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue