From 041eacdfd58451d0d561f332e1cb3d17a0970cd1 Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Wed, 11 Jul 2007 13:54:53 +0200 Subject: 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 --- src/Screen.cc | 46 ++++++++++++++++++++++++++++++++++++++-------- src/Screen.hh | 2 +- 2 files changed, 39 insertions(+), 9 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, Display *disp = m_root_window.display(); Fluxbox *fluxbox = Fluxbox::instance(); + // TODO fluxgen: check if this is the right place (it was not -lis) + // + // Create the first one, initXinerama will expand this if needed. + m_head_areas.resize(1); + m_head_areas[0] = new HeadArea(); + initXinerama(); // setup error handler to catch "screen already managed by other wm" @@ -402,9 +408,6 @@ BScreen::BScreen(FbTk::ResourceManager &rm, XFree(ret_prop); } - // TODO fluxgen: check if this is the right place - m_head_areas = new HeadArea[numHeads() ? numHeads() : 1]; - #ifdef HAVE_RANDR // setup RANDR for this screens root window // we need to determine if we should use old randr select input function or not @@ -600,7 +603,8 @@ BScreen::~BScreen() { m_slit.reset(0); // TODO fluxgen: check if this is the right place - delete [] m_head_areas; + for (int i = 0; i < m_head_areas.size(); i++) + delete m_head_areas[i]; delete m_focus_control; delete m_placement_strategy; @@ -722,7 +726,12 @@ unsigned int BScreen::currentWorkspaceID() const { } const Strut* BScreen::availableWorkspaceArea(int head) const { - return m_head_areas[head ? head-1 : 0].availableWorkspaceArea(); + if (head > numHeads()) { + /* May this ever happen? */ + static Strut whole(-1 /* should never be used */, 0, width(), 0, height()); + return &whole; + } + return m_head_areas[head ? head-1 : 0]->availableWorkspaceArea(); } unsigned int BScreen::maxLeft(int head) const { @@ -1412,7 +1421,7 @@ Strut *BScreen::requestStrut(int head, int left, int right, int top, int bottom) Strut* next = 0; for (int i = begin; i != end; i++) { - next = m_head_areas[i].requestStrut(i+1, left, right, top, bottom, next); + next = m_head_areas[i]->requestStrut(i+1, left, right, top, bottom, next); } return next; @@ -1422,7 +1431,9 @@ void BScreen::clearStrut(Strut *str) { if (str->next()) clearStrut(str->next()); int head = str->head() ? str->head() - 1 : 0; - m_head_areas[head].clearStrut(str); + /* The number of heads may have changed, be careful. */ + if (head < numHeads()) + m_head_areas[head]->clearStrut(str); // str is invalid now } @@ -1431,7 +1442,7 @@ void BScreen::updateAvailableWorkspaceArea() { bool updated = false; for (size_t i = 0; i < n; i++) { - updated = m_head_areas[i].updateAvailableWorkspaceArea() || updated; + updated = m_head_areas[i]->updateAvailableWorkspaceArea() || updated; } if (updated) @@ -1886,6 +1897,9 @@ void BScreen::renderPosWindow() { } void BScreen::updateSize() { + // update xinerama layout + initXinerama(); + // force update geometry rootWindow().updateGeometry(); @@ -1945,6 +1959,8 @@ void BScreen::initXinerama() { cerr<<"BScreen::initXinerama(): dont have Xinerama"<