diff options
author | fluxgen <fluxgen> | 2002-03-19 14:30:43 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-03-19 14:30:43 (GMT) |
commit | 95aeda26271cce3061a46a3ca0b122bc13c8f5c8 (patch) | |
tree | aaa01d20e77a2445a20a0522d86296b981049b8e /src/BaseDisplay.cc | |
parent | 1871169b06d8b9909ff26b761d24a40a65ef18f9 (diff) | |
download | fluxbox-95aeda26271cce3061a46a3ca0b122bc13c8f5c8.zip fluxbox-95aeda26271cce3061a46a3ca0b122bc13c8f5c8.tar.bz2 |
Xinerama support
Diffstat (limited to 'src/BaseDisplay.cc')
-rw-r--r-- | src/BaseDisplay.cc | 203 |
1 files changed, 202 insertions, 1 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc index 6bcbd5e..e540136 100644 --- a/src/BaseDisplay.cc +++ b/src/BaseDisplay.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // 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 |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: BaseDisplay.cc,v 1.8 2002/03/18 23:41:08 fluxgen Exp $ | 25 | // $Id: BaseDisplay.cc,v 1.9 2002/03/19 14:30:42 fluxgen Exp $ |
26 | 26 | ||
27 | // use GNU extensions | 27 | // use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -423,4 +423,205 @@ ScreenInfo::ScreenInfo(BaseDisplay *d, int num) { | |||
423 | visual = DefaultVisual(basedisplay->getXDisplay(), screen_number); | 423 | visual = DefaultVisual(basedisplay->getXDisplay(), screen_number); |
424 | colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number); | 424 | colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number); |
425 | } | 425 | } |
426 | |||
427 | #ifdef XINERAMA | ||
428 | // check if we have Xinerama extension enabled | ||
429 | if (XineramaIsActive(basedisplay->getXDisplay())) { | ||
430 | m_hasXinerama = true; | ||
431 | xineramaLastHead = 0; // initialize this | ||
432 | xineramaInfos = | ||
433 | XineramaQueryScreens(basedisplay->getXDisplay(), &xineramaNumHeads); | ||
434 | } else { | ||
435 | m_hasXinerama = false; | ||
436 | xineramaInfos = 0; // make sure we don't point anywhere we shouldn't | ||
437 | } | ||
438 | #endif // XINERAMA | ||
426 | } | 439 | } |
440 | |||
441 | ScreenInfo::~ScreenInfo(void) { | ||
442 | #ifdef XINERAMA | ||
443 | if (m_hasXinerama) { // only free if we first had it | ||
444 | XFree(xineramaInfos); | ||
445 | xineramaInfos = 0; | ||
446 | } | ||
447 | #endif // XINERAMA | ||
448 | } | ||
449 | |||
450 | #ifdef XINERAMA | ||
451 | |||
452 | //---------------- getHead --------------- | ||
453 | // Searches for the head at the coordinates | ||
454 | // x,y. If it fails or Xinerama isn't | ||
455 | // activated it'll return head nr 0 | ||
456 | //----------------------------------------- | ||
457 | unsigned int ScreenInfo::getHead(int x, int y) { | ||
458 | unsigned int head = 0; | ||
459 | |||
460 | // is Xinerama extensions enabled? | ||
461 | if (hasXinerama()) { | ||
462 | // check if last head is still active | ||
463 | if ((xineramaInfos[xineramaLastHead].x_org <= x) && | ||
464 | ((xineramaInfos[xineramaLastHead].x_org + | ||
465 | xineramaInfos[xineramaLastHead].width) > x) && | ||
466 | (xineramaInfos[xineramaLastHead].y_org <= y) && | ||
467 | ((xineramaInfos[xineramaLastHead].y_org + | ||
468 | xineramaInfos[xineramaLastHead].height) > y)) { | ||
469 | head = xineramaLastHead; | ||
470 | |||
471 | } else { | ||
472 | // go trough all the heads, and search | ||
473 | for (int i = 0; (signed) head < xineramaNumHeads; i++) { | ||
474 | if ((xineramaInfos[i].x_org <= x) && | ||
475 | ((xineramaInfos[i].x_org + xineramaInfos[i].width) > x) && | ||
476 | (xineramaInfos[i].y_org <= y) && | ||
477 | ((xineramaInfos[i].y_org + xineramaInfos[i].height) > y)) { | ||
478 | // TODO: actually set this to last head? | ||
479 | head = xineramaLastHead = i; | ||
480 | |||
481 | break; // we don't wanna spend CPU searching what we | ||
482 | } // allready have found, do we? | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | |||
487 | return head; | ||
488 | } | ||
489 | |||
490 | //------------- getCurrHead -------------- | ||
491 | // Searches for the head that the pointer | ||
492 | // currently is on, if it isn't found | ||
493 | // the first one is returned | ||
494 | //---------------------------------------- | ||
495 | unsigned int ScreenInfo::getCurrHead(void) { | ||
496 | unsigned int head = 0; | ||
497 | |||
498 | // is Xinerama extensions enabled? | ||
499 | if (hasXinerama()) { | ||
500 | int pX, pY, wX, wY; | ||
501 | unsigned int mask; | ||
502 | Window rRoot, rChild; | ||
503 | |||
504 | // check if last head is still active | ||
505 | if ((xineramaInfos[xineramaLastHead].x_org <= pX) && | ||
506 | ((xineramaInfos[xineramaLastHead].x_org + | ||
507 | xineramaInfos[xineramaLastHead].width) > pX) && | ||
508 | (xineramaInfos[xineramaLastHead].y_org <= pY) && | ||
509 | ((xineramaInfos[xineramaLastHead].y_org + | ||
510 | xineramaInfos[xineramaLastHead].height) > pY)) { | ||
511 | head = xineramaLastHead; | ||
512 | |||
513 | } else { | ||
514 | // get pointer cordinates , we need to know were we are! | ||
515 | if ( (XQueryPointer(basedisplay->getXDisplay(), root_window, | ||
516 | &rRoot, &rChild, &pX, &pY, &wX, &wY, &mask)) != 0 ) { | ||
517 | |||
518 | // go trough all the heads, and search | ||
519 | for (int i = 0; i < xineramaNumHeads; i++) { | ||
520 | if ((xineramaInfos[i].x_org <= pX) && | ||
521 | ((xineramaInfos[i].x_org + xineramaInfos[i].width) > pX) && | ||
522 | (xineramaInfos[i].y_org <= pY) && | ||
523 | ((xineramaInfos[i].y_org + xineramaInfos[i].height) > pY)) { | ||
524 | |||
525 | head = xineramaLastHead = i; | ||
526 | break; // we don't wanna spend CPU searching what we | ||
527 | } // allready have found, do we? | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | |||
533 | return head; | ||
534 | } | ||
535 | |||
536 | //----------- getHeadWidth ------------ | ||
537 | // Returns the width of head nr head | ||
538 | //------------------------------------- | ||
539 | unsigned int ScreenInfo::getHeadWidth(unsigned int head) { | ||
540 | unsigned int width; | ||
541 | |||
542 | if (hasXinerama()) { | ||
543 | if ((signed) head >= xineramaNumHeads) { | ||
544 | #ifdef DEBUG | ||
545 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
546 | "Head: " << head << " doesn't exist!" << endl; | ||
547 | #endif // DEBUG | ||
548 | |||
549 | head = xineramaNumHeads - 1; | ||
550 | } | ||
551 | |||
552 | width = xineramaInfos[head].width; | ||
553 | } else { | ||
554 | width = getWidth(); | ||
555 | } | ||
556 | |||
557 | return width; | ||
558 | } | ||
559 | |||
560 | //----------- getHeadHeight ------------ | ||
561 | // Returns the heigt of head nr head | ||
562 | //-------------------------------------- | ||
563 | unsigned int ScreenInfo::getHeadHeight(unsigned int head) { | ||
564 | unsigned int height; | ||
565 | |||
566 | if (hasXinerama()) { | ||
567 | if ((signed) head >= xineramaNumHeads) { | ||
568 | #ifdef DEBUG | ||
569 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
570 | "Head: " << head << " doesn't exist!" << endl; | ||
571 | #endif // DEBUG | ||
572 | |||
573 | head = xineramaNumHeads - 1; | ||
574 | } | ||
575 | |||
576 | height = xineramaInfos[head].height; | ||
577 | } else { | ||
578 | height = getHeight(); | ||
579 | } | ||
580 | |||
581 | return height; | ||
582 | } | ||
583 | |||
584 | |||
585 | //----------- getHeadX ----------------- | ||
586 | // Returns the X start of head nr head | ||
587 | //-------------------------------------- | ||
588 | int ScreenInfo::getHeadX(unsigned int head) { | ||
589 | int x = 0; | ||
590 | |||
591 | if (hasXinerama()) { | ||
592 | if ((signed) head >= xineramaNumHeads) { | ||
593 | #ifdef DEBUG | ||
594 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
595 | "Head: " << head << " doesn't exist!" << endl; | ||
596 | #endif // DEBUG | ||
597 | |||
598 | head = xineramaNumHeads - 1; | ||
599 | } | ||
600 | x = xineramaInfos[head].x_org; | ||
601 | } | ||
602 | |||
603 | return x; | ||
604 | } | ||
605 | |||
606 | //----------- getHeadY ----------------- | ||
607 | // Returns the Y start of head nr head | ||
608 | //-------------------------------------- | ||
609 | int ScreenInfo::getHeadY(unsigned int head) { | ||
610 | int y = 0; | ||
611 | |||
612 | if (hasXinerama()) { | ||
613 | if ((signed) head >= xineramaNumHeads) { | ||
614 | #ifdef DEBUG | ||
615 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | ||
616 | "Head: " << head << " doesn't exist!" << endl; | ||
617 | #endif // DEBUG | ||
618 | |||
619 | head = xineramaNumHeads - 1; | ||
620 | } | ||
621 | y = xineramaInfos[head].y_org; | ||
622 | } | ||
623 | |||
624 | return y; | ||
625 | } | ||
626 | |||
627 | #endif // XINERAMA | ||