diff options
author | fluxgen <fluxgen> | 2002-03-19 21:19:55 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-03-19 21:19:55 (GMT) |
commit | ccf9f5749e34ecc454124a6a3db8d817956399da (patch) | |
tree | 3e9459c246c573120da27b78c654f242fbfe5ffb /src | |
parent | 95aeda26271cce3061a46a3ca0b122bc13c8f5c8 (diff) | |
download | fluxbox_pavel-ccf9f5749e34ecc454124a6a3db8d817956399da.zip fluxbox_pavel-ccf9f5749e34ecc454124a6a3db8d817956399da.tar.bz2 |
we don't like to modify the arguments, const-correctness and other strange code in Xinerama
Diffstat (limited to 'src')
-rw-r--r-- | src/BaseDisplay.cc | 125 | ||||
-rw-r--r-- | src/BaseDisplay.hh | 27 |
2 files changed, 54 insertions, 98 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc index e540136..cb3ca28 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.9 2002/03/19 14:30:42 fluxgen Exp $ | 25 | // $Id: BaseDisplay.cc,v 1.10 2002/03/19 21:19:55 fluxgen Exp $ |
26 | 26 | ||
27 | // use GNU extensions | 27 | // use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -428,7 +428,7 @@ ScreenInfo::ScreenInfo(BaseDisplay *d, int num) { | |||
428 | // check if we have Xinerama extension enabled | 428 | // check if we have Xinerama extension enabled |
429 | if (XineramaIsActive(basedisplay->getXDisplay())) { | 429 | if (XineramaIsActive(basedisplay->getXDisplay())) { |
430 | m_hasXinerama = true; | 430 | m_hasXinerama = true; |
431 | xineramaLastHead = 0; // initialize this | 431 | xineramaLastHead = 0; |
432 | xineramaInfos = | 432 | xineramaInfos = |
433 | XineramaQueryScreens(basedisplay->getXDisplay(), &xineramaNumHeads); | 433 | XineramaQueryScreens(basedisplay->getXDisplay(), &xineramaNumHeads); |
434 | } else { | 434 | } else { |
@@ -455,7 +455,6 @@ ScreenInfo::~ScreenInfo(void) { | |||
455 | // activated it'll return head nr 0 | 455 | // activated it'll return head nr 0 |
456 | //----------------------------------------- | 456 | //----------------------------------------- |
457 | unsigned int ScreenInfo::getHead(int x, int y) { | 457 | unsigned int ScreenInfo::getHead(int x, int y) { |
458 | unsigned int head = 0; | ||
459 | 458 | ||
460 | // is Xinerama extensions enabled? | 459 | // is Xinerama extensions enabled? |
461 | if (hasXinerama()) { | 460 | if (hasXinerama()) { |
@@ -466,25 +465,20 @@ unsigned int ScreenInfo::getHead(int x, int y) { | |||
466 | (xineramaInfos[xineramaLastHead].y_org <= y) && | 465 | (xineramaInfos[xineramaLastHead].y_org <= y) && |
467 | ((xineramaInfos[xineramaLastHead].y_org + | 466 | ((xineramaInfos[xineramaLastHead].y_org + |
468 | xineramaInfos[xineramaLastHead].height) > y)) { | 467 | xineramaInfos[xineramaLastHead].height) > y)) { |
469 | head = xineramaLastHead; | 468 | return xineramaLastHead; |
470 | |||
471 | } else { | 469 | } else { |
472 | // go trough all the heads, and search | 470 | // go trough all the heads, and search |
473 | for (int i = 0; (signed) head < xineramaNumHeads; i++) { | 471 | for (int i = 0; (signed) i < xineramaNumHeads; i++) { |
474 | if ((xineramaInfos[i].x_org <= x) && | 472 | if (xineramaInfos[i].x_org <= x && |
475 | ((xineramaInfos[i].x_org + xineramaInfos[i].width) > x) && | 473 | xineramaInfos[i].x_org + xineramaInfos[i].width) > x && |
476 | (xineramaInfos[i].y_org <= y) && | 474 | xineramaInfos[i].y_org <= y && |
477 | ((xineramaInfos[i].y_org + xineramaInfos[i].height) > y)) { | 475 | xineramaInfos[i].y_org + xineramaInfos[i].height) > y) |
478 | // TODO: actually set this to last head? | 476 | return (xineramaLastHead = i); |
479 | head = xineramaLastHead = i; | ||
480 | |||
481 | break; // we don't wanna spend CPU searching what we | ||
482 | } // allready have found, do we? | ||
483 | } | 477 | } |
484 | } | 478 | } |
485 | } | 479 | } |
486 | 480 | ||
487 | return head; | 481 | return 0; |
488 | } | 482 | } |
489 | 483 | ||
490 | //------------- getCurrHead -------------- | 484 | //------------- getCurrHead -------------- |
@@ -492,52 +486,27 @@ unsigned int ScreenInfo::getHead(int x, int y) { | |||
492 | // currently is on, if it isn't found | 486 | // currently is on, if it isn't found |
493 | // the first one is returned | 487 | // the first one is returned |
494 | //---------------------------------------- | 488 | //---------------------------------------- |
495 | unsigned int ScreenInfo::getCurrHead(void) { | 489 | unsigned int ScreenInfo::getCurrHead(void) const { |
496 | unsigned int head = 0; | ||
497 | 490 | ||
498 | // is Xinerama extensions enabled? | 491 | // is Xinerama extensions enabled? |
499 | if (hasXinerama()) { | 492 | if (hasXinerama()) { |
500 | int pX, pY, wX, wY; | 493 | int x, y, wX, wY; |
501 | unsigned int mask; | 494 | unsigned int mask; |
502 | Window rRoot, rChild; | 495 | Window rRoot, rChild; |
503 | 496 | // get pointer cordinates | |
504 | // check if last head is still active | 497 | if ( (XQueryPointer(basedisplay->getXDisplay(), root_window, |
505 | if ((xineramaInfos[xineramaLastHead].x_org <= pX) && | 498 | &rRoot, &rChild, &x, &y, &wX, &wY, &mask)) != 0 ) { |
506 | ((xineramaInfos[xineramaLastHead].x_org + | 499 | return getHead(x, y); |
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 | } | 500 | } |
531 | } | 501 | } |
532 | 502 | ||
533 | return head; | 503 | return 0; |
534 | } | 504 | } |
535 | 505 | ||
536 | //----------- getHeadWidth ------------ | 506 | //----------- getHeadWidth ------------ |
537 | // Returns the width of head nr head | 507 | // Returns the width of head |
538 | //------------------------------------- | 508 | //------------------------------------- |
539 | unsigned int ScreenInfo::getHeadWidth(unsigned int head) { | 509 | unsigned int ScreenInfo::getHeadWidth(unsigned int head) { |
540 | unsigned int width; | ||
541 | 510 | ||
542 | if (hasXinerama()) { | 511 | if (hasXinerama()) { |
543 | if ((signed) head >= xineramaNumHeads) { | 512 | if ((signed) head >= xineramaNumHeads) { |
@@ -545,23 +514,19 @@ unsigned int ScreenInfo::getHeadWidth(unsigned int head) { | |||
545 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | 514 | cerr << __FILE__ << ":" <<__LINE__ << ": " << |
546 | "Head: " << head << " doesn't exist!" << endl; | 515 | "Head: " << head << " doesn't exist!" << endl; |
547 | #endif // DEBUG | 516 | #endif // DEBUG |
548 | 517 | return xineramaInfos[xineramaNumHeads - 1].width; | |
549 | head = xineramaNumHeads - 1; | 518 | } else |
550 | } | 519 | return xineramaInfos[head].width; |
551 | |||
552 | width = xineramaInfos[head].width; | ||
553 | } else { | ||
554 | width = getWidth(); | ||
555 | } | 520 | } |
521 | |||
522 | return getWidth(); | ||
556 | 523 | ||
557 | return width; | ||
558 | } | 524 | } |
559 | 525 | ||
560 | //----------- getHeadHeight ------------ | 526 | //----------- getHeadHeight ------------ |
561 | // Returns the heigt of head nr head | 527 | // Returns the heigt of head |
562 | //-------------------------------------- | 528 | //-------------------------------------- |
563 | unsigned int ScreenInfo::getHeadHeight(unsigned int head) { | 529 | unsigned int ScreenInfo::getHeadHeight(unsigned int head) const { |
564 | unsigned int height; | ||
565 | 530 | ||
566 | if (hasXinerama()) { | 531 | if (hasXinerama()) { |
567 | if ((signed) head >= xineramaNumHeads) { | 532 | if ((signed) head >= xineramaNumHeads) { |
@@ -569,59 +534,49 @@ unsigned int ScreenInfo::getHeadHeight(unsigned int head) { | |||
569 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | 534 | cerr << __FILE__ << ":" <<__LINE__ << ": " << |
570 | "Head: " << head << " doesn't exist!" << endl; | 535 | "Head: " << head << " doesn't exist!" << endl; |
571 | #endif // DEBUG | 536 | #endif // DEBUG |
572 | 537 | return xineramaInfos[xineramaNumHeads - 1].height; | |
573 | head = xineramaNumHeads - 1; | 538 | } else |
574 | } | 539 | return xineramaInfos[head].height; |
575 | |||
576 | height = xineramaInfos[head].height; | ||
577 | } else { | ||
578 | height = getHeight(); | ||
579 | } | 540 | } |
580 | 541 | ||
581 | return height; | 542 | return getHeight(); |
582 | } | 543 | } |
583 | 544 | ||
584 | 545 | ||
585 | //----------- getHeadX ----------------- | 546 | //----------- getHeadX ----------------- |
586 | // Returns the X start of head nr head | 547 | // Returns the X start of head nr head |
587 | //-------------------------------------- | 548 | //-------------------------------------- |
588 | int ScreenInfo::getHeadX(unsigned int head) { | 549 | int ScreenInfo::getHeadX(unsigned int head) const { |
589 | int x = 0; | ||
590 | |||
591 | if (hasXinerama()) { | 550 | if (hasXinerama()) { |
592 | if ((signed) head >= xineramaNumHeads) { | 551 | if ((signed) head >= xineramaNumHeads) { |
593 | #ifdef DEBUG | 552 | #ifdef DEBUG |
594 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | 553 | cerr << __FILE__ << ":" <<__LINE__ << ": " << |
595 | "Head: " << head << " doesn't exist!" << endl; | 554 | "Head: " << head << " doesn't exist!" << endl; |
596 | #endif // DEBUG | 555 | #endif // DEBUG |
597 | 556 | return xineramaInfos[head = xineramaNumHeads - 1].x_org; | |
598 | head = xineramaNumHeads - 1; | 557 | } else |
599 | } | 558 | return xineramaInfos[head].x_org; |
600 | x = xineramaInfos[head].x_org; | ||
601 | } | 559 | } |
602 | 560 | ||
603 | return x; | 561 | return 0; |
604 | } | 562 | } |
605 | 563 | ||
606 | //----------- getHeadY ----------------- | 564 | //----------- getHeadY ----------------- |
607 | // Returns the Y start of head nr head | 565 | // Returns the Y start of head |
608 | //-------------------------------------- | 566 | //-------------------------------------- |
609 | int ScreenInfo::getHeadY(unsigned int head) { | 567 | int ScreenInfo::getHeadY(unsigned int head) const { |
610 | int y = 0; | ||
611 | |||
612 | if (hasXinerama()) { | 568 | if (hasXinerama()) { |
613 | if ((signed) head >= xineramaNumHeads) { | 569 | if ((signed) head >= xineramaNumHeads) { |
614 | #ifdef DEBUG | 570 | #ifdef DEBUG |
615 | cerr << __FILE__ << ":" <<__LINE__ << ": " << | 571 | cerr << __FILE__ << ":" <<__LINE__ << ": " << |
616 | "Head: " << head << " doesn't exist!" << endl; | 572 | "Head: " << head << " doesn't exist!" << endl; |
617 | #endif // DEBUG | 573 | #endif // DEBUG |
618 | 574 | return xineramaInfos[xineramaNumHeads - 1].y_org; | |
619 | head = xineramaNumHeads - 1; | 575 | } else |
620 | } | 576 | return xineramaInfos[head].y_org; |
621 | y = xineramaInfos[head].y_org; | ||
622 | } | 577 | } |
623 | 578 | ||
624 | return y; | 579 | return 0; |
625 | } | 580 | } |
626 | 581 | ||
627 | #endif // XINERAMA | 582 | #endif // XINERAMA |
diff --git a/src/BaseDisplay.hh b/src/BaseDisplay.hh index 3cf8d40..d7075c1 100644 --- a/src/BaseDisplay.hh +++ b/src/BaseDisplay.hh | |||
@@ -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.hh,v 1.16 2002/03/19 14:30:42 fluxgen Exp $ | 25 | // $Id: BaseDisplay.hh,v 1.17 2002/03/19 21:19:55 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef BASEDISPLAY_HH | 27 | #ifndef BASEDISPLAY_HH |
28 | #define BASEDISPLAY_HH | 28 | #define BASEDISPLAY_HH |
@@ -32,9 +32,9 @@ | |||
32 | #include <X11/Xlib.h> | 32 | #include <X11/Xlib.h> |
33 | 33 | ||
34 | #ifdef XINERAMA | 34 | #ifdef XINERAMA |
35 | extern "C" { | 35 | extern "C" { |
36 | #include <X11/extensions/Xinerama.h> | 36 | #include <X11/extensions/Xinerama.h> |
37 | } | 37 | } |
38 | #endif // XINERAMA | 38 | #endif // XINERAMA |
39 | 39 | ||
40 | #include <list> | 40 | #include <list> |
@@ -166,12 +166,12 @@ public: | |||
166 | inline const unsigned int getHeight(void) const { return height; } | 166 | inline const unsigned int getHeight(void) const { return height; } |
167 | 167 | ||
168 | #ifdef XINERAMA | 168 | #ifdef XINERAMA |
169 | inline bool hasXinerama(void) { return m_hasXinerama; } | 169 | inline bool hasXinerama(void) const { return m_hasXinerama; } |
170 | inline int getNumHeads(void) { return xineramaNumHeads; } | 170 | inline int getNumHeads(void) const { return xineramaNumHeads; } |
171 | unsigned int getHead(int x, int y); | 171 | unsigned int getHead(int x, int y) const; |
172 | unsigned int getCurrHead(void); | 172 | unsigned int getCurrHead(void) const; |
173 | unsigned int getHeadWidth(unsigned int head); | 173 | unsigned int getHeadWidth(unsigned int head) const; |
174 | unsigned int getHeadHeight(unsigned int head); | 174 | unsigned int getHeadHeight(unsigned int head) const; |
175 | int getHeadX(unsigned int head); | 175 | int getHeadX(unsigned int head); |
176 | int getHeadY(unsigned int head); | 176 | int getHeadY(unsigned int head); |
177 | #endif // XINERAMA | 177 | #endif // XINERAMA |
@@ -184,13 +184,14 @@ private: | |||
184 | 184 | ||
185 | int depth, screen_number; | 185 | int depth, screen_number; |
186 | unsigned int width, height; | 186 | unsigned int width, height; |
187 | |||
188 | }; | ||
189 | |||
190 | #ifdef XINERAMA | 187 | #ifdef XINERAMA |
191 | bool m_hasXinerama; | 188 | bool m_hasXinerama; |
192 | int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead; | 189 | int xineramaMajor, xineramaMinor, xineramaNumHeads, xineramaLastHead; |
193 | XineramaScreenInfo *xineramaInfos; | 190 | XineramaScreenInfo *xineramaInfos; |
194 | #endif // XINERAMA | 191 | #endif // XINERAMA |
195 | 192 | ||
193 | }; | ||
194 | |||
195 | |||
196 | |||
196 | #endif // BASEDISPLAY_HH | 197 | #endif // BASEDISPLAY_HH |