head specific strut, patch from Mathieu De Zutter

This commit is contained in:
fluxgen 2004-09-11 13:45:16 +00:00
parent 3775776963
commit 768d98a39d
8 changed files with 109 additions and 102 deletions

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Ewmh.cc,v 1.50 2004/09/10 15:36:04 akir Exp $ // $Id: Ewmh.cc,v 1.51 2004/09/11 13:34:36 fluxgen Exp $
#include "Ewmh.hh" #include "Ewmh.hh"
@ -829,7 +829,9 @@ void Ewmh::updateStrut(WinClient &winclient) {
&ret_type, &fmt, &nitems, &bytes_after, &ret_type, &fmt, &nitems, &bytes_after,
(unsigned char **) &data) && data) { (unsigned char **) &data) && data) {
winclient.setStrut(winclient.screen().requestStrut(data[0], data[1], int head = winclient.screen().getHead(winclient);
winclient.setStrut(winclient.screen().requestStrut(head,
data[0], data[1],
data[2], data[3])); data[2], data[3]));
winclient.screen().updateAvailableWorkspaceArea(); winclient.screen().updateAvailableWorkspaceArea();
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Menu.cc,v 1.81 2004/09/11 12:33:14 rathnor Exp $ // $Id: Menu.cc,v 1.82 2004/09/11 13:45:16 fluxgen Exp $
//use GNU extensions //use GNU extensions
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
@ -79,6 +79,8 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
m_theme(tm), m_theme(tm),
m_parent(0), m_parent(0),
m_image_ctrl(imgctrl), m_image_ctrl(imgctrl),
m_screen_x(0),
m_screen_y(0),
m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())), m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())),
m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())),
m_alignment(ALIGNDONTCARE), m_alignment(ALIGNDONTCARE),
@ -192,8 +194,6 @@ Menu::~Menu() {
if (menu.sel_pixmap) if (menu.sel_pixmap)
m_image_ctrl.removeImage(menu.sel_pixmap); m_image_ctrl.removeImage(menu.sel_pixmap);
FbTk::EventManager &evm = *FbTk::EventManager::instance();
if (s_focused == this) if (s_focused == this)
s_focused = 0; s_focused = 0;
} }
@ -236,6 +236,7 @@ int Menu::remove(unsigned int index) {
if (item) { if (item) {
menuitems.erase(it); menuitems.erase(it);
if (!internal_menu && item->submenu() != 0) { if (!internal_menu && item->submenu() != 0) {
Menu *tmp = item->submenu(); Menu *tmp = item->submenu();
// if menu is interal we should just hide it instead // if menu is interal we should just hide it instead
@ -797,6 +798,8 @@ void Menu::drawSubmenu(unsigned int index) {
if (item->submenu()->m_parent != this) if (item->submenu()->m_parent != this)
item->submenu()->m_parent = this; item->submenu()->m_parent = this;
item->submenu()->setScreen(m_screen_x, m_screen_y, m_screen_width, m_screen_height);
int sbl = index / menu.persub, i = index - (sbl * menu.persub); int sbl = index / menu.persub, i = index - (sbl * menu.persub);
int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth()); int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth());
int new_y; int new_y;
@ -821,24 +824,26 @@ void Menu::drawSubmenu(unsigned int index) {
height() - item->submenu()->height()); height() - item->submenu()->height());
} }
if ((new_x + item->submenu()->width()) > m_screen_width) { int borderw = item->submenu()->fbwindow().borderWidth();
if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) {
new_x = ((shifted) ? menu.x_shift : x()) - new_x = ((shifted) ? menu.x_shift : x()) -
item->submenu()->width() - menu.window.borderWidth(); item->submenu()->width() - menu.window.borderWidth();
} }
if (new_x < 0) if (new_x < m_screen_x)
new_x = 0; new_x = m_screen_x;
if ((new_y + item->submenu()->height()) > m_screen_height) { if ((new_y + item->submenu()->height()) > m_screen_y + m_screen_height) {
new_y = m_screen_height - item->submenu()->height() - new_y = m_screen_y + m_screen_height - item->submenu()->height() -
menu.window.borderWidth() * 2; menu.window.borderWidth() * 2;
} }
item->submenu()->moving = moving; item->submenu()->moving = moving;
which_sub = index; which_sub = index;
if (new_y < 0) if (new_y < m_screen_y)
new_y = 0; new_y = m_screen_y;
item->submenu()->move(new_x, new_y); item->submenu()->move(new_x, new_y);
if (! moving) if (! moving)
@ -1085,10 +1090,11 @@ void Menu::buttonPressEvent(XButtonEvent &be) {
if (item->submenu()) { if (item->submenu()) {
if (!item->submenu()->isVisible()) if (!item->submenu()->isVisible())
drawSubmenu(w); drawSubmenu(w);
} else } else {
drawItem(w, drawItem(w,
true, // clear true, // clear
true); // render transparency true); // render transparency
}
} }
} else { } else {
@ -1120,14 +1126,10 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
} }
} }
if (re.x >= 0 && re.x <= (signed) width() && if (re.button == 3)
re.y >= 0 && re.y <= (signed) theme().titleHeight() &&
re.button == 3)
hide(); hide();
} else if (re.window == menu.frame && } else if (re.window == menu.frame) {
re.x >= 0 && re.x < (signed) width() &&
re.y >= 0 && re.y < (signed) menu.frame_h) {
int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()),
ix = sbl * menu.item_w, iy = i * theme().itemHeight(), ix = sbl * menu.item_w, iy = i * theme().itemHeight(),
@ -1140,17 +1142,16 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { re.y > iy && re.y < (signed) (iy + theme().itemHeight())) {
menuitems[w]->click(re.button, re.time); menuitems[w]->click(re.button, re.time);
itemSelected(re.button, w); itemSelected(re.button, w);
// just redraw this item
drawItem(w, drawItem(w,
true, // clear true, // clear
true); // transparent true); // transparent
} }
} else { } else {
drawItem(p, drawItem(p,
true, // clear true, // clear
true); // transparent true); // transparent
} }
} else { } else {
drawItem(p, drawItem(p,
true, // clear true, // clear
@ -1284,8 +1285,8 @@ void Menu::enterNotifyEvent(XCrossingEvent &ce) {
return; return;
menu.x_shift = x(), menu.y_shift = y(); menu.x_shift = x(), menu.y_shift = y();
if (x() + width() > m_screen_width) { if (x() + width() > m_screen_x + m_screen_width) {
menu.x_shift = m_screen_width - width() - 2*theme().borderWidth(); menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth();
shifted = true; shifted = true;
} else if (x() < 0) { } else if (x() < 0) {
menu.x_shift = 0; //-theme().borderWidth(); menu.x_shift = 0; //-theme().borderWidth();
@ -1381,6 +1382,7 @@ void Menu::keyPressEvent(XKeyEvent &event) {
} }
} }
void Menu::reconfigure() { void Menu::reconfigure() {
@ -1515,4 +1517,11 @@ void Menu::renderTransp(int x, int y,
} }
void Menu::setScreen(int x, int y, int w, int h) {
m_screen_x = x;
m_screen_y = y;
m_screen_width = w;
m_screen_height = h;
}
}; // end namespace FbTk }; // end namespace FbTk

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Menu.hh,v 1.39 2004/08/29 12:35:29 rathnor Exp $ // $Id: Menu.hh,v 1.40 2004/09/11 13:45:16 fluxgen Exp $
#ifndef FBTK_MENU_HH #ifndef FBTK_MENU_HH
#define FBTK_MENU_HH #define FBTK_MENU_HH
@ -95,6 +95,8 @@ public:
void disableTitle(); void disableTitle();
void enableTitle(); void enableTitle();
void setScreen(int x, int y, int w, int h);
/** /**
@name event handlers @name event handlers
*/ */
@ -200,7 +202,8 @@ private:
ImageControl &m_image_ctrl; ImageControl &m_image_ctrl;
Menuitems menuitems; Menuitems menuitems;
const unsigned int m_screen_width, m_screen_height; int m_screen_x, m_screen_y;
int m_screen_width, m_screen_height;
bool moving; ///< if we're moving/draging or not bool moving; ///< if we're moving/draging or not
bool visible; ///< menu visibility bool visible; ///< menu visibility
bool torn; ///< torn from parent bool torn; ///< torn from parent

View file

@ -113,6 +113,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \
WorkspaceMenu.hh WorkspaceMenu.cc \ WorkspaceMenu.hh WorkspaceMenu.cc \
FocusModelMenuItem.hh \ FocusModelMenuItem.hh \
ToggleMenu.hh \ ToggleMenu.hh \
HeadArea.hh HeadArea.cc \
${newwmspec_SOURCE} ${gnome_SOURCE} \ ${newwmspec_SOURCE} ${gnome_SOURCE} \
${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE}

View file

@ -20,28 +20,35 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Strut.hh,v 1.3 2004/01/19 18:30:59 fluxgen Exp $ // $Id: Strut.hh,v 1.4 2004/09/11 13:36:03 fluxgen Exp $
#ifndef STRUT_HH #ifndef STRUT_HH
#define STRUT_HH #define STRUT_HH
class Strut { class Strut {
public: public:
Strut(int left, int right, Strut(int head, int left, int right,
int top, int bottom):m_left(left), m_right(right), int top, int bottom, Strut* next = 0)
m_top(top), m_bottom(bottom) { } :m_head(head), m_left(left), m_right(right),
m_top(top), m_bottom(bottom), m_next(next) { }
inline int head() const { return m_head; }
inline int left() const { return m_left; } inline int left() const { return m_left; }
inline int right() const { return m_right; } inline int right() const { return m_right; }
inline int bottom() const { return m_bottom; } inline int bottom() const { return m_bottom; }
inline int top() const { return m_top; } inline int top() const { return m_top; }
inline Strut* next() const { return m_next; }
bool operator == (const Strut &test) const { bool operator == (const Strut &test) const {
return (left() == test.left() && return (head() == test.head() &&
left() == test.left() &&
right() == test.right() && right() == test.right() &&
top() == test.top() && top() == test.top() &&
bottom() == test.bottom()); bottom() == test.bottom());
} }
private: private:
Strut():m_head(0), m_left(0), m_right(0), m_top(0), m_bottom(0), m_next(0) {}
int m_head;
int m_left, m_right, m_top, m_bottom; int m_left, m_right, m_top, m_bottom;
Strut *m_next; ///< link to struts on all heads
}; };
#endif // STRUT_HH #endif // STRUT_HH

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: ToolFactory.cc,v 1.7 2004/08/27 14:36:12 rathnor Exp $ // $Id: ToolFactory.cc,v 1.8 2004/09/11 13:40:57 fluxgen Exp $
#include "ToolFactory.hh" #include "ToolFactory.hh"
@ -43,6 +43,8 @@
#include "FbTk/FbWindow.hh" #include "FbTk/FbWindow.hh"
#include <utility>
namespace { namespace {
class ShowMenuAboveToolbar: public FbTk::Command { class ShowMenuAboveToolbar: public FbTk::Command {
public: public:
@ -51,20 +53,18 @@ public:
m_tbar.screen().hideMenus(); m_tbar.screen().hideMenus();
// get last button pos // get last button pos
const XEvent &event = Fluxbox::instance()->lastEvent(); const XEvent &event = Fluxbox::instance()->lastEvent();
int x = event.xbutton.x_root - (m_tbar.menu().width() / 2); int head = m_tbar.screen().getHead(event.xbutton.x_root, event.xbutton.y_root);
int y = event.xbutton.y_root - (m_tbar.menu().height() / 2); std::pair<int, int> m =
m_tbar.screen().clampToHead( head,
if (x < 0) event.xbutton.x_root - (m_tbar.menu().width() / 2),
x = 0; event.xbutton.y_root - (m_tbar.menu().height() / 2),
else if (x + m_tbar.menu().width() > m_tbar.screen().width()) m_tbar.menu().width(),
x = m_tbar.screen().width() - m_tbar.menu().width(); m_tbar.menu().height());
m_tbar.menu().setScreen(m_tbar.screen().getHeadX(head),
if (y < 0) m_tbar.screen().getHeadY(head),
y = 0; m_tbar.screen().getHeadWidth(head),
else if (y + m_tbar.menu().height() > m_tbar.screen().height()) m_tbar.screen().getHeadHeight(head));
y = m_tbar.screen().height() - m_tbar.menu().height(); m_tbar.menu().move(m.first, m.second);
m_tbar.menu().move(x, y);
m_tbar.menu().show(); m_tbar.menu().show();
} }
private: private:

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Toolbar.cc,v 1.153 2004/09/11 13:33:07 fluxgen Exp $ // $Id: Toolbar.cc,v 1.154 2004/09/11 13:34:01 fluxgen Exp $
#include "Toolbar.hh" #include "Toolbar.hh"
@ -488,14 +488,13 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
int head = screen().getHead(be.x_root, be.y_root); int head = screen().getHead(be.x_root, be.y_root);
int borderw = menu().fbwindow().borderWidth(); int borderw = menu().fbwindow().borderWidth();
pair<int, int> m = screen().clampToHead( head, pair<int, int> m = screen().clampToHead(head,
be.x_root - (menu().width() / 2), be.x_root - (menu().width() / 2),
be.y_root - (menu().titleWindow().height() / 2), be.y_root - (menu().titleWindow().height() / 2),
menu().width() + 2*borderw, menu().width() + 2*borderw,
menu().height() + 2*borderw); menu().height() + 2*borderw);
menu().setScreen( menu().setScreen(screen().getHeadX(head),
screen().getHeadX(head),
screen().getHeadY(head), screen().getHeadY(head),
screen().getHeadWidth(head), screen().getHeadWidth(head),
screen().getHeadHeight(head)); screen().getHeadHeight(head));

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: fluxbox.cc,v 1.253 2004/09/11 12:33:14 rathnor Exp $ // $Id: fluxbox.cc,v 1.254 2004/09/11 13:38:58 fluxgen Exp $
#include "fluxbox.hh" #include "fluxbox.hh"
@ -1104,28 +1104,20 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
screen->getRootmenu().hide(); screen->getRootmenu().hide();
} else if (be.button == 2) { } else if (be.button == 2) {
int mx = be.x_root - int borderw = screen->getWorkspacemenu().fbwindow().borderWidth();
(screen->getWorkspacemenu().width() / 2); int head = screen->getHead(be.x_root, be.y_root);
int my = be.y_root -
(screen->getWorkspacemenu().titleWindow().height() / 2);
if (mx < 0) mx = 0; pair<int, int> m =
if (my < 0) my = 0; screen->clampToHead(head,
be.x_root - (screen->getWorkspacemenu().width() / 2),
if (mx + screen->getWorkspacemenu().width() > be.y_root - (screen->getWorkspacemenu().titleWindow().height() / 2),
screen->width()) { screen->getWorkspacemenu().width() + 2*borderw,
mx = screen->width()-1 - screen->getWorkspacemenu().height() + 2*borderw);
screen->getWorkspacemenu().width() - screen->getWorkspacemenu().move(m.first, m.second);
2*screen->getWorkspacemenu().fbwindow().borderWidth(); screen->getWorkspacemenu().setScreen(screen->getHeadX(head),
} screen->getHeadY(head),
screen->getHeadWidth(head),
if (my + screen->getWorkspacemenu().height() > screen->getHeadHeight(head));
screen->height()) {
my = screen->height()-1 -
screen->getWorkspacemenu().height() -
2*screen->getWorkspacemenu().fbwindow().borderWidth();
}
screen->getWorkspacemenu().move(mx, my);
if (! screen->getWorkspacemenu().isVisible()) { if (! screen->getWorkspacemenu().isVisible()) {
screen->getWorkspacemenu().removeParent(); screen->getWorkspacemenu().removeParent();
@ -1135,28 +1127,22 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
} else if (be.button == 3) { } else if (be.button == 3) {
//calculate placement of root menu //calculate placement of root menu
//and show/hide it //and show/hide it
int mx = be.x_root -
(screen->getRootmenu().width() / 2);
int my = be.y_root -
(screen->getRootmenu().titleWindow().height() / 2);
int borderw = screen->getRootmenu().fbwindow().borderWidth(); int borderw = screen->getRootmenu().fbwindow().borderWidth();
int head = screen->getHead(be.x_root, be.y_root);
if (mx < 0) mx = 0; pair<int, int> m =
if (my < 0) my = 0; screen->clampToHead(head,
be.x_root - (screen->getRootmenu().width() / 2),
be.y_root - (screen->getRootmenu().titleWindow().height() / 2),
screen->getRootmenu().width() + 2*borderw,
screen->getRootmenu().height() + 2*borderw);
if (mx + screen->getRootmenu().width() + 2*borderw > screen->width()) { screen->getRootmenu().move(m.first, m.second);
mx = screen->width() - screen->getRootmenu().setScreen(screen->getHeadX(head),
screen->getRootmenu().width() - screen->getHeadY(head),
2*borderw; screen->getHeadWidth(head),
} screen->getHeadHeight(head));
if (my + screen->getRootmenu().height() + 2*borderw >
screen->height()) {
my = screen->height() -
screen->getRootmenu().height() -
2*borderw;
}
screen->getRootmenu().move(mx, my);
if (! screen->getRootmenu().isVisible()) { if (! screen->getRootmenu().isVisible()) {
checkMenu(); checkMenu();