diff options
-rw-r--r-- | src/fluxbox.cc | 179 | ||||
-rw-r--r-- | src/fluxbox.hh | 2 |
2 files changed, 114 insertions, 67 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 821fbd1..ede9a5a 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -324,87 +324,56 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile | |||
324 | m_fluxbox_pid = XInternAtom(disp, "_BLACKBOX_PID", False); | 324 | m_fluxbox_pid = XInternAtom(disp, "_BLACKBOX_PID", False); |
325 | #endif // HAVE_GETPID | 325 | #endif // HAVE_GETPID |
326 | 326 | ||
327 | // Allocate screens | ||
328 | for (int i = 0; i < ScreenCount(display()); i++) { | ||
329 | char scrname[128], altscrname[128]; | ||
330 | sprintf(scrname, "session.screen%d", i); | ||
331 | sprintf(altscrname, "session.Screen%d", i); | ||
332 | BScreen *screen = new BScreen(m_screen_rm.lock(), | ||
333 | scrname, altscrname, | ||
334 | i, getNumberOfLayers()); | ||
335 | if (! screen->isScreenManaged()) { | ||
336 | delete screen; | ||
337 | continue; | ||
338 | } | ||
339 | // add to our list | ||
340 | m_screen_list.push_back(screen); | ||
341 | |||
342 | // now we can create menus (which needs this screen to be in screen_list) | ||
343 | screen->initMenus(); | ||
344 | 327 | ||
345 | #ifdef HAVE_GETPID | 328 | vector<int> screens; |
346 | pid_t bpid = getpid(); | 329 | int i; |
347 | |||
348 | screen->rootWindow().changeProperty(getFluxboxPidAtom(), XA_CARDINAL, | ||
349 | sizeof(pid_t) * 8, PropModeReplace, | ||
350 | (unsigned char *) &bpid, 1); | ||
351 | #endif // HAVE_GETPID | ||
352 | 330 | ||
353 | #ifdef HAVE_RANDR | 331 | // default is "use all screens" |
354 | // setup RANDR for this screens root window | 332 | for (i = 0; i < ScreenCount(disp); i++) |
355 | // we need to determine if we should use old randr select input function or not | 333 | screens.push_back(i); |
356 | #ifdef X_RRScreenChangeSelectInput | ||
357 | // use old set randr event | ||
358 | XRRScreenChangeSelectInput(disp, screen->rootWindow().window(), True); | ||
359 | #else | ||
360 | XRRSelectInput(disp, screen->rootWindow().window(), | ||
361 | RRScreenChangeNotifyMask); | ||
362 | #endif // X_RRScreenChangeSelectInput | ||
363 | 334 | ||
364 | #endif // HAVE_RANDR | 335 | // find out, on what "screens" fluxbox should run |
365 | 336 | for (i = 1; i < m_argc; i++) { | |
366 | 337 | if (! strcmp(m_argv[i], "-screen")) { | |
367 | #ifdef USE_TOOLBAR | 338 | if ((++i) >= m_argc) { |
368 | m_toolbars.push_back(new Toolbar(*screen, | 339 | cerr<<"error, -screen requires argument\n"; |
369 | *screen->layerManager(). | 340 | exit(1); |
370 | getLayer(Fluxbox::instance()->getNormalLayer()))); | 341 | } |
371 | #endif // USE_TOOLBAR | ||
372 | 342 | ||
373 | // must do this after toolbar is created | 343 | // "all" is default |
374 | screen->initWindows(); | 344 | if (! strcmp(m_argv[i], "all")) |
345 | break; | ||
375 | 346 | ||
376 | // attach screen signals to this | 347 | vector<string> vals; |
377 | screen->currentWorkspaceSig().attach(this); | 348 | vector<int> scrtmp; |
378 | screen->workspaceCountSig().attach(this); | 349 | int scrnr = 0; |
379 | screen->workspaceNamesSig().attach(this); | 350 | FbTk::StringUtil::stringtok(vals, m_argv[i], ",:"); |
380 | screen->workspaceAreaSig().attach(this); | 351 | for (vector<string>::iterator scrit = vals.begin(); |
381 | screen->clientListSig().attach(this); | 352 | scrit != vals.end(); scrit++) { |
353 | scrnr = atoi(scrit->c_str()); | ||
354 | if (scrnr >= 0 && scrnr < ScreenCount(disp)) | ||
355 | scrtmp.push_back(scrnr); | ||
356 | } | ||
382 | 357 | ||
383 | // initiate atomhandler for screen specific stuff | 358 | if (!vals.empty()) |
384 | for (AtomHandlerContainerIt it= m_atomhandler.begin(); | 359 | swap(scrtmp, screens); |
385 | it != m_atomhandler.end(); | ||
386 | it++) { | ||
387 | (*it).first->initForScreen(*screen); | ||
388 | } | 360 | } |
389 | 361 | } | |
390 | revertFocus(*screen); // make sure focus style is correct | 362 | |
391 | #ifdef SLIT | 363 | // init all "screens" |
392 | if (screen->slit()) | 364 | for(i = 0; i < screens.size(); i++) |
393 | screen->slit()->show(); | 365 | initScreen(screens[i]); |
394 | #endif // SLIT | 366 | |
395 | |||
396 | |||
397 | } // end init screens | ||
398 | XAllowEvents(disp, ReplayPointer, CurrentTime); | 367 | XAllowEvents(disp, ReplayPointer, CurrentTime); |
399 | 368 | ||
400 | 369 | ||
401 | m_keyscreen = m_mousescreen = m_screen_list.front(); | ||
402 | |||
403 | if (m_screen_list.empty()) { | 370 | if (m_screen_list.empty()) { |
404 | throw string(_FBTEXT(Fluxbox, ErrorNoScreens, | 371 | throw string(_FBTEXT(Fluxbox, ErrorNoScreens, |
405 | "Couldn't find screens to manage.\nMake sure you don't have another window manager running.", "Error message when no unmanaged screens found - usually means another window manager is running")); | 372 | "Couldn't find screens to manage.\nMake sure you don't have another window manager running.", "Error message when no unmanaged screens found - usually means another window manager is running")); |
406 | } | 373 | } |
407 | 374 | ||
375 | m_keyscreen = m_mousescreen = m_screen_list.front(); | ||
376 | |||
408 | // setup theme manager to have our style file ready to be scanned | 377 | // setup theme manager to have our style file ready to be scanned |
409 | FbTk::ThemeManager::instance().load(FbTk::StringUtil::expandFilename(getStyleFilename())); | 378 | FbTk::ThemeManager::instance().load(FbTk::StringUtil::expandFilename(getStyleFilename())); |
410 | 379 | ||
@@ -467,6 +436,84 @@ Fluxbox::~Fluxbox() { | |||
467 | clearMenuFilenames(); | 436 | clearMenuFilenames(); |
468 | } | 437 | } |
469 | 438 | ||
439 | |||
440 | int Fluxbox::initScreen(int scrnr) { | ||
441 | |||
442 | Display* disp = display(); | ||
443 | char scrname[128], altscrname[128]; | ||
444 | sprintf(scrname, "session.screen%d", scrnr); | ||
445 | sprintf(altscrname, "session.Screen%d", scrnr); | ||
446 | BScreen *screen = new BScreen(m_screen_rm.lock(), | ||
447 | scrname, altscrname, | ||
448 | scrnr, getNumberOfLayers()); | ||
449 | |||
450 | // already handled | ||
451 | if (! screen->isScreenManaged()) { | ||
452 | delete screen; | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | // add to our list | ||
457 | m_screen_list.push_back(screen); | ||
458 | |||
459 | // now we can create menus (which needs this screen to be in screen_list) | ||
460 | screen->initMenus(); | ||
461 | |||
462 | #ifdef HAVE_GETPID | ||
463 | pid_t bpid = getpid(); | ||
464 | |||
465 | screen->rootWindow().changeProperty(getFluxboxPidAtom(), XA_CARDINAL, | ||
466 | sizeof(pid_t) * 8, PropModeReplace, | ||
467 | (unsigned char *) &bpid, 1); | ||
468 | #endif // HAVE_GETPID | ||
469 | |||
470 | #ifdef HAVE_RANDR | ||
471 | // setup RANDR for this screens root window | ||
472 | // we need to determine if we should use old randr select input function or not | ||
473 | #ifdef X_RRScreenChangeSelectInput | ||
474 | // use old set randr event | ||
475 | XRRScreenChangeSelectInput(disp, screen->rootWindow().window(), True); | ||
476 | #else | ||
477 | XRRSelectInput(disp, screen->rootWindow().window(), | ||
478 | RRScreenChangeNotifyMask); | ||
479 | #endif // X_RRScreenChangeSelectInput | ||
480 | |||
481 | #endif // HAVE_RANDR | ||
482 | |||
483 | |||
484 | #ifdef USE_TOOLBAR | ||
485 | m_toolbars.push_back(new Toolbar(*screen, | ||
486 | *screen->layerManager(). | ||
487 | getLayer(Fluxbox::instance()->getNormalLayer()))); | ||
488 | #endif // USE_TOOLBAR | ||
489 | |||
490 | // must do this after toolbar is created | ||
491 | screen->initWindows(); | ||
492 | |||
493 | // attach screen signals to this | ||
494 | screen->currentWorkspaceSig().attach(this); | ||
495 | screen->workspaceCountSig().attach(this); | ||
496 | screen->workspaceNamesSig().attach(this); | ||
497 | screen->workspaceAreaSig().attach(this); | ||
498 | screen->clientListSig().attach(this); | ||
499 | |||
500 | // initiate atomhandler for screen specific stuff | ||
501 | for (AtomHandlerContainerIt it= m_atomhandler.begin(); | ||
502 | it != m_atomhandler.end(); | ||
503 | it++) { | ||
504 | (*it).first->initForScreen(*screen); | ||
505 | } | ||
506 | |||
507 | revertFocus(*screen); // make sure focus style is correct | ||
508 | #ifdef SLIT | ||
509 | if (screen->slit()) | ||
510 | screen->slit()->show(); | ||
511 | #endif // SLIT | ||
512 | |||
513 | return 1; | ||
514 | } | ||
515 | |||
516 | |||
470 | void Fluxbox::eventLoop() { | 517 | void Fluxbox::eventLoop() { |
471 | Display *disp = display(); | 518 | Display *disp = display(); |
472 | while (!m_shutdown) { | 519 | while (!m_shutdown) { |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index b39c5af..17d9124 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -98,7 +98,7 @@ public: | |||
98 | WinClient *searchWindow(Window); | 98 | WinClient *searchWindow(Window); |
99 | inline WinClient *getFocusedWindow() { return m_focused_window; } | 99 | inline WinClient *getFocusedWindow() { return m_focused_window; } |
100 | 100 | ||
101 | 101 | int initScreen(int screen_nr); | |
102 | BScreen *searchScreen(Window w); | 102 | BScreen *searchScreen(Window w); |
103 | 103 | ||
104 | inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } | 104 | inline unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } |