aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-12 15:24:37 (GMT)
committerfluxgen <fluxgen>2003-06-12 15:24:37 (GMT)
commit0a4d2b858b3c6a39c8703d14ca1eef9be2f90bc2 (patch)
treeb44531f244b844246d2112a43c0170cc7cce193a /src/Screen.cc
parent243d8723fc755b0ed864696701fee1dddfccc91e (diff)
downloadfluxbox-0a4d2b858b3c6a39c8703d14ca1eef9be2f90bc2.zip
fluxbox-0a4d2b858b3c6a39c8703d14ca1eef9be2f90bc2.tar.bz2
cleaning
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc145
1 files changed, 64 insertions, 81 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 70f0657..85fdec9 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,12 +22,12 @@
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.180 2003/06/11 00:51:07 fluxgen Exp $ 25// $Id: Screen.cc,v 1.181 2003/06/12 15:24:37 fluxgen Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
29 29
30#include "i18n.hh" 30#include "I18n.hh"
31#include "fluxbox.hh" 31#include "fluxbox.hh"
32#include "ImageControl.hh" 32#include "ImageControl.hh"
33#include "Toolbar.hh" 33#include "Toolbar.hh"
@@ -114,6 +114,7 @@
114 114
115#include <X11/Xatom.h> 115#include <X11/Xatom.h>
116#include <X11/keysym.h> 116#include <X11/keysym.h>
117#include <X11/cursorfont.h>
117 118
118#ifdef XINERAMA 119#ifdef XINERAMA
119extern "C" { 120extern "C" {
@@ -152,7 +153,9 @@ FbTk::Menu *createMenuFromScreen(BScreen &screen) {
152 153
153class FocusModelMenuItem : public FbTk::MenuItem { 154class FocusModelMenuItem : public FbTk::MenuItem {
154public: 155public:
155 FocusModelMenuItem(const char *label, BScreen &screen, Fluxbox::FocusModel model, FbTk::RefCount<FbTk::Command> &cmd): 156 FocusModelMenuItem(const char *label, BScreen &screen,
157 Fluxbox::FocusModel model,
158 FbTk::RefCount<FbTk::Command> &cmd):
156 FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) { 159 FbTk::MenuItem(label, cmd), m_screen(screen), m_focusmodel(model) {
157 } 160 }
158 bool isEnabled() const { return m_screen.getFocusModel() != m_focusmodel; } 161 bool isEnabled() const { return m_screen.getFocusModel() != m_focusmodel; }
@@ -524,14 +527,14 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
524 527
525 initXinerama(); 528 initXinerama();
526 529
527 unsigned long event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
528 SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
529 ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask;
530
531 XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); 530 XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
532 rootWindow().setEventMask(event_mask); 531
532 rootWindow().setEventMask(ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
533 SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
534 ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask);
533 535
534 XSync(disp, False); 536 XSync(disp, False);
537
535 XSetErrorHandler((XErrorHandler) old); 538 XSetErrorHandler((XErrorHandler) old);
536 539
537 managed = running; 540 managed = running;
@@ -540,35 +543,24 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
540 543
541 I18n *i18n = I18n::instance(); 544 I18n *i18n = I18n::instance();
542 545
543 fprintf(stderr, 546 fprintf(stderr, i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenManagingScreen,
544 i18n-> 547 "BScreen::BScreen: managing screen %d "
545 getMessage( 548 "using visual 0x%lx, depth %d\n"),
546 FBNLS::ScreenSet, FBNLS::ScreenManagingScreen,
547 "BScreen::BScreen: managing screen %d "
548 "using visual 0x%lx, depth %d\n"),
549 screenNumber(), XVisualIDFromVisual(rootWindow().visual()), 549 screenNumber(), XVisualIDFromVisual(rootWindow().visual()),
550 rootWindow().depth()); 550 rootWindow().depth());
551 551
552 Fluxbox * const fluxbox = Fluxbox::instance();
553#ifdef HAVE_GETPID
554 pid_t bpid = getpid();
555
556 rootWindow().changeProperty(Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL,
557 sizeof(pid_t) * 8, PropModeReplace,
558 (unsigned char *) &bpid, 1);
559#endif // HAVE_GETPID
560
561
562 cycling_window = focused_list.end(); 552 cycling_window = focused_list.end();
553
554 rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr));
563 555
564 XDefineCursor(disp, rootWindow().window(), fluxbox->getSessionCursor()); 556 Fluxbox *fluxbox = Fluxbox::instance();
565
566 m_image_control.reset(new FbTk::ImageControl(scrn, true, fluxbox->colorsPerChannel(), 557 m_image_control.reset(new FbTk::ImageControl(scrn, true, fluxbox->colorsPerChannel(),
567 fluxbox->getCacheLife(), fluxbox->getCacheMax())); 558 fluxbox->getCacheLife(), fluxbox->getCacheMax()));
568 imageControl().installRootColormap(); 559 imageControl().installRootColormap();
569 root_colormap_installed = true; 560 root_colormap_installed = true;
570 561
571 fluxbox->load_rc(*this); 562 fluxbox->load_rc(*this);
563
572 FbTk::Menu::setAlpha(*resource.menu_alpha); 564 FbTk::Menu::setAlpha(*resource.menu_alpha);
573 565
574 imageControl().setDither(*resource.image_dither); 566 imageControl().setDither(*resource.image_dither);
@@ -585,10 +577,8 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
585 const char *s = i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenPositionLength, 577 const char *s = i18n->getMessage(FBNLS::ScreenSet, FBNLS::ScreenPositionLength,
586 "W: 0000 x H: 0000"); 578 "W: 0000 x H: 0000");
587 579
588 int l = strlen(s);
589
590 int geom_h = winFrameTheme().font().height() + m_root_theme->bevelWidth()*2; 580 int geom_h = winFrameTheme().font().height() + m_root_theme->bevelWidth()*2;
591 int geom_w = winFrameTheme().font().textWidth(s, l) + m_root_theme->bevelWidth()*2; 581 int geom_w = winFrameTheme().font().textWidth(s, strlen(s)) + m_root_theme->bevelWidth()*2;
592 582
593 XSetWindowAttributes attrib; 583 XSetWindowAttributes attrib;
594 unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder; 584 unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
@@ -601,39 +591,24 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
601 0, 0, geom_w, geom_h, rootTheme().borderWidth(), rootWindow().depth(), 591 0, 0, geom_w, geom_h, rootTheme().borderWidth(), rootWindow().depth(),
602 InputOutput, rootWindow().visual(), mask, &attrib); 592 InputOutput, rootWindow().visual(), mask, &attrib);
603 geom_visible = false; 593 geom_visible = false;
594 geom_pixmap = 0;
604 595
605 if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) { 596 renderGeomWindow();
606 if (winFrameTheme().titleFocusTexture().type() ==
607 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
608 geom_pixmap = None;
609 m_geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color());
610 } else {
611 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
612 winFrameTheme().titleFocusTexture());
613 m_geom_window.setBackgroundPixmap(geom_pixmap);
614 }
615 } else {
616 if (winFrameTheme().labelFocusTexture().type() ==
617 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
618 geom_pixmap = None;
619 m_geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color());
620 } else {
621 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
622 winFrameTheme().labelFocusTexture());
623 m_geom_window.setBackgroundPixmap(geom_pixmap);
624 }
625 }
626 597
627 workspacemenu.reset(createMenuFromScreen(*this)); 598 workspacemenu.reset(createMenuFromScreen(*this));
628 workspacemenu->setInternalMenu(); 599 workspacemenu->setInternalMenu();
629 600
630 if (*resource.workspaces != 0) { 601 if (*resource.workspaces != 0) {
631 for (int i = 0; i < *resource.workspaces; ++i) { 602 for (int i = 0; i < *resource.workspaces; ++i) {
632 Workspace *wkspc = new Workspace(*this, m_layermanager, m_workspaces_list.size()); 603 Workspace *wkspc = new Workspace(*this, m_layermanager,
604 getNameOfWorkspace(m_workspaces_list.size()),
605 m_workspaces_list.size());
633 m_workspaces_list.push_back(wkspc); 606 m_workspaces_list.push_back(wkspc);
634 } 607 }
635 } else { // create at least one workspace 608 } else { // create at least one workspace
636 Workspace *wkspc = new Workspace(*this, m_layermanager, m_workspaces_list.size()); 609 Workspace *wkspc = new Workspace(*this, m_layermanager,
610 getNameOfWorkspace(m_workspaces_list.size()),
611 m_workspaces_list.size());
637 m_workspaces_list.push_back(wkspc); 612 m_workspaces_list.push_back(wkspc);
638 } 613 }
639 614
@@ -862,31 +837,8 @@ void BScreen::reconfigure() {
862 int geom_h = winFrameTheme().font().height() + m_root_theme->bevelWidth()*2; 837 int geom_h = winFrameTheme().font().height() + m_root_theme->bevelWidth()*2;
863 int geom_w = winFrameTheme().font().textWidth(s, l) + m_root_theme->bevelWidth()*2; 838 int geom_w = winFrameTheme().font().textWidth(s, l) + m_root_theme->bevelWidth()*2;
864 m_geom_window.resize(geom_w, geom_h); 839 m_geom_window.resize(geom_w, geom_h);
865 840
866 Pixmap tmp = geom_pixmap; 841 renderGeomWindow();
867 if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
868 if (winFrameTheme().titleFocusTexture().type() ==
869 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
870 geom_pixmap = None;
871 m_geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color());
872 } else {
873 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
874 winFrameTheme().titleFocusTexture());
875 m_geom_window.setBackgroundPixmap(geom_pixmap);
876 }
877 } else {
878 if (winFrameTheme().labelFocusTexture().type() ==
879 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
880 geom_pixmap = None;
881 m_geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color());
882 } else {
883 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
884 winFrameTheme().labelFocusTexture());
885 m_geom_window.setBackgroundPixmap(geom_pixmap);
886 }
887 }
888 if (tmp)
889 imageControl().removeImage(tmp);
890 842
891 m_geom_window.setBorderWidth(m_root_theme->borderWidth()); 843 m_geom_window.setBorderWidth(m_root_theme->borderWidth());
892 m_geom_window.setBorderColor(m_root_theme->borderColor()); 844 m_geom_window.setBorderColor(m_root_theme->borderColor());
@@ -1054,12 +1006,14 @@ void BScreen::setAntialias(bool value) {
1054} 1006}
1055 1007
1056int BScreen::addWorkspace() { 1008int BScreen::addWorkspace() {
1057 Workspace *wkspc = new Workspace(*this, m_layermanager, m_workspaces_list.size()); 1009 Workspace *wkspc = new Workspace(*this, m_layermanager,
1010 "",
1011 m_workspaces_list.size());
1058 m_workspaces_list.push_back(wkspc); 1012 m_workspaces_list.push_back(wkspc);
1059 addWorkspaceName(wkspc->name().c_str()); // update names 1013 addWorkspaceName(wkspc->name().c_str()); // update names
1060 //add workspace to workspacemenu 1014 //add workspace to workspacemenu
1061 workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu(), 1015 workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu(),
1062 wkspc->workspaceID() + 2); //+2 so we add it after "remove last" 1016 wkspc->workspaceID() + 2); //+2 so we add it after "remove last" item
1063 1017
1064 workspacemenu->update(); 1018 workspacemenu->update();
1065 saveWorkspaces(m_workspaces_list.size()); 1019 saveWorkspaces(m_workspaces_list.size());
@@ -1068,7 +1022,6 @@ int BScreen::addWorkspace() {
1068 1022
1069 updateNetizenWorkspaceCount(); 1023 updateNetizenWorkspaceCount();
1070 1024
1071
1072 return m_workspaces_list.size(); 1025 return m_workspaces_list.size();
1073 1026
1074} 1027}
@@ -2465,6 +2418,36 @@ bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) {
2465 (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded 2418 (opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded
2466} 2419}
2467 2420
2421void BScreen::renderGeomWindow() {
2422 Pixmap tmp = geom_pixmap;
2423
2424 if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
2425 if (winFrameTheme().titleFocusTexture().type() ==
2426 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
2427 geom_pixmap = None;
2428 m_geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color());
2429 } else {
2430 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
2431 winFrameTheme().titleFocusTexture());
2432 m_geom_window.setBackgroundPixmap(geom_pixmap);
2433 }
2434 } else {
2435 if (winFrameTheme().labelFocusTexture().type() ==
2436 (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
2437 geom_pixmap = None;
2438 m_geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color());
2439 } else {
2440 geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
2441 winFrameTheme().labelFocusTexture());
2442 m_geom_window.setBackgroundPixmap(geom_pixmap);
2443 }
2444 }
2445
2446 if (tmp)
2447 imageControl().removeImage(tmp);
2448
2449}
2450
2468/** 2451/**
2469 Called when a set of watched modifiers has been released 2452 Called when a set of watched modifiers has been released
2470*/ 2453*/