From 54acafe5a895bc11225ebcca5db27e25b8234e21 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 14 May 2003 14:43:06 +0000 Subject: added better shape support --- src/Window.cc | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/Window.hh | 7 ++++-- 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.174 2003/05/13 14:05:00 fluxgen Exp $ +// $Id: Window.cc,v 1.175 2003/05/14 14:42:30 fluxgen Exp $ #include "Window.hh" @@ -326,6 +326,27 @@ FluxboxWindow::~FluxboxWindow() { void FluxboxWindow::init() { m_attaching_tab = 0; assert(m_client); + + // check for shape extension and whether the window is shaped + m_shaped = false; +#ifdef SHAPE + if (Fluxbox::instance()->haveShape()) { + Display *disp = FbTk::App::instance()->display(); + int not_used; + unsigned int not_used2; + int shaped; + XShapeSelectInput(disp, m_client->window(), ShapeNotifyMask); + XShapeQueryExtents(disp, m_client->window(), + &shaped, /// bShaped + ¬_used, ¬_used, // xbs, ybs + ¬_used2, ¬_used2, // wbs, hbs + ¬_used, // cShaped + ¬_used, ¬_used, // xcs, ycs + ¬_used2, ¬_used2); // wcs, hcs + m_shaped = (shaped != 0 ? true : false); + } +#endif // SHAPE + //!! TODO init of client should be better // we don't want to duplicate code here and in attachClient m_clientlist.push_back(m_client); @@ -335,6 +356,8 @@ void FluxboxWindow::init() { #endif // DEBUG + + m_frame.resize(m_client->width(), m_client->height()); TextButton *btn = new TextButton(m_frame.label(), m_frame.theme().font(), @@ -403,7 +426,7 @@ void FluxboxWindow::init() { XWindowAttributes wattrib; if (! m_client->getAttrib(wattrib) || !wattrib.screen // no screen? ?? - || wattrib.override_redirect) { // override redirect + || wattrib.override_redirect) { // override redirect return; } @@ -514,8 +537,27 @@ void FluxboxWindow::init() { // no focus default setFocusFlag(false); + if (m_shaped) + shape(); } +/// apply shape to this window +void FluxboxWindow::shape() { +#ifdef SHAPE + if (m_shaped) { + Display *disp = FbTk::App::instance()->display(); + XShapeCombineShape(disp, + m_frame.window().window(), ShapeBounding, + 0, m_frame.clientArea().y(), // xOff, yOff + m_client->window(), + ShapeBounding, ShapeSet); + XFlush(disp); + } +#endif // SHAPE + +} + + /// attach a client to this window and destroy old window void FluxboxWindow::attachClient(WinClient &client) { //!! TODO: check for isGroupable in client @@ -1122,6 +1164,8 @@ void FluxboxWindow::moveResize(int new_x, int new_y, if (send_event && ! moving) { sendConfigureNotify(); } + + shape(); } bool FluxboxWindow::setInputFocus() { @@ -1949,7 +1993,36 @@ void FluxboxWindow::handleEvent(XEvent &event) { propertyNotifyEvent(event.xproperty.atom); } break; + + + default: +#ifdef SHAPE + if (Fluxbox::instance()->haveShape() && + event.type == Fluxbox::instance()->shapeEventbase() + ShapeNotify) { + XShapeEvent *shape_event = (XShapeEvent *)&event; + + if (shape_event->kind != ShapeBounding) + break; + + if (shape_event->shaped) { + m_shaped = true; + shape(); + } else { + m_shaped = false; + // set no shape + Display *disp = FbTk::App::instance()->display(); + XShapeCombineMask(disp, + m_frame.window().window(), ShapeBounding, + 0, 0, + None, ShapeSet); + } + + XSync(FbTk::App::instance()->display(), False); + break; + } +#endif // SHAPE + break; } } 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.71 2003/05/11 13:36:11 fluxgen Exp $ +// $Id: Window.hh,v 1.72 2003/05/14 14:43:06 fluxgen Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -361,6 +361,7 @@ public: private: void init(); + void shape(); void grabButtons(); @@ -450,7 +451,9 @@ private: struct _functions { bool resize, move, iconify, maximize, close; } functions; - + + bool m_shaped; ///< if the window is shaped with a mask + int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state int m_last_button_x, ///< last known x position of the mouse button -- cgit v0.11.2