From 4c2f4e75372c4814413e3a105a045395e10892ca Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 17 Jan 2003 02:43:31 +0000 Subject: [PATCH] add a getGravity function to get the gravity from the window attributes initially --- src/client.cc | 35 +++++++++++++++++++++++------------ src/client.hh | 2 ++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/client.cc b/src/client.cc index df136bf2..4e44d4bc 100644 --- a/src/client.cc +++ b/src/client.cc @@ -47,6 +47,7 @@ Client::Client(int screen, Window window) // pick a layer to start from _layer = Layer_Normal; + getGravity(); getArea(); getDesktop(); @@ -60,7 +61,6 @@ Client::Client(int screen, Window window) getShaped(); updateProtocols(); - updateNormalHints(); updateWMHints(); updateTitle(); updateIconTitle(); @@ -91,6 +91,17 @@ Client::~Client() } +void Client::getGravity() +{ + XWindowAttributes wattrib; + Status ret; + + ret = XGetWindowAttributes(**otk::display, _window, &wattrib); + assert(ret != BadWindow); + + _gravity = wattrib.win_gravity; +} + void Client::getDesktop() { // defaults to the current desktop @@ -378,7 +389,6 @@ void Client::updateNormalHints() int oldgravity = _gravity; // defaults - _gravity = NorthWestGravity; _size_inc.setPoint(1, 1); _base_size.setPoint(0, 0); _min_size.setPoint(0, 0); @@ -391,8 +401,18 @@ void Client::updateNormalHints() if (XGetWMNormalHints(**otk::display, _window, &size, &ret)) { _positioned = (size.flags & (PPosition|USPosition)); - if (size.flags & PWinGravity) + if (size.flags & PWinGravity) { _gravity = size.win_gravity; + + // if the client has a frame, i.e. has already been mapped and is + // changing its gravity + if (frame && _gravity != oldgravity) { + // move our idea of the client's position based on its new gravity + int x, y; + frame->frameGravity(x, y); + _area.setPos(x, y); + } + } if (size.flags & PMinSize) _min_size.setPoint(size.min_width, size.min_height); @@ -406,15 +426,6 @@ void Client::updateNormalHints() if (size.flags & PResizeInc) _size_inc.setPoint(size.width_inc, size.height_inc); } - - // if the client has a frame, i.e. has already been mapped and is - // changing its gravity - if (frame && _gravity != oldgravity) { - // move our idea of the client's position based on its new gravity - int x, y; - frame->frameGravity(x, y); - _area.setPos(x, y); - } } diff --git a/src/client.hh b/src/client.hh index 9bac56f5..37a38ac1 100644 --- a/src/client.hh +++ b/src/client.hh @@ -311,6 +311,8 @@ private: */ FunctionFlags _functions; + //! Retrieves the window's initial gravity + void getGravity(); //! Retrieves the desktop hint's value and sets Client::_desktop void getDesktop(); //! Retrieves the window's type and sets Client::_type -- 2.39.2