aboutsummaryrefslogtreecommitdiff
path: root/src/Toolbar.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-03-19 14:30:43 (GMT)
committerfluxgen <fluxgen>2002-03-19 14:30:43 (GMT)
commit95aeda26271cce3061a46a3ca0b122bc13c8f5c8 (patch)
treeaaa01d20e77a2445a20a0522d86296b981049b8e /src/Toolbar.cc
parent1871169b06d8b9909ff26b761d24a40a65ef18f9 (diff)
downloadfluxbox_pavel-95aeda26271cce3061a46a3ca0b122bc13c8f5c8.zip
fluxbox_pavel-95aeda26271cce3061a46a3ca0b122bc13c8f5c8.tar.bz2
Xinerama support
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r--src/Toolbar.cc152
1 files changed, 127 insertions, 25 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index 9cf2752..3b9b652 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -1,3 +1,6 @@
1// Toolbar.cc for Fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
1// Toolbar.cc for Blackbox - an X11 Window manager 4// Toolbar.cc for Blackbox - an X11 Window manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -13,13 +16,13 @@
13// 16//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22// $Id: Toolbar.cc,v 1.13 2002/03/19 00:12:36 fluxgen Exp $ 25// $Id: Toolbar.cc,v 1.14 2002/03/19 14:30:42 fluxgen Exp $
23 26
24// stupid macros needed to access some functions in version 2 of the GNU C 27// stupid macros needed to access some functions in version 2 of the GNU C
25// library 28// library
@@ -215,9 +218,38 @@ void Toolbar::delIcon(FluxboxWindow *w) {
215} 218}
216 219
217void Toolbar::reconfigure(void) { 220void Toolbar::reconfigure(void) {
221 int head_x = 0,
222 head_y = 0,
223 head_w,
224 head_h;
225
218 frame.bevel_w = screen->getBevelWidth(); 226 frame.bevel_w = screen->getBevelWidth();
227#ifdef XINERAMA
228 int head = (screen->hasXinerama())
229 ? screen->getToolbarOnHead()
230 : -1;
231
232 if (head >= 0) { // toolbar on head nr, if -1 then over ALL heads
233 head_x = screen->getHeadX(head);
234 head_y = screen->getHeadY(head);
235 head_w = screen->getHeadWidth(head);
236 head_h = screen->getHeadHeight(head);
237
238 frame.width =
239 (screen->getHeadWidth(head) * screen->getToolbarWidthPercent() / 100);
240 } else {
241 head_w = screen->getHeadWidth(head);
242 head_h = screen->getHeadHeight(head);
243
244 frame.width = screen->getWidth() * screen->getToolbarWidthPercent() / 100;
245 }
246#else // !XINERAMA
247 head_w = screen->getWidth();
248 head_h = screen->getHeight();
249
219 frame.width = screen->getWidth() * screen->getToolbarWidthPercent() / 100; 250 frame.width = screen->getWidth() * screen->getToolbarWidthPercent() / 100;
220 251#endif // XINERAMA
252
221 I18n *i18n = I18n::instance(); 253 I18n *i18n = I18n::instance();
222 254
223 if (i18n->multibyte()) 255 if (i18n->multibyte())
@@ -233,50 +265,51 @@ void Toolbar::reconfigure(void) {
233 265
234 switch (screen->getToolbarPlacement()) { 266 switch (screen->getToolbarPlacement()) {
235 case TOPLEFT: 267 case TOPLEFT:
236 frame.x = 0; 268 frame.x = head_x;
237 frame.y = 0; 269 frame.y = head_y;
238 frame.x_hidden = 0; 270 frame.x_hidden = head_x;
239 frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - frame.height; 271 frame.y_hidden = head_y +
272 screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
240 break; 273 break;
241 274
242 case BOTTOMLEFT: 275 case BOTTOMLEFT:
243 frame.x = 0; 276 frame.x = head_x;
244 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 277 frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
245 frame.x_hidden = 0; 278 frame.x_hidden = head_x;
246 frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - 279 frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
247 screen->getBorderWidth(); 280 screen->getBorderWidth();
248 break; 281 break;
249 282
250 case TOPCENTER: 283 case TOPCENTER:
251 frame.x = (screen->getWidth() - frame.width) / 2; 284 frame.x = head_x + ((head_w - frame.width) / 2);
252 frame.y = 0; 285 frame.y = head_y;
253 frame.x_hidden = frame.x; 286 frame.x_hidden = frame.x;
254 frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - 287 frame.y_hidden = head_y +
255 frame.height; 288 screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
256 break; 289 break;
257 290
258 case BOTTOMCENTER: 291 case BOTTOMCENTER:
259 default: 292 default:
260 frame.x = (screen->getWidth() - frame.width) / 2; 293 frame.x = head_x + ((head_w - frame.width) / 2);
261 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 294 frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
262 frame.x_hidden = frame.x; 295 frame.x_hidden = frame.x;
263 frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - 296 frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
264 screen->getBorderWidth(); 297 screen->getBorderWidth();
265 break; 298 break;
266 299
267 case TOPRIGHT: 300 case TOPRIGHT:
268 frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); 301 frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
269 frame.y = 0; 302 frame.y = head_y;
270 frame.x_hidden = frame.x; 303 frame.x_hidden = frame.x;
271 frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - 304 frame.y_hidden = head_y +
272 frame.height; 305 screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
273 break; 306 break;
274 307
275 case BOTTOMRIGHT: 308 case BOTTOMRIGHT:
276 frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); 309 frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
277 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 310 frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
278 frame.x_hidden = frame.x; 311 frame.x_hidden = frame.x;
279 frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - 312 frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
280 screen->getBorderWidth(); 313 screen->getBorderWidth();
281 break; 314 break;
282 } 315 }
@@ -1226,6 +1259,11 @@ Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) {
1226 setInternalMenu(); 1259 setInternalMenu();
1227 1260
1228 placementmenu = new Placementmenu(this); 1261 placementmenu = new Placementmenu(this);
1262#ifdef XINERAMA
1263 if (toolbar->screen->hasXinerama()) { // only create if we need it
1264 headmenu = new Headmenu(this);
1265 }
1266#endif // XINERAMA
1229 1267
1230 insert(i18n->getMessage( 1268 insert(i18n->getMessage(
1231#ifdef NLS 1269#ifdef NLS
@@ -1235,6 +1273,13 @@ Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) {
1235#endif // NLS 1273#endif // NLS
1236 "Placement"), 1274 "Placement"),
1237 placementmenu); 1275 placementmenu);
1276
1277#ifdef XINERAMA
1278 if (toolbar->screen->hasXinerama()) { //TODO: NLS
1279 insert(i18n->getMessage(0, 0, "Place on Head"), headmenu);
1280 }
1281#endif // XINERAMA
1282
1238 insert(i18n->getMessage( 1283 insert(i18n->getMessage(
1239#ifdef NLS 1284#ifdef NLS
1240 CommonSet, CommonAlwaysOnTop, 1285 CommonSet, CommonAlwaysOnTop,
@@ -1271,6 +1316,12 @@ Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) {
1271 1316
1272Toolbarmenu::~Toolbarmenu(void) { 1317Toolbarmenu::~Toolbarmenu(void) {
1273 delete placementmenu; 1318 delete placementmenu;
1319#ifdef XINERAMA
1320 if (toolbar->screen->hasXinerama()) {
1321 delete headmenu;
1322 }
1323#endif // XINERAMA
1324
1274} 1325}
1275 1326
1276 1327
@@ -1321,6 +1372,11 @@ void Toolbarmenu::internal_hide(void) {
1321 1372
1322void Toolbarmenu::reconfigure(void) { 1373void Toolbarmenu::reconfigure(void) {
1323 placementmenu->reconfigure(); 1374 placementmenu->reconfigure();
1375#ifdef XINERAMA
1376 if (toolbar->screen->hasXinerama()) {
1377 headmenu->reconfigure();
1378 }
1379#endif // XINERAMA
1324 1380
1325 Basemenu::reconfigure(); 1381 Basemenu::reconfigure();
1326} 1382}
@@ -1413,3 +1469,49 @@ void Toolbarmenu::Placementmenu::itemSelected(int button, int index) {
1413 1469
1414 } 1470 }
1415} 1471}
1472
1473#ifdef XINERAMA
1474
1475Toolbarmenu::Headmenu::Headmenu(Toolbarmenu *tm)
1476 : Basemenu(tm->toolbar->screen) {
1477 toolbarmenu = tm;
1478 I18n *i18n = I18n::instance();
1479
1480 setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS
1481 setInternalMenu();
1482
1483 int numHeads = toolbarmenu->toolbar->screen->getNumHeads();
1484 // fill menu with head entries
1485 for (int i = 0; i < numHeads; i++) {
1486 char headName[32];
1487 sprintf(headName, "Head %i", i+1); //TODO: NLS
1488 insert(i18n->getMessage(0, 0, headName), i);
1489 }
1490
1491 insert(i18n->getMessage(0, 0, "All Heads"), -1); //TODO: NLS
1492
1493 update();
1494}
1495
1496
1497void Toolbarmenu::Headmenu::itemSelected(int button, int index) {
1498 if (button == 1) {
1499 BasemenuItem *item = find(index);
1500 if (! item)
1501 return;
1502
1503 toolbarmenu->toolbar->screen->saveToolbarOnHead(
1504 static_cast<int>(item->function()));
1505 hide();
1506 toolbarmenu->toolbar->reconfigure();
1507
1508#ifdef SLIT
1509 // reposition the slit as well to make sure it doesn't intersect the
1510 // toolbar
1511 toolbarmenu->toolbar->screen->getSlit()->reposition();
1512#endif // SLIT
1513
1514 }
1515}
1516
1517#endif // XINERAMA