support for _NET_WM_MOVERESIZE

This commit is contained in:
fluxgen 2006-06-11 13:09:44 +00:00
parent 9699cda56e
commit 331a52115d
4 changed files with 85 additions and 45 deletions

View file

@ -1,6 +1,8 @@
(Format: Year/Month/Day)
Changes for 0.9.16:
*06/06/11:
* Added support for _NET_WM_MOVERESIZE (Henrik)
Ewmh.hh/cc, Window.hh/cc
* Added support for urgency hint.
This make apps, that support this hint, flash the titlebar and iconbar
when they want attention.

View file

@ -166,7 +166,7 @@ void Ewmh::initForScreen(BScreen &screen) {
m_net_workarea,
m_net_restack_window,
// m_net_wm_moveresize,
m_net_wm_moveresize,
// desktop properties
@ -672,7 +672,9 @@ void Ewmh::updateHints(FluxboxWindow &win) {
}
void Ewmh::updateWorkspace(FluxboxWindow &win) {
long workspace = win.isInitialized() ? win.workspaceNumber() : win.screen().currentWorkspaceID();
long workspace = win.isInitialized() ?
win.workspaceNumber() :
win.screen().currentWorkspaceID();
if (win.isStuck())
workspace = -1; // appear on all desktops/workspaces
@ -713,7 +715,8 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
// which doesn't apply here (so borrow the variable :) )
screen = &fbwin->screen();
// valid workspace number?
if (static_cast<unsigned int>(ce.data.l[0]) < screen->numberOfWorkspaces())
if (static_cast<unsigned int>
(ce.data.l[0]) < screen->numberOfWorkspaces())
screen->sendToWorkspace(ce.data.l[0], fbwin, false);
return true;
@ -846,8 +849,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
return true;
} /* Still in progress...
else if (ce.message_type == m_net_wm_moveresize) {
} else if (ce.message_type == m_net_wm_moveresize) {
if (winclient == 0 || winclient->fbwindow() == 0)
return true;
// data.l[0] = x_root
@ -855,10 +857,6 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
// data.l[2] = direction
// data.l[3] = button
// data.l[4] = source indication
cerr<<"("<<ce.data.l[0]<<", "<<ce.data.l[1]<<")"<<endl;
cerr<<"dir="<<ce.data.l[2]<<endl;
cerr<<"button="<<ce.data.l[3]<<endl;
cerr<<"source="<<ce.data.l[4]<<endl;
switch (ce.data.l[2] ) {
case _NET_WM_MOVERESIZE_SIZE_TOPLEFT:
case _NET_WM_MOVERESIZE_SIZE_TOP:
@ -883,7 +881,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
}
return true;
}
*/
// we didn't handle the ce.message_type here
return false;
}
@ -929,7 +927,7 @@ void Ewmh::createAtoms() {
m_net_moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
m_net_restack_window = XInternAtom(disp, "_NET_RESTACK_WINDOW", False);
// TODO: implement this one
m_net_wm_moveresize = XInternAtom(disp, "_NET_WM_MOVERESIZE", False);
m_net_properties = XInternAtom(disp, "_NET_PROPERTIES", False);

View file

@ -1158,8 +1158,6 @@ void FluxboxWindow::updateTitleFromClient(WinClient &client) {
m_labelbuttons[&client]->setText(client.title());
if (&client == m_client)
frame().setFocusTitle(client.title());
titleSig().notify();
}
}
@ -1734,7 +1732,7 @@ void FluxboxWindow::maximize(int type) {
m_last_resize_w = new_w;
m_last_resize_h = new_h;
ResizeCorner old_resize_corner = m_resize_corner;
ResizeDirection old_resize_corner = m_resize_corner;
m_resize_corner = NOCORNER;
fixsize();
m_resize_corner = old_resize_corner;
@ -2525,6 +2523,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) {
client.updateIconTitle();
case XA_WM_NAME:
updateTitleFromClient(client);
titleSig().notify();
break;
case XA_WM_NORMAL_HINTS: {
@ -2774,12 +2773,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
!isResizing()) {
if (! isMoving()) {
startMoving(me.window);
// save first event point
m_last_resize_x = me.x_root;
m_last_resize_y = me.y_root;
m_button_grab_x = me.x_root - frame().x() - frame().window().borderWidth();
m_button_grab_y = me.y_root - frame().y() - frame().window().borderWidth();
startMoving(me.x_root, me.y_root);
} else {
int dx = me.x_root - m_button_grab_x,
dy = me.y_root - m_button_grab_y;
@ -2854,22 +2848,33 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
int cx = frame().width() / 2;
int cy = frame().height() / 2;
ResizeDirection resize_corner = RIGHTBOTTOM;
if (me.window == frame().gripRight())
m_resize_corner = RIGHTBOTTOM;
resize_corner = RIGHTBOTTOM;
else if (me.window == frame().gripLeft())
m_resize_corner = LEFTBOTTOM;
resize_corner = LEFTBOTTOM;
else if (screen().getResizeModel() != BScreen::QUADRANTRESIZE) {
if (screen().getResizeModel() == BScreen::CENTERRESIZE)
m_resize_corner = ALLCORNERS;
resize_corner = ALLCORNERS;
else
m_resize_corner = RIGHTBOTTOM;
resize_corner = RIGHTBOTTOM;
} else if (me.x < cx)
m_resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
resize_corner = (me.y < cy) ? LEFTTOP : LEFTBOTTOM;
else
m_resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
resize_corner = (me.y < cy) ? RIGHTTOP : RIGHTBOTTOM;
startResizing(me.window, me.x, me.y);
// We are grabbing frame window in startResizing
// we need to translate coordinates to it.
int start_x = me.x, start_y = me.y;
Window child;
XTranslateCoordinates(display,
me.window, fbWindow().window(),
start_x, start_y,
&start_x, &start_y,
&child);
startResizing(start_x, start_y, resize_corner);
} else if (resizing) {
@ -3236,10 +3241,16 @@ void FluxboxWindow::setDecorationMask(unsigned int mask) {
applyDecorations();
}
void FluxboxWindow::startMoving(Window win) {
void FluxboxWindow::startMoving(int x, int y) {
if (s_num_grabs > 0)
return;
// save first event point
m_last_resize_x = x;
m_last_resize_y = y;
m_button_grab_x = x - frame().x() - frame().window().borderWidth();
m_button_grab_y = y - frame().y() - frame().window().borderWidth();
moving = true;
maximized = MAX_NONE;
@ -3498,11 +3509,13 @@ void FluxboxWindow::doSnapping(int &orig_left, int &orig_top) {
}
void FluxboxWindow::startResizing(Window win, int x, int y) {
void FluxboxWindow::startResizing(int x, int y, ResizeDirection dir) {
if (s_num_grabs > 0 || isShaded() || isIconic() )
return;
m_resize_corner = dir;
resizing = true;
maximized = MAX_NONE;
@ -3511,7 +3524,8 @@ void FluxboxWindow::startResizing(Window win, int x, int y) {
(m_resize_corner == RIGHTBOTTOM) ? frame().theme().lowerRightAngleCursor() :
frame().theme().lowerLeftAngleCursor();
grabPointer(win, false, ButtonMotionMask | ButtonReleaseMask,
grabPointer(fbWindow().window(),
false, ButtonMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
int gx = 0, gy = 0;

View file

@ -134,13 +134,18 @@ public:
DECORM_LAST = (1<<11) // useful for getting "All"
};
enum ResizeCorner {
NOCORNER,
LEFTTOP,
LEFTBOTTOM,
RIGHTBOTTOM,
RIGHTTOP,
ALLCORNERS
enum ResizeDirection {
NOCORNER = -1,
LEFTTOP = 0,
TOP = 1,
RIGHTTOP = 2,
RIGHT = 3,
RIGHTBOTTOM = 4,
BOTTOM = 5,
LEFTBOTTOM = 6,
LEFT = 7,
ALLCORNERS = 8
};
typedef struct _blackbox_hints {
@ -274,6 +279,26 @@ public:
unsigned int decorationMask() const;
void setDecorationMask(unsigned int mask);
/**
* Start moving process, grabs the pointer and draws move rectangle
* @param x position of pointer
* @param y position of pointer
*/
void startMoving(int x, int y);
/**
* Stop moving process
* @param interrupted whether the move was interrupted by hide or destroy
*/
void stopMoving(bool interrupted = false);
/**
* Starts resizing process
* @param x start position
* @param y start position
* @param dir the resize direction
*/
void startResizing(int x, int y, ResizeDirection dir);
/// stops the resizing
void stopResizing(bool interrupted = false);
/**
@name accessors
@ -410,10 +435,6 @@ private:
void updateClientLeftWindow();
void grabButtons();
void startMoving(Window win);
void stopMoving(bool interrupted = false);
void startResizing(Window win, int x, int y);
void stopResizing(bool interrupted = false);
/// try to attach current attaching client to a window at pos x, y
void attachTo(int x, int y, bool interrupted = false);
@ -452,8 +473,13 @@ private:
void associateClient(WinClient &client);
// state and hint signals
WinSubject m_hintsig, m_statesig, m_layersig, m_workspacesig,
m_diesig, m_focussig, m_titlesig, m_attentionsig;
WinSubject m_hintsig,
m_statesig,
m_layersig,
m_workspacesig,
m_diesig, m_focussig,
m_titlesig,
m_attentionsig;
class ThemeListener: public FbTk::Observer {
public:
@ -524,7 +550,7 @@ private:
FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window")
ResizeCorner m_resize_corner;
ResizeDirection m_resize_corner;
static int s_num_grabs; ///< number of XGrabPointer's
};