diff options
-rw-r--r-- | src/ClientPattern.cc | 2 | ||||
-rw-r--r-- | src/Ewmh.cc | 15 | ||||
-rw-r--r-- | src/FbTk/FbWindow.cc | 52 | ||||
-rw-r--r-- | src/FbTk/FbWindow.hh | 5 | ||||
-rw-r--r-- | src/Focusable.hh | 3 | ||||
-rw-r--r-- | src/Gnome.cc | 30 | ||||
-rw-r--r-- | src/Screen.cc | 11 | ||||
-rw-r--r-- | src/WinClient.hh | 3 | ||||
-rw-r--r-- | src/Window.cc | 8 | ||||
-rw-r--r-- | src/Window.hh | 3 |
10 files changed, 69 insertions, 63 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index b2ad691..f49f7fd 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc | |||
@@ -322,7 +322,7 @@ bool ClientPattern::match(const Focusable &win) const { | |||
322 | for (; it != it_end; ++it) { | 322 | for (; it != it_end; ++it) { |
323 | const Term& term = *(*it); | 323 | const Term& term = *(*it); |
324 | if (term.prop == XPROP) { | 324 | if (term.prop == XPROP) { |
325 | if (!term.negate ^ (term.regexp.match(win.getTextProperty(term.xprop)))) | 325 | if (!term.negate ^ ((term.regexp.match(win.getTextProperty(term.xprop))) || term.regexp.match(FbTk::StringUtil::number2String(win.getCardinalProperty(term.xprop))))) |
326 | return false; | 326 | return false; |
327 | } else if (term.regstr == "[current]") { | 327 | } else if (term.regstr == "[current]") { |
328 | WinClient *focused = FocusControl::focusedWindow(); | 328 | WinClient *focused = FocusControl::focusedWindow(); |
diff --git a/src/Ewmh.cc b/src/Ewmh.cc index bab543b..52568a1 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc | |||
@@ -695,22 +695,13 @@ void Ewmh::setupClient(WinClient &winclient) { | |||
695 | 695 | ||
696 | void Ewmh::setupFrame(FluxboxWindow &win) { | 696 | void Ewmh::setupFrame(FluxboxWindow &win) { |
697 | setupState(win); | 697 | setupState(win); |
698 | 698 | bool exists; | |
699 | Atom ret_type; | 699 | unsigned int desktop=static_cast<unsigned int>(win.winClient().cardinalProperty(m_net->wm_desktop, &exists)); |
700 | int fmt; | 700 | if (exists) { |
701 | unsigned long nitems, bytes_after; | ||
702 | unsigned char *data = 0; | ||
703 | |||
704 | if (win.winClient().property(m_net->wm_desktop, 0, 1, False, XA_CARDINAL, | ||
705 | &ret_type, &fmt, &nitems, &bytes_after, | ||
706 | (unsigned char **) &data) && data) { | ||
707 | unsigned int desktop = static_cast<long>(*data); | ||
708 | if (desktop == (unsigned int)(-1) && !win.isStuck()) | 701 | if (desktop == (unsigned int)(-1) && !win.isStuck()) |
709 | win.stick(); | 702 | win.stick(); |
710 | else | 703 | else |
711 | win.setWorkspace(desktop); | 704 | win.setWorkspace(desktop); |
712 | |||
713 | XFree(data); | ||
714 | } else { | 705 | } else { |
715 | updateWorkspace(win); | 706 | updateWorkspace(win); |
716 | } | 707 | } |
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 00dde66..9fa59fc 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc | |||
@@ -41,6 +41,8 @@ | |||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #include <limits> | ||
45 | |||
44 | namespace FbTk { | 46 | namespace FbTk { |
45 | 47 | ||
46 | FbWindow::FbWindow(): | 48 | FbWindow::FbWindow(): |
@@ -483,29 +485,45 @@ struct TextPropPtr { | |||
483 | }; | 485 | }; |
484 | } | 486 | } |
485 | 487 | ||
486 | std::string FbWindow::textProperty(Atom property) const { | 488 | long FbWindow::cardinalProperty(Atom prop,bool*exists) const { |
489 | Atom type; | ||
490 | int format; | ||
491 | unsigned long nitems, bytes_after; | ||
492 | int result; | ||
493 | long* num; | ||
494 | long ret=0; | ||
495 | if (exists) *exists=false; | ||
496 | if (property(prop, 0, 1, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, reinterpret_cast<unsigned char**>(&num))) { | ||
497 | if (type == XA_CARDINAL && nitems) { | ||
498 | ret = *num; | ||
499 | if (exists) *exists=true; | ||
500 | } | ||
501 | XFree(num); | ||
502 | } | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | FbTk::FbString FbWindow::textProperty(Atom prop,bool*exists) const { | ||
487 | XTextProperty text_prop; | 507 | XTextProperty text_prop; |
488 | TextPropPtr helper(text_prop); | 508 | TextPropPtr helper(text_prop); |
489 | char ** stringlist = 0; | 509 | char ** stringlist = 0; |
490 | int count = 0; | 510 | int count = 0; |
491 | std::string ret; | 511 | FbTk::FbString ret; |
492 | 512 | ||
493 | static Atom m_utf8string = XInternAtom(display(), "UTF8_STRING", False); | 513 | static const Atom utf8string = XInternAtom(display(), "UTF8_STRING", False); |
494 | 514 | ||
495 | if (XGetTextProperty(display(), window(), &text_prop, property) == 0) { | 515 | if (exists) *exists=false; |
516 | if (XGetTextProperty(display(), window(), &text_prop, prop) == 0 || text_prop.value == 0 || text_prop.nitems == 0) { | ||
496 | return ""; | 517 | return ""; |
497 | } | 518 | } |
498 | 519 | ||
499 | if (text_prop.value == 0 || text_prop.nitems == 0) { | ||
500 | return ""; | ||
501 | } | ||
502 | 520 | ||
503 | if (text_prop.encoding == XA_STRING) { | 521 | if (text_prop.encoding == XA_STRING) { |
504 | if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0) { | 522 | if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0) { |
505 | return ""; | 523 | return ""; |
506 | } | 524 | } |
507 | ret = FbStringUtil::XStrToFb(stringlist[0]); | 525 | ret = FbStringUtil::XStrToFb(stringlist[0]); |
508 | } else if (text_prop.encoding == m_utf8string && text_prop.format == 8) { | 526 | } else if (text_prop.encoding == utf8string && text_prop.format == 8) { |
509 | #ifdef X_HAVE_UTF8_STRING | 527 | #ifdef X_HAVE_UTF8_STRING |
510 | Xutf8TextPropertyToTextList(display(), &text_prop, &stringlist, &count); | 528 | Xutf8TextPropertyToTextList(display(), &text_prop, &stringlist, &count); |
511 | if (count == 0 || stringlist == 0) { | 529 | if (count == 0 || stringlist == 0) { |
@@ -530,11 +548,11 @@ std::string FbWindow::textProperty(Atom property) const { | |||
530 | if (stringlist) { | 548 | if (stringlist) { |
531 | XFreeStringList(stringlist); | 549 | XFreeStringList(stringlist); |
532 | } | 550 | } |
533 | 551 | if (exists) *exists=true; | |
534 | return ret; | 552 | return ret; |
535 | } | 553 | } |
536 | 554 | ||
537 | bool FbWindow::property(Atom property, | 555 | bool FbWindow::property(Atom prop, |
538 | long long_offset, long long_length, | 556 | long long_offset, long long_length, |
539 | bool do_delete, | 557 | bool do_delete, |
540 | Atom req_type, | 558 | Atom req_type, |
@@ -544,7 +562,7 @@ bool FbWindow::property(Atom property, | |||
544 | unsigned long *bytes_after_return, | 562 | unsigned long *bytes_after_return, |
545 | unsigned char **prop_return) const { | 563 | unsigned char **prop_return) const { |
546 | if (XGetWindowProperty(display(), window(), | 564 | if (XGetWindowProperty(display(), window(), |
547 | property, long_offset, long_length, do_delete, | 565 | prop, long_offset, long_length, do_delete, |
548 | req_type, actual_type_return, | 566 | req_type, actual_type_return, |
549 | actual_format_return, nitems_return, | 567 | actual_format_return, nitems_return, |
550 | bytes_after_return, prop_return) == Success) | 568 | bytes_after_return, prop_return) == Success) |
@@ -553,19 +571,19 @@ bool FbWindow::property(Atom property, | |||
553 | return false; | 571 | return false; |
554 | } | 572 | } |
555 | 573 | ||
556 | void FbWindow::changeProperty(Atom property, Atom type, | 574 | void FbWindow::changeProperty(Atom prop, Atom type, |
557 | int format, | 575 | int format, |
558 | int mode, | 576 | int mode, |
559 | unsigned char *data, | 577 | unsigned char *data, |
560 | int nelements) { | 578 | int nelements) { |
561 | 579 | ||
562 | XChangeProperty(display(), m_window, property, type, | 580 | XChangeProperty(display(), m_window, prop, type, |
563 | format, mode, | 581 | format, mode, |
564 | data, nelements); | 582 | data, nelements); |
565 | } | 583 | } |
566 | 584 | ||
567 | void FbWindow::deleteProperty(Atom property) { | 585 | void FbWindow::deleteProperty(Atom prop) { |
568 | XDeleteProperty(display(), m_window, property); | 586 | XDeleteProperty(display(), m_window, prop); |
569 | } | 587 | } |
570 | 588 | ||
571 | void FbWindow::addToSaveSet() { | 589 | void FbWindow::addToSaveSet() { |
@@ -590,9 +608,9 @@ long FbWindow::eventMask() const { | |||
590 | 608 | ||
591 | void FbWindow::setOpaque(int alpha) { | 609 | void FbWindow::setOpaque(int alpha) { |
592 | #ifdef HAVE_XRENDER | 610 | #ifdef HAVE_XRENDER |
593 | static Atom m_alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False); | 611 | static const Atom alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False); |
594 | unsigned long opacity = alpha * 0x1010101; | 612 | unsigned long opacity = alpha * 0x1010101; |
595 | changeProperty(m_alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l); | 613 | changeProperty(alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l); |
596 | #endif // HAVE_XRENDER | 614 | #endif // HAVE_XRENDER |
597 | } | 615 | } |
598 | 616 | ||
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index 9e92923..6f6a558 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh | |||
@@ -23,7 +23,7 @@ | |||
23 | #define FBTK_FBWINDOW_HH | 23 | #define FBTK_FBWINDOW_HH |
24 | 24 | ||
25 | #include "FbDrawable.hh" | 25 | #include "FbDrawable.hh" |
26 | 26 | #include "FbString.hh" | |
27 | #include <memory> | 27 | #include <memory> |
28 | #include <string> | 28 | #include <string> |
29 | #include <set> | 29 | #include <set> |
@@ -158,7 +158,8 @@ public: | |||
158 | 158 | ||
159 | void deleteProperty(Atom property); | 159 | void deleteProperty(Atom property); |
160 | 160 | ||
161 | std::string textProperty(Atom property) const; | 161 | long cardinalProperty(Atom property,bool*exists=NULL) const; |
162 | FbTk::FbString textProperty(Atom property,bool*exists=NULL) const; | ||
162 | 163 | ||
163 | void addToSaveSet(); | 164 | void addToSaveSet(); |
164 | void removeFromSaveSet(); | 165 | void removeFromSaveSet(); |
diff --git a/src/Focusable.hh b/src/Focusable.hh index 4583a62..0aae1a4 100644 --- a/src/Focusable.hh +++ b/src/Focusable.hh | |||
@@ -88,7 +88,8 @@ public: | |||
88 | /// @return wm role string (for pattern matching) | 88 | /// @return wm role string (for pattern matching) |
89 | virtual std::string getWMRole() const { return "Focusable"; } | 89 | virtual std::string getWMRole() const { return "Focusable"; } |
90 | 90 | ||
91 | virtual FbTk::FbString getTextProperty(Atom prop) const { return ""; } | 91 | virtual FbTk::FbString getTextProperty(Atom prop,bool*exists=NULL) const { return ""; } |
92 | virtual long getCardinalProperty(Atom prop,bool*exists=NULL) const { return 0; } | ||
92 | 93 | ||
93 | /// @return whether this window is a transient (for pattern matching) | 94 | /// @return whether this window is a transient (for pattern matching) |
94 | virtual bool isTransient() const { return false; } | 95 | virtual bool isTransient() const { return false; } |
diff --git a/src/Gnome.cc b/src/Gnome.cc index 91a0aef..0c3b6f1 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc | |||
@@ -98,40 +98,30 @@ void Gnome::initForScreen(BScreen &screen) { | |||
98 | 98 | ||
99 | void Gnome::setupFrame(FluxboxWindow &win) { | 99 | void Gnome::setupFrame(FluxboxWindow &win) { |
100 | // load gnome state (take queues from the main window of the frame) | 100 | // load gnome state (take queues from the main window of the frame) |
101 | Atom ret_type; | 101 | long flags; |
102 | int fmt; | 102 | bool exists; |
103 | unsigned long nitems, bytes_after; | 103 | flags=win.winClient().cardinalProperty(m_gnome_wm_win_state,&exists); |
104 | long flags, *data = 0; | 104 | if (exists) { |
105 | |||
106 | if (win.winClient().property(m_gnome_wm_win_state, 0, 1, False, XA_CARDINAL, | ||
107 | &ret_type, &fmt, &nitems, &bytes_after, | ||
108 | (unsigned char **) &data) && data) { | ||
109 | flags = *data; | ||
110 | setState(&win, flags); | 105 | setState(&win, flags); |
111 | XFree (data); | ||
112 | } else { | 106 | } else { |
113 | updateState(win); | 107 | updateState(win); |
114 | } | 108 | } |
115 | 109 | ||
116 | // load gnome layer atom | 110 | // load gnome layer atom |
117 | if (win.winClient().property(m_gnome_wm_win_layer, 0, 1, False, XA_CARDINAL, | 111 | flags=win.winClient().cardinalProperty(m_gnome_wm_win_layer,&exists); |
118 | &ret_type, &fmt, &nitems, &bytes_after, | 112 | if (exists) { |
119 | (unsigned char **) &data) && data) { | ||
120 | flags = *data; | ||
121 | setLayer(&win, flags); | 113 | setLayer(&win, flags); |
122 | XFree (data); | ||
123 | } else { | 114 | } else { |
124 | updateLayer(win); | 115 | updateLayer(win); |
125 | } | 116 | } |
126 | 117 | ||
127 | // load gnome workspace atom | 118 | // load gnome workspace atom |
128 | if (win.winClient().property(m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL, | 119 | flags=win.winClient().cardinalProperty(m_gnome_wm_win_workspace,&exists); |
129 | &ret_type, &fmt, &nitems, &bytes_after, | 120 | if (exists) |
130 | (unsigned char **) &data) && data) { | 121 | { |
131 | unsigned int workspace_num = *data; | 122 | unsigned int workspace_num = flags; |
132 | if (win.workspaceNumber() != workspace_num) | 123 | if (win.workspaceNumber() != workspace_num) |
133 | win.setWorkspace(workspace_num); | 124 | win.setWorkspace(workspace_num); |
134 | XFree (data); | ||
135 | } else { | 125 | } else { |
136 | updateWorkspace(win); | 126 | updateWorkspace(win); |
137 | } | 127 | } |
diff --git a/src/Screen.cc b/src/Screen.cc index bf131fb..a8eca72 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -477,12 +477,11 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
477 | unsigned int first_desktop = 0; | 477 | unsigned int first_desktop = 0; |
478 | if (m_restart) { | 478 | if (m_restart) { |
479 | Atom net_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False); | 479 | Atom net_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False); |
480 | if (rootWindow().property(net_desktop, 0l, 1l, | 480 | bool exists; |
481 | False, XA_CARDINAL, &xa_ret_type, &ret_format, &ret_nitems, | 481 | unsigned int ret=static_cast<unsigned int>(rootWindow().cardinalProperty(net_desktop, &exists)); |
482 | &ret_bytes_after, &ret_prop) == Success) { | 482 | if (exists) { |
483 | if (ret_prop && static_cast<unsigned int>(*ret_prop) < static_cast<unsigned int>(nr_ws)) | 483 | if (ret < static_cast<unsigned int>(nr_ws)) |
484 | first_desktop = static_cast<unsigned int>(*ret_prop); | 484 | first_desktop = ret; |
485 | XFree(ret_prop); | ||
486 | } | 485 | } |
487 | } | 486 | } |
488 | 487 | ||
diff --git a/src/WinClient.hh b/src/WinClient.hh index 157278e..5a29a5e 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh | |||
@@ -96,7 +96,8 @@ public: | |||
96 | std::string getWMRole() const; | 96 | std::string getWMRole() const; |
97 | WindowState::WindowType getWindowType() const { return m_window_type; } | 97 | WindowState::WindowType getWindowType() const { return m_window_type; } |
98 | void setWindowType(WindowState::WindowType type) { m_window_type = type; } | 98 | void setWindowType(WindowState::WindowType type) { m_window_type = type; } |
99 | FbTk::FbString getTextProperty(Atom prop) const { return FbTk::FbWindow::textProperty(prop); } | 99 | long getCardinalProperty(Atom prop,bool*exists=NULL) const { return FbTk::FbWindow::cardinalProperty(prop,exists); } |
100 | FbTk::FbString getTextProperty(Atom prop,bool*exists=NULL) const { return FbTk::FbWindow::textProperty(prop,exists); } | ||
100 | 101 | ||
101 | WinClient *transientFor() { return transient_for; } | 102 | WinClient *transientFor() { return transient_for; } |
102 | const WinClient *transientFor() const { return transient_for; } | 103 | const WinClient *transientFor() const { return transient_for; } |
diff --git a/src/Window.cc b/src/Window.cc index 1a5bd91..369b480 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -3342,8 +3342,12 @@ FbTk::FbString FluxboxWindow::getWMRole() const { | |||
3342 | return (m_client ? m_client->getWMRole() : "FluxboxWindow"); | 3342 | return (m_client ? m_client->getWMRole() : "FluxboxWindow"); |
3343 | } | 3343 | } |
3344 | 3344 | ||
3345 | FbTk::FbString FluxboxWindow::getTextProperty(Atom prop) const { | 3345 | long FluxboxWindow::getCardinalProperty(Atom prop,bool*exists) const { |
3346 | return (m_client ? m_client->getTextProperty(prop) : Focusable::getTextProperty(prop)); | 3346 | return (m_client ? m_client->getCardinalProperty(prop,exists) : Focusable::getCardinalProperty(prop,exists)); |
3347 | } | ||
3348 | |||
3349 | FbTk::FbString FluxboxWindow::getTextProperty(Atom prop,bool*exists) const { | ||
3350 | return (m_client ? m_client->getTextProperty(prop,exists) : Focusable::getTextProperty(prop,exists)); | ||
3347 | } | 3351 | } |
3348 | 3352 | ||
3349 | bool FluxboxWindow::isTransient() const { | 3353 | bool FluxboxWindow::isTransient() const { |
diff --git a/src/Window.hh b/src/Window.hh index bb27060..8f599a4 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -422,7 +422,8 @@ public: | |||
422 | const FbTk::FbString &getWMClassName() const; | 422 | const FbTk::FbString &getWMClassName() const; |
423 | const FbTk::FbString &getWMClassClass() const; | 423 | const FbTk::FbString &getWMClassClass() const; |
424 | std::string getWMRole() const; | 424 | std::string getWMRole() const; |
425 | FbTk::FbString getTextProperty(Atom prop) const; | 425 | long getCardinalProperty(Atom prop,bool*exists=NULL) const; |
426 | FbTk::FbString getTextProperty(Atom prop,bool*exists=NULL) const; | ||
426 | void setWindowType(WindowState::WindowType type); | 427 | void setWindowType(WindowState::WindowType type); |
427 | bool isTransient() const; | 428 | bool isTransient() const; |
428 | 429 | ||