diff options
author | fluxgen <fluxgen> | 2002-11-14 10:32:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-11-14 10:32:11 (GMT) |
commit | d68f996683d28a287ad439acdf0713c4828afea3 (patch) | |
tree | a63e4f14d17486a59f57d1f3e54c2a5c8b6120b4 /src | |
parent | d6e2f5d0ee329a90ca06916007467b19c8026c16 (diff) | |
download | fluxbox_pavel-d68f996683d28a287ad439acdf0713c4828afea3.zip fluxbox_pavel-d68f996683d28a287ad439acdf0713c4828afea3.tar.bz2 |
cleaning and fixed menu always fully visible
Diffstat (limited to 'src')
-rw-r--r-- | src/Rootmenu.cc | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/Rootmenu.cc b/src/Rootmenu.cc index 513a971..12099fa 100644 --- a/src/Rootmenu.cc +++ b/src/Rootmenu.cc | |||
@@ -1,3 +1,5 @@ | |||
1 | // Rootmenu.cc for fluxbox | ||
2 | // Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org) | ||
1 | // Rootmenu.cc for Blackbox - an X11 Window manager | 3 | // Rootmenu.cc for Blackbox - an X11 Window manager |
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | 4 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) |
3 | // | 5 | // |
@@ -54,7 +56,7 @@ Rootmenu::Rootmenu(BScreen *scrn) | |||
54 | : Basemenu(scrn), | 56 | : Basemenu(scrn), |
55 | auto_group_window(0) | 57 | auto_group_window(0) |
56 | { | 58 | { |
57 | screen = scrn; | 59 | |
58 | } | 60 | } |
59 | 61 | ||
60 | 62 | ||
@@ -69,20 +71,19 @@ void Rootmenu::itemSelected(int button, unsigned int index) { | |||
69 | switch (item->function()) { | 71 | switch (item->function()) { |
70 | case BScreen::EXECUTE: | 72 | case BScreen::EXECUTE: |
71 | if (item->exec().size()) { | 73 | if (item->exec().size()) { |
72 | #ifndef __EMX__ | 74 | #ifndef __EMX__ |
73 | char displaystring[MAXPATHLEN]; | 75 | char displaystring[MAXPATHLEN]; |
74 | sprintf(displaystring, "DISPLAY=%s", | 76 | sprintf(displaystring, "DISPLAY=%s", |
75 | DisplayString(screen->getBaseDisplay()->getXDisplay())); | 77 | DisplayString(screen()->getBaseDisplay()->getXDisplay())); |
76 | sprintf(displaystring + strlen(displaystring) - 1, "%d", | 78 | sprintf(displaystring + strlen(displaystring) - 1, "%d", |
77 | screen->getScreenNumber()); | 79 | screen()->getScreenNumber()); |
78 | 80 | ||
79 | screen->setAutoGroupWindow(useAutoGroupWindow()); | 81 | screen()->setAutoGroupWindow(useAutoGroupWindow()); |
80 | 82 | ||
81 | bexec(item->exec().c_str(), displaystring); | 83 | bexec(item->exec().c_str(), displaystring); |
82 | 84 | #else // __EMX__ | |
83 | #else // __EMX__ | ||
84 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); | 85 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec().c_str(), NULL); |
85 | #endif // !__EMX__ | 86 | #endif // !__EMX__ |
86 | } | 87 | } |
87 | break; | 88 | break; |
88 | 89 | ||
@@ -111,7 +112,7 @@ void Rootmenu::itemSelected(int button, unsigned int index) { | |||
111 | fluxbox->reconfigure(); | 112 | fluxbox->reconfigure(); |
112 | return; | 113 | return; |
113 | } | 114 | } |
114 | if (! (screen->getRootmenu()->isTorn() || isTorn()) && | 115 | if (! (screen()->getRootmenu()->isTorn() || isTorn()) && |
115 | item->function() != BScreen::RECONFIGURE && | 116 | item->function() != BScreen::RECONFIGURE && |
116 | item->function() != BScreen::SETSTYLE) | 117 | item->function() != BScreen::SETSTYLE) |
117 | hide(); | 118 | hide(); |
@@ -119,23 +120,39 @@ void Rootmenu::itemSelected(int button, unsigned int index) { | |||
119 | } | 120 | } |
120 | } | 121 | } |
121 | 122 | ||
122 | void Rootmenu::setAutoGroupWindow(Window window) | 123 | void Rootmenu::setAutoGroupWindow(Window window) { |
123 | { | ||
124 | auto_group_window = window; | 124 | auto_group_window = window; |
125 | } | 125 | } |
126 | 126 | ||
127 | Window Rootmenu::useAutoGroupWindow() | 127 | void Rootmenu::show() { |
128 | { | 128 | Basemenu::show(); |
129 | // make sure it's full visible | ||
130 | |||
131 | int newx = x(), newy = y(); | ||
132 | if (x() < 0) | ||
133 | newx = 0; | ||
134 | else if (x() + width() > screen()->getWidth()) | ||
135 | newx = screen()->getWidth() - width(); | ||
136 | if (y() < 0) | ||
137 | newy = 0; | ||
138 | else if (y() + height() > screen()->getHeight()) | ||
139 | newy = screen()->getHeight() - height(); | ||
140 | |||
141 | move(newx, newy); | ||
142 | } | ||
143 | |||
144 | Window Rootmenu::useAutoGroupWindow() { | ||
129 | // Return and clear the auto-grouping state. | 145 | // Return and clear the auto-grouping state. |
130 | Window w = auto_group_window; | 146 | Window w = auto_group_window; |
131 | if (w) | 147 | if (w) |
132 | auto_group_window = 0; // clear it immediately | 148 | auto_group_window = 0; // clear it immediately |
133 | // If not set check the parent and the parent's parent, ... | 149 | // If not set check the parent and the parent's parent, ... |
134 | else { | 150 | else if (parent()) { |
135 | // TODO: dynamic_cast throws std::bad_cast! | 151 | // TODO: dynamic_cast throws std::bad_cast! |
136 | Rootmenu *p = dynamic_cast<Rootmenu*>(parent()); | 152 | Rootmenu *p = dynamic_cast<Rootmenu*>(parent()); |
137 | if (p) | 153 | w = p->useAutoGroupWindow(); |
138 | w = p->useAutoGroupWindow(); | ||
139 | } | 154 | } |
140 | return w; | 155 | return w; |
141 | } | 156 | } |
157 | |||
158 | |||