summaryrefslogtreecommitdiff
path: root/src/Slit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Slit.cc')
-rw-r--r--src/Slit.cc140
1 files changed, 109 insertions, 31 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index ef16c2f..c33d2e0 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -404,93 +404,114 @@ void Slit::reconfigure(void) {
404 404
405 405
406void Slit::reposition(void) { 406void Slit::reposition(void) {
407 int head_x = 0,
408 head_y = 0,
409 head_w,
410 head_h;
411#ifdef XINERMA
412 if (screen->hasXinerama()) {
413 unsigned int head = screen->getSlitOnHead();
414
415 head_x = screen->getHeadX(head);
416 head_y = screen->getHeadY(head);
417 head_w = screen->getHeadWidth(head);
418 head_h = screen->getHeadHeight(head);
419 } else {
420 head_w = screen->getWidth();
421 head_h = screen->getHeight();
422 }
423#else // !XINERAMA
424 head_w = screen->getWidth();
425 head_h = screen->getHeight();
426#endif // XINERAMA
427
407 // place the slit in the appropriate place 428 // place the slit in the appropriate place
408 switch (screen->getSlitPlacement()) { 429 switch (screen->getSlitPlacement()) {
409 case TOPLEFT: 430 case TOPLEFT:
410 frame.x = 0; 431 frame.x = head_x;
411 frame.y = 0; 432 frame.y = head_y;
412 if (screen->getSlitDirection() == VERTICAL) { 433 if (screen->getSlitDirection() == VERTICAL) {
413 frame.x_hidden = screen->getBevelWidth() - 434 frame.x_hidden = screen->getBevelWidth() -
414 screen->getBorderWidth() - frame.width; 435 screen->getBorderWidth() - frame.width;
415 frame.y_hidden = 0; 436 frame.y_hidden = head_y;
416 } else { 437 } else {
417 frame.x_hidden = 0; 438 frame.x_hidden = head_x;
418 frame.y_hidden = screen->getBevelWidth() - 439 frame.y_hidden = screen->getBevelWidth() -
419 screen->getBorderWidth() - frame.height; 440 screen->getBorderWidth() - frame.height;
420 } 441 }
421 break; 442 break;
422 443
423 case CENTERLEFT: 444 case CENTERLEFT:
424 frame.x = 0; 445 frame.x = head_x;
425 frame.y = (screen->getHeight() - frame.height) / 2; 446 frame.y = head_y + (head_h - frame.height) / 2;
426 frame.x_hidden = screen->getBevelWidth() - 447 frame.x_hidden = head_x + screen->getBevelWidth() -
427 screen->getBorderWidth() - frame.width; 448 screen->getBorderWidth() - frame.width;
428 frame.y_hidden = frame.y; 449 frame.y_hidden = frame.y;
429 break; 450 break;
430 451
431 case BOTTOMLEFT: 452 case BOTTOMLEFT:
432 frame.x = 0; 453 frame.x = head_x;
433 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 454 frame.y = head_h - frame.height - screen->getBorderWidth2x();
434 if (screen->getSlitDirection() == VERTICAL) { 455 if (screen->getSlitDirection() == VERTICAL) {
435 frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() 456 frame.x_hidden = head_x + screen->getBevelWidth() -
436 - frame.width; 457 screen->getBorderWidth() - frame.width;
437 frame.y_hidden = frame.y; 458 frame.y_hidden = frame.y;
438 } else { 459 } else {
439 frame.x_hidden = 0; 460 frame.x_hidden = head_x;
440 frame.y_hidden = screen->getHeight() - 461 frame.y_hidden = head_y + head_h -
441 screen->getBevelWidth() - screen->getBorderWidth(); 462 screen->getBevelWidth() - screen->getBorderWidth();
442 } 463 }
443 break; 464 break;
444 465
445 case TOPCENTER: 466 case TOPCENTER:
446 frame.x = (screen->getWidth() - frame.width) / 2; 467 frame.x = head_x + ((head_w - frame.width) / 2);
447 frame.y = 0; 468 frame.y = head_y;
448 frame.x_hidden = frame.x; 469 frame.x_hidden = frame.x;
449 frame.y_hidden = screen->getBevelWidth() - 470 frame.y_hidden = head_y + screen->getBevelWidth() -
450 screen->getBorderWidth() - frame.height; 471 screen->getBorderWidth() - frame.height;
451 break; 472 break;
452 473
453 case BOTTOMCENTER: 474 case BOTTOMCENTER:
454 frame.x = (screen->getWidth() - frame.width) / 2; 475 frame.x = head_x + ((head_w - frame.width) / 2);
455 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 476 frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
456 frame.x_hidden = frame.x; 477 frame.x_hidden = frame.x;
457 frame.y_hidden = screen->getHeight() - 478 frame.y_hidden = head_y + head_h -
458 screen->getBevelWidth() - screen->getBorderWidth(); 479 screen->getBevelWidth() - screen->getBorderWidth();
459 break; 480 break;
460 481
461 case TOPRIGHT: 482 case TOPRIGHT:
462 frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); 483 frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
463 frame.y = 0; 484 frame.y = head_y;
464 if (screen->getSlitDirection() == VERTICAL) { 485 if (screen->getSlitDirection() == VERTICAL) {
465 frame.x_hidden = screen->getWidth() - 486 frame.x_hidden = head_x + head_w -
466 screen->getBevelWidth() - screen->getBorderWidth(); 487 screen->getBevelWidth() - screen->getBorderWidth();
467 frame.y_hidden = 0; 488 frame.y_hidden = head_y;
468 } else { 489 } else {
469 frame.x_hidden = frame.x; 490 frame.x_hidden = frame.x;
470 frame.y_hidden = screen->getBevelWidth() - 491 frame.y_hidden = head_y + screen->getBevelWidth() -
471 screen->getBorderWidth() - frame.height; 492 screen->getBorderWidth() - frame.height;
472 } 493 }
473 break; 494 break;
474 495
475 case CENTERRIGHT: 496 case CENTERRIGHT:
476 default: 497 default:
477 frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); 498 frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
478 frame.y = (screen->getHeight() - frame.height) / 2; 499 frame.y = head_y + ((head_h - frame.height) / 2);
479 frame.x_hidden = screen->getWidth() - 500 frame.x_hidden = head_x + head_w -
480 screen->getBevelWidth() - screen->getBorderWidth(); 501 screen->getBevelWidth() - screen->getBorderWidth();
481 frame.y_hidden = frame.y; 502 frame.y_hidden = frame.y;
482 break; 503 break;
483 504
484 case BOTTOMRIGHT: 505 case BOTTOMRIGHT:
485 frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); 506 frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
486 frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); 507 frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
487 if (screen->getSlitDirection() == VERTICAL) { 508 if (screen->getSlitDirection() == VERTICAL) {
488 frame.x_hidden = screen->getWidth() - 509 frame.x_hidden = head_x + head_w -
489 screen->getBevelWidth() - screen->getBorderWidth(); 510 screen->getBevelWidth() - screen->getBorderWidth();
490 frame.y_hidden = frame.y; 511 frame.y_hidden = frame.y;
491 } else { 512 } else {
492 frame.x_hidden = frame.x; 513 frame.x_hidden = frame.x;
493 frame.y_hidden = screen->getHeight() - 514 frame.y_hidden = head_y + head_h -
494 screen->getBevelWidth() - screen->getBorderWidth(); 515 screen->getBevelWidth() - screen->getBorderWidth();
495 } 516 }
496 break; 517 break;
@@ -654,6 +675,11 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
654 675
655 directionmenu = new Directionmenu(this); 676 directionmenu = new Directionmenu(this);
656 placementmenu = new Placementmenu(this); 677 placementmenu = new Placementmenu(this);
678#ifdef XINERAMA
679 if (slit->screen->hasXinerama()) { // only create if we need
680 headmenu = new Headmenu(this);
681 }
682#endif // XINERAMA
657 683
658 insert(i18n->getMessage( 684 insert(i18n->getMessage(
659#ifdef NLS 685#ifdef NLS
@@ -671,6 +697,14 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
671#endif // NLS 697#endif // NLS
672 "Placement"), 698 "Placement"),
673 placementmenu); 699 placementmenu);
700
701#ifdef XINERAMA
702 //TODO: NLS
703 if (slit->screen->hasXinerama()) {
704 insert(i18n->getMessage(0, 0, "Place on Head"), headmenu);
705 }
706#endif // XINERAMA
707
674 insert(i18n->getMessage( 708 insert(i18n->getMessage(
675#ifdef NLS 709#ifdef NLS
676 CommonSet, CommonAlwaysOnTop, 710 CommonSet, CommonAlwaysOnTop,
@@ -696,6 +730,11 @@ Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
696Slitmenu::~Slitmenu(void) { 730Slitmenu::~Slitmenu(void) {
697 delete directionmenu; 731 delete directionmenu;
698 delete placementmenu; 732 delete placementmenu;
733#ifdef XINERAMA
734 if (slit->screen->hasXinerama()) {
735 delete headmenu;
736 }
737#endif // XINERAMA
699} 738}
700 739
701 740
@@ -738,6 +777,11 @@ void Slitmenu::internal_hide(void) {
738void Slitmenu::reconfigure(void) { 777void Slitmenu::reconfigure(void) {
739 directionmenu->reconfigure(); 778 directionmenu->reconfigure();
740 placementmenu->reconfigure(); 779 placementmenu->reconfigure();
780#ifdef XINERAMA
781 if (slit->screen->hasXinerama()) {
782 headmenu->reconfigure();
783 }
784#endif // XINERAMA
741 785
742 Basemenu::reconfigure(); 786 Basemenu::reconfigure();
743} 787}
@@ -900,5 +944,39 @@ void Slitmenu::Placementmenu::itemSelected(int button, int index) {
900 } 944 }
901} 945}
902 946
947#ifdef XINERAMA
948
949Slitmenu::Headmenu::Headmenu(Slitmenu *sm)
950 : Basemenu(sm->slit->screen) {
951 slitmenu = sm;
952 I18n *i18n = I18n::instance();
953
954 setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS
955 setInternalMenu();
956
957 int numHeads = slitmenu->slit->screen->getNumHeads();
958 // fill menu with head entries
959 for (int i = 0; i < numHeads; i++) {
960 char headName[32];
961 sprintf(headName, "Head %i", i+1); //TODO: NLS
962 insert(i18n->getMessage(0, 0, headName), i);
963 }
964
965 update();
966}
967
968void Slitmenu::Headmenu::itemSelected(int button, int index) {
969 if (button == 1) {
970 BasemenuItem *item = find(index);
971 if (! item)
972 return;
973
974 slitmenu->slit->screen->saveSlitOnHead(item->function());
975 hide();
976 slitmenu->slit->reconfigure();
977 }
978}
979
980#endif // XINERAMA
903 981
904#endif // SLIT 982#endif // SLIT