xinerama updates

This commit is contained in:
rathnor 2003-05-19 15:32:47 +00:00
parent 3b2afa5a30
commit b68b1c7623
7 changed files with 103 additions and 68 deletions

View file

@ -1,6 +1,8 @@
(Format: Year/Month/Day)
Changes for 0.9.3:
*03/05/19:
* Clean + change xinerama, plus add maximize smarts (Simon)
Screen.hh/cc Window.cc Workspace.cc Toolbar.cc Slit.cc
* Fixed minor bug in bsetroot (Henrik)
bsetroot.cc
* Add back some Xinerama support (still need placement + maximise) (Simon)

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.172 2003/05/19 14:26:29 rathnor Exp $
// $Id: Screen.cc,v 1.173 2003/05/19 15:32:46 rathnor Exp $
#include "Screen.hh"
@ -53,6 +53,7 @@
#include "WinClient.hh"
#include "Subject.hh"
#include "FbWinFrame.hh"
#include "FbWindow.hh"
//use GNU extensions
#ifndef _GNU_SOURCE
@ -523,9 +524,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
Display *disp = FbTk::App::instance()->display();
#ifdef XINERAMA
initXinerama(disp);
#endif // XINERAMA
initXinerama();
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
@ -815,23 +814,47 @@ Pixmap BScreen::rootPixmap() const {
}
/// TODO
unsigned int BScreen::maxLeft() const {
return 0;
unsigned int BScreen::maxLeft(FbTk::FbWindow &win) const {
if (hasXinerama()) {
int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
// we MUST use a head, we use the center of the window, or if that
// isn't in a head, then the mouse's head
if (head == 0) head = getCurrHead();
return getHeadX(head);
} else
return 0;
}
///!! TODO
unsigned int BScreen::maxRight() const {
return width();
unsigned int BScreen::maxRight(FbTk::FbWindow &win) const {
if (hasXinerama()) {
int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
// we MUST use a head, we use the center of the window, or if that
// isn't in a head, then the mouse's head
if (head == 0) head = getCurrHead();
return getHeadX(head) + getHeadWidth(head);
} else
return width();
}
///!! TODO
unsigned int BScreen::maxTop() const {
return 0;
unsigned int BScreen::maxTop(FbTk::FbWindow &win) const {
if (hasXinerama()) {
int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
// we MUST use a head, we use the center of the window, or if that
// isn't in a head, then the mouse's head
if (head == 0) head = getCurrHead();
return getHeadY(head);
} else
return 0;
}
///!! TODO
unsigned int BScreen::maxBottom() const {
return height();
unsigned int BScreen::maxBottom(FbTk::FbWindow &win) const {
if (hasXinerama()) {
int head = getHead(win.x() + win.width()/2, win.y() + win.height()/2);
// we MUST use a head, we use the center of the window, or if that
// isn't in a head, then the mouse's head
if (head == 0) head = getCurrHead();
return getHeadY(head) + getHeadHeight(head);
} else
return height();
}
void BScreen::reconfigure() {
@ -2542,9 +2565,11 @@ void BScreen::updateSize() {
}
#ifdef XINERAMA
void BScreen::initXinerama(Display *display) {
void BScreen::initXinerama() {
#ifdef XINERAMA
Display *display = FbTk::App::instance()->display();
if (!XineramaIsActive(display)) {
m_xinerama_avail = false;
m_xinerama_headinfo = 0;
@ -2563,11 +2588,16 @@ void BScreen::initXinerama(Display *display) {
m_xinerama_headinfo[i].width = screen_info[i].width;
m_xinerama_headinfo[i].height = screen_info[i].height;
}
#else // XINERAMA
m_xinerama_avail = false;
m_xinerama_num_heads = 0;
#endif // XINERAMA
}
int BScreen::getHead(int x, int y) const {
if (!hasXinerama()) return 0;
#ifdef XINERAMA
for (int i=0; i < m_xinerama_num_heads; i++) {
if (x >= m_xinerama_headinfo[i].x &&
@ -2578,13 +2608,15 @@ int BScreen::getHead(int x, int y) const {
}
}
#endif // XINERAMA
return 0;
}
int BScreen::getCurrHead() const {
if (!hasXinerama()) return 0;
int root_x, root_y, ignore_i;
int root_x = 0, root_y = 0;
#ifdef XINERAMA
int ignore_i;
unsigned int ignore_ui;
Window ignore_w;
@ -2593,28 +2625,44 @@ int BScreen::getCurrHead() const {
rootWindow().window(), &ignore_w,
&ignore_w, &root_x, &root_y,
&ignore_i, &ignore_i, &ignore_ui);
#endif // XINERAMA
return getHead(root_x, root_y);
}
int BScreen::getHeadX(int head) const {
#ifdef XINERAMA
if (head == 0 || head > m_xinerama_num_heads) return 0;
return m_xinerama_headinfo[head-1].x;
#else
return 0;
#endif // XINERAMA
}
int BScreen::getHeadY(int head) const {
#ifdef XINERAMA
if (head == 0 || head > m_xinerama_num_heads) return 0;
return m_xinerama_headinfo[head-1].y;
#else
return 0;
#endif // XINERAMA
}
int BScreen::getHeadWidth(int head) const {
#ifdef XINERAMA
if (head == 0 || head > m_xinerama_num_heads) return width();
return m_xinerama_headinfo[head-1].width;
#else
return width();
#endif // XINERAMA
}
int BScreen::getHeadHeight(int head) const {
#ifdef XINERAMA
if (head == 0 || head > m_xinerama_num_heads) return height();
return m_xinerama_headinfo[head-1].height;
#else
return height();
#endif // XINERAMA
}
template <>
@ -2638,5 +2686,3 @@ void BScreen::setOnHead<Slit>(Slit &slit, int head) {
saveSlitOnHead(head);
slit.reconfigure();
}
#endif // XINERAMA

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Screen.hh,v 1.100 2003/05/19 14:26:30 rathnor Exp $
// $Id: Screen.hh,v 1.101 2003/05/19 15:32:46 rathnor Exp $
#ifndef SCREEN_HH
#define SCREEN_HH
@ -58,6 +58,7 @@ class MenuTheme;
class Menu;
class ImageControl;
class XLayerItem;
class FbWindow;
};
/// Handles screen connection, screen clients and workspaces
@ -134,12 +135,12 @@ public:
unsigned int currentWorkspaceID() const;
Pixmap rootPixmap() const;
/*
maximum screen surface
maximum screen bounds for given window
*/
unsigned int maxLeft() const;
unsigned int maxRight() const;
unsigned int maxTop() const;
unsigned int maxBottom() const;
unsigned int maxLeft(FbTk::FbWindow &win) const;
unsigned int maxRight(FbTk::FbWindow &win) const;
unsigned int maxTop(FbTk::FbWindow &win) const;
unsigned int maxBottom(FbTk::FbWindow &win) const;
inline unsigned int width() const { return rootWindow().width(); }
inline unsigned int height() const { return rootWindow().height(); }
@ -296,12 +297,11 @@ public:
/// (and maximized windows?)
void updateSize();
#ifdef XINERAMA
// Xinerama-related functions
inline bool hasXinerama() const { return m_xinerama_avail; }
inline int numHeads() const { return m_xinerama_num_heads; }
void initXinerama(Display *display);
void initXinerama();
int getHead(int x, int y) const;
int getCurrHead() const;
@ -310,14 +310,13 @@ public:
int getHeadWidth(int head) const;
int getHeadHeight(int head) const;
// magic to allow us to have "on head" placement without
// magic to allow us to have "on head" placement (menu) without
// the object really knowing about it.
template <typename OnHeadObject>
int getOnHead(OnHeadObject &obj);
template <typename OnHeadObject>
void setOnHead(OnHeadObject &obj, int head);
#endif // XINERAMA
// notify netizens
void updateNetizenCurrentWorkspace();
@ -447,19 +446,17 @@ private:
std::auto_ptr<ToolbarHandler> m_toolbarhandler;
#ifdef XINERAMA
// Xinerama related private data
bool m_xinerama_avail;
int m_xinerama_num_heads;
#ifdef XINERAMA
// Xinerama related private data
int m_xinerama_center_x, m_xinerama_center_y;
struct XineramaHeadInfo {
int x, y, width, height;
} *m_xinerama_headinfo;
#endif
};

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Slit.cc,v 1.56 2003/05/19 14:26:30 rathnor Exp $
// $Id: Slit.cc,v 1.57 2003/05/19 15:32:47 rathnor Exp $
#include "Slit.hh"
@ -51,10 +51,7 @@
#include "FbMenu.hh"
#include "Transparent.hh"
#include "IntResMenuItem.hh"
#ifdef XINERAMA
#include "Xinerama.hh"
#endif // XINERAMA
#include <algorithm>
#include <iostream>
@ -794,16 +791,13 @@ void Slit::reposition() {
head_w,
head_h;
#ifdef XINERAMA
if (screen().hasXinerama()) {
int head = screen().getSlitOnHead();
head_x = screen().getHeadX(head);
head_y = screen().getHeadY(head);
head_w = screen().getHeadWidth(head);
head_h = screen().getHeadHeight(head);
} else
#endif // XINERAMA
{
} else {
head_w = screen().width();
head_h = screen().height();
}

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Toolbar.cc,v 1.85 2003/05/19 14:26:30 rathnor Exp $
// $Id: Toolbar.cc,v 1.86 2003/05/19 15:32:47 rathnor Exp $
#include "Toolbar.hh"
@ -42,10 +42,7 @@
#include "RootTheme.hh"
#include "BoolMenuItem.hh"
#include "FbWinFrameTheme.hh"
#ifdef XINERAMA
#include "Xinerama.hh"
#endif XINERAMA
// use GNU extensions
#ifndef _GNU_SOURCE
@ -138,7 +135,7 @@ void setupMenus(Toolbar &tbar) {
menu.setInternalMenu();
menu.insert("Layer...", &tbar.layermenu());
#ifdef XINERAMA
if (tbar.screen().hasXinerama()) {
menu.insert("On Head...", new XineramaHeadMenu<Toolbar>(
*tbar.screen().menuTheme(),
@ -148,8 +145,6 @@ void setupMenus(Toolbar &tbar) {
&tbar
));
}
#endif //XINERAMA
// setup items in placement menu
struct {

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Window.cc,v 1.179 2003/05/17 11:08:06 fluxgen Exp $
// $Id: Window.cc,v 1.180 2003/05/19 15:32:47 rathnor Exp $
#include "Window.hh"
@ -1386,12 +1386,12 @@ void FluxboxWindow::maximize() {
m_old_height = frame().height();
m_old_pos_x = frame().x();
m_old_pos_y = frame().y();
unsigned int left_x = screen().maxLeft();
unsigned int max_width = screen().maxRight();
unsigned int max_top = screen().maxTop();
unsigned int left_x = screen().maxLeft(frame().window());
unsigned int max_width = screen().maxRight(frame().window());
unsigned int max_top = screen().maxTop(frame().window());
moveResize(left_x, max_top,
max_width - left_x,
screen().maxBottom() - max_top - frame().window().borderWidth());
max_width - left_x - 2*frame().window().borderWidth(),
screen().maxBottom(frame().window()) - max_top - 2*frame().window().borderWidth());
} else { // demaximize, restore to old values
moveResize(m_old_pos_x, m_old_pos_y,
m_old_width, m_old_height);
@ -1401,8 +1401,8 @@ void FluxboxWindow::maximize() {
}
void FluxboxWindow::maximizeHorizontal() {
unsigned int left_x = screen().maxLeft();
unsigned int max_width = screen().maxRight();
unsigned int left_x = screen().maxLeft(frame().window());
unsigned int max_width = screen().maxRight(frame().window());
moveResize(left_x, frame().y(),
max_width - left_x, frame().height() - frame().window().borderWidth());
@ -1412,10 +1412,10 @@ void FluxboxWindow::maximizeHorizontal() {
Maximize window horizontal
*/
void FluxboxWindow::maximizeVertical() {
unsigned int max_top = screen().maxTop();
unsigned int max_top = screen().maxTop(frame().window());
moveResize(frame().x(), max_top,
frame().width() - frame().window().borderWidth(),
screen().maxBottom() - max_top);
screen().maxBottom(frame().window()) - max_top);
}

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Workspace.cc,v 1.66 2003/05/15 23:30:07 fluxgen Exp $
// $Id: Workspace.cc,v 1.67 2003/05/19 15:32:47 rathnor Exp $
#include "Workspace.hh"
@ -33,6 +33,7 @@
#include "StringUtil.hh"
#include "SimpleCommand.hh"
#include "WinClient.hh"
#include "FbWinFrame.hh"
// use GNU extensions
#ifndef _GNU_SOURCE
@ -507,10 +508,10 @@ void Workspace::placeWindow(FluxboxWindow &win) {
test_x = root_x - (win_w / 2);
test_y = root_y - (win_h / 2);
min_x = (int) screen().maxLeft();
min_y = (int) screen().maxTop();
max_x = (int) screen().maxRight() - win_w;
max_y = (int) screen().maxBottom() - win_h;
min_x = (int) screen().maxLeft(win.frame().window());
min_y = (int) screen().maxTop(win.frame().window());
max_x = (int) screen().maxRight(win.frame().window()) - win_w;
max_y = (int) screen().maxBottom(win.frame().window()) - win_h;
// keep the window inside the screen