aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-05-14 14:43:06 (GMT)
committerfluxgen <fluxgen>2003-05-14 14:43:06 (GMT)
commit54acafe5a895bc11225ebcca5db27e25b8234e21 (patch)
tree9dd312354b6ba822e259ade60eb53961b9ae1363
parent615ec14ab26bdff2458457a26c5adfe743154873 (diff)
downloadfluxbox-54acafe5a895bc11225ebcca5db27e25b8234e21.zip
fluxbox-54acafe5a895bc11225ebcca5db27e25b8234e21.tar.bz2
added better shape support
-rw-r--r--src/Window.cc77
-rw-r--r--src/Window.hh7
2 files changed, 80 insertions, 4 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 385565a..a9aa97d 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.174 2003/05/13 14:05:00 fluxgen Exp $ 25// $Id: Window.cc,v 1.175 2003/05/14 14:42:30 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -326,6 +326,27 @@ FluxboxWindow::~FluxboxWindow() {
326void FluxboxWindow::init() { 326void FluxboxWindow::init() {
327 m_attaching_tab = 0; 327 m_attaching_tab = 0;
328 assert(m_client); 328 assert(m_client);
329
330 // check for shape extension and whether the window is shaped
331 m_shaped = false;
332#ifdef SHAPE
333 if (Fluxbox::instance()->haveShape()) {
334 Display *disp = FbTk::App::instance()->display();
335 int not_used;
336 unsigned int not_used2;
337 int shaped;
338 XShapeSelectInput(disp, m_client->window(), ShapeNotifyMask);
339 XShapeQueryExtents(disp, m_client->window(),
340 &shaped, /// bShaped
341 &not_used, &not_used, // xbs, ybs
342 &not_used2, &not_used2, // wbs, hbs
343 &not_used, // cShaped
344 &not_used, &not_used, // xcs, ycs
345 &not_used2, &not_used2); // wcs, hcs
346 m_shaped = (shaped != 0 ? true : false);
347 }
348#endif // SHAPE
349
329 //!! TODO init of client should be better 350 //!! TODO init of client should be better
330 // we don't want to duplicate code here and in attachClient 351 // we don't want to duplicate code here and in attachClient
331 m_clientlist.push_back(m_client); 352 m_clientlist.push_back(m_client);
@@ -335,6 +356,8 @@ void FluxboxWindow::init() {
335 356
336#endif // DEBUG 357#endif // DEBUG
337 358
359
360
338 m_frame.resize(m_client->width(), m_client->height()); 361 m_frame.resize(m_client->width(), m_client->height());
339 TextButton *btn = new TextButton(m_frame.label(), 362 TextButton *btn = new TextButton(m_frame.label(),
340 m_frame.theme().font(), 363 m_frame.theme().font(),
@@ -403,7 +426,7 @@ void FluxboxWindow::init() {
403 XWindowAttributes wattrib; 426 XWindowAttributes wattrib;
404 if (! m_client->getAttrib(wattrib) || 427 if (! m_client->getAttrib(wattrib) ||
405 !wattrib.screen // no screen? ?? 428 !wattrib.screen // no screen? ??
406 || wattrib.override_redirect) { // override redirect 429 || wattrib.override_redirect) { // override redirect
407 return; 430 return;
408 } 431 }
409 432
@@ -514,8 +537,27 @@ void FluxboxWindow::init() {
514 // no focus default 537 // no focus default
515 setFocusFlag(false); 538 setFocusFlag(false);
516 539
540 if (m_shaped)
541 shape();
517} 542}
518 543
544/// apply shape to this window
545void FluxboxWindow::shape() {
546#ifdef SHAPE
547 if (m_shaped) {
548 Display *disp = FbTk::App::instance()->display();
549 XShapeCombineShape(disp,
550 m_frame.window().window(), ShapeBounding,
551 0, m_frame.clientArea().y(), // xOff, yOff
552 m_client->window(),
553 ShapeBounding, ShapeSet);
554 XFlush(disp);
555 }
556#endif // SHAPE
557
558}
559
560
519/// attach a client to this window and destroy old window 561/// attach a client to this window and destroy old window
520void FluxboxWindow::attachClient(WinClient &client) { 562void FluxboxWindow::attachClient(WinClient &client) {
521 //!! TODO: check for isGroupable in client 563 //!! TODO: check for isGroupable in client
@@ -1122,6 +1164,8 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
1122 if (send_event && ! moving) { 1164 if (send_event && ! moving) {
1123 sendConfigureNotify(); 1165 sendConfigureNotify();
1124 } 1166 }
1167
1168 shape();
1125} 1169}
1126 1170
1127bool FluxboxWindow::setInputFocus() { 1171bool FluxboxWindow::setInputFocus() {
@@ -1949,7 +1993,36 @@ void FluxboxWindow::handleEvent(XEvent &event) {
1949 propertyNotifyEvent(event.xproperty.atom); 1993 propertyNotifyEvent(event.xproperty.atom);
1950 } 1994 }
1951 break; 1995 break;
1996
1997
1998
1952 default: 1999 default:
2000#ifdef SHAPE
2001 if (Fluxbox::instance()->haveShape() &&
2002 event.type == Fluxbox::instance()->shapeEventbase() + ShapeNotify) {
2003 XShapeEvent *shape_event = (XShapeEvent *)&event;
2004
2005 if (shape_event->kind != ShapeBounding)
2006 break;
2007
2008 if (shape_event->shaped) {
2009 m_shaped = true;
2010 shape();
2011 } else {
2012 m_shaped = false;
2013 // set no shape
2014 Display *disp = FbTk::App::instance()->display();
2015 XShapeCombineMask(disp,
2016 m_frame.window().window(), ShapeBounding,
2017 0, 0,
2018 None, ShapeSet);
2019 }
2020
2021 XSync(FbTk::App::instance()->display(), False);
2022 break;
2023 }
2024#endif // SHAPE
2025
1953 break; 2026 break;
1954 } 2027 }
1955} 2028}
diff --git a/src/Window.hh b/src/Window.hh
index e6d8633..7285acf 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -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.hh,v 1.71 2003/05/11 13:36:11 fluxgen Exp $ 25// $Id: Window.hh,v 1.72 2003/05/14 14:43:06 fluxgen Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -361,6 +361,7 @@ public:
361 361
362private: 362private:
363 void init(); 363 void init();
364 void shape();
364 365
365 void grabButtons(); 366 void grabButtons();
366 367
@@ -450,7 +451,9 @@ private:
450 struct _functions { 451 struct _functions {
451 bool resize, move, iconify, maximize, close; 452 bool resize, move, iconify, maximize, close;
452 } functions; 453 } functions;
453 454
455 bool m_shaped; ///< if the window is shaped with a mask
456
454 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized 457 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized
455 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state 458 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state
456 int m_last_button_x, ///< last known x position of the mouse button 459 int m_last_button_x, ///< last known x position of the mouse button