diff options
author | rathnor <rathnor> | 2003-05-19 14:26:30 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-05-19 14:26:30 (GMT) |
commit | cc9c7960c1c5413002c3a6c456650e59ee1ff501 (patch) | |
tree | db11494b3cbd61619229328b722f2c47c6b0a916 /src/Screen.cc | |
parent | 68e9677bbb9ebe8f7c1a5edea25f236c09ed3460 (diff) | |
download | fluxbox_pavel-cc9c7960c1c5413002c3a6c456650e59ee1ff501.zip fluxbox_pavel-cc9c7960c1c5413002c3a6c456650e59ee1ff501.tar.bz2 |
add back some xinerama support (toolbar, slit (+menu), screen)
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 132 |
1 files changed, 124 insertions, 8 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index d3eb39e..aaa2209 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.171 2003/05/18 22:01:14 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.172 2003/05/19 14:26:29 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -114,6 +114,12 @@ | |||
114 | #include <X11/Xatom.h> | 114 | #include <X11/Xatom.h> |
115 | #include <X11/keysym.h> | 115 | #include <X11/keysym.h> |
116 | 116 | ||
117 | #ifdef XINERAMA | ||
118 | extern "C" { | ||
119 | #include <X11/extensions/Xinerama.h> | ||
120 | } | ||
121 | #endif // XINERAMA | ||
122 | |||
117 | #include <iostream> | 123 | #include <iostream> |
118 | #include <memory> | 124 | #include <memory> |
119 | #include <algorithm> | 125 | #include <algorithm> |
@@ -480,13 +486,14 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm, | |||
480 | toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), | 486 | toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), |
481 | toolbar_placement(rm, Toolbar::BOTTOMCENTER, | 487 | toolbar_placement(rm, Toolbar::BOTTOMCENTER, |
482 | scrname+".toolbar.placement", altscrname+".Toolbar.Placement"), | 488 | scrname+".toolbar.placement", altscrname+".Toolbar.Placement"), |
483 | slit_auto_hide(rm, false, | 489 | slit_auto_hide(rm, false, |
484 | scrname+".slit.autoHide", altscrname+".Slit.AutoHide"), | 490 | scrname+".slit.autoHide", altscrname+".Slit.AutoHide"), |
485 | slit_placement(rm, Slit::BOTTOMRIGHT, | 491 | slit_placement(rm, Slit::BOTTOMRIGHT, |
486 | scrname+".slit.placement", altscrname+".Slit.Placement"), | 492 | scrname+".slit.placement", altscrname+".Slit.Placement"), |
487 | slit_direction(rm, Slit::VERTICAL, | 493 | slit_direction(rm, Slit::VERTICAL, |
488 | scrname+".slit.direction", altscrname+".Slit.Direction"), | 494 | scrname+".slit.direction", altscrname+".Slit.Direction"), |
489 | slit_alpha(rm, 255, scrname+".slit.alpha", altscrname+".Slit.Alpha") { | 495 | slit_alpha(rm, 255, scrname+".slit.alpha", altscrname+".Slit.Alpha"), |
496 | slit_on_head(rm, 0, scrname+".slit.onhead", altscrname+".Slit.onHead") { | ||
490 | 497 | ||
491 | }; | 498 | }; |
492 | 499 | ||
@@ -516,6 +523,10 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
516 | 523 | ||
517 | Display *disp = FbTk::App::instance()->display(); | 524 | Display *disp = FbTk::App::instance()->display(); |
518 | 525 | ||
526 | #ifdef XINERAMA | ||
527 | initXinerama(disp); | ||
528 | #endif // XINERAMA | ||
529 | |||
519 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | | 530 | event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | |
520 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | | 531 | SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | |
521 | ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; | 532 | ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask; |
@@ -761,6 +772,12 @@ BScreen::~BScreen() { | |||
761 | } | 772 | } |
762 | 773 | ||
763 | netizenList.clear(); | 774 | netizenList.clear(); |
775 | |||
776 | #ifdef XINERAMA | ||
777 | if (hasXinerama() && m_xinerama_headinfo) { | ||
778 | delete [] m_xinerama_headinfo; | ||
779 | } | ||
780 | #endif // XINERAMA | ||
764 | } | 781 | } |
765 | 782 | ||
766 | const FbTk::Menu &BScreen::toolbarModemenu() const { | 783 | const FbTk::Menu &BScreen::toolbarModemenu() const { |
@@ -2524,3 +2541,102 @@ void BScreen::updateSize() { | |||
2524 | //!! TODO: should we re-maximize the maximized windows? | 2541 | //!! TODO: should we re-maximize the maximized windows? |
2525 | 2542 | ||
2526 | } | 2543 | } |
2544 | |||
2545 | #ifdef XINERAMA | ||
2546 | |||
2547 | void BScreen::initXinerama(Display *display) { | ||
2548 | if (!XineramaIsActive(display)) { | ||
2549 | m_xinerama_avail = false; | ||
2550 | m_xinerama_headinfo = 0; | ||
2551 | return; | ||
2552 | } | ||
2553 | m_xinerama_avail = true; | ||
2554 | |||
2555 | XineramaScreenInfo *screen_info; | ||
2556 | int number; | ||
2557 | screen_info = XineramaQueryScreens(display, &number); | ||
2558 | m_xinerama_headinfo = new XineramaHeadInfo[number]; | ||
2559 | m_xinerama_num_heads = number; | ||
2560 | for (int i=0; i < number; i++) { | ||
2561 | m_xinerama_headinfo[i].x = screen_info[i].x_org; | ||
2562 | m_xinerama_headinfo[i].y = screen_info[i].y_org; | ||
2563 | m_xinerama_headinfo[i].width = screen_info[i].width; | ||
2564 | m_xinerama_headinfo[i].height = screen_info[i].height; | ||
2565 | } | ||
2566 | |||
2567 | } | ||
2568 | |||
2569 | int BScreen::getHead(int x, int y) const { | ||
2570 | if (!hasXinerama()) return 0; | ||
2571 | |||
2572 | for (int i=0; i < m_xinerama_num_heads; i++) { | ||
2573 | if (x >= m_xinerama_headinfo[i].x && | ||
2574 | x < (m_xinerama_headinfo[i].x + m_xinerama_headinfo[i].width) && | ||
2575 | y >= m_xinerama_headinfo[i].y && | ||
2576 | y < (m_xinerama_headinfo[i].y + m_xinerama_headinfo[i].height)) { | ||
2577 | return i+1; | ||
2578 | } | ||
2579 | } | ||
2580 | |||
2581 | return 0; | ||
2582 | } | ||
2583 | |||
2584 | int BScreen::getCurrHead() const { | ||
2585 | if (!hasXinerama()) return 0; | ||
2586 | int root_x, root_y, ignore_i; | ||
2587 | |||
2588 | unsigned int ignore_ui; | ||
2589 | |||
2590 | Window ignore_w; | ||
2591 | |||
2592 | XQueryPointer(FbTk::App::instance()->display(), | ||
2593 | rootWindow().window(), &ignore_w, | ||
2594 | &ignore_w, &root_x, &root_y, | ||
2595 | &ignore_i, &ignore_i, &ignore_ui); | ||
2596 | return getHead(root_x, root_y); | ||
2597 | |||
2598 | } | ||
2599 | |||
2600 | int BScreen::getHeadX(int head) const { | ||
2601 | if (head == 0 || head > m_xinerama_num_heads) return 0; | ||
2602 | return m_xinerama_headinfo[head-1].x; | ||
2603 | } | ||
2604 | |||
2605 | int BScreen::getHeadY(int head) const { | ||
2606 | if (head == 0 || head > m_xinerama_num_heads) return 0; | ||
2607 | return m_xinerama_headinfo[head-1].y; | ||
2608 | } | ||
2609 | |||
2610 | int BScreen::getHeadWidth(int head) const { | ||
2611 | if (head == 0 || head > m_xinerama_num_heads) return width(); | ||
2612 | return m_xinerama_headinfo[head-1].width; | ||
2613 | } | ||
2614 | |||
2615 | int BScreen::getHeadHeight(int head) const { | ||
2616 | if (head == 0 || head > m_xinerama_num_heads) return height(); | ||
2617 | return m_xinerama_headinfo[head-1].height; | ||
2618 | } | ||
2619 | |||
2620 | template <> | ||
2621 | int BScreen::getOnHead<Toolbar>(Toolbar &tbar) { | ||
2622 | return getToolbarOnHead(); | ||
2623 | } | ||
2624 | |||
2625 | template <> | ||
2626 | void BScreen::setOnHead<Toolbar>(Toolbar &tbar, int head) { | ||
2627 | saveToolbarOnHead(head); | ||
2628 | tbar.reconfigure(); | ||
2629 | } | ||
2630 | |||
2631 | template <> | ||
2632 | int BScreen::getOnHead<Slit>(Slit &tbar) { | ||
2633 | return getSlitOnHead(); | ||
2634 | } | ||
2635 | |||
2636 | template <> | ||
2637 | void BScreen::setOnHead<Slit>(Slit &slit, int head) { | ||
2638 | saveSlitOnHead(head); | ||
2639 | slit.reconfigure(); | ||
2640 | } | ||
2641 | |||
2642 | #endif // XINERAMA | ||