diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Slit.cc | 131 |
1 files changed, 75 insertions, 56 deletions
diff --git a/src/Slit.cc b/src/Slit.cc index 421ff79..e5fcf37 100644 --- a/src/Slit.cc +++ b/src/Slit.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: Slit.cc,v 1.40 2003/04/16 16:18:02 rathnor Exp $ | 25 | // $Id: Slit.cc,v 1.41 2003/04/25 10:46:07 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Slit.hh" | 27 | #include "Slit.hh" |
28 | 28 | ||
@@ -46,6 +46,8 @@ | |||
46 | #include "LayerMenu.hh" | 46 | #include "LayerMenu.hh" |
47 | #include "fluxbox.hh" | 47 | #include "fluxbox.hh" |
48 | #include "XLayer.hh" | 48 | #include "XLayer.hh" |
49 | #include "RootTheme.hh" | ||
50 | #include "FbTk/Theme.hh" | ||
49 | 51 | ||
50 | #include <algorithm> | 52 | #include <algorithm> |
51 | #include <iostream> | 53 | #include <iostream> |
@@ -238,20 +240,34 @@ private: | |||
238 | 240 | ||
239 | }; // End anonymous namespace | 241 | }; // End anonymous namespace |
240 | 242 | ||
243 | class SlitTheme:public FbTk::Theme { | ||
244 | public: | ||
245 | explicit SlitTheme(Slit &slit):FbTk::Theme(slit.screen().getScreenNumber()), | ||
246 | m_slit(slit), | ||
247 | m_texture(*this, "slit", "Slit") { } | ||
248 | void reconfigTheme() { | ||
249 | m_slit.reconfigure(); | ||
250 | } | ||
251 | const FbTk::Texture &texture() const { return *m_texture; } | ||
252 | private: | ||
253 | Slit &m_slit; | ||
254 | FbTk::ThemeItem<FbTk::Texture> m_texture; | ||
255 | }; | ||
256 | |||
241 | Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) | 257 | Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) |
242 | : m_screen(scr), timer(this), | 258 | : m_screen(scr), timer(this), |
243 | slitmenu(*scr.menuTheme(), | 259 | slitmenu(*scr.menuTheme(), |
244 | scr.getScreenNumber(), | 260 | scr.getScreenNumber(), |
245 | *scr.getImageControl()), | 261 | *scr.getImageControl()), |
246 | placement_menu(*scr.menuTheme(), | 262 | placement_menu(*scr.menuTheme(), |
247 | scr.getScreenNumber(), | 263 | scr.getScreenNumber(), |
248 | *scr.getImageControl()), | 264 | *scr.getImageControl()), |
249 | clientlist_menu(*scr.menuTheme(), | 265 | clientlist_menu(*scr.menuTheme(), |
250 | scr.getScreenNumber(), | 266 | scr.getScreenNumber(), |
251 | *scr.getImageControl()), | 267 | *scr.getImageControl()), |
252 | slit_layermenu(0), | 268 | slit_layermenu(0), |
253 | m_layeritem(0) | 269 | m_layeritem(0), |
254 | { | 270 | m_slit_theme(new SlitTheme(*this)) { |
255 | 271 | ||
256 | slit_layermenu.reset(new LayerMenu<Slit>(*scr.menuTheme(), | 272 | slit_layermenu.reset(new LayerMenu<Slit>(*scr.menuTheme(), |
257 | scr.getScreenNumber(), | 273 | scr.getScreenNumber(), |
@@ -275,7 +291,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) | |||
275 | CWColormap | CWOverrideRedirect | CWEventMask; | 291 | CWColormap | CWOverrideRedirect | CWEventMask; |
276 | attrib.background_pixmap = None; | 292 | attrib.background_pixmap = None; |
277 | attrib.background_pixel = attrib.border_pixel = | 293 | attrib.background_pixel = attrib.border_pixel = |
278 | screen().getBorderColor()->pixel(); | 294 | screen().rootTheme().borderColor().pixel(); |
279 | attrib.colormap = screen().colormap(); | 295 | attrib.colormap = screen().colormap(); |
280 | attrib.override_redirect = True; | 296 | attrib.override_redirect = True; |
281 | attrib.event_mask = SubstructureRedirectMask | ButtonPressMask | | 297 | attrib.event_mask = SubstructureRedirectMask | ButtonPressMask | |
@@ -286,7 +302,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) | |||
286 | Display *disp = FbTk::App::instance()->display(); | 302 | Display *disp = FbTk::App::instance()->display(); |
287 | frame.window = | 303 | frame.window = |
288 | XCreateWindow(disp, screen().getRootWindow(), frame.x, frame.y, | 304 | XCreateWindow(disp, screen().getRootWindow(), frame.x, frame.y, |
289 | frame.width, frame.height, screen().getBorderWidth(), | 305 | frame.width, frame.height, screen().rootTheme().borderWidth(), |
290 | screen().getDepth(), InputOutput, screen().getVisual(), | 306 | screen().getDepth(), InputOutput, screen().getVisual(), |
291 | create_mask, &attrib); | 307 | create_mask, &attrib); |
292 | 308 | ||
@@ -544,7 +560,7 @@ void Slit::reconfigure() { | |||
544 | // Need to count windows because not all client list entries | 560 | // Need to count windows because not all client list entries |
545 | // actually correspond to mapped windows. | 561 | // actually correspond to mapped windows. |
546 | int num_windows = 0; | 562 | int num_windows = 0; |
547 | 563 | const int bevel_width = screen().rootTheme().bevelWidth(); | |
548 | switch (direction()) { | 564 | switch (direction()) { |
549 | case VERTICAL: | 565 | case VERTICAL: |
550 | { | 566 | { |
@@ -554,7 +570,8 @@ void Slit::reconfigure() { | |||
554 | //client created window? | 570 | //client created window? |
555 | if ((*it)->window != None && (*it)->visible) { | 571 | if ((*it)->window != None && (*it)->visible) { |
556 | num_windows++; | 572 | num_windows++; |
557 | frame.height += (*it)->height + screen().getBevelWidth(); | 573 | frame.height += (*it)->height + |
574 | bevel_width; | ||
558 | 575 | ||
559 | //frame width < client window? | 576 | //frame width < client window? |
560 | if (frame.width < (*it)->width) | 577 | if (frame.width < (*it)->width) |
@@ -566,12 +583,12 @@ void Slit::reconfigure() { | |||
566 | if (frame.width < 1) | 583 | if (frame.width < 1) |
567 | frame.width = 1; | 584 | frame.width = 1; |
568 | else | 585 | else |
569 | frame.width += (screen().getBevelWidth() * 2); | 586 | frame.width += (bevel_width * 2); |
570 | 587 | ||
571 | if (frame.height < 1) | 588 | if (frame.height < 1) |
572 | frame.height = 1; | 589 | frame.height = 1; |
573 | else | 590 | else |
574 | frame.height += screen().getBevelWidth(); | 591 | frame.height += bevel_width; |
575 | 592 | ||
576 | break; | 593 | break; |
577 | 594 | ||
@@ -583,7 +600,7 @@ void Slit::reconfigure() { | |||
583 | //client created window? | 600 | //client created window? |
584 | if ((*it)->window != None && (*it)->visible) { | 601 | if ((*it)->window != None && (*it)->visible) { |
585 | num_windows++; | 602 | num_windows++; |
586 | frame.width += (*it)->width + screen().getBevelWidth(); | 603 | frame.width += (*it)->width + bevel_width; |
587 | //frame height < client height? | 604 | //frame height < client height? |
588 | if (frame.height < (*it)->height) | 605 | if (frame.height < (*it)->height) |
589 | frame.height = (*it)->height; | 606 | frame.height = (*it)->height; |
@@ -594,12 +611,12 @@ void Slit::reconfigure() { | |||
594 | if (frame.width < 1) | 611 | if (frame.width < 1) |
595 | frame.width = 1; | 612 | frame.width = 1; |
596 | else | 613 | else |
597 | frame.width += screen().getBevelWidth(); | 614 | frame.width += bevel_width; |
598 | 615 | ||
599 | if (frame.height < 1) | 616 | if (frame.height < 1) |
600 | frame.height = 1; | 617 | frame.height = 1; |
601 | else | 618 | else |
602 | frame.height += (screen().getBevelWidth() * 2); | 619 | frame.height += bevel_width*2; |
603 | 620 | ||
604 | break; | 621 | break; |
605 | } | 622 | } |
@@ -607,8 +624,8 @@ void Slit::reconfigure() { | |||
607 | reposition(); | 624 | reposition(); |
608 | Display *disp = FbTk::App::instance()->display(); | 625 | Display *disp = FbTk::App::instance()->display(); |
609 | 626 | ||
610 | frame.window.setBorderWidth(screen().getBorderWidth()); | 627 | frame.window.setBorderWidth(screen().rootTheme().borderWidth()); |
611 | frame.window.setBorderColor(*screen().getBorderColor()); | 628 | frame.window.setBorderColor(screen().rootTheme().borderColor()); |
612 | //did we actually use slit slots | 629 | //did we actually use slit slots |
613 | if (num_windows == 0) | 630 | if (num_windows == 0) |
614 | frame.window.hide(); | 631 | frame.window.hide(); |
@@ -617,7 +634,7 @@ void Slit::reconfigure() { | |||
617 | 634 | ||
618 | Pixmap tmp = frame.pixmap; | 635 | Pixmap tmp = frame.pixmap; |
619 | FbTk::ImageControl *image_ctrl = screen().getImageControl(); | 636 | FbTk::ImageControl *image_ctrl = screen().getImageControl(); |
620 | const FbTk::Texture &texture = screen().getTheme()->getSlitTexture(); | 637 | const FbTk::Texture &texture = m_slit_theme->texture(); |
621 | if (texture.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { | 638 | if (texture.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { |
622 | frame.pixmap = None; | 639 | frame.pixmap = None; |
623 | frame.window.setBackgroundColor(texture.color()); | 640 | frame.window.setBackgroundColor(texture.color()); |
@@ -637,7 +654,7 @@ void Slit::reconfigure() { | |||
637 | switch (direction()) { | 654 | switch (direction()) { |
638 | case VERTICAL: | 655 | case VERTICAL: |
639 | x = 0; | 656 | x = 0; |
640 | y = screen().getBevelWidth(); | 657 | y = bevel_width; |
641 | 658 | ||
642 | { | 659 | { |
643 | SlitClients::iterator it = clientList.begin(); | 660 | SlitClients::iterator it = clientList.begin(); |
@@ -682,14 +699,14 @@ void Slit::reconfigure() { | |||
682 | XSendEvent(disp, (*it)->window, False, StructureNotifyMask, | 699 | XSendEvent(disp, (*it)->window, False, StructureNotifyMask, |
683 | &event); | 700 | &event); |
684 | 701 | ||
685 | y += (*it)->height + screen().getBevelWidth(); | 702 | y += (*it)->height + bevel_width; |
686 | } | 703 | } // end for |
687 | } | 704 | } |
688 | 705 | ||
689 | break; | 706 | break; |
690 | 707 | ||
691 | case HORIZONTAL: | 708 | case HORIZONTAL: |
692 | x = screen().getBevelWidth(); | 709 | x = bevel_width; |
693 | y = 0; | 710 | y = 0; |
694 | 711 | ||
695 | { | 712 | { |
@@ -728,8 +745,8 @@ void Slit::reconfigure() { | |||
728 | event.xconfigure.display = disp; | 745 | event.xconfigure.display = disp; |
729 | event.xconfigure.event = (*it)->window; | 746 | event.xconfigure.event = (*it)->window; |
730 | event.xconfigure.window = (*it)->window; | 747 | event.xconfigure.window = (*it)->window; |
731 | event.xconfigure.x = frame.x + x + screen().getBorderWidth(); | 748 | event.xconfigure.x = frame.x + x + screen().rootTheme().borderWidth(); |
732 | event.xconfigure.y = frame.y + y + screen().getBorderWidth(); | 749 | event.xconfigure.y = frame.y + y + screen().rootTheme().borderWidth(); |
733 | event.xconfigure.width = (*it)->width; | 750 | event.xconfigure.width = (*it)->width; |
734 | event.xconfigure.height = (*it)->height; | 751 | event.xconfigure.height = (*it)->height; |
735 | event.xconfigure.border_width = 0; | 752 | event.xconfigure.border_width = 0; |
@@ -739,7 +756,7 @@ void Slit::reconfigure() { | |||
739 | XSendEvent(disp, (*it)->window, False, StructureNotifyMask, | 756 | XSendEvent(disp, (*it)->window, False, StructureNotifyMask, |
740 | &event); | 757 | &event); |
741 | 758 | ||
742 | x += (*it)->width + screen().getBevelWidth(); | 759 | x += (*it)->width + bevel_width; |
743 | } | 760 | } |
744 | } | 761 | } |
745 | 762 | ||
@@ -759,6 +776,8 @@ void Slit::reposition() { | |||
759 | 776 | ||
760 | head_w = screen().getWidth(); | 777 | head_w = screen().getWidth(); |
761 | head_h = screen().getHeight(); | 778 | head_h = screen().getHeight(); |
779 | int border_width = screen().rootTheme().borderWidth(); | ||
780 | int bevel_width = screen().rootTheme().bevelWidth(); | ||
762 | 781 | ||
763 | // place the slit in the appropriate place | 782 | // place the slit in the appropriate place |
764 | switch (placement()) { | 783 | switch (placement()) { |
@@ -766,35 +785,35 @@ void Slit::reposition() { | |||
766 | frame.x = head_x; | 785 | frame.x = head_x; |
767 | frame.y = head_y; | 786 | frame.y = head_y; |
768 | if (direction() == VERTICAL) { | 787 | if (direction() == VERTICAL) { |
769 | frame.x_hidden = screen().getBevelWidth() - | 788 | frame.x_hidden = bevel_width - |
770 | screen().getBorderWidth() - frame.width; | 789 | border_width - frame.width; |
771 | frame.y_hidden = head_y; | 790 | frame.y_hidden = head_y; |
772 | } else { | 791 | } else { |
773 | frame.x_hidden = head_x; | 792 | frame.x_hidden = head_x; |
774 | frame.y_hidden = screen().getBevelWidth() - | 793 | frame.y_hidden = bevel_width - |
775 | screen().getBorderWidth() - frame.height; | 794 | border_width - frame.height; |
776 | } | 795 | } |
777 | break; | 796 | break; |
778 | 797 | ||
779 | case CENTERLEFT: | 798 | case CENTERLEFT: |
780 | frame.x = head_x; | 799 | frame.x = head_x; |
781 | frame.y = head_y + (head_h - frame.height) / 2; | 800 | frame.y = head_y + (head_h - frame.height) / 2; |
782 | frame.x_hidden = head_x + screen().getBevelWidth() - | 801 | frame.x_hidden = head_x + bevel_width - |
783 | screen().getBorderWidth() - frame.width; | 802 | border_width - frame.width; |
784 | frame.y_hidden = frame.y; | 803 | frame.y_hidden = frame.y; |
785 | break; | 804 | break; |
786 | 805 | ||
787 | case BOTTOMLEFT: | 806 | case BOTTOMLEFT: |
788 | frame.x = head_x; | 807 | frame.x = head_x; |
789 | frame.y = head_h - frame.height - screen().getBorderWidth2x(); | 808 | frame.y = head_h - frame.height - border_width*2; |
790 | if (direction() == VERTICAL) { | 809 | if (direction() == VERTICAL) { |
791 | frame.x_hidden = head_x + screen().getBevelWidth() - | 810 | frame.x_hidden = head_x + bevel_width - |
792 | screen().getBorderWidth() - frame.width; | 811 | border_width - frame.width; |
793 | frame.y_hidden = frame.y; | 812 | frame.y_hidden = frame.y; |
794 | } else { | 813 | } else { |
795 | frame.x_hidden = head_x; | 814 | frame.x_hidden = head_x; |
796 | frame.y_hidden = head_y + head_h - | 815 | frame.y_hidden = head_y + head_h - |
797 | screen().getBevelWidth() - screen().getBorderWidth(); | 816 | bevel_width - border_width; |
798 | } | 817 | } |
799 | break; | 818 | break; |
800 | 819 | ||
@@ -802,52 +821,52 @@ void Slit::reposition() { | |||
802 | frame.x = head_x + ((head_w - frame.width) / 2); | 821 | frame.x = head_x + ((head_w - frame.width) / 2); |
803 | frame.y = head_y; | 822 | frame.y = head_y; |
804 | frame.x_hidden = frame.x; | 823 | frame.x_hidden = frame.x; |
805 | frame.y_hidden = head_y + screen().getBevelWidth() - | 824 | frame.y_hidden = head_y + bevel_width - |
806 | screen().getBorderWidth() - frame.height; | 825 | border_width - frame.height; |
807 | break; | 826 | break; |
808 | 827 | ||
809 | case BOTTOMCENTER: | 828 | case BOTTOMCENTER: |
810 | frame.x = head_x + ((head_w - frame.width) / 2); | 829 | frame.x = head_x + ((head_w - frame.width) / 2); |
811 | frame.y = head_y + head_h - frame.height - screen().getBorderWidth2x(); | 830 | frame.y = head_y + head_h - frame.height - border_width*2; |
812 | frame.x_hidden = frame.x; | 831 | frame.x_hidden = frame.x; |
813 | frame.y_hidden = head_y + head_h - | 832 | frame.y_hidden = head_y + head_h - |
814 | screen().getBevelWidth() - screen().getBorderWidth(); | 833 | bevel_width - border_width; |
815 | break; | 834 | break; |
816 | 835 | ||
817 | case TOPRIGHT: | 836 | case TOPRIGHT: |
818 | frame.x = head_x + head_w - frame.width - screen().getBorderWidth2x(); | 837 | frame.x = head_x + head_w - frame.width - border_width*2; |
819 | frame.y = head_y; | 838 | frame.y = head_y; |
820 | if (direction() == VERTICAL) { | 839 | if (direction() == VERTICAL) { |
821 | frame.x_hidden = head_x + head_w - | 840 | frame.x_hidden = head_x + head_w - |
822 | screen().getBevelWidth() - screen().getBorderWidth(); | 841 | bevel_width - border_width; |
823 | frame.y_hidden = head_y; | 842 | frame.y_hidden = head_y; |
824 | } else { | 843 | } else { |
825 | frame.x_hidden = frame.x; | 844 | frame.x_hidden = frame.x; |
826 | frame.y_hidden = head_y + screen().getBevelWidth() - | 845 | frame.y_hidden = head_y + bevel_width - |
827 | screen().getBorderWidth() - frame.height; | 846 | border_width - frame.height; |
828 | } | 847 | } |
829 | break; | 848 | break; |
830 | 849 | ||
831 | case CENTERRIGHT: | 850 | case CENTERRIGHT: |
832 | default: | 851 | default: |
833 | frame.x = head_x + head_w - frame.width - screen().getBorderWidth2x(); | 852 | frame.x = head_x + head_w - frame.width - border_width*2; |
834 | frame.y = head_y + ((head_h - frame.height) / 2); | 853 | frame.y = head_y + ((head_h - frame.height) / 2); |
835 | frame.x_hidden = head_x + head_w - | 854 | frame.x_hidden = head_x + head_w - |
836 | screen().getBevelWidth() - screen().getBorderWidth(); | 855 | bevel_width - border_width; |
837 | frame.y_hidden = frame.y; | 856 | frame.y_hidden = frame.y; |
838 | break; | 857 | break; |
839 | 858 | ||
840 | case BOTTOMRIGHT: | 859 | case BOTTOMRIGHT: |
841 | frame.x = head_x + head_w - frame.width - screen().getBorderWidth2x(); | 860 | frame.x = head_x + head_w - frame.width - border_width*2; |
842 | frame.y = head_y + head_h - frame.height - screen().getBorderWidth2x(); | 861 | frame.y = head_y + head_h - frame.height - border_width*2; |
843 | if (direction() == VERTICAL) { | 862 | if (direction() == VERTICAL) { |
844 | frame.x_hidden = head_x + head_w - | 863 | frame.x_hidden = head_x + head_w - |
845 | screen().getBevelWidth() - screen().getBorderWidth(); | 864 | bevel_width - border_width; |
846 | frame.y_hidden = frame.y; | 865 | frame.y_hidden = frame.y; |
847 | } else { | 866 | } else { |
848 | frame.x_hidden = frame.x; | 867 | frame.x_hidden = frame.x; |
849 | frame.y_hidden = head_y + head_h - | 868 | frame.y_hidden = head_y + head_h - |
850 | screen().getBevelWidth() - screen().getBorderWidth(); | 869 | bevel_width - border_width; |
851 | } | 870 | } |
852 | break; | 871 | break; |
853 | } | 872 | } |