aboutsummaryrefslogtreecommitdiff
path: root/src/ScreenPlacement.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2011-02-24 10:21:16 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-02-24 10:21:16 (GMT)
commitf0ffaf890f65d9902ba23e2cd019de5ddba071c5 (patch)
treeecfbba4c6b1f60f5f3d259c8d9e2ef77ec261d54 /src/ScreenPlacement.cc
parent49623390b623bcf4851e5cdd972e4c37d5103ecf (diff)
downloadfluxbox-f0ffaf890f65d9902ba23e2cd019de5ddba071c5.zip
fluxbox-f0ffaf890f65d9902ba23e2cd019de5ddba071c5.tar.bz2
moved Menu placement into ScreenPlacement::placeAndShowMenu()
Diffstat (limited to 'src/ScreenPlacement.cc')
-rw-r--r--src/ScreenPlacement.cc49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/ScreenPlacement.cc b/src/ScreenPlacement.cc
index 3e0c377..46ff718 100644
--- a/src/ScreenPlacement.cc
+++ b/src/ScreenPlacement.cc
@@ -30,6 +30,8 @@
30#include "Screen.hh" 30#include "Screen.hh"
31#include "Window.hh" 31#include "Window.hh"
32 32
33#include "FbTk/Menu.hh"
34
33#include <iostream> 35#include <iostream>
34#include <exception> 36#include <exception>
35#ifdef HAVE_CSTRING 37#ifdef HAVE_CSTRING
@@ -51,7 +53,8 @@ ScreenPlacement::ScreenPlacement(BScreen &screen):
51 screen.name()+".windowPlacement", 53 screen.name()+".windowPlacement",
52 screen.altName()+".WindowPlacement"), 54 screen.altName()+".WindowPlacement"),
53 m_old_policy(ROWSMARTPLACEMENT), 55 m_old_policy(ROWSMARTPLACEMENT),
54 m_strategy(0) 56 m_strategy(0),
57 m_screen(screen)
55{ 58{
56} 59}
57 60
@@ -128,7 +131,51 @@ bool ScreenPlacement::placeWindow(const FluxboxWindow &win, int head,
128 return true; 131 return true;
129} 132}
130 133
134bool ScreenPlacement::placeAndShowMenu(FbTk::Menu& menu, int x, int y, bool respect_struts) {
135
136 int head = m_screen.getHead(x, y);
137
138 menu.setScreen(m_screen.getHeadX(head),
139 m_screen.getHeadY(head),
140 m_screen.getHeadWidth(head),
141 m_screen.getHeadHeight(head));
142
143 menu.updateMenu(); // recalculate the size
144
145 x = x - (menu.width() / 2);
146 if (menu.isTitleVisible())
147 y = y - (menu.titleWindow().height() / 2);
148
149 // adjust (x, y) to fit on the screen
150 if (!respect_struts) {
151
152 int bw = 2 * menu.fbwindow().borderWidth();
153 std::pair<int, int> pos = m_screen.clampToHead(head, x, y, menu.width() + bw, menu.height() + bw);
154 x = pos.first;
155 y = pos.second;
131 156
157 } else { // do not cover toolbar if no title
158
159 int top = static_cast<signed>(m_screen.maxTop(head));
160 int bottom = static_cast<signed>(m_screen.maxBottom(head));
161 int left = static_cast<signed>(m_screen.maxLeft(head));
162 int right = static_cast<signed>(m_screen.maxRight(head));
163
164 if (y < top)
165 y = top;
166 else if (y + static_cast<signed>(menu.height()) >= bottom)
167 y = bottom - menu.height() - 1 - menu.fbwindow().borderWidth();
168
169 if (x < left)
170 x = left;
171 else if (x + static_cast<signed>(menu.width()) >= right)
172 x = right - static_cast<int>(menu.width()) - 1;
173 }
174
175 menu.move(x, y);
176 menu.show();
177 menu.grabInputFocus();
178}
132 179
133////////////////////// Placement Resources 180////////////////////// Placement Resources
134namespace FbTk { 181namespace FbTk {