diff options
author | markt <markt> | 2007-11-05 17:05:58 (GMT) |
---|---|---|
committer | markt <markt> | 2007-11-05 17:05:58 (GMT) |
commit | 97f7c3e1b59b9a94e36a78d97c141f6a05f43e20 (patch) | |
tree | 982ba8f35083fb54e5058f564ec8e301d8a229dc /src/WinClient.cc | |
parent | 2c4e1f9a024433396f17ea5f3ef3fda46e0d8edd (diff) | |
download | fluxbox-97f7c3e1b59b9a94e36a78d97c141f6a05f43e20.zip fluxbox-97f7c3e1b59b9a94e36a78d97c141f6a05f43e20.tar.bz2 |
various refactoring and minor changes
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r-- | src/WinClient.cc | 100 |
1 files changed, 19 insertions, 81 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc index 99264d2..83637e2 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc | |||
@@ -79,13 +79,13 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin): | |||
79 | wm_hint_flags(0), | 79 | wm_hint_flags(0), |
80 | m_modal_count(0), | 80 | m_modal_count(0), |
81 | m_modal(false), | 81 | m_modal(false), |
82 | accepts_input(false), | ||
82 | send_focus_message(false), | 83 | send_focus_message(false), |
83 | send_close_message(false), | 84 | send_close_message(false), |
84 | m_win_gravity(0), | 85 | m_win_gravity(0), |
85 | m_title_override(false), | 86 | m_title_override(false), |
86 | m_icon_title_override(false), | 87 | m_window_type(Focusable::TYPE_NORMAL), |
87 | m_mwm_hint(0), | 88 | m_mwm_hint(0), |
88 | m_focus_mode(F_PASSIVE), | ||
89 | m_strut(0) { | 89 | m_strut(0) { |
90 | updateWMProtocols(); | 90 | updateWMProtocols(); |
91 | updateMWMHints(); | 91 | updateMWMHints(); |
@@ -93,7 +93,6 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin): | |||
93 | updateWMNormalHints(); | 93 | updateWMNormalHints(); |
94 | updateWMClassHint(); | 94 | updateWMClassHint(); |
95 | updateTitle(); | 95 | updateTitle(); |
96 | updateIconTitle(); | ||
97 | Fluxbox::instance()->saveWindowSearch(win, this); | 96 | Fluxbox::instance()->saveWindowSearch(win, this); |
98 | if (window_group != None) | 97 | if (window_group != None) |
99 | Fluxbox::instance()->saveGroupSearch(window_group, this); | 98 | Fluxbox::instance()->saveGroupSearch(window_group, this); |
@@ -167,11 +166,17 @@ WinClient::~WinClient() { | |||
167 | } | 166 | } |
168 | 167 | ||
169 | bool WinClient::acceptsFocus() const { | 168 | bool WinClient::acceptsFocus() const { |
170 | return (m_focus_mode == F_LOCALLYACTIVE || | 169 | return ((accepts_input || send_focus_message) && |
171 | m_focus_mode == F_PASSIVE); | 170 | // focusing fbpanel messes up quite a few things |
171 | m_window_type != Focusable::TYPE_DOCK && | ||
172 | m_window_type != Focusable::TYPE_SPLASH); | ||
172 | } | 173 | } |
173 | 174 | ||
174 | bool WinClient::sendFocus() { | 175 | bool WinClient::sendFocus() { |
176 | if (accepts_input) { | ||
177 | setInputFocus(RevertToParent, CurrentTime); | ||
178 | return true; | ||
179 | } | ||
175 | if (!send_focus_message) | 180 | if (!send_focus_message) |
176 | return false; | 181 | return false; |
177 | #ifdef DEBUG | 182 | #ifdef DEBUG |
@@ -236,12 +241,6 @@ string WinClient::getWMRole() const { | |||
236 | return textProperty(wm_role); | 241 | return textProperty(wm_role); |
237 | } | 242 | } |
238 | 243 | ||
239 | const string &WinClient::title() const { | ||
240 | if (!fbwindow() || !fbwindow()->isIconic() || m_icon_title.empty()) | ||
241 | return m_title; | ||
242 | return m_icon_title; | ||
243 | } | ||
244 | |||
245 | void WinClient::updateWMClassHint() { | 244 | void WinClient::updateWMClassHint() { |
246 | XClassHint ch; | 245 | XClassHint ch; |
247 | if (XGetClassHint(display(), window(), &ch) == 0) { | 246 | if (XGetClassHint(display(), window(), &ch) == 0) { |
@@ -369,48 +368,6 @@ void WinClient::setTitle(FbTk::FbString &title) { | |||
369 | fbwindow()->updateTitleFromClient(*this); | 368 | fbwindow()->updateTitleFromClient(*this); |
370 | } | 369 | } |
371 | 370 | ||
372 | void WinClient::setIconTitle(FbTk::FbString &icon_title) { | ||
373 | m_icon_title = icon_title; | ||
374 | m_icon_title_override = true; | ||
375 | if (fbwindow() && fbwindow()->isIconic()) | ||
376 | fbwindow()->updateTitleFromClient(*this); | ||
377 | } | ||
378 | |||
379 | void WinClient::updateIconTitle() { | ||
380 | if (m_icon_title_override) | ||
381 | return; | ||
382 | |||
383 | XTextProperty text_prop; | ||
384 | char **list = 0; | ||
385 | int num = 0; | ||
386 | |||
387 | if (getWMIconName(text_prop)) { | ||
388 | if (text_prop.value && text_prop.nitems > 0) { | ||
389 | if (text_prop.encoding != XA_STRING) { | ||
390 | text_prop.nitems = strlen((char *) text_prop.value); | ||
391 | XmbTextPropertyToTextList(display(), &text_prop, &list, &num); | ||
392 | |||
393 | if (num > 0 && list) | ||
394 | m_icon_title = (char *)*list; | ||
395 | else | ||
396 | m_icon_title = text_prop.value ? (char *)text_prop.value : ""; | ||
397 | if (list) | ||
398 | XFreeStringList(list); | ||
399 | |||
400 | } else | ||
401 | m_icon_title = text_prop.value ? (char *)text_prop.value : ""; | ||
402 | |||
403 | if (text_prop.value) | ||
404 | XFree((char *) text_prop.value); | ||
405 | } else | ||
406 | m_icon_title = ""; | ||
407 | } else | ||
408 | m_icon_title = ""; | ||
409 | |||
410 | if (fbwindow() && fbwindow()->isIconic()) | ||
411 | fbwindow()->updateTitleFromClient(*this); | ||
412 | } | ||
413 | |||
414 | void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) { | 371 | void WinClient::saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs) { |
415 | changeProperty(FbAtoms::instance()->getFluxboxAttributesAtom(), | 372 | changeProperty(FbAtoms::instance()->getFluxboxAttributesAtom(), |
416 | XA_CARDINAL, 32, PropModeReplace, | 373 | XA_CARDINAL, 32, PropModeReplace, |
@@ -450,11 +407,10 @@ void WinClient::updateMWMHints() { | |||
450 | 407 | ||
451 | void WinClient::updateWMHints() { | 408 | void WinClient::updateWMHints() { |
452 | XWMHints *wmhint = XGetWMHints(display(), window()); | 409 | XWMHints *wmhint = XGetWMHints(display(), window()); |
453 | if (! wmhint) { | 410 | accepts_input = true; |
454 | m_focus_mode = F_PASSIVE; | 411 | window_group = None; |
455 | window_group = None; | 412 | initial_state = NormalState; |
456 | initial_state = NormalState; | 413 | if (wmhint) { |
457 | } else { | ||
458 | wm_hint_flags = wmhint->flags; | 414 | wm_hint_flags = wmhint->flags; |
459 | /* | 415 | /* |
460 | * ICCCM 4.1.7 | 416 | * ICCCM 4.1.7 |
@@ -467,34 +423,16 @@ void WinClient::updateWMHints() { | |||
467 | * Globally Active False Present | 423 | * Globally Active False Present |
468 | *--------------------------------------------- | 424 | *--------------------------------------------- |
469 | * Here: WM_TAKE_FOCUS = send_focus_message | 425 | * Here: WM_TAKE_FOCUS = send_focus_message |
470 | * Input Field = wmhint->input | 426 | * Input Field = accepts_input |
471 | * Input Model = m_focus_mode | ||
472 | */ | 427 | */ |
473 | if (wmhint->flags & InputHint) { | 428 | if (wmhint->flags & InputHint) |
474 | if (wmhint->input) { | 429 | accepts_input = (bool)wmhint->input; |
475 | if (send_focus_message) | ||
476 | m_focus_mode = F_LOCALLYACTIVE; | ||
477 | else | ||
478 | m_focus_mode = F_PASSIVE; | ||
479 | } else { | ||
480 | if (send_focus_message) | ||
481 | m_focus_mode = F_GLOBALLYACTIVE; | ||
482 | else | ||
483 | m_focus_mode = F_NOINPUT; | ||
484 | } | ||
485 | } else // InputHint not present: ignoring send_focus_message and assuming F_PASSIVE | ||
486 | m_focus_mode = F_PASSIVE; | ||
487 | 430 | ||
488 | if (wmhint->flags & StateHint) | 431 | if (wmhint->flags & StateHint) |
489 | initial_state = wmhint->initial_state; | 432 | initial_state = wmhint->initial_state; |
490 | else | ||
491 | initial_state = NormalState; | ||
492 | 433 | ||
493 | if (wmhint->flags & WindowGroupHint) { | 434 | if (wmhint->flags & WindowGroupHint && !window_group) |
494 | if (! window_group) | 435 | window_group = wmhint->window_group; |
495 | window_group = wmhint->window_group; | ||
496 | } else | ||
497 | window_group = None; | ||
498 | 436 | ||
499 | if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0) | 437 | if ((bool)(wmhint->flags & IconPixmapHint) && wmhint->icon_pixmap != 0) |
500 | m_icon.pixmap().copy(wmhint->icon_pixmap, 0, 0); | 438 | m_icon.pixmap().copy(wmhint->icon_pixmap, 0, 0); |