diff options
author | rathnor <rathnor> | 2003-05-19 15:32:47 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-05-19 15:32:47 (GMT) |
commit | b68b1c7623be09100bb1e6a0d3923d6e1c86a91a (patch) | |
tree | ee8c1f69ab45b29943565384c877df15f3a9634d /src/Screen.cc | |
parent | 3b2afa5a305f0106baef32068066b7d41eeab777 (diff) | |
download | fluxbox_pavel-b68b1c7623be09100bb1e6a0d3923d6e1c86a91a.zip fluxbox_pavel-b68b1c7623be09100bb1e6a0d3923d6e1c86a91a.tar.bz2 |
xinerama updates
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 90 |
1 files changed, 68 insertions, 22 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index aaa2209..5c61289 100644 --- a/src/Screen.cc +++ b/src/Screen.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: Screen.cc,v 1.172 2003/05/19 14:26:29 rathnor Exp $ | 25 | // $Id: Screen.cc,v 1.173 2003/05/19 15:32:46 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -53,6 +53,7 @@ | |||
53 | #include "WinClient.hh" | 53 | #include "WinClient.hh" |
54 | #include "Subject.hh" | 54 | #include "Subject.hh" |
55 | #include "FbWinFrame.hh" | 55 | #include "FbWinFrame.hh" |
56 | #include "FbWindow.hh" | ||
56 | 57 | ||
57 | //use GNU extensions | 58 | //use GNU extensions |
58 | #ifndef _GNU_SOURCE | 59 | #ifndef _GNU_SOURCE |
@@ -523,9 +524,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
523 | 524 | ||
524 | Display *disp = FbTk::App::instance()->display(); | 525 | Display *disp = FbTk::App::instance()->display(); |
525 | 526 | ||
526 | #ifdef XINERAMA | 527 | initXinerama(); |
527 | initXinerama(disp); | ||
528 | #endif // XINERAMA | ||
529 | 528 | ||
530 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | | 529 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | |
531 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | | 530 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | |
@@ -815,23 +814,47 @@ Pixmap BScreen::rootPixmap() const { | |||
815 | 814 | ||
816 | } | 815 | } |
817 | 816 | ||
818 | /// TODO | 817 | unsigned int BScreen::maxLeft(FbTk::FbWindow &win) const { |
819 | unsigned int BScreen::maxLeft() const { | 818 | if (hasXinerama()) { |
820 | return 0; | 819 | int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); |
820 | // we MUST use a head, we use the center of the window, or if that | ||
821 | // isn't in a head, then the mouse's head | ||
822 | if (head == 0) head = getCurrHead(); | ||
823 | return getHeadX(head); | ||
824 | } else | ||
825 | return 0; | ||
821 | } | 826 | } |
822 | 827 | ||
823 | ///!! TODO | 828 | unsigned int BScreen::maxRight(FbTk::FbWindow &win) const { |
824 | unsigned int BScreen::maxRight() const { | 829 | if (hasXinerama()) { |
825 | return width(); | 830 | int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); |
831 | // we MUST use a head, we use the center of the window, or if that | ||
832 | // isn't in a head, then the mouse's head | ||
833 | if (head == 0) head = getCurrHead(); | ||
834 | return getHeadX(head) + getHeadWidth(head); | ||
835 | } else | ||
836 | return width(); | ||
826 | } | 837 | } |
827 | 838 | ||
828 | ///!! TODO | 839 | unsigned int BScreen::maxTop(FbTk::FbWindow &win) const { |
829 | unsigned int BScreen::maxTop() const { | 840 | if (hasXinerama()) { |
830 | return 0; | 841 | int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); |
842 | // we MUST use a head, we use the center of the window, or if that | ||
843 | // isn't in a head, then the mouse's head | ||
844 | if (head == 0) head = getCurrHead(); | ||
845 | return getHeadY(head); | ||
846 | } else | ||
847 | return 0; | ||
831 | } | 848 | } |
832 | ///!! TODO | 849 | unsigned int BScreen::maxBottom(FbTk::FbWindow &win) const { |
833 | unsigned int BScreen::maxBottom() const { | 850 | if (hasXinerama()) { |
834 | return height(); | 851 | int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2); |
852 | // we MUST use a head, we use the center of the window, or if that | ||
853 | // isn't in a head, then the mouse's head | ||
854 | if (head == 0) head = getCurrHead(); | ||
855 | return getHeadY(head) + getHeadHeight(head); | ||
856 | } else | ||
857 | return height(); | ||
835 | } | 858 | } |
836 | 859 | ||
837 | void BScreen::reconfigure() { | 860 | void BScreen::reconfigure() { |
@@ -2542,9 +2565,11 @@ void BScreen::updateSize() { | |||
2542 | 2565 | ||
2543 | } | 2566 | } |
2544 | 2567 | ||
2568 | |||
2569 | void BScreen::initXinerama() { | ||
2545 | #ifdef XINERAMA | 2570 | #ifdef XINERAMA |
2571 | Display *display = FbTk::App::instance()->display(); | ||
2546 | 2572 | ||
2547 | void BScreen::initXinerama(Display *display) { | ||
2548 | if (!XineramaIsActive(display)) { | 2573 | if (!XineramaIsActive(display)) { |
2549 | m_xinerama_avail = false; | 2574 | m_xinerama_avail = false; |
2550 | m_xinerama_headinfo = 0; | 2575 | m_xinerama_headinfo = 0; |
@@ -2563,11 +2588,16 @@ void BScreen::initXinerama(Display *display) { | |||
2563 | m_xinerama_headinfo[i].width = screen_info[i].width; | 2588 | m_xinerama_headinfo[i].width = screen_info[i].width; |
2564 | m_xinerama_headinfo[i].height = screen_info[i].height; | 2589 | m_xinerama_headinfo[i].height = screen_info[i].height; |
2565 | } | 2590 | } |
2591 | #else // XINERAMA | ||
2592 | m_xinerama_avail = false; | ||
2593 | m_xinerama_num_heads = 0; | ||
2594 | #endif // XINERAMA | ||
2566 | 2595 | ||
2567 | } | 2596 | } |
2568 | 2597 | ||
2569 | int BScreen::getHead(int x, int y) const { | 2598 | int BScreen::getHead(int x, int y) const { |
2570 | if (!hasXinerama()) return 0; | 2599 | if (!hasXinerama()) return 0; |
2600 | #ifdef XINERAMA | ||
2571 | 2601 | ||
2572 | for (int i=0; i < m_xinerama_num_heads; i++) { | 2602 | for (int i=0; i < m_xinerama_num_heads; i++) { |
2573 | if (x >= m_xinerama_headinfo[i].x && | 2603 | if (x >= m_xinerama_headinfo[i].x && |
@@ -2578,13 +2608,15 @@ int BScreen::getHead(int x, int y) const { | |||
2578 | } | 2608 | } |
2579 | } | 2609 | } |
2580 | 2610 | ||
2611 | #endif // XINERAMA | ||
2581 | return 0; | 2612 | return 0; |
2582 | } | 2613 | } |
2583 | 2614 | ||
2584 | int BScreen::getCurrHead() const { | 2615 | int BScreen::getCurrHead() const { |
2585 | if (!hasXinerama()) return 0; | 2616 | if (!hasXinerama()) return 0; |
2586 | int root_x, root_y, ignore_i; | 2617 | int root_x = 0, root_y = 0; |
2587 | 2618 | #ifdef XINERAMA | |
2619 | int ignore_i; | ||
2588 | unsigned int ignore_ui; | 2620 | unsigned int ignore_ui; |
2589 | 2621 | ||
2590 | Window ignore_w; | 2622 | Window ignore_w; |
@@ -2593,28 +2625,44 @@ int BScreen::getCurrHead() const { | |||
2593 | rootWindow().window(), &ignore_w, | 2625 | rootWindow().window(), &ignore_w, |
2594 | &ignore_w, &root_x, &root_y, | 2626 | &ignore_w, &root_x, &root_y, |
2595 | &ignore_i, &ignore_i, &ignore_ui); | 2627 | &ignore_i, &ignore_i, &ignore_ui); |
2628 | #endif // XINERAMA | ||
2596 | return getHead(root_x, root_y); | 2629 | return getHead(root_x, root_y); |
2597 | |||
2598 | } | 2630 | } |
2599 | 2631 | ||
2600 | int BScreen::getHeadX(int head) const { | 2632 | int BScreen::getHeadX(int head) const { |
2633 | #ifdef XINERAMA | ||
2601 | if (head == 0 || head > m_xinerama_num_heads) return 0; | 2634 | if (head == 0 || head > m_xinerama_num_heads) return 0; |
2602 | return m_xinerama_headinfo[head-1].x; | 2635 | return m_xinerama_headinfo[head-1].x; |
2636 | #else | ||
2637 | return 0; | ||
2638 | #endif // XINERAMA | ||
2603 | } | 2639 | } |
2604 | 2640 | ||
2605 | int BScreen::getHeadY(int head) const { | 2641 | int BScreen::getHeadY(int head) const { |
2642 | #ifdef XINERAMA | ||
2606 | if (head == 0 || head > m_xinerama_num_heads) return 0; | 2643 | if (head == 0 || head > m_xinerama_num_heads) return 0; |
2607 | return m_xinerama_headinfo[head-1].y; | 2644 | return m_xinerama_headinfo[head-1].y; |
2645 | #else | ||
2646 | return 0; | ||
2647 | #endif // XINERAMA | ||
2608 | } | 2648 | } |
2609 | 2649 | ||
2610 | int BScreen::getHeadWidth(int head) const { | 2650 | int BScreen::getHeadWidth(int head) const { |
2651 | #ifdef XINERAMA | ||
2611 | if (head == 0 || head > m_xinerama_num_heads) return width(); | 2652 | if (head == 0 || head > m_xinerama_num_heads) return width(); |
2612 | return m_xinerama_headinfo[head-1].width; | 2653 | return m_xinerama_headinfo[head-1].width; |
2654 | #else | ||
2655 | return width(); | ||
2656 | #endif // XINERAMA | ||
2613 | } | 2657 | } |
2614 | 2658 | ||
2615 | int BScreen::getHeadHeight(int head) const { | 2659 | int BScreen::getHeadHeight(int head) const { |
2660 | #ifdef XINERAMA | ||
2616 | if (head == 0 || head > m_xinerama_num_heads) return height(); | 2661 | if (head == 0 || head > m_xinerama_num_heads) return height(); |
2617 | return m_xinerama_headinfo[head-1].height; | 2662 | return m_xinerama_headinfo[head-1].height; |
2663 | #else | ||
2664 | return height(); | ||
2665 | #endif // XINERAMA | ||
2618 | } | 2666 | } |
2619 | 2667 | ||
2620 | template <> | 2668 | template <> |
@@ -2638,5 +2686,3 @@ void BScreen::setOnHead<Slit>(Slit &slit, int head) { | |||
2638 | saveSlitOnHead(head); | 2686 | saveSlitOnHead(head); |
2639 | slit.reconfigure(); | 2687 | slit.reconfigure(); |
2640 | } | 2688 | } |
2641 | |||
2642 | #endif // XINERAMA | ||