aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r--src/WinClient.cc110
1 files changed, 89 insertions, 21 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 092c10d..60cf647 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinClient.cc,v 1.19 2003/07/21 15:26:56 rathnor Exp $ 22// $Id: WinClient.cc,v 1.20 2003/07/28 15:06:34 rathnor Exp $
23 23
24#include "WinClient.hh" 24#include "WinClient.hh"
25 25
@@ -52,9 +52,10 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
52 initial_state(0), 52 initial_state(0),
53 normal_hint_flags(0), 53 normal_hint_flags(0),
54 wm_hint_flags(0), 54 wm_hint_flags(0),
55 send_focus_message(false),
56 m_win(fbwin), 55 m_win(fbwin),
57 m_modal(0), 56 m_modal(0),
57 send_focus_message(false),
58 closable(false),
58 m_title(""), m_icon_title(""), 59 m_title(""), m_icon_title(""),
59 m_class_name(""), m_instance_name(""), 60 m_class_name(""), m_instance_name(""),
60 m_blackbox_hint(0), 61 m_blackbox_hint(0),
@@ -68,6 +69,10 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
68 updateWMClassHint(); 69 updateWMClassHint();
69 updateTitle(); 70 updateTitle();
70 updateIconTitle(); 71 updateIconTitle();
72 Fluxbox::instance()->saveWindowSearch(win, this);
73 if (window_group != None)
74 Fluxbox::instance()->saveGroupSearch(window_group, this);
75
71} 76}
72 77
73WinClient::~WinClient() { 78WinClient::~WinClient() {
@@ -77,6 +82,8 @@ WinClient::~WinClient() {
77 82
78 FbTk::EventManager::instance()->remove(window()); 83 FbTk::EventManager::instance()->remove(window());
79 84
85 clearStrut();
86
80 if (m_win != 0) 87 if (m_win != 0)
81 m_win->removeClient(*this); 88 m_win->removeClient(*this);
82 89
@@ -160,22 +167,27 @@ bool WinClient::sendFocus() {
160 return true; 167 return true;
161} 168}
162 169
163void WinClient::sendClose() { 170void WinClient::sendClose(bool forceful) {
164 Display *disp = FbTk::App::instance()->display(); 171 if (forceful || !isClosable())
165 // fill in XClientMessage structure for delete message 172 XKillClient(FbTk::App::instance()->display(), window());
166 XEvent ce; 173 else {
167 ce.xclient.type = ClientMessage; 174 // send WM_DELETE message
168 ce.xclient.message_type = FbAtoms::instance()->getWMProtocolsAtom(); 175 Display *disp = FbTk::App::instance()->display();
169 ce.xclient.display = disp; 176 // fill in XClientMessage structure for delete message
170 ce.xclient.window = window(); 177 XEvent ce;
171 ce.xclient.format = 32; 178 ce.xclient.type = ClientMessage;
172 ce.xclient.data.l[0] = FbAtoms::instance()->getWMDeleteAtom(); 179 ce.xclient.message_type = FbAtoms::instance()->getWMProtocolsAtom();
173 ce.xclient.data.l[1] = CurrentTime; 180 ce.xclient.display = disp;
174 ce.xclient.data.l[2] = 0l; 181 ce.xclient.window = window();
175 ce.xclient.data.l[3] = 0l; 182 ce.xclient.format = 32;
176 ce.xclient.data.l[4] = 0l; 183 ce.xclient.data.l[0] = FbAtoms::instance()->getWMDeleteAtom();
177 // send event delete message to client window 184 ce.xclient.data.l[1] = CurrentTime;
178 XSendEvent(disp, window(), false, NoEventMask, &ce); 185 ce.xclient.data.l[2] = 0l;
186 ce.xclient.data.l[3] = 0l;
187 ce.xclient.data.l[4] = 0l;
188 // send event delete message to client window
189 XSendEvent(disp, window(), false, NoEventMask, &ce);
190 }
179} 191}
180 192
181void WinClient::reparent(Window win, int x, int y) { 193void WinClient::reparent(Window win, int x, int y) {
@@ -251,9 +263,8 @@ void WinClient::updateTransientInfo() {
251 return; 263 return;
252 } 264 }
253 265
254 FluxboxWindow *transient_win = Fluxbox::instance()->searchWindow(win); 266
255 if (transient_win) 267 transient_for = Fluxbox::instance()->searchWindow(win);
256 transient_for = transient_win->findClient(win);
257 268
258 // make sure we don't have deadlock loop in transient chain 269 // make sure we don't have deadlock loop in transient chain
259 for (WinClient *w = this; w != 0; w = w->transient_for) { 270 for (WinClient *w = this; w != 0; w = w->transient_for) {
@@ -528,3 +539,60 @@ void WinClient::removeModal() {
528 if (transient_for) 539 if (transient_for)
529 transient_for->removeModal(); 540 transient_for->removeModal();
530} 541}
542
543bool WinClient::validateClient() const {
544 Display *display = FbTk::App::instance()->display();
545 XSync(display, false);
546
547 XEvent e;
548 if (( XCheckTypedWindowEvent(display, window(), DestroyNotify, &e) ||
549 XCheckTypedWindowEvent(display, window(), UnmapNotify, &e))
550 && XPutBackEvent(display, &e)) {
551 Fluxbox::instance()->ungrab();
552 return false;
553 }
554
555 return true;
556}
557
558void WinClient::setStrut(Strut *strut) {
559 clearStrut();
560 m_strut = strut;
561}
562
563void WinClient::clearStrut() {
564 if (m_strut != 0) {
565 screen().clearStrut(m_strut);
566 m_strut = 0;
567 }
568}
569
570bool WinClient::focus() {
571 if (m_win == 0)
572 return false;
573 else
574 return m_win->setCurrentClient(*this, true);
575}
576
577void WinClient::getWMProtocols() {
578 Atom *proto = 0;
579 int num_return = 0;
580 FbAtoms *fbatoms = FbAtoms::instance();
581
582 if (XGetWMProtocols(FbTk::App::instance()->display(), window(), &proto, &num_return)) {
583
584 for (int i = 0; i < num_return; ++i) {
585 if (proto[i] == fbatoms->getWMDeleteAtom())
586 closable = true;
587 else if (proto[i] == fbatoms->getWMTakeFocusAtom())
588 send_focus_message = true;
589 else if (proto[i] == fbatoms->getFluxboxStructureMessagesAtom())
590 screen().addNetizen(window());
591 }
592
593 XFree(proto);
594 } else {
595 cerr<<"Warning: Failed to read WM Protocols. "<<endl;
596 }
597
598}