aboutsummaryrefslogtreecommitdiff
path: root/src/Slit.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-22 12:31:37 (GMT)
committerfluxgen <fluxgen>2003-06-22 12:31:37 (GMT)
commitd156afb9ac465f6395f4c63eea4757752f9deb7d (patch)
tree3685e2c6b33c9497e1b0c42c6fa1108c5b8632ab /src/Slit.cc
parent74b34bf3aed23fa57de6d20dcf3556494e848c7f (diff)
downloadfluxbox-d156afb9ac465f6395f4c63eea4757752f9deb7d.zip
fluxbox-d156afb9ac465f6395f4c63eea4757752f9deb7d.tar.bz2
cleaning
Diffstat (limited to 'src/Slit.cc')
-rw-r--r--src/Slit.cc123
1 files changed, 49 insertions, 74 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index 2dd9a78..a219fd8 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Slit.cc,v 1.62 2003/06/20 01:27:28 fluxgen Exp $ 25// $Id: Slit.cc,v 1.63 2003/06/22 12:31:37 fluxgen Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -54,6 +54,7 @@
54#include "Xinerama.hh" 54#include "Xinerama.hh"
55#include "SlitTheme.hh" 55#include "SlitTheme.hh"
56#include "SlitClient.hh" 56#include "SlitClient.hh"
57#include "Xutil.hh"
57 58
58#include <algorithm> 59#include <algorithm>
59#include <iostream> 60#include <iostream>
@@ -69,53 +70,6 @@
69#include <iostream> 70#include <iostream>
70#include <algorithm> 71#include <algorithm>
71using namespace std; 72using namespace std;
72namespace {
73
74void getWMName(BScreen *screen, Window window, std::string& name) {
75 name = "";
76
77 if (screen == 0 || window == None)
78 return;
79
80 Display *display = FbTk::App::instance()->display();
81
82 XTextProperty text_prop;
83 char **list;
84 int num;
85 I18n *i18n = I18n::instance();
86
87 if (XGetWMName(display, window, &text_prop)) {
88 if (text_prop.value && text_prop.nitems > 0) {
89 if (text_prop.encoding != XA_STRING) {
90
91 text_prop.nitems = strlen((char *) text_prop.value);
92
93 if ((XmbTextPropertyToTextList(display, &text_prop,
94 &list, &num) == Success) &&
95 (num > 0) && *list) {
96 name = static_cast<char *>(*list);
97 XFreeStringList(list);
98 } else
99 name = (char *)text_prop.value;
100
101 } else
102 name = (char *)text_prop.value;
103 } else { // default name
104 name = i18n->getMessage(
105 FBNLS::WindowSet, FBNLS::WindowUnnamed,
106 "Unnamed");
107 }
108 } else {
109 // default name
110 name = i18n->getMessage(
111 FBNLS::WindowSet, FBNLS::WindowUnnamed,
112 "Unnamed");
113 }
114
115}
116
117};
118
119 73
120namespace { 74namespace {
121 75
@@ -148,6 +102,7 @@ public:
148 m_label(label ? label : "") { 102 m_label(label ? label : "") {
149 setLabel(m_label.c_str()); // update label 103 setLabel(m_label.c_str()); // update label
150 } 104 }
105
151 void click(int button, int time) { 106 void click(int button, int time) {
152 // toggle direction 107 // toggle direction
153 if (m_slit.direction() == Slit::HORIZONTAL) 108 if (m_slit.direction() == Slit::HORIZONTAL)
@@ -163,11 +118,9 @@ public:
163 m_label = (label ? label : ""); 118 m_label = (label ? label : "");
164 std::string reallabel = m_label + " " + 119 std::string reallabel = m_label + " " +
165 ( m_slit.direction() == Slit::HORIZONTAL ? 120 ( m_slit.direction() == Slit::HORIZONTAL ?
166 i18n->getMessage( 121 i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionHoriz,
167 FBNLS::CommonSet, FBNLS::CommonDirectionHoriz,
168 "Horizontal") : 122 "Horizontal") :
169 i18n->getMessage( 123 i18n->getMessage(FBNLS::CommonSet, FBNLS::CommonDirectionVert,
170 FBNLS::CommonSet, FBNLS::CommonDirectionVert,
171 "Vertical") ); 124 "Vertical") );
172 FbTk::MenuItem::setLabel(reallabel.c_str()); 125 FbTk::MenuItem::setLabel(reallabel.c_str());
173 } 126 }
@@ -198,7 +151,8 @@ unsigned int Slit::s_eventmask = SubstructureRedirectMask | ButtonPressMask |
198 EnterWindowMask | LeaveWindowMask | ExposureMask; 151 EnterWindowMask | LeaveWindowMask | ExposureMask;
199 152
200Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) 153Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
201 : m_screen(scr), m_timer(this), 154 : m_hidden(false),
155 m_screen(scr), m_timer(this),
202 m_slitmenu(*scr.menuTheme(), 156 m_slitmenu(*scr.menuTheme(),
203 scr.screenNumber(), 157 scr.screenNumber(),
204 scr.imageControl(), 158 scr.imageControl(),
@@ -226,11 +180,14 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
226 m_layeritem(0), 180 m_layeritem(0),
227 m_slit_theme(new SlitTheme(*this)), 181 m_slit_theme(new SlitTheme(*this)),
228 m_strut(0), 182 m_strut(0),
183
184 // resources
185
229 m_rc_auto_hide(scr.resourceManager(), false, 186 m_rc_auto_hide(scr.resourceManager(), false,
230 scr.name() + ".slit.autoHide", scr.altName() + ".Slit.AutoHide"), 187 scr.name() + ".slit.autoHide", scr.altName() + ".Slit.AutoHide"),
231 // TODO: this resource name must change 188 // TODO: this resource name must change
232 m_rc_maximize_over(scr.resourceManager(), false, 189 m_rc_maximize_over(scr.resourceManager(), false,
233 scr.name() + ".maxOverSlit", scr.altName() + ".MaxOverSlit"), 190 scr.name() + ".slit.maxOver", scr.altName() + ".Slit.MaxOver"),
234 m_rc_placement(scr.resourceManager(), BOTTOMRIGHT, 191 m_rc_placement(scr.resourceManager(), BOTTOMRIGHT,
235 scr.name() + ".slit.placement", scr.altName() + ".Slit.Placement"), 192 scr.name() + ".slit.placement", scr.altName() + ".Slit.Placement"),
236 m_rc_direction(scr.resourceManager(), VERTICAL, 193 m_rc_direction(scr.resourceManager(), VERTICAL,
@@ -248,6 +205,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
248 m_timer.setTimeout(200); // default timeout 205 m_timer.setTimeout(200); // default timeout
249 m_timer.fireOnce(true); 206 m_timer.fireOnce(true);
250 207
208 // create main window
209
251 XSetWindowAttributes attrib; 210 XSetWindowAttributes attrib;
252 unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | 211 unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
253 CWColormap | CWOverrideRedirect | CWEventMask; 212 CWColormap | CWOverrideRedirect | CWEventMask;
@@ -287,6 +246,8 @@ Slit::~Slit() {
287 clearStrut(); 246 clearStrut();
288 if (frame.pixmap != 0) 247 if (frame.pixmap != 0)
289 screen().imageControl().removeImage(frame.pixmap); 248 screen().imageControl().removeImage(frame.pixmap);
249
250 shutdown();
290} 251}
291 252
292void Slit::clearStrut() { 253void Slit::clearStrut() {
@@ -355,7 +316,7 @@ void Slit::addClient(Window w) {
355 // Look for slot in client list by name 316 // Look for slot in client list by name
356 SlitClient *client = 0; 317 SlitClient *client = 0;
357 std::string match_name; 318 std::string match_name;
358 ::getWMName(&screen(), w, match_name); 319 match_name = Xutil::getWMName(w);
359 SlitClients::iterator it = m_client_list.begin(); 320 SlitClients::iterator it = m_client_list.begin();
360 SlitClients::iterator it_end = m_client_list.end(); 321 SlitClients::iterator it_end = m_client_list.end();
361 bool found_match = false; 322 bool found_match = false;
@@ -422,9 +383,10 @@ void Slit::addClient(Window w) {
422 m_kwm2_dockwindow, 0l, 1l, False, 383 m_kwm2_dockwindow, 0l, 1l, False,
423 m_kwm2_dockwindow, 384 m_kwm2_dockwindow,
424 &ajunk, &ijunk, &uljunk, &uljunk, 385 &ajunk, &ijunk, &uljunk, &uljunk,
425 (unsigned char **) &data) == Success) { 386 (unsigned char **) &data) == Success && data) {
426 iskdedockapp = (data && data[0] != 0); 387 iskdedockapp = (data && data[0] != 0);
427 XFree((char *) data); 388 XFree((char *) data);
389 data = 0;
428 } 390 }
429 391
430 // Check if KDE v1.x dock applet 392 // Check if KDE v1.x dock applet
@@ -433,9 +395,10 @@ void Slit::addClient(Window w) {
433 m_kwm1_dockwindow, 0l, 1l, False, 395 m_kwm1_dockwindow, 0l, 1l, False,
434 m_kwm1_dockwindow, 396 m_kwm1_dockwindow,
435 &ajunk, &ijunk, &uljunk, &uljunk, 397 &ajunk, &ijunk, &uljunk, &uljunk,
436 (unsigned char **) &data) == Success) { 398 (unsigned char **) &data) == Success && data) {
437 iskdedockapp = (data && data[0] != 0); 399 iskdedockapp = (data && data[0] != 0);
438 XFree((char *) data); 400 XFree((char *) data);
401 data = 0;
439 } 402 }
440 } 403 }
441 404
@@ -496,10 +459,14 @@ void Slit::setPlacement(Placement place) {
496} 459}
497 460
498void Slit::removeClient(SlitClient *client, bool remap, bool destroy) { 461void Slit::removeClient(SlitClient *client, bool remap, bool destroy) {
462 if (client == 0)
463 return;
464
499#ifdef DEBUG 465#ifdef DEBUG
500 cerr<<"Slit::removeClient( client->client_window = 0x"<<hex<<client->clientWindow()<< 466 cerr<<"Slit::removeClient( client->client_window = 0x"<<hex<<client->clientWindow()<<
501 ", client->icon_window)"<<endl; 467 ", client->icon_window)"<<endl;
502#endif // DEBUG 468#endif // DEBUG
469
503 // remove from event manager 470 // remove from event manager
504 if (client->clientWindow() != 0) 471 if (client->clientWindow() != 0)
505 FbTk::EventManager::instance()->remove(client->clientWindow()); 472 FbTk::EventManager::instance()->remove(client->clientWindow());
@@ -677,6 +644,7 @@ void Slit::reconfigure() {
677 (*client_it)->enableEvents(); 644 (*client_it)->enableEvents();
678 continue; 645 continue;
679 } 646 }
647
680 if (height_inc) 648 if (height_inc)
681 x = (frame.width - (*client_it)->width()) / 2; 649 x = (frame.width - (*client_it)->width()) / 2;
682 else 650 else
@@ -717,6 +685,8 @@ void Slit::reconfigure() {
717 m_slitmenu.reconfigure(); 685 m_slitmenu.reconfigure();
718 updateClientmenu(); 686 updateClientmenu();
719 updateStrut(); 687 updateStrut();
688
689
720} 690}
721 691
722 692
@@ -839,6 +809,10 @@ void Slit::reposition() {
839 frame.window.moveResize(frame.x, frame.y, 809 frame.window.moveResize(frame.x, frame.y,
840 frame.width, frame.height); 810 frame.width, frame.height);
841 } 811 }
812#ifdef DEBUG
813 cerr<<__FILE__<<"("<<__FUNCTION__<<"): frame("<<dec<<frame.x<<", "<<frame.y<<", "<<frame.width<<", "<<frame.height<<")"<<endl;
814#endif // DEBUG
815
842} 816}
843 817
844 818
@@ -896,7 +870,7 @@ void Slit::handleEvent(XEvent &event) {
896 if (data) 870 if (data)
897 iskdedockapp = True; 871 iskdedockapp = True;
898 XFree((char *) data); 872 XFree((char *) data);
899 873 data = 0;
900 } 874 }
901 875
902 // Check if KDE v1.x dock applet 876 // Check if KDE v1.x dock applet
@@ -904,9 +878,10 @@ void Slit::handleEvent(XEvent &event) {
904 if (XGetWindowProperty(disp, event.xmaprequest.window, 878 if (XGetWindowProperty(disp, event.xmaprequest.window,
905 m_kwm1_dockwindow, 0l, 1l, False, 879 m_kwm1_dockwindow, 0l, 1l, False,
906 m_kwm1_dockwindow, &ajunk, &ijunk, &uljunk, 880 m_kwm1_dockwindow, &ajunk, &ijunk, &uljunk,
907 &uljunk, (unsigned char **) &data) == Success) { 881 &uljunk, (unsigned char **) &data) == Success && data) {
908 iskdedockapp = (data && data[0] != 0); 882 iskdedockapp = (data && data[0] != 0);
909 XFree((char *) data); 883 XFree((char *) data);
884 data = 0;
910 } 885 }
911 } 886 }
912 887
@@ -1142,8 +1117,7 @@ void Slit::setupMenu() {
1142 1117
1143 // setup base menu 1118 // setup base menu
1144 m_slitmenu.setLabel("Slit"); 1119 m_slitmenu.setLabel("Slit");
1145 m_slitmenu.insert(i18n->getMessage( 1120 m_slitmenu.insert(i18n->getMessage(CommonSet, CommonPlacementTitle,
1146 CommonSet, CommonPlacementTitle,
1147 "Placement"), 1121 "Placement"),
1148 &m_placement_menu); 1122 &m_placement_menu);
1149 1123
@@ -1152,29 +1126,31 @@ void Slit::setupMenu() {
1152#ifdef XINERAMA 1126#ifdef XINERAMA
1153 if (screen().hasXinerama()) { 1127 if (screen().hasXinerama()) {
1154 m_slitmenu.insert("On Head...", new XineramaHeadMenu<Slit>( 1128 m_slitmenu.insert("On Head...", new XineramaHeadMenu<Slit>(
1155 *screen().menuTheme(), 1129 *screen().menuTheme(),
1156 screen(), 1130 screen(),
1157 screen().imageControl(), 1131 screen().imageControl(),
1158 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), 1132 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
1159 this 1133 this
1160 )); 1134 ));
1161 } 1135 }
1162 1136
1163#endif //XINERAMA 1137#endif //XINERAMA
1164 m_slitmenu.insert(new BoolMenuItem(i18n->getMessage( 1138 m_slitmenu.insert(new BoolMenuItem(i18n->getMessage(CommonSet, CommonAutoHide,
1165 CommonSet, CommonAutoHide,
1166 "Auto hide"), 1139 "Auto hide"),
1167 *m_rc_auto_hide, 1140 *m_rc_auto_hide,
1168 save_and_reconfigure_slit)); 1141 save_and_reconfigure_slit));
1169 1142
1143 m_slitmenu.insert(new BoolMenuItem("Maximize Over",
1144 *m_rc_maximize_over,
1145 save_and_reconfigure_slit));
1146
1170 FbTk::MenuItem *alpha_menuitem = new IntResMenuItem("Alpha", 1147 FbTk::MenuItem *alpha_menuitem = new IntResMenuItem("Alpha",
1171 m_rc_alpha, 1148 m_rc_alpha,
1172 0, 255); 1149 0, 255);
1173 alpha_menuitem->setCommand(save_and_reconfigure_slit); 1150 alpha_menuitem->setCommand(save_and_reconfigure_slit);
1174 m_slitmenu.insert(alpha_menuitem); 1151 m_slitmenu.insert(alpha_menuitem);
1175 1152
1176 m_slitmenu.insert(new SlitDirMenuItem(i18n->getMessage( 1153 m_slitmenu.insert(new SlitDirMenuItem(i18n->getMessage(SlitSet, SlitSlitDirection,
1177 SlitSet, SlitSlitDirection,
1178 "Slit Direction"), 1154 "Slit Direction"),
1179 *this, 1155 *this,
1180 save_and_reconfigure)); 1156 save_and_reconfigure));
@@ -1182,9 +1158,8 @@ void Slit::setupMenu() {
1182 m_slitmenu.update(); 1158 m_slitmenu.update();
1183 1159
1184 // setup sub menu 1160 // setup sub menu
1185 m_placement_menu.setLabel(i18n->getMessage( 1161 m_placement_menu.setLabel(i18n->getMessage(SlitSet, SlitSlitPlacement,
1186 SlitSet, SlitSlitPlacement, 1162 "Slit Placement"));
1187 "Slit Placement"));
1188 m_placement_menu.setMinimumSublevels(3); 1163 m_placement_menu.setMinimumSublevels(3);
1189 m_layermenu->setInternalMenu(); 1164 m_layermenu->setInternalMenu();
1190 m_clientlist_menu.setInternalMenu(); 1165 m_clientlist_menu.setInternalMenu();