aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-01-20 02:17:23 (GMT)
committerfluxgen <fluxgen>2002-01-20 02:17:23 (GMT)
commit6ea3678d0221914a3f54a78bbe8b8b282c4ce8e7 (patch)
treef4bf575038afede621ecf6568ec4384463d8e631 /src/Screen.cc
parentaaa0c6d0780ceb021a3306e2f0c3ae965541eff6 (diff)
downloadfluxbox-6ea3678d0221914a3f54a78bbe8b8b282c4ce8e7.zip
fluxbox-6ea3678d0221914a3f54a78bbe8b8b282c4ce8e7.tar.bz2
Fixed resources
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc171
1 files changed, 136 insertions, 35 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 27373d3..60914ef 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -99,6 +99,8 @@
99#endif // FONT_ELEMENT_SIZE 99#endif // FONT_ELEMENT_SIZE
100 100
101#include <iostream> 101#include <iostream>
102#include <memory>
103
102using namespace std; 104using namespace std;
103 105
104static Bool running = True; 106static Bool running = True;
@@ -125,15 +127,113 @@ static int dcmp(const void *one, const void *two) {
125 return (strcmp((*(char **) one), (*(char **) two))); 127 return (strcmp((*(char **) one), (*(char **) two)));
126} 128}
127 129
128BScreen::BScreen(Fluxbox *b, int scrn) : ScreenInfo(b, scrn), 130//---------- resource manipulators ---------
129rootcommand("") 131template<>
132void Resource<Tab::Alignment>::
133setFromString(const char *strval) {
134 m_value = Tab::getTabAlignmentNum(strval);
135}
136
137template<>
138void Resource<Tab::Placement>::
139setFromString(const char *strval) {
140 m_value = Tab::getTabPlacementNum(strval);
141}
142
143template<>
144void Resource<Toolbar::Placement>::
145setFromString(const char *strval) {
146 if (strcasecmp(strval, "TopLeft")==0)
147 m_value = Toolbar::TOPLEFT;
148 else if (strcasecmp(strval, "BottomLeft")==0)
149 m_value = Toolbar::BOTTOMLEFT;
150 else if (strcasecmp(strval, "TopCenter")==0)
151 m_value = Toolbar::TOPCENTER;
152 else if (strcasecmp(strval, "BottomCenter")==0)
153 m_value = Toolbar::BOTTOMCENTER;
154 else if (strcasecmp(strval, "TopRight")==0)
155 m_value = Toolbar::TOPRIGHT;
156 else if (strcasecmp(strval, "BottomRight")==0)
157 m_value = Toolbar::BOTTOMRIGHT;
158 else
159 setDefaultValue();
160}
161
162//--------- resource accessors --------------
163template<>
164string Resource<Tab::Alignment>::
165getString() {
166 return Tab::getTabAlignmentString(m_value);
167}
168
169template<>
170string Resource<Tab::Placement>::
171getString() {
172 return Tab::getTabPlacementString(m_value);
173}
174
175template<>
176string Resource<Toolbar::Placement>::
177getString() {
178 switch (m_value) {
179 case Toolbar::TOPLEFT:
180 return string("TopLeft");
181 break;
182 case Toolbar::BOTTOMLEFT:
183 return string("BottomLeft");
184 break;
185 case Toolbar::TOPCENTER:
186 return string("TopCenter");
187 break;
188 case Toolbar::BOTTOMCENTER:
189 return string("BottomCenter");
190 break;
191 case Toolbar::TOPRIGHT:
192 return string("TopRight");
193 break;
194 case Toolbar::BOTTOMRIGHT:
195 return string("BottomRight");
196 break;
197 }
198 //default string
199 return string("BottomCenter");
200}
201
202
203BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
204 const std::string &scrname, const std::string &altscrname):
205toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"),
206toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"),
207image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"),
208opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"),
209full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"),
210max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"),
211tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"),
212sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"),
213rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
214workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
215toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"),
216edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),
217tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"),
218tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"),
219tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"),
220tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"),
221toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement")
222{
223
224};
225
226BScreen::BScreen(ResourceManager &rm, Fluxbox *b,
227 const string &screenname, const string &altscreenname,
228 int scrn) : ScreenInfo(b, scrn),
229theme(0),
230resource(rm, screenname, altscreenname)
130{ 231{
131 theme = 0;
132 fluxbox = b; 232 fluxbox = b;
133 233
134 event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask | 234 event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
135 SubstructureRedirectMask | KeyPressMask | KeyReleaseMask | 235 SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
136 ButtonPressMask | ButtonReleaseMask; 236 ButtonPressMask | ButtonReleaseMask;
137 237
138 XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning); 238 XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
139 XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask); 239 XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask);
@@ -149,11 +249,11 @@ rootcommand("")
149 fprintf(stderr, 249 fprintf(stderr,
150 i18n-> 250 i18n->
151 getMessage( 251 getMessage(
152#ifdef NLS 252 #ifdef NLS
153 ScreenSet, ScreenManagingScreen, 253 ScreenSet, ScreenManagingScreen,
154#else // !NLS 254 #else // !NLS
155 0, 0, 255 0, 0,
156#endif // NLS 256 #endif // NLS
157 "BScreen::BScreen: managing screen %d " 257 "BScreen::BScreen: managing screen %d "
158 "using visual 0x%lx, depth %d\n"), 258 "using visual 0x%lx, depth %d\n"),
159 getScreenNumber(), XVisualIDFromVisual(getVisual()), 259 getScreenNumber(), XVisualIDFromVisual(getVisual()),
@@ -161,22 +261,22 @@ rootcommand("")
161 261
162 rootmenu = 0; 262 rootmenu = 0;
163 263
164#ifdef HAVE_STRFTIME 264 #ifdef HAVE_STRFTIME
165 resource.strftime_format = 0; 265 resource.strftime_format = 0;
166#endif // HAVE_STRFTIME 266 #endif // HAVE_STRFTIME
167 267
168#ifdef HAVE_GETPID 268 #ifdef HAVE_GETPID
169 pid_t bpid = getpid(); 269 pid_t bpid = getpid();
170 270
171 XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(), 271 XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
172 fluxbox->getFluxboxPidAtom(), XA_CARDINAL, 272 fluxbox->getFluxboxPidAtom(), XA_CARDINAL,
173 sizeof(pid_t) * 8, PropModeReplace, 273 sizeof(pid_t) * 8, PropModeReplace,
174 (unsigned char *) &bpid, 1); 274 (unsigned char *) &bpid, 1);
175#endif // HAVE_GETPID 275 #endif // HAVE_GETPID
176 276
177 277
178 XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(), 278 XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(),
179 fluxbox->getSessionCursor()); 279 fluxbox->getSessionCursor());
180 280
181 workspaceNames = new LinkedList<char>; 281 workspaceNames = new LinkedList<char>;
182 workspacesList = new LinkedList<Workspace>; 282 workspacesList = new LinkedList<Workspace>;
@@ -192,40 +292,41 @@ rootcommand("")
192 292
193 fluxbox->load_rc(this); 293 fluxbox->load_rc(this);
194 294
195 image_control->setDither(resource.image_dither); 295 image_control->setDither(*resource.image_dither);
196 theme = new Theme(getBaseDisplay()->getXDisplay(), getRootWindow(), getColormap(), getScreenNumber(), 296 theme = new Theme(getBaseDisplay()->getXDisplay(), getRootWindow(), getColormap(), getScreenNumber(),
197 image_control, fluxbox->getStyleFilename(), getRootCommand().c_str()); 297 image_control, fluxbox->getStyleFilename(), getRootCommand().c_str());
198 298
199#ifdef GNOME 299 #ifdef GNOME
200 /* create the GNOME window */ 300 /* create the GNOME window */
201 Window gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(), 301 Window gnome_win = XCreateSimpleWindow(getBaseDisplay()->getXDisplay(),
202 getRootWindow(), 0, 0, 5, 5, 0, 0, 0); 302 getRootWindow(), 0, 0, 5, 5, 0, 0, 0);
203 303
204 /* supported WM check */ 304 /* supported WM check */
205 XChangeProperty(getBaseDisplay()->getXDisplay(), 305 XChangeProperty(getBaseDisplay()->getXDisplay(),
206 getRootWindow(), getBaseDisplay()->getGnomeSupportingWMCheckAtom(), 306 getRootWindow(), getBaseDisplay()->getGnomeSupportingWMCheckAtom(),
207 XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); 307 XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1);
208 308
209 XChangeProperty(getBaseDisplay()->getXDisplay(), gnome_win, 309 XChangeProperty(getBaseDisplay()->getXDisplay(), gnome_win,
210 getBaseDisplay()->getGnomeSupportingWMCheckAtom(), 310 getBaseDisplay()->getGnomeSupportingWMCheckAtom(),
211 XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1); 311 XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &gnome_win, 1);
212 312
213 Atom gnomeatomlist[1] = {getBaseDisplay()->getGnomeWorkspaceAtom()}; 313 Atom gnomeatomlist[1] = {getBaseDisplay()->getGnomeWorkspaceAtom()};
214 314
215 XChangeProperty(getBaseDisplay()->getXDisplay(), 315 XChangeProperty(getBaseDisplay()->getXDisplay(),
216 getRootWindow(), getBaseDisplay()->getGnomeProtAtom(), 316 getRootWindow(), getBaseDisplay()->getGnomeProtAtom(),
217 XA_ATOM, 32, PropModeReplace, 317 XA_ATOM, 32, PropModeReplace,
218 (unsigned char *)gnomeatomlist, 1); 318 (unsigned char *)gnomeatomlist, 1);
219#endif 319 #endif
220 320
221 321
222 const char *s = i18n->getMessage( 322 const char *s = i18n->getMessage(
223#ifdef NLS 323 #ifdef NLS
224 ScreenSet, ScreenPositionLength, 324 ScreenSet, ScreenPositionLength,
225#else // !NLS 325 #else // !NLS
226 0, 0, 326 0, 0,
227#endif // NLS 327 #endif // NLS
228 "0: 0000 x 0: 0000"); 328 "0: 0000 x 0: 0000");
329
229 int l = strlen(s); 330 int l = strlen(s);
230 331
231 if (i18n->multibyte()) { 332 if (i18n->multibyte()) {
@@ -236,7 +337,7 @@ rootcommand("")
236 geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height; 337 geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height;
237 } else { 338 } else {
238 geom_h = theme->getWindowStyle().font.fontstruct->ascent + 339 geom_h = theme->getWindowStyle().font.fontstruct->ascent +
239 theme->getWindowStyle().font.fontstruct->descent; 340 theme->getWindowStyle().font.fontstruct->descent;
240 341
241 geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l); 342 geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l);
242 } 343 }
@@ -287,8 +388,8 @@ rootcommand("")
287 configmenu = new Configmenu(this); 388 configmenu = new Configmenu(this);
288 389
289 Workspace *wkspc = (Workspace *) 0; 390 Workspace *wkspc = (Workspace *) 0;
290 if (resource.workspaces != 0) { 391 if (*resource.workspaces != 0) {
291 for (int i = 0; i < resource.workspaces; ++i) { 392 for (int i = 0; i < *resource.workspaces; ++i) {
292 wkspc = new Workspace(this, workspacesList->count()); 393 wkspc = new Workspace(this, workspacesList->count());
293 workspacesList->insert(wkspc); 394 workspacesList->insert(wkspc);
294 workspacemenu->insert(wkspc->getName(), wkspc->getMenu()); 395 workspacemenu->insert(wkspc->getName(), wkspc->getMenu());
@@ -1597,8 +1698,8 @@ void BScreen::shutdown(void) {
1597void BScreen::showPosition(int x, int y) { 1698void BScreen::showPosition(int x, int y) {
1598 if (! geom_visible) { 1699 if (! geom_visible) {
1599 XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window, 1700 XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window,
1600 (getWidth() - geom_w) / 2, 1701 (getWidth() - geom_w) / 2,
1601 (getHeight() - geom_h) / 2, geom_w, geom_h); 1702 (getHeight() - geom_h) / 2, geom_w, geom_h);
1602 XMapWindow(getBaseDisplay()->getXDisplay(), geom_window); 1703 XMapWindow(getBaseDisplay()->getXDisplay(), geom_window);
1603 XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window); 1704 XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window);
1604 1705