aboutsummaryrefslogtreecommitdiff
path: root/src/WinClient.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-27 06:57:43 (GMT)
committermathias <mathias>2006-10-27 06:57:43 (GMT)
commit10082d821d6691f42a8d8ad6fa2e42e5b3f44edd (patch)
tree99c94a6105cf35612307e307be343eda2aea8baf /src/WinClient.cc
parent34b7f7ddfc3e914238fd0d30ff50c4f37c2a6dd8 (diff)
downloadfluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.zip
fluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.tar.bz2
cosmetic patch from slava semushin, removes whitespaces and
uses only those things from "namespace std" what we really need.
Diffstat (limited to 'src/WinClient.cc')
-rw-r--r--src/WinClient.cc86
1 files changed, 47 insertions, 39 deletions
diff --git a/src/WinClient.cc b/src/WinClient.cc
index b8149b2..458ac01 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -44,8 +44,16 @@
44 #include <assert.h> 44 #include <assert.h>
45#endif 45#endif
46 46
47using namespace std; 47using std::string;
48using std::list;
49using std::mem_fun;
48 50
51#ifdef DEBUG
52using std::cerr;
53using std::endl;
54using std::hex;
55using std::dec;
56#endif // DEBUG
49 57
50WinClient::TransientWaitMap WinClient::s_transient_wait; 58WinClient::TransientWaitMap WinClient::s_transient_wait;
51 59
@@ -75,7 +83,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
75 m_mwm_hint(0), 83 m_mwm_hint(0),
76 m_focus_mode(F_PASSIVE), 84 m_focus_mode(F_PASSIVE),
77 m_diesig(*this), m_focussig(*this), 85 m_diesig(*this), m_focussig(*this),
78 m_screen(screen), 86 m_screen(screen),
79 m_strut(0) { 87 m_strut(0) {
80 updateWMProtocols(); 88 updateWMProtocols();
81 updateBlackboxHints(); 89 updateBlackboxHints();
@@ -86,7 +94,7 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
86 updateTitle(); 94 updateTitle();
87 updateIconTitle(); 95 updateIconTitle();
88 Fluxbox::instance()->saveWindowSearch(win, this); 96 Fluxbox::instance()->saveWindowSearch(win, this);
89 if (window_group != None) 97 if (window_group != None)
90 Fluxbox::instance()->saveGroupSearch(window_group, this); 98 Fluxbox::instance()->saveGroupSearch(window_group, this);
91 99
92 // search for this in transient waiting list 100 // search for this in transient waiting list
@@ -127,7 +135,7 @@ WinClient::~WinClient() {
127 transient_for->transientList().remove(this); 135 transient_for->transientList().remove(this);
128 transient_for = 0; 136 transient_for = 0;
129 } 137 }
130 138
131 while (!transients.empty()) { 139 while (!transients.empty()) {
132 transients.back()->transient_for = 0; 140 transients.back()->transient_for = 0;
133 transients.pop_back(); 141 transients.pop_back();
@@ -158,8 +166,8 @@ WinClient::~WinClient() {
158} 166}
159 167
160bool WinClient::acceptsFocus() const { 168bool WinClient::acceptsFocus() const {
161 return (m_focus_mode == F_LOCALLYACTIVE || 169 return (m_focus_mode == F_LOCALLYACTIVE ||
162 m_focus_mode == F_PASSIVE || 170 m_focus_mode == F_PASSIVE ||
163 m_focus_mode == F_GLOBALLYACTIVE && send_focus_message); 171 m_focus_mode == F_GLOBALLYACTIVE && send_focus_message);
164} 172}
165 173
@@ -222,11 +230,11 @@ bool WinClient::getWMIconName(XTextProperty &textprop) const {
222 return XGetWMName(display(), window(), &textprop); 230 return XGetWMName(display(), window(), &textprop);
223} 231}
224 232
225const std::string &WinClient::getWMClassName() const { 233const string &WinClient::getWMClassName() const {
226 return m_instance_name; 234 return m_instance_name;
227} 235}
228 236
229const std::string &WinClient::getWMClassClass() const { 237const string &WinClient::getWMClassClass() const {
230 return m_class_name; 238 return m_class_name;
231} 239}
232 240
@@ -236,15 +244,15 @@ void WinClient::updateWMClassHint() {
236#ifdef DEBUG 244#ifdef DEBUG
237 cerr<<"WinClient: Failed to read class hint!"<<endl; 245 cerr<<"WinClient: Failed to read class hint!"<<endl;
238#endif //DEBUG 246#endif //DEBUG
239 } else { 247 } else {
240 248
241 if (ch.res_name != 0) { 249 if (ch.res_name != 0) {
242 m_instance_name = const_cast<char *>(ch.res_name); 250 m_instance_name = const_cast<char *>(ch.res_name);
243 XFree(ch.res_name); 251 XFree(ch.res_name);
244 ch.res_name = 0; 252 ch.res_name = 0;
245 } else 253 } else
246 m_instance_name = ""; 254 m_instance_name = "";
247 255
248 if (ch.res_class != 0) { 256 if (ch.res_class != 0) {
249 m_class_name = const_cast<char *>(ch.res_class); 257 m_class_name = const_cast<char *>(ch.res_class);
250 XFree(ch.res_class); 258 XFree(ch.res_class);
@@ -266,7 +274,7 @@ void WinClient::updateTransientInfo() {
266 if (transientFor() != 0) { 274 if (transientFor() != 0) {
267 transientFor()->transientList().remove(this); 275 transientFor()->transientList().remove(this);
268 } 276 }
269 277
270 transient_for = 0; 278 transient_for = 0;
271 // determine if this is a transient window 279 // determine if this is a transient window
272 Window win = 0; 280 Window win = 0;
@@ -284,24 +292,24 @@ void WinClient::updateTransientInfo() {
284#endif // DEBUG 292#endif // DEBUG
285 return; 293 return;
286 } 294 }
287 295
288 if (win != None && m_win->screen().rootWindow() == win) { 296 if (win != None && m_win->screen().rootWindow() == win) {
289 // transient for root window... = transient for group 297 // transient for root window... = transient for group
290 // I don't think we are group-aware yet 298 // I don't think we are group-aware yet
291 return; 299 return;
292 } 300 }
293 301
294 302
295 transient_for = Fluxbox::instance()->searchWindow(win); 303 transient_for = Fluxbox::instance()->searchWindow(win);
296 // if we did not find a transient WinClient but still 304 // if we did not find a transient WinClient but still
297 // have a transient X window, then we have to put the 305 // have a transient X window, then we have to put the
298 // X transient_for window in a waiting list and update this clients transient 306 // X transient_for window in a waiting list and update this clients transient
299 // list later when the transient_for has a Winclient 307 // list later when the transient_for has a Winclient
300 if (!transient_for) { 308 if (!transient_for) {
301 // We might also already waiting for an old transient_for; 309 // We might also already waiting for an old transient_for;
302 // 310 //
303 // this call fixes issue 2: 311 // this call fixes issue 2:
304 // If transients changes to new transient_for before the old transient_for is created. 312 // If transients changes to new transient_for before the old transient_for is created.
305 // (see comment in WinClient.hh) 313 // (see comment in WinClient.hh)
306 // 314 //
307 removeTransientFromWaitingList(); 315 removeTransientFromWaitingList();
@@ -335,11 +343,11 @@ void WinClient::updateTransientInfo() {
335 343
336 344
337void WinClient::updateTitle() { 345void WinClient::updateTitle() {
338 // why 512? very very long wmnames seem to either 346 // why 512? very very long wmnames seem to either
339 // crash fluxbox or to make it have high cpuload 347 // crash fluxbox or to make it have high cpuload
340 // see also: 348 // see also:
341 // http://www.securityfocus.com/archive/1/382398/2004-11-24/2004-11-30/2 349 // http://www.securityfocus.com/archive/1/382398/2004-11-24/2004-11-30/2
342 // 350 //
343 // TODO: - find out why this mostly happens when using xft-fonts 351 // TODO: - find out why this mostly happens when using xft-fonts
344 // - why other windowmanagers (pekwm/pwm3/openbox etc) are 352 // - why other windowmanagers (pekwm/pwm3/openbox etc) are
345 // also influenced 353 // also influenced
@@ -492,7 +500,7 @@ void WinClient::updateWMHints() {
492 m_focus_mode = F_NOINPUT; 500 m_focus_mode = F_NOINPUT;
493 } 501 }
494 } else // InputHint not present: ignoring send_focus_message and assuming F_PASSIVE 502 } else // InputHint not present: ignoring send_focus_message and assuming F_PASSIVE
495 m_focus_mode = F_PASSIVE; 503 m_focus_mode = F_PASSIVE;
496 504
497 if (wmhint->flags & StateHint) 505 if (wmhint->flags & StateHint)
498 initial_state = wmhint->initial_state; 506 initial_state = wmhint->initial_state;
@@ -626,7 +634,7 @@ void WinClient::setGroupLeftWindow(Window win) {
626 if (m_screen.isShuttingdown()) 634 if (m_screen.isShuttingdown())
627 return; 635 return;
628 Atom group_left_hint = XInternAtom(display(), "_FLUXBOX_GROUP_LEFT", False); 636 Atom group_left_hint = XInternAtom(display(), "_FLUXBOX_GROUP_LEFT", False);
629 changeProperty(group_left_hint, XA_WINDOW, 32, 637 changeProperty(group_left_hint, XA_WINDOW, 32,
630 PropModeReplace, (unsigned char *) &win, 1); 638 PropModeReplace, (unsigned char *) &win, 1);
631} 639}
632 640
@@ -672,7 +680,7 @@ bool WinClient::validateClient() const {
672 680
673 XEvent e; 681 XEvent e;
674 if (( XCheckTypedWindowEvent(display(), window(), DestroyNotify, &e) || 682 if (( XCheckTypedWindowEvent(display(), window(), DestroyNotify, &e) ||
675 XCheckTypedWindowEvent(display(), window(), UnmapNotify, &e)) 683 XCheckTypedWindowEvent(display(), window(), UnmapNotify, &e))
676 && XPutBackEvent(display(), &e)) { 684 && XPutBackEvent(display(), &e)) {
677 Fluxbox::instance()->ungrab(); 685 Fluxbox::instance()->ungrab();
678 return false; 686 return false;
@@ -681,7 +689,7 @@ bool WinClient::validateClient() const {
681 return true; 689 return true;
682} 690}
683 691
684void WinClient::setStrut(Strut *strut) { 692void WinClient::setStrut(Strut *strut) {
685 clearStrut(); 693 clearStrut();
686 m_strut = strut; 694 m_strut = strut;
687} 695}
@@ -736,14 +744,14 @@ void WinClient::updateWMProtocols() {
736 Note that its slightly simplified in that only the 744 Note that its slightly simplified in that only the
737 line gradient is given - this is because for aspect 745 line gradient is given - this is because for aspect
738 ratios, we always have the line going through the origin 746 ratios, we always have the line going through the origin
739 747
740 * Based on this formula: 748 * Based on this formula:
741 http://astronomy.swin.edu.au/~pbourke/geometry/pointline/ 749 http://astronomy.swin.edu.au/~pbourke/geometry/pointline/
742 750
743 Note that a gradient from origin goes through ( grad , 1 ) 751 Note that a gradient from origin goes through ( grad , 1 )
744 */ 752 */
745 753
746void closestPointToLine(double &ret_x, double &ret_y, 754void closestPointToLine(double &ret_x, double &ret_y,
747 double point_x, double point_y, 755 double point_x, double point_y,
748 double gradient) { 756 double gradient) {
749 double u = (point_x * gradient + point_y) / 757 double u = (point_x * gradient + point_y) /
@@ -763,13 +771,13 @@ void closestPointToLine(double &ret_x, double &ret_y,
763 * 771 *
764 * See ICCCM section 4.1.2.3 772 * See ICCCM section 4.1.2.3
765 */ 773 */
766void WinClient::applySizeHints(int &width, int &height, 774void WinClient::applySizeHints(int &width, int &height,
767 int *display_width, int *display_height) { 775 int *display_width, int *display_height) {
768 776
769 int i = width, j = height; 777 int i = width, j = height;
770 778
771 // Check minimum size 779 // Check minimum size
772 if (width < 0 || width < static_cast<signed>(min_width)) 780 if (width < 0 || width < static_cast<signed>(min_width))
773 width = min_width; 781 width = min_width;
774 782
775 if (height < 0 || height < static_cast<signed>(min_height)) 783 if (height < 0 || height < static_cast<signed>(min_height))
@@ -783,8 +791,8 @@ void WinClient::applySizeHints(int &width, int &height,
783 height = max_height; 791 height = max_height;
784 792
785 // we apply aspect ratios before incrementals 793 // we apply aspect ratios before incrementals
786 // Too difficult to exactly satisfy both incremental+aspect 794 // Too difficult to exactly satisfy both incremental+aspect
787 // in most situations 795 // in most situations
788 // (they really shouldn't happen at the same time anyway). 796 // (they really shouldn't happen at the same time anyway).
789 797
790 /* aspect ratios are applied exclusive to the base_width 798 /* aspect ratios are applied exclusive to the base_width
@@ -809,11 +817,11 @@ void WinClient::applySizeHints(int &width, int &height,
809 double widthd = static_cast<double>(width - base_width); 817 double widthd = static_cast<double>(width - base_width);
810 double heightd = static_cast<double>(height - base_height); 818 double heightd = static_cast<double>(height - base_height);
811 819
812 double min = static_cast<double>(min_aspect_x) / 820 double min = static_cast<double>(min_aspect_x) /
813 static_cast<double>(min_aspect_y); 821 static_cast<double>(min_aspect_y);
814 822
815 double max = static_cast<double>(max_aspect_x) / 823 double max = static_cast<double>(max_aspect_x) /
816 static_cast<double>(max_aspect_y); 824 static_cast<double>(max_aspect_y);
817 825
818 double actual = widthd / heightd; 826 double actual = widthd / heightd;
819 827
@@ -836,7 +844,7 @@ void WinClient::applySizeHints(int &width, int &height,
836 844
837 // enforce incremental size limits, wrt base size 845 // enforce incremental size limits, wrt base size
838 // only calculate this if we really need to 846 // only calculate this if we really need to
839 i = (width - static_cast<signed>(base_width)) / 847 i = (width - static_cast<signed>(base_width)) /
840 static_cast<signed>(width_inc); 848 static_cast<signed>(width_inc);
841 width = i*static_cast<signed>(width_inc) + 849 width = i*static_cast<signed>(width_inc) +
842 static_cast<signed>(base_width); 850 static_cast<signed>(base_width);
@@ -857,9 +865,9 @@ void WinClient::removeTransientFromWaitingList() {
857 865
858 // holds the windows that dont have empty 866 // holds the windows that dont have empty
859 // transient waiting list 867 // transient waiting list
860 std::list<Window> remove_list; 868 list<Window> remove_list;
861 869
862 // The worst case complexity is huge, but since we usually do not (virtualy never) 870 // The worst case complexity is huge, but since we usually do not (virtualy never)
863 // have a large transient waiting list the time spent here is neglectable 871 // have a large transient waiting list the time spent here is neglectable
864 TransientWaitMap::iterator t_it = s_transient_wait.begin(); 872 TransientWaitMap::iterator t_it = s_transient_wait.begin();
865 TransientWaitMap::iterator t_it_end = s_transient_wait.end(); 873 TransientWaitMap::iterator t_it_end = s_transient_wait.end();
@@ -872,8 +880,8 @@ void WinClient::removeTransientFromWaitingList() {
872 } 880 }
873 881
874 // erase empty waiting lists 882 // erase empty waiting lists
875 std::list<Window>::iterator it = remove_list.begin(); 883 list<Window>::iterator it = remove_list.begin();
876 std::list<Window>::iterator it_end = remove_list.end(); 884 list<Window>::iterator it_end = remove_list.end();
877 for (; it != it_end; ++it) 885 for (; it != it_end; ++it)
878 s_transient_wait.erase(*it); 886 s_transient_wait.erase(*it);
879} 887}