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 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "Window.hh"
@ -326,6 +326,27 @@ FluxboxWindow::~FluxboxWindow() {
void FluxboxWindow::init() { void FluxboxWindow::init() {
m_attaching_tab = 0; m_attaching_tab = 0;
assert(m_client); 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 //!! TODO init of client should be better
// we don't want to duplicate code here and in attachClient // we don't want to duplicate code here and in attachClient
m_clientlist.push_back(m_client); m_clientlist.push_back(m_client);
@ -335,6 +356,8 @@ void FluxboxWindow::init() {
#endif // DEBUG #endif // DEBUG
m_frame.resize(m_client->width(), m_client->height()); m_frame.resize(m_client->width(), m_client->height());
TextButton *btn = new TextButton(m_frame.label(), TextButton *btn = new TextButton(m_frame.label(),
m_frame.theme().font(), m_frame.theme().font(),
@ -514,8 +537,27 @@ void FluxboxWindow::init() {
// no focus default // no focus default
setFocusFlag(false); 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 /// attach a client to this window and destroy old window
void FluxboxWindow::attachClient(WinClient &client) { void FluxboxWindow::attachClient(WinClient &client) {
//!! TODO: check for isGroupable in client //!! TODO: check for isGroupable in client
@ -1122,6 +1164,8 @@ void FluxboxWindow::moveResize(int new_x, int new_y,
if (send_event && ! moving) { if (send_event && ! moving) {
sendConfigureNotify(); sendConfigureNotify();
} }
shape();
} }
bool FluxboxWindow::setInputFocus() { bool FluxboxWindow::setInputFocus() {
@ -1949,7 +1993,36 @@ void FluxboxWindow::handleEvent(XEvent &event) {
propertyNotifyEvent(event.xproperty.atom); propertyNotifyEvent(event.xproperty.atom);
} }
break; break;
default: 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; break;
} }
} }

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef WINDOW_HH
#define WINDOW_HH #define WINDOW_HH
@ -361,6 +361,7 @@ public:
private: private:
void init(); void init();
void shape();
void grabButtons(); void grabButtons();
@ -451,6 +452,8 @@ private:
bool resize, move, iconify, maximize, close; bool resize, move, iconify, maximize, close;
} functions; } 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 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 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 int m_last_button_x, ///< last known x position of the mouse button