added better shape support

This commit is contained in:
fluxgen 2003-05-14 14:43:06 +00:00
parent 615ec14ab2
commit 54acafe5a8
2 changed files with 80 additions and 4 deletions

View file

@ -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
&not_used, &not_used, // xbs, ybs
&not_used2, &not_used2, // wbs, hbs
&not_used, // cShaped
&not_used, &not_used, // xcs, ycs
&not_used2, &not_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;
}
}

View file

@ -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