cleaning and fixed menu always fully visible
This commit is contained in:
parent
d6e2f5d0ee
commit
d68f996683
1 changed files with 33 additions and 16 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
// Rootmenu.cc for fluxbox
|
||||||
|
// Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
|
||||||
// Rootmenu.cc for Blackbox - an X11 Window manager
|
// Rootmenu.cc for Blackbox - an X11 Window manager
|
||||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||||
//
|
//
|
||||||
|
@ -54,7 +56,7 @@ Rootmenu::Rootmenu(BScreen *scrn)
|
||||||
: Basemenu(scrn),
|
: Basemenu(scrn),
|
||||||
auto_group_window(0)
|
auto_group_window(0)
|
||||||
{
|
{
|
||||||
screen = scrn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,20 +71,19 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
|
||||||
switch (item->function()) {
|
switch (item->function()) {
|
||||||
case BScreen::EXECUTE:
|
case BScreen::EXECUTE:
|
||||||
if (item->exec().size()) {
|
if (item->exec().size()) {
|
||||||
#ifndef __EMX__
|
#ifndef __EMX__
|
||||||
char displaystring[MAXPATHLEN];
|
char displaystring[MAXPATHLEN];
|
||||||
sprintf(displaystring, "DISPLAY=%s",
|
sprintf(displaystring, "DISPLAY=%s",
|
||||||
DisplayString(screen->getBaseDisplay()->getXDisplay()));
|
DisplayString(screen()->getBaseDisplay()->getXDisplay()));
|
||||||
sprintf(displaystring + strlen(displaystring) - 1, "%d",
|
sprintf(displaystring + strlen(displaystring) - 1, "%d",
|
||||||
screen->getScreenNumber());
|
screen()->getScreenNumber());
|
||||||
|
|
||||||
screen->setAutoGroupWindow(useAutoGroupWindow());
|
screen()->setAutoGroupWindow(useAutoGroupWindow());
|
||||||
|
|
||||||
bexec(item->exec().c_str(), displaystring);
|
bexec(item->exec().c_str(), displaystring);
|
||||||
|
#else // __EMX__
|
||||||
#else // __EMX__
|
|
||||||
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL);
|
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL);
|
||||||
#endif // !__EMX__
|
#endif // !__EMX__
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
|
||||||
fluxbox->reconfigure();
|
fluxbox->reconfigure();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (! (screen->getRootmenu()->isTorn() || isTorn()) &&
|
if (! (screen()->getRootmenu()->isTorn() || isTorn()) &&
|
||||||
item->function() != BScreen::RECONFIGURE &&
|
item->function() != BScreen::RECONFIGURE &&
|
||||||
item->function() != BScreen::SETSTYLE)
|
item->function() != BScreen::SETSTYLE)
|
||||||
hide();
|
hide();
|
||||||
|
@ -119,23 +120,39 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rootmenu::setAutoGroupWindow(Window window)
|
void Rootmenu::setAutoGroupWindow(Window window) {
|
||||||
{
|
|
||||||
auto_group_window = window;
|
auto_group_window = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window Rootmenu::useAutoGroupWindow()
|
void Rootmenu::show() {
|
||||||
{
|
Basemenu::show();
|
||||||
|
// make sure it's full visible
|
||||||
|
|
||||||
|
int newx = x(), newy = y();
|
||||||
|
if (x() < 0)
|
||||||
|
newx = 0;
|
||||||
|
else if (x() + width() > screen()->getWidth())
|
||||||
|
newx = screen()->getWidth() - width();
|
||||||
|
if (y() < 0)
|
||||||
|
newy = 0;
|
||||||
|
else if (y() + height() > screen()->getHeight())
|
||||||
|
newy = screen()->getHeight() - height();
|
||||||
|
|
||||||
|
move(newx, newy);
|
||||||
|
}
|
||||||
|
|
||||||
|
Window Rootmenu::useAutoGroupWindow() {
|
||||||
// Return and clear the auto-grouping state.
|
// Return and clear the auto-grouping state.
|
||||||
Window w = auto_group_window;
|
Window w = auto_group_window;
|
||||||
if (w)
|
if (w)
|
||||||
auto_group_window = 0; // clear it immediately
|
auto_group_window = 0; // clear it immediately
|
||||||
// If not set check the parent and the parent's parent, ...
|
// If not set check the parent and the parent's parent, ...
|
||||||
else {
|
else if (parent()) {
|
||||||
// TODO: dynamic_cast throws std::bad_cast!
|
// TODO: dynamic_cast throws std::bad_cast!
|
||||||
Rootmenu *p = dynamic_cast<Rootmenu*>(parent());
|
Rootmenu *p = dynamic_cast<Rootmenu*>(parent());
|
||||||
if (p)
|
w = p->useAutoGroupWindow();
|
||||||
w = p->useAutoGroupWindow();
|
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue