aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2007-07-11 11:54:53 (GMT)
committerTomas Janousek <tomi@nomi.cz>2008-01-27 14:01:14 (GMT)
commit041eacdfd58451d0d561f332e1cb3d17a0970cd1 (patch)
tree55e87f626ae94cf225e0374b30141a0c26ae7293 /src/Screen.cc
parent6717a1c805529ea6e1b1c19a591f876c9c8803db (diff)
downloadfluxbox-041eacdfd58451d0d561f332e1cb3d17a0970cd1.zip
fluxbox-041eacdfd58451d0d561f332e1cb3d17a0970cd1.tar.bz2
Reload the Xinerama layout on RandR signal.
The m_head_areas became a vector, because we need to dynamically change its size. The functions manipulating struts (which refer to a particular head) now check whether the head still exists. Signed-off-by: Tomas Janousek <tomi@nomi.cz>
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index e3b08c6..2e8c265 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -360,6 +360,12 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
360 Display *disp = m_root_window.display(); 360 Display *disp = m_root_window.display();
361 Fluxbox *fluxbox = Fluxbox::instance(); 361 Fluxbox *fluxbox = Fluxbox::instance();
362 362
363 // TODO fluxgen: check if this is the right place (it was not -lis)
364 //
365 // Create the first one, initXinerama will expand this if needed.
366 m_head_areas.resize(1);
367 m_head_areas[0] = new HeadArea();
368
363 initXinerama(); 369 initXinerama();
364 370
365 // setup error handler to catch "screen already managed by other wm" 371 // setup error handler to catch "screen already managed by other wm"
@@ -402,9 +408,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
402 XFree(ret_prop); 408 XFree(ret_prop);
403 } 409 }
404 410
405 // TODO fluxgen: check if this is the right place
406 m_head_areas = new HeadArea[numHeads() ? numHeads() : 1];
407
408#ifdef HAVE_RANDR 411#ifdef HAVE_RANDR
409 // setup RANDR for this screens root window 412 // setup RANDR for this screens root window
410 // we need to determine if we should use old randr select input function or not 413 // we need to determine if we should use old randr select input function or not
@@ -600,7 +603,8 @@ BScreen::~BScreen() {
600 m_slit.reset(0); 603 m_slit.reset(0);
601 604
602 // TODO fluxgen: check if this is the right place 605 // TODO fluxgen: check if this is the right place
603 delete [] m_head_areas; 606 for (int i = 0; i < m_head_areas.size(); i++)
607 delete m_head_areas[i];
604 608
605 delete m_focus_control; 609 delete m_focus_control;
606 delete m_placement_strategy; 610 delete m_placement_strategy;
@@ -722,7 +726,12 @@ unsigned int BScreen::currentWorkspaceID() const {
722} 726}
723 727
724const Strut* BScreen::availableWorkspaceArea(int head) const { 728const Strut* BScreen::availableWorkspaceArea(int head) const {
725 return m_head_areas[head ? head-1 : 0].availableWorkspaceArea(); 729 if (head > numHeads()) {
730 /* May this ever happen? */
731 static Strut whole(-1 /* should never be used */, 0, width(), 0, height());
732 return &whole;
733 }
734 return m_head_areas[head ? head-1 : 0]->availableWorkspaceArea();
726} 735}
727 736
728unsigned int BScreen::maxLeft(int head) const { 737unsigned int BScreen::maxLeft(int head) const {
@@ -1412,7 +1421,7 @@ Strut *BScreen::requestStrut(int head, int left, int right, int top, int bottom)
1412 1421
1413 Strut* next = 0; 1422 Strut* next = 0;
1414 for (int i = begin; i != end; i++) { 1423 for (int i = begin; i != end; i++) {
1415 next = m_head_areas[i].requestStrut(i+1, left, right, top, bottom, next); 1424 next = m_head_areas[i]->requestStrut(i+1, left, right, top, bottom, next);
1416 } 1425 }
1417 1426
1418 return next; 1427 return next;
@@ -1422,7 +1431,9 @@ void BScreen::clearStrut(Strut *str) {
1422 if (str->next()) 1431 if (str->next())
1423 clearStrut(str->next()); 1432 clearStrut(str->next());
1424 int head = str->head() ? str->head() - 1 : 0; 1433 int head = str->head() ? str->head() - 1 : 0;
1425 m_head_areas[head].clearStrut(str); 1434 /* The number of heads may have changed, be careful. */
1435 if (head < numHeads())
1436 m_head_areas[head]->clearStrut(str);
1426 // str is invalid now 1437 // str is invalid now
1427} 1438}
1428 1439
@@ -1431,7 +1442,7 @@ void BScreen::updateAvailableWorkspaceArea() {
1431 bool updated = false; 1442 bool updated = false;
1432 1443
1433 for (size_t i = 0; i < n; i++) { 1444 for (size_t i = 0; i < n; i++) {
1434 updated = m_head_areas[i].updateAvailableWorkspaceArea() || updated; 1445 updated = m_head_areas[i]->updateAvailableWorkspaceArea() || updated;
1435 } 1446 }
1436 1447
1437 if (updated) 1448 if (updated)
@@ -1886,6 +1897,9 @@ void BScreen::renderPosWindow() {
1886} 1897}
1887 1898
1888void BScreen::updateSize() { 1899void BScreen::updateSize() {
1900 // update xinerama layout
1901 initXinerama();
1902
1889 // force update geometry 1903 // force update geometry
1890 rootWindow().updateGeometry(); 1904 rootWindow().updateGeometry();
1891 1905
@@ -1945,6 +1959,8 @@ void BScreen::initXinerama() {
1945 cerr<<"BScreen::initXinerama(): dont have Xinerama"<<endl; 1959 cerr<<"BScreen::initXinerama(): dont have Xinerama"<<endl;
1946#endif // DEBUG 1960#endif // DEBUG
1947 m_xinerama_avail = false; 1961 m_xinerama_avail = false;
1962 if (m_xinerama_headinfo)
1963 delete [] m_xinerama_headinfo;
1948 m_xinerama_headinfo = 0; 1964 m_xinerama_headinfo = 0;
1949 m_xinerama_num_heads = 0; 1965 m_xinerama_num_heads = 0;
1950 return; 1966 return;
@@ -1957,6 +1973,8 @@ void BScreen::initXinerama() {
1957 XineramaScreenInfo *screen_info; 1973 XineramaScreenInfo *screen_info;
1958 int number; 1974 int number;
1959 screen_info = XineramaQueryScreens(display, &number); 1975 screen_info = XineramaQueryScreens(display, &number);
1976 if (m_xinerama_headinfo)
1977 delete [] m_xinerama_headinfo;
1960 m_xinerama_headinfo = new XineramaHeadInfo[number]; 1978 m_xinerama_headinfo = new XineramaHeadInfo[number];
1961 m_xinerama_num_heads = number; 1979 m_xinerama_num_heads = number;
1962 for (int i=0; i < number; i++) { 1980 for (int i=0; i < number; i++) {
@@ -1970,6 +1988,18 @@ void BScreen::initXinerama() {
1970 cerr<<"BScreen::initXinerama(): number of heads ="<<number<<endl; 1988 cerr<<"BScreen::initXinerama(): number of heads ="<<number<<endl;
1971#endif // DEBUG 1989#endif // DEBUG
1972 1990
1991 /* Reallocate to the new number of heads. */
1992 int ha_num = numHeads() ? numHeads() : 1, ha_oldnum = m_head_areas.size();
1993 if (ha_num > ha_oldnum) {
1994 m_head_areas.resize(ha_num);
1995 for (int i = ha_oldnum; i < ha_num; i++)
1996 m_head_areas[i] = new HeadArea();
1997 } else if (ha_num < ha_oldnum) {
1998 for (int i = ha_num; i < ha_oldnum; i++)
1999 delete m_head_areas[i];
2000 m_head_areas.resize(ha_num);
2001 }
2002
1973#else // XINERAMA 2003#else // XINERAMA
1974 // no xinerama 2004 // no xinerama
1975 m_xinerama_avail = false; 2005 m_xinerama_avail = false;