From c91926cf71dcaaea2cf6e56e74b1de50ff17f6f5 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Fri, 3 Oct 2008 20:48:38 -0700 Subject: fix flickering of shaped windows on focus changes --- ChangeLog | 3 +++ src/FbTk/Shape.cc | 71 ++++++++++++++++++++++++++----------------------------- src/FbWinFrame.cc | 6 ----- src/FbWinFrame.hh | 2 -- src/Window.cc | 13 +++++----- 5 files changed, 44 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index a734149..c4f3ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1.2 +*08/10/04: + * Fix flickering of shaped windows, #2131548 and #2001027 (Mark) + FbTk/Shape.cc *08/10/01: * Don't flash original window while cycling (Mark) FocusControl.cc FbTk/XLayer.cc/hh diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc index 7c14832..6bb63aa 100644 --- a/src/FbTk/Shape.cc +++ b/src/FbTk/Shape.cc @@ -190,32 +190,23 @@ void Shape::update() { return; } + Region clip = XCreateRegion(); + Region bound = XCreateRegion(); + XRectangle rect; rect.x = 0; rect.y = 0; rect.width = width; rect.height = height; - XShapeCombineRectangles(display, - m_win->window(), ShapeClip, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSet, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + XUnionRectWithRegion(&rect, clip, clip); rect.x = -bw; rect.y = -bw; rect.width = width+2*bw; rect.height = height+2*bw; - XShapeCombineRectangles(display, - m_win->window(), ShapeBounding, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSet, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + XUnionRectWithRegion(&rect, bound, bound); if (m_shapesource != 0) { @@ -229,45 +220,51 @@ void Shape::update() { rect.width = m_shapesource->width(); rect.height = m_shapesource->height(); - XShapeCombineRectangles(display, - m_win->window(), ShapeClip, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSubtract, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); + Region clientarea = XCreateRegion(); + XUnionRectWithRegion(&rect, clientarea, clientarea); + XSubtractRegion(clip, clientarea, clip); + XSubtractRegion(bound, clientarea, bound); + XDestroyRegion(clientarea); XShapeCombineShape(display, m_win->window(), ShapeClip, rect.x, rect.y, // xOff, yOff m_shapesource->window(), - ShapeClip, ShapeUnion); + ShapeClip, ShapeSet); + + XShapeCombineRegion(display, + m_win->window(), ShapeClip, + 0, 0, // offsets + clip, ShapeUnion); /* Now the bounding rectangle. Note that the frame has a shared border with the region above the client (i.e. titlebar), so we don't want to wipe the shared border, hence the adjustments. */ - rect.x = m_shapesource_xoff; // note that the full bounding region is already offset by a -borderwidth! - rect.y = m_shapesource_yoff; - rect.width = m_shapesource->width(); // we don't wipe the outer bounding region [i think] - rect.height = m_shapesource->height(); - - // we want to delete the client area, dont care about borders really - XShapeCombineRectangles(display, - m_win->window(), ShapeBounding, - 0, 0, /* offsets */ - &rect, - 1, /* number of rectangles */ - ShapeSubtract, /* op */ - 2 /* ordering: YXSorted... only 1: doesn't matter */ ); XShapeCombineShape(display, m_win->window(), ShapeBounding, - rect.x , rect.y, // xOff, yOff + rect.x, rect.y, // xOff, yOff m_shapesource->window(), - ShapeBounding, ShapeUnion); + ShapeBounding, ShapeSet); + + XShapeCombineRegion(display, + m_win->window(), ShapeBounding, + 0, 0, // offsets + bound, ShapeUnion); + } else { + XShapeCombineRegion(display, + m_win->window(), ShapeClip, + 0, 0, // offsets + clip, ShapeSet); + XShapeCombineRegion(display, + m_win->window(), ShapeBounding, + 0, 0, // offsets + bound, ShapeSet); } + XDestroyRegion(clip); + XDestroyRegion(bound); CornerPixmaps &corners = s_corners[m_win->screenNumber()]; #define SHAPECORNER(corner, x, y, shapekind) \ diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 85cd25b..ce25004 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -665,12 +665,6 @@ void FbWinFrame::moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextB m_tab_container.moveItem(&btn, movement); } -void FbWinFrame::setLabelButtonFocus(IconButton &btn) { - if (btn.parent() != &m_tab_container) - return; - m_label.setText(btn.text()); -} - void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { win.setBorderWidth(0); diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index ff9c19e..4cb5c65 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -146,8 +146,6 @@ public: void moveLabelButtonLeftOf(FbTk::TextButton &btn, const FbTk::TextButton &dest); //move the first label button to the right of the second void moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextButton &dest); - /// which button is to be rendered focused - void setLabelButtonFocus(IconButton &btn); /// attach a client window for client area void setClientWindow(FbTk::FbWindow &win); /// remove attached client window diff --git a/src/Window.cc b/src/Window.cc index cd0e708..4606da5 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -409,7 +409,7 @@ void FluxboxWindow::init() { associateClient(*m_client); - frame().setLabelButtonFocus(*m_labelbuttons[m_client]); + frame().setFocusTitle(title()); // redirect events from frame to us frame().setEventHandler(*this); @@ -987,16 +987,17 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) { if (old) old->focusSig().notify(); } - if (old != &client) - titleSig().notify(); #ifdef DEBUG cerr<<"FluxboxWindow::"<<__FUNCTION__<<": labelbutton[client] = "<< button<