aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-10-13 21:51:37 (GMT)
committermarkt <markt>2007-10-13 21:51:37 (GMT)
commita59428d67a95a9df16554962f0a6257d6378328a (patch)
treef856ed9300c34f7a17d499f22d895610cfbc08e5 /src/WinClient.cc
parent41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff)
downloadfluxbox_pavel-a59428d67a95a9df16554962f0a6257d6378328a.zip
fluxbox_pavel-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2
merged changes from pre-devel
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r--src/WinClient.cc122
1 files changed, 54 insertions, 68 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 989088b..d75d6eb 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -25,6 +25,7 @@
25 25
26#include "Window.hh" 26#include "Window.hh"
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28#include "FocusControl.hh"
28#include "Screen.hh" 29#include "Screen.hh"
29#include "FbAtoms.hh" 30#include "FbAtoms.hh"
30 31
@@ -62,7 +63,8 @@ using std::dec;
62 63
63WinClient::TransientWaitMap WinClient::s_transient_wait; 64WinClient::TransientWaitMap WinClient::s_transient_wait;
64 65
65WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::FbWindow(win), 66WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):
67 Focusable(screen, fbwin), FbTk::FbWindow(win),
66 transient_for(0), 68 transient_for(0),
67 window_group(0), 69 window_group(0),
68 x(0), y(0), old_bw(0), 70 x(0), y(0), old_bw(0),
@@ -75,24 +77,17 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
75 initial_state(0), 77 initial_state(0),
76 normal_hint_flags(0), 78 normal_hint_flags(0),
77 wm_hint_flags(0), 79 wm_hint_flags(0),
78 m_win(fbwin),
79 m_modal_count(0), 80 m_modal_count(0),
80 m_modal(false), 81 m_modal(false),
81 send_focus_message(false), 82 send_focus_message(false),
82 send_close_message(false), 83 send_close_message(false),
83 m_win_gravity(0), 84 m_win_gravity(0),
84 m_title(""), m_icon_title(""),
85 m_class_name(""), m_instance_name(""),
86 m_title_override(false), 85 m_title_override(false),
87 m_icon_title_override(false), 86 m_icon_title_override(false),
88 m_blackbox_hint(0),
89 m_mwm_hint(0), 87 m_mwm_hint(0),
90 m_focus_mode(F_PASSIVE), 88 m_focus_mode(F_PASSIVE),
91 m_diesig(*this), m_focussig(*this),
92 m_screen(screen),
93 m_strut(0) { 89 m_strut(0) {
94 updateWMProtocols(); 90 updateWMProtocols();
95 updateBlackboxHints();
96 updateMWMHints(); 91 updateMWMHints();
97 updateWMHints(); 92 updateWMHints();
98 updateWMNormalHints(); 93 updateWMNormalHints();
@@ -145,8 +140,8 @@ WinClient::~WinClient() {
145 transients.pop_back(); 140 transients.pop_back();
146 } 141 }
147 142
148 if (m_win != 0) 143 if (fbwindow() != 0)
149 m_win->removeClient(*this); 144 fbwindow()->removeClient(*this);
150 145
151 // this takes care of any focus issues 146 // this takes care of any focus issues
152 m_diesig.notify(); 147 m_diesig.notify();
@@ -159,8 +154,6 @@ WinClient::~WinClient() {
159 s_transient_wait.erase(window()); 154 s_transient_wait.erase(window());
160 155
161 156
162 screen().removeNetizen(window());
163
164 if (window_group != 0) { 157 if (window_group != 0) {
165 fluxbox->removeGroupSearch(window_group); 158 fluxbox->removeGroupSearch(window_group);
166 window_group = 0; 159 window_group = 0;
@@ -169,13 +162,8 @@ WinClient::~WinClient() {
169 if (m_mwm_hint != 0) 162 if (m_mwm_hint != 0)
170 XFree(m_mwm_hint); 163 XFree(m_mwm_hint);
171 164
172 if (m_blackbox_hint != 0)
173 XFree(m_blackbox_hint);
174
175 if (window()) 165 if (window())
176 fluxbox->removeWindowSearch(window()); 166 fluxbox->removeWindowSearch(window());
177
178 m_win = 0;
179} 167}
180 168
181bool WinClient::acceptsFocus() const { 169bool WinClient::acceptsFocus() const {
@@ -243,12 +231,16 @@ bool WinClient::getWMIconName(XTextProperty &textprop) const {
243 return XGetWMIconName(display(), window(), &textprop); 231 return XGetWMIconName(display(), window(), &textprop);
244} 232}
245 233
246const string &WinClient::getWMClassName() const { 234string WinClient::getWMRole() const {
247 return m_instance_name; 235 Atom wm_role = XInternAtom(FbTk::App::instance()->display(),
236 "WM_WINDOW_ROLE", False);
237 return textProperty(wm_role);
248} 238}
249 239
250const string &WinClient::getWMClassClass() const { 240const string &WinClient::title() const {
251 return m_class_name; 241 if (!fbwindow() || !fbwindow()->isIconic() || m_icon_title.empty())
242 return m_title;
243 return m_icon_title;
252} 244}
253 245
254void WinClient::updateWMClassHint() { 246void WinClient::updateWMClassHint() {
@@ -257,6 +249,7 @@ void WinClient::updateWMClassHint() {
257#ifdef DEBUG 249#ifdef DEBUG
258 cerr<<"WinClient: Failed to read class hint!"<<endl; 250 cerr<<"WinClient: Failed to read class hint!"<<endl;
259#endif //DEBUG 251#endif //DEBUG
252 m_instance_name = m_class_name = "";
260 } else { 253 } else {
261 254
262 if (ch.res_name != 0) { 255 if (ch.res_name != 0) {
@@ -364,18 +357,24 @@ void WinClient::updateTitle() {
364 return; 357 return;
365 358
366 m_title = string(Xutil::getWMName(window()), 0, 512); 359 m_title = string(Xutil::getWMName(window()), 0, 512);
360 titleSig().notify();
361 if (fbwindow())
362 fbwindow()->updateTitleFromClient(*this);
367} 363}
368 364
369void WinClient::setTitle(FbTk::FbString &title) { 365void WinClient::setTitle(FbTk::FbString &title) {
370 m_title = title; 366 m_title = title;
371 m_title_override = true; 367 m_title_override = true;
372 if (m_win) 368 titleSig().notify();
373 m_win->updateTitleFromClient(*this); 369 if (fbwindow())
370 fbwindow()->updateTitleFromClient(*this);
374} 371}
375 372
376void WinClient::setIconTitle(FbTk::FbString &icon_title) { 373void WinClient::setIconTitle(FbTk::FbString &icon_title) {
377 m_icon_title = icon_title; 374 m_icon_title = icon_title;
378 m_icon_title_override = true; 375 m_icon_title_override = true;
376 if (fbwindow() && fbwindow()->isIconic())
377 fbwindow()->updateTitleFromClient(*this);
379} 378}
380 379
381void WinClient::updateIconTitle() { 380void WinClient::updateIconTitle() {
@@ -390,24 +389,27 @@ void WinClient::updateIconTitle() {
390 if (text_prop.value && text_prop.nitems > 0) { 389 if (text_prop.value && text_prop.nitems > 0) {
391 if (text_prop.encoding != XA_STRING) { 390 if (text_prop.encoding != XA_STRING) {
392 text_prop.nitems = strlen((char *) text_prop.value); 391 text_prop.nitems = strlen((char *) text_prop.value);
392 XmbTextPropertyToTextList(display(), &text_prop, &list, &num);
393 393
394 if (XmbTextPropertyToTextList(display(), &text_prop, 394 if (num > 0 && list)
395 &list, &num) == Success &&
396 num > 0 && *list) {
397 m_icon_title = (char *)*list; 395 m_icon_title = (char *)*list;
398 XFreeStringList(list); 396 else
399 } else
400 m_icon_title = text_prop.value ? (char *)text_prop.value : ""; 397 m_icon_title = text_prop.value ? (char *)text_prop.value : "";
398 if (list)
399 XFreeStringList(list);
400
401 } else 401 } else
402 m_icon_title = text_prop.value ? (char *)text_prop.value : ""; 402 m_icon_title = text_prop.value ? (char *)text_prop.value : "";
403 403
404 if (text_prop.value) 404 if (text_prop.value)
405 XFree((char *) text_prop.value); 405 XFree((char *) text_prop.value);
406 } else 406 } else
407 m_icon_title = title(); 407 m_icon_title = "";
408 } else 408 } else
409 m_icon_title = title(); 409 m_icon_title = "";
410 410
411 if (fbwindow() && fbwindow()->isIconic())
412 fbwindow()->updateTitleFromClient(*this);
411} 413}
412 414
413void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) { 415void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) {
@@ -419,32 +421,7 @@ void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_
419} 421}
420 422
421void WinClient::setFluxboxWindow(FluxboxWindow *win) { 423void WinClient::setFluxboxWindow(FluxboxWindow *win) {
422 m_win = win; 424 m_fbwin = win;
423}
424
425void WinClient::updateBlackboxHints() {
426 int format;
427 Atom atom_return;
428 unsigned long num, len;
429 FbAtoms *atoms = FbAtoms::instance();
430
431 if (m_blackbox_hint) {
432 XFree(m_blackbox_hint);
433 m_blackbox_hint = 0;
434 }
435
436 if (property(atoms->getFluxboxHintsAtom(), 0,
437 PropBlackboxHintsElements, False,
438 atoms->getFluxboxHintsAtom(), &atom_return,
439 &format, &num, &len,
440 (unsigned char **) &m_blackbox_hint) &&
441 m_blackbox_hint) {
442
443 if (num != (unsigned)PropBlackboxHintsElements) {
444 XFree(m_blackbox_hint);
445 m_blackbox_hint = 0;
446 }
447 }
448} 425}
449 426
450void WinClient::updateMWMHints() { 427void WinClient::updateMWMHints() {
@@ -521,16 +498,16 @@ void WinClient::updateWMHints() {
521 window_group = None; 498 window_group = None;
522 499
523 if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0) 500 if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0)
524 m_icon_pixmap.copy(wmhint->icon_pixmap, 0, 0); 501 m_icon.pixmap().copy(wmhint->icon_pixmap, 0, 0);
525 else 502 else
526 m_icon_pixmap = 0; 503 m_icon.pixmap().release();
527 504
528 if ((bool)(wmhint->flags & IconMaskHint) && wmhint->icon_mask != 0) 505 if ((bool)(wmhint->flags & IconMaskHint) && wmhint->icon_mask != 0)
529 m_icon_mask.copy(wmhint->icon_mask, 0, 0); 506 m_icon.mask().copy(wmhint->icon_mask, 0, 0);
530 else 507 else
531 m_icon_mask = 0; 508 m_icon.mask().release();
532 509
533 if (m_win) { 510 if (fbwindow()) {
534 if (wmhint->flags & XUrgencyHint) { 511 if (wmhint->flags & XUrgencyHint) {
535 Fluxbox::instance()->attentionHandler().addAttention(*this); 512 Fluxbox::instance()->attentionHandler().addAttention(*this);
536 } else { 513 } else {
@@ -715,10 +692,22 @@ void WinClient::clearStrut() {
715} 692}
716 693
717bool WinClient::focus() { 694bool WinClient::focus() {
718 if (m_win == 0) 695 if (fbwindow() == 0)
719 return false; 696 return false;
720 else 697 else
721 return m_win->setCurrentClient(*this, true); 698 return fbwindow()->setCurrentClient(*this, true);
699}
700
701bool WinClient::isFocused() const {
702 return (fbwindow() ?
703 fbwindow()->isFocused() && &fbwindow()->winClient() == this :
704 false);
705}
706
707void WinClient::setAttentionState(bool value) {
708 Focusable::setAttentionState(value);
709 if (fbwindow() && !fbwindow()->isFocused())
710 fbwindow()->setAttentionState(value);
722} 711}
723 712
724void WinClient::updateWMProtocols() { 713void WinClient::updateWMProtocols() {
@@ -731,19 +720,16 @@ void WinClient::updateWMProtocols() {
731 // defaults 720 // defaults
732 send_focus_message = false; 721 send_focus_message = false;
733 send_close_message = false; 722 send_close_message = false;
734 // could be added to netizens twice...
735 for (int i = 0; i < num_return; ++i) { 723 for (int i = 0; i < num_return; ++i) {
736 if (proto[i] == fbatoms->getWMDeleteAtom()) 724 if (proto[i] == fbatoms->getWMDeleteAtom())
737 send_close_message = true; 725 send_close_message = true;
738 else if (proto[i] == fbatoms->getWMTakeFocusAtom()) 726 else if (proto[i] == fbatoms->getWMTakeFocusAtom())
739 send_focus_message = true; 727 send_focus_message = true;
740 else if (proto[i] == fbatoms->getFluxboxStructureMessagesAtom())
741 screen().addNetizen(window());
742 } 728 }
743 729
744 XFree(proto); 730 XFree(proto);
745 if (m_win) 731 if (fbwindow())
746 m_win->updateFunctions(); 732 fbwindow()->updateFunctions();
747#ifdef DEBUG 733#ifdef DEBUG
748 } else { 734 } else {
749 cerr<<"Warning: Failed to read WM Protocols. "<<endl; 735 cerr<<"Warning: Failed to read WM Protocols. "<<endl;