diff options
author | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
commit | 1b063dcea92e0a7ac5008518fc5c13f03c055f54 (patch) | |
tree | 29d5b622c0870f06a94086ed463ab90e23bc673e /src/Window.cc | |
parent | 5244fc32447d2649a52a06dc84d96da94e9fd715 (diff) | |
download | fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.zip fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.tar.bz2 |
Integration of new Layering code, plus updates to the layering code itself
- new KeyActions: Raise/LowerLayer, AlwaysOnTop/Bottom, Top/BottomLayer
Added a "Quit" KeyAction
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 108 |
1 files changed, 80 insertions, 28 deletions
diff --git a/src/Window.cc b/src/Window.cc index 8d1069e..ca26e5a 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Window.cc,v 1.112 2003/01/10 20:20:37 fluxgen Exp $ | 25 | // $Id: Window.cc,v 1.113 2003/02/02 16:32:39 rathnor Exp $ |
26 | 26 | ||
27 | #include "Window.hh" | 27 | #include "Window.hh" |
28 | 28 | ||
@@ -99,6 +99,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
99 | FbTk::MenuTheme &menutheme): | 99 | FbTk::MenuTheme &menutheme): |
100 | m_hintsig(*this), | 100 | m_hintsig(*this), |
101 | m_statesig(*this), | 101 | m_statesig(*this), |
102 | m_layersig(*this), | ||
102 | m_workspacesig(*this), | 103 | m_workspacesig(*this), |
103 | m_diesig(*this), | 104 | m_diesig(*this), |
104 | moving(false), resizing(false), shaded(false), maximized(false), | 105 | moving(false), resizing(false), shaded(false), maximized(false), |
@@ -109,7 +110,9 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
109 | display(0), | 110 | display(0), |
110 | lastButtonPressTime(0), | 111 | lastButtonPressTime(0), |
111 | m_windowmenu(menutheme, screen_num, imgctrl), | 112 | m_windowmenu(menutheme, screen_num, imgctrl), |
112 | m_layer(LAYER_NORMAL), old_decoration(DECOR_NORMAL), | 113 | m_layeritem(0), |
114 | m_layernum(4), | ||
115 | old_decoration(DECOR_NORMAL), | ||
113 | tab(0), | 116 | tab(0), |
114 | m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100) { | 117 | m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100) { |
115 | 118 | ||
@@ -150,13 +153,18 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
150 | client.mwm_hint = 0; | 153 | client.mwm_hint = 0; |
151 | client.blackbox_hint = 0; | 154 | client.blackbox_hint = 0; |
152 | Fluxbox *fluxbox = Fluxbox::instance(); | 155 | Fluxbox *fluxbox = Fluxbox::instance(); |
156 | |||
157 | // default to normal layer | ||
158 | m_layernum = fluxbox->getNormalLayer(); | ||
153 | 159 | ||
154 | getBlackboxHints(); | 160 | getBlackboxHints(); |
155 | if (! client.blackbox_hint) | 161 | if (! client.blackbox_hint) { |
156 | getMWMHints(); | 162 | getMWMHints(); |
163 | } | ||
157 | 164 | ||
158 | // get size, aspect, minimum/maximum size and other hints set | 165 | // get size, aspect, minimum/maximum size and other hints set |
159 | // by the client | 166 | // by the client |
167 | |||
160 | getWMProtocols(); | 168 | getWMProtocols(); |
161 | getWMHints(); | 169 | getWMHints(); |
162 | getWMNormalHints(); | 170 | getWMNormalHints(); |
@@ -206,7 +214,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
206 | } | 214 | } |
207 | 215 | ||
208 | upsize(); | 216 | upsize(); |
209 | 217 | ||
210 | bool place_window = true; | 218 | bool place_window = true; |
211 | if (fluxbox->isStartup() || transient || | 219 | if (fluxbox->isStartup() || transient || |
212 | client.normal_hint_flags & (PPosition|USPosition)) { | 220 | client.normal_hint_flags & (PPosition|USPosition)) { |
@@ -241,13 +249,18 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
241 | associateClientWindow(); | 249 | associateClientWindow(); |
242 | 250 | ||
243 | grabButtons(); | 251 | grabButtons(); |
244 | 252 | ||
245 | positionWindows(); | 253 | positionWindows(); |
246 | 254 | ||
255 | m_layeritem = new FbTk::XLayerItem(getFrameWindow()); | ||
256 | |||
247 | if (workspace_number < 0 || workspace_number >= screen->getCount()) | 257 | if (workspace_number < 0 || workspace_number >= screen->getCount()) |
248 | screen->getCurrentWorkspace()->addWindow(this, place_window); | 258 | workspace_number = screen->getCurrentWorkspaceID(); |
249 | else | 259 | |
250 | screen->getWorkspace(workspace_number)->addWindow(this, place_window); | 260 | restoreAttributes(place_window); |
261 | |||
262 | screen->moveWindowToLayer(this, m_layernum); | ||
263 | screen->getWorkspace(workspace_number)->addWindow(this, place_window); | ||
251 | 264 | ||
252 | moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); | 265 | moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); |
253 | 266 | ||
@@ -267,10 +280,13 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, FbTk::ImageCo | |||
267 | deiconify(); //we're omnipresent and visible | 280 | deiconify(); //we're omnipresent and visible |
268 | } | 281 | } |
269 | 282 | ||
283 | setState(current_state); | ||
284 | |||
270 | // no focus default | 285 | // no focus default |
271 | setFocusFlag(false); | 286 | setFocusFlag(false); |
272 | 287 | ||
273 | // finaly show the frame and the client window | 288 | // finaly show the frame and the client window |
289 | |||
274 | m_frame.show(); | 290 | m_frame.show(); |
275 | XSync(display, False); | 291 | XSync(display, False); |
276 | } | 292 | } |
@@ -342,6 +358,15 @@ FluxboxWindow::~FluxboxWindow() { | |||
342 | if (client.window) | 358 | if (client.window) |
343 | fluxbox->removeWindowSearch(client.window); | 359 | fluxbox->removeWindowSearch(client.window); |
344 | 360 | ||
361 | if (m_layeritem) { | ||
362 | m_layeritem->removeWindow(getFrameWindow()); | ||
363 | //if (hasTab()) | ||
364 | // m_layeritem->removeWindow(get tab window) | ||
365 | if (m_layeritem->isEmpty()) { | ||
366 | screen->removeLayerItem(m_layeritem); | ||
367 | } | ||
368 | } | ||
369 | |||
345 | #ifdef DEBUG | 370 | #ifdef DEBUG |
346 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; | 371 | cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; |
347 | #endif // DEBUG | 372 | #endif // DEBUG |
@@ -732,6 +757,8 @@ void FluxboxWindow::getBlackboxHints() { | |||
732 | if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_WORKSPACE) | 757 | if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_WORKSPACE) |
733 | workspace_number = client.blackbox_hint->workspace; | 758 | workspace_number = client.blackbox_hint->workspace; |
734 | 759 | ||
760 | if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_STACK) | ||
761 | workspace_number = client.blackbox_hint->stack; | ||
735 | 762 | ||
736 | if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_DECORATION) { | 763 | if (client.blackbox_hint->flags & BaseDisplay::ATTRIB_DECORATION) { |
737 | old_decoration = static_cast<Decoration>(client.blackbox_hint->decoration); | 764 | old_decoration = static_cast<Decoration>(client.blackbox_hint->decoration); |
@@ -1093,6 +1120,19 @@ void FluxboxWindow::setWorkspace(int n) { | |||
1093 | m_workspacesig.notify(); | 1120 | m_workspacesig.notify(); |
1094 | } | 1121 | } |
1095 | 1122 | ||
1123 | void FluxboxWindow::setLayerNum(int layernum) { | ||
1124 | m_layernum = layernum; | ||
1125 | |||
1126 | blackbox_attrib.flags |= BaseDisplay::ATTRIB_STACK; | ||
1127 | blackbox_attrib.stack = layernum; | ||
1128 | saveBlackboxHints(); | ||
1129 | |||
1130 | #ifdef DEBUG | ||
1131 | cerr<<this<<" notify layer signal"<<endl; | ||
1132 | #endif // DEBUG | ||
1133 | |||
1134 | m_layersig.notify(); | ||
1135 | } | ||
1096 | 1136 | ||
1097 | void FluxboxWindow::shade() { | 1137 | void FluxboxWindow::shade() { |
1098 | if (decorations.titlebar) { | 1138 | if (decorations.titlebar) { |
@@ -1147,18 +1187,13 @@ void FluxboxWindow::lower() { | |||
1147 | if (isIconic()) | 1187 | if (isIconic()) |
1148 | deiconify(); | 1188 | deiconify(); |
1149 | 1189 | ||
1150 | screen->getWorkspace(workspace_number)->lowerWindow(this); | 1190 | screen->lowerWindow(this); |
1151 | if (hasTab()) | ||
1152 | getTab()->lower(); //lower the tab AND it's windows | ||
1153 | } | 1191 | } |
1154 | 1192 | ||
1155 | void FluxboxWindow::raise() { | 1193 | void FluxboxWindow::raise() { |
1156 | if (isIconic()) | 1194 | if (isIconic()) |
1157 | deiconify(); | 1195 | deiconify(); |
1158 | screen->getWorkspace(workspace_number)->raiseWindow(this); | 1196 | screen->raiseWindow(this); |
1159 | //raise tab first if there is any | ||
1160 | if (hasTab()) | ||
1161 | tab->raise(); | ||
1162 | } | 1197 | } |
1163 | 1198 | ||
1164 | void FluxboxWindow::setFocusFlag(bool focus) { | 1199 | void FluxboxWindow::setFocusFlag(bool focus) { |
@@ -1214,6 +1249,13 @@ void FluxboxWindow::installColormap(bool install) { | |||
1214 | fluxbox->ungrab(); | 1249 | fluxbox->ungrab(); |
1215 | } | 1250 | } |
1216 | 1251 | ||
1252 | void FluxboxWindow::saveBlackboxHints() { | ||
1253 | Fluxbox *fluxbox = Fluxbox::instance(); | ||
1254 | XChangeProperty(display, client.window, fluxbox->getFluxboxAttributesAtom(), | ||
1255 | fluxbox->getFluxboxAttributesAtom(), 32, PropModeReplace, | ||
1256 | (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); | ||
1257 | } | ||
1258 | |||
1217 | 1259 | ||
1218 | void FluxboxWindow::setState(unsigned long new_state) { | 1260 | void FluxboxWindow::setState(unsigned long new_state) { |
1219 | current_state = new_state; | 1261 | current_state = new_state; |
@@ -1225,10 +1267,7 @@ void FluxboxWindow::setState(unsigned long new_state) { | |||
1225 | fluxbox->getWMStateAtom(), 32, PropModeReplace, | 1267 | fluxbox->getWMStateAtom(), 32, PropModeReplace, |
1226 | (unsigned char *) state, 2); | 1268 | (unsigned char *) state, 2); |
1227 | 1269 | ||
1228 | XChangeProperty(display, client.window, fluxbox->getFluxboxAttributesAtom(), | 1270 | saveBlackboxHints(); |
1229 | fluxbox->getFluxboxAttributesAtom(), 32, PropModeReplace, | ||
1230 | (unsigned char *) &blackbox_attrib, PropBlackboxAttributesElements); | ||
1231 | |||
1232 | //notify state changed | 1271 | //notify state changed |
1233 | m_statesig.notify(); | 1272 | m_statesig.notify(); |
1234 | } | 1273 | } |
@@ -1328,8 +1367,12 @@ void FluxboxWindow::setGravityOffsets() { | |||
1328 | m_frame.move(newx, newy); | 1367 | m_frame.move(newx, newy); |
1329 | } | 1368 | } |
1330 | 1369 | ||
1331 | 1370 | /* | |
1332 | void FluxboxWindow::restoreAttributes() { | 1371 | * restoreAttributes sets the attributes to what they should be |
1372 | * but doesn't change the actual state | ||
1373 | * (so the caller can set defaults etc as well) | ||
1374 | */ | ||
1375 | void FluxboxWindow::restoreAttributes(bool place_window) { | ||
1333 | if (!getState()) | 1376 | if (!getState()) |
1334 | current_state = NormalState; | 1377 | current_state = NormalState; |
1335 | 1378 | ||
@@ -1363,15 +1406,14 @@ void FluxboxWindow::restoreAttributes() { | |||
1363 | int save_state = | 1406 | int save_state = |
1364 | ((current_state == IconicState) ? NormalState : current_state); | 1407 | ((current_state == IconicState) ? NormalState : current_state); |
1365 | 1408 | ||
1366 | shaded = false; | 1409 | shaded = true; |
1367 | shade(); | ||
1368 | 1410 | ||
1369 | current_state = save_state; | 1411 | current_state = save_state; |
1370 | } | 1412 | } |
1371 | 1413 | ||
1372 | if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && | 1414 | if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && |
1373 | ( blackbox_attrib.workspace < screen->getCount())) { | 1415 | ( blackbox_attrib.workspace < screen->getCount())) { |
1374 | screen->reassociateWindow(this, blackbox_attrib.workspace, true); | 1416 | workspace_number = blackbox_attrib.workspace; |
1375 | 1417 | ||
1376 | if (current_state == NormalState) current_state = WithdrawnState; | 1418 | if (current_state == NormalState) current_state = WithdrawnState; |
1377 | } else if (current_state == WithdrawnState) | 1419 | } else if (current_state == WithdrawnState) |
@@ -1379,12 +1421,16 @@ void FluxboxWindow::restoreAttributes() { | |||
1379 | 1421 | ||
1380 | if (blackbox_attrib.flags & BaseDisplay::ATTRIB_OMNIPRESENT && | 1422 | if (blackbox_attrib.flags & BaseDisplay::ATTRIB_OMNIPRESENT && |
1381 | blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) { | 1423 | blackbox_attrib.attrib & BaseDisplay::ATTRIB_OMNIPRESENT) { |
1382 | stuck = false; | 1424 | stuck = true; |
1383 | stick(); | ||
1384 | 1425 | ||
1385 | current_state = NormalState; | 1426 | current_state = NormalState; |
1386 | } | 1427 | } |
1387 | 1428 | ||
1429 | if (blackbox_attrib.flags & BaseDisplay::ATTRIB_STACK) { | ||
1430 | //TODO check value? | ||
1431 | m_layernum = blackbox_attrib.stack; | ||
1432 | } | ||
1433 | |||
1388 | if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) || | 1434 | if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) || |
1389 | (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) { | 1435 | (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) { |
1390 | int x = blackbox_attrib.premax_x, y = blackbox_attrib.premax_y; | 1436 | int x = blackbox_attrib.premax_x, y = blackbox_attrib.premax_y; |
@@ -1392,7 +1438,7 @@ void FluxboxWindow::restoreAttributes() { | |||
1392 | maximized = false; | 1438 | maximized = false; |
1393 | if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) && | 1439 | if ((blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) && |
1394 | (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) | 1440 | (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT)) |
1395 | maximize(); | 1441 | maximized = true; |
1396 | else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT) | 1442 | else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXVERT) |
1397 | maximizeVertical(); | 1443 | maximizeVertical(); |
1398 | else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) | 1444 | else if (blackbox_attrib.flags & BaseDisplay::ATTRIB_MAXHORIZ) |
@@ -2221,7 +2267,7 @@ void FluxboxWindow::restore(bool remap) { | |||
2221 | if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify, | 2267 | if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify, |
2222 | &dummy)) { | 2268 | &dummy)) { |
2223 | #ifdef DEBUG | 2269 | #ifdef DEBUG |
2224 | cerr<<"FluxboxWindow::restore: reparent 0x"<<hex<<client.window<<dec<<"to root"<<endl; | 2270 | cerr<<"FluxboxWindow::restore: reparent 0x"<<hex<<client.window<<dec<<" to root"<<endl; |
2225 | #endif // DEBUG | 2271 | #endif // DEBUG |
2226 | 2272 | ||
2227 | // reparent to screen window | 2273 | // reparent to screen window |
@@ -2282,6 +2328,12 @@ void FluxboxWindow::changeBlackboxHints(const BaseDisplay::BlackboxHints &net) { | |||
2282 | deiconify(); | 2328 | deiconify(); |
2283 | } | 2329 | } |
2284 | 2330 | ||
2331 | if (net.flags & BaseDisplay::ATTRIB_STACK) { | ||
2332 | if ((unsigned int) m_layernum != net.stack) { | ||
2333 | screen->moveWindowToLayer(this, net.stack); | ||
2334 | } | ||
2335 | } | ||
2336 | |||
2285 | if (net.flags & BaseDisplay::ATTRIB_DECORATION) { | 2337 | if (net.flags & BaseDisplay::ATTRIB_DECORATION) { |
2286 | old_decoration = static_cast<Decoration>(net.decoration); | 2338 | old_decoration = static_cast<Decoration>(net.decoration); |
2287 | setDecoration(old_decoration); | 2339 | setDecoration(old_decoration); |