2002-01-09 14:07:09 +00:00
|
|
|
// fluxbox.cc for Fluxbox Window Manager
|
|
|
|
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
2002-01-08 00:29:12 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// blackbox.cc for blackbox - an X11 Window manager
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2002-01-18 01:23:54 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2002-11-30 20:18:35 +00:00
|
|
|
// $Id: fluxbox.cc,v 1.83 2002/11/30 20:18:35 fluxgen Exp $
|
2002-08-17 22:14:00 +00:00
|
|
|
|
2002-01-09 14:07:09 +00:00
|
|
|
|
2002-08-13 21:19:00 +00:00
|
|
|
#include "fluxbox.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#include "i18n.hh"
|
|
|
|
#include "Basemenu.hh"
|
|
|
|
#include "Clientmenu.hh"
|
|
|
|
#include "Rootmenu.hh"
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
|
|
|
#include "Workspacemenu.hh"
|
2002-01-06 11:07:42 +00:00
|
|
|
#include "StringUtil.hh"
|
2002-01-18 01:23:54 +00:00
|
|
|
#include "Resource.hh"
|
2002-01-20 02:19:16 +00:00
|
|
|
#include "XrmDatabaseHelper.hh"
|
2002-09-07 20:25:39 +00:00
|
|
|
#include "AtomHandler.hh"
|
2002-11-30 20:18:35 +00:00
|
|
|
#include "ImageControl.hh"
|
2002-08-13 21:19:00 +00:00
|
|
|
|
|
|
|
//Use GNU extensions
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-10-25 21:17:15 +00:00
|
|
|
#ifdef SLIT
|
|
|
|
#include "Slit.hh"
|
|
|
|
#endif // SLIT
|
|
|
|
#ifdef USE_GNOME
|
|
|
|
#include "Gnome.hh"
|
|
|
|
#endif // USE_GNOME
|
|
|
|
#ifdef USE_NEWWMSPEC
|
|
|
|
#include "Ewmh.hh"
|
|
|
|
#endif //USE_NEWWMSPEC
|
|
|
|
|
2002-08-17 22:14:00 +00:00
|
|
|
// X headers
|
2002-01-06 11:07:42 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2002-08-17 22:14:00 +00:00
|
|
|
#include <X11/cursorfont.h>
|
2002-08-02 13:00:23 +00:00
|
|
|
#ifdef SHAPE
|
2002-01-06 11:07:42 +00:00
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#endif // SHAPE
|
|
|
|
|
2002-08-02 13:00:23 +00:00
|
|
|
#include <cstdio>
|
2002-08-13 21:19:00 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-02 13:00:23 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
2002-08-02 13:00:23 +00:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_SYS_PARAM_H
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifndef MAXPATHLEN
|
|
|
|
#define MAXPATHLEN 255
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // MAXPATHLEN
|
|
|
|
|
2002-08-02 13:00:23 +00:00
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
#include <sys/select.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_SYS_SELECT_H
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2002-10-25 21:17:15 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_SYS_STAT_H
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
2002-10-25 21:17:15 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#else // !TIME_WITH_SYS_TIME
|
2002-10-25 21:17:15 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#else // !HAVE_SYS_TIME_H
|
|
|
|
#include <time.h>
|
|
|
|
#endif // HAVE_SYS_TIME_H
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // TIME_WITH_SYS_TIME
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef HAVE_LIBGEN_H
|
|
|
|
# include <libgen.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_LIBGEN_H
|
|
|
|
|
2002-08-14 00:01:10 +00:00
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
2002-01-09 15:08:22 +00:00
|
|
|
#include <memory>
|
2002-07-14 01:00:23 +00:00
|
|
|
#include <algorithm>
|
2002-09-07 20:25:39 +00:00
|
|
|
#include <typeinfo>
|
2002-01-20 02:19:16 +00:00
|
|
|
|
2002-01-08 00:29:12 +00:00
|
|
|
using namespace std;
|
2002-08-14 00:01:10 +00:00
|
|
|
using namespace FbTk;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifndef HAVE_BASENAME
|
2002-08-02 13:00:23 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
char *basename (char *s) {
|
2002-01-18 01:23:54 +00:00
|
|
|
char *save = s;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-02 13:00:23 +00:00
|
|
|
while (*s) {
|
|
|
|
if (*s++ == '/')
|
|
|
|
save = s;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
return save;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-08-14 23:03:07 +00:00
|
|
|
|
|
|
|
}; // end anonymous namespace
|
2002-08-02 13:00:23 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_BASENAME
|
|
|
|
|
|
|
|
#define RC_PATH "fluxbox"
|
|
|
|
#define RC_INIT_FILE "init"
|
|
|
|
|
2002-01-08 00:29:12 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
// X event scanner for enter/leave notifies - adapted from twm
|
|
|
|
typedef struct scanargs {
|
2002-01-18 01:23:54 +00:00
|
|
|
Window w;
|
|
|
|
Bool leave, inferior, enter;
|
2001-12-11 20:47:02 +00:00
|
|
|
} scanargs;
|
|
|
|
|
|
|
|
static Bool queueScanner(Display *, XEvent *e, char *args) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if ((e->type == LeaveNotify) &&
|
|
|
|
(e->xcrossing.window == ((scanargs *) args)->w) &&
|
|
|
|
(e->xcrossing.mode == NotifyNormal)) {
|
|
|
|
((scanargs *) args)->leave = True;
|
|
|
|
((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior);
|
|
|
|
} else if ((e->type == EnterNotify) &&
|
2002-01-21 02:04:23 +00:00
|
|
|
(e->xcrossing.mode == NotifyUngrab))
|
2002-01-18 01:23:54 +00:00
|
|
|
((scanargs *) args)->enter = True;
|
|
|
|
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
//---- accessors for int, bool, and some enums with Resource ------
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
void Resource<int>::
|
|
|
|
setFromString(const char* strval) {
|
|
|
|
int val;
|
|
|
|
if (sscanf(strval, "%d", &val)==1)
|
|
|
|
*this = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<std::string>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
*this = strval;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<bool>::
|
|
|
|
setFromString(char const *strval) {
|
|
|
|
if (strcasecmp(strval, "true")==0)
|
|
|
|
*this = true;
|
|
|
|
else
|
|
|
|
*this = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<Fluxbox::TitlebarList>::
|
|
|
|
setFromString(char const *strval) {
|
|
|
|
vector<std::string> val;
|
|
|
|
StringUtil::stringtok(val, strval);
|
|
|
|
int size=val.size();
|
|
|
|
//clear old values
|
|
|
|
m_value.clear();
|
|
|
|
|
|
|
|
for (int i=0; i<size; i++) {
|
|
|
|
if (strcasecmp(val[i].c_str(), "Maximize")==0)
|
|
|
|
m_value.push_back(Fluxbox::MAXIMIZE);
|
|
|
|
else if (strcasecmp(val[i].c_str(), "Minimize")==0)
|
|
|
|
m_value.push_back(Fluxbox::MINIMIZE);
|
|
|
|
else if (strcasecmp(val[i].c_str(), "Shade")==0)
|
|
|
|
m_value.push_back(Fluxbox::SHADE);
|
|
|
|
else if (strcasecmp(val[i].c_str(), "Stick")==0)
|
|
|
|
m_value.push_back(Fluxbox::STICK);
|
|
|
|
else if (strcasecmp(val[i].c_str(), "Menu")==0)
|
|
|
|
m_value.push_back(Fluxbox::MENU);
|
|
|
|
else if (strcasecmp(val[i].c_str(), "Close")==0)
|
|
|
|
m_value.push_back(Fluxbox::CLOSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<unsigned int>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
if (sscanf(strval, "%ul", &m_value) != 1)
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
//---- manipulators for int, bool, and some enums with Resource ---
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
std::string Resource<bool>::
|
|
|
|
getString() {
|
|
|
|
return std::string(**this == true ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
std::string Resource<int>::
|
|
|
|
getString() {
|
|
|
|
char strval[256];
|
|
|
|
sprintf(strval, "%d", **this);
|
|
|
|
return std::string(strval);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
std::string Resource<std::string>::
|
|
|
|
getString() { return **this; }
|
|
|
|
|
|
|
|
template<>
|
2002-02-04 06:57:26 +00:00
|
|
|
std::string Resource<Fluxbox::TitlebarList>::
|
2002-01-18 01:23:54 +00:00
|
|
|
getString() {
|
|
|
|
string retval;
|
|
|
|
int size=m_value.size();
|
|
|
|
for (int i=0; i<size; i++) {
|
|
|
|
switch (m_value[i]) {
|
|
|
|
case Fluxbox::SHADE:
|
|
|
|
retval.append("Shade");
|
|
|
|
break;
|
|
|
|
case Fluxbox::MINIMIZE:
|
|
|
|
retval.append("Minimize");
|
|
|
|
break;
|
|
|
|
case Fluxbox::MAXIMIZE:
|
|
|
|
retval.append("Maximize");
|
|
|
|
break;
|
|
|
|
case Fluxbox::CLOSE:
|
|
|
|
retval.append("Close");
|
|
|
|
break;
|
|
|
|
case Fluxbox::STICK:
|
|
|
|
retval.append("Stick");
|
|
|
|
break;
|
|
|
|
case Fluxbox::MENU:
|
|
|
|
retval.append("Menu");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
retval.append(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
template<>
|
|
|
|
string Resource<unsigned int>::
|
|
|
|
getString() {
|
|
|
|
char tmpstr[128];
|
|
|
|
sprintf(tmpstr, "%ul", m_value);
|
|
|
|
return string(tmpstr);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
//static singleton var
|
|
|
|
Fluxbox *Fluxbox::singleton=0;
|
|
|
|
|
2002-03-01 15:28:56 +00:00
|
|
|
//default values for titlebar left and right
|
|
|
|
//don't forget to change last value in m_rc_titlebar_* if you add more to these
|
|
|
|
Fluxbox::Titlebar Fluxbox::m_titlebar_left[] = {STICK};
|
|
|
|
Fluxbox::Titlebar Fluxbox::m_titlebar_right[] = {MINIMIZE, MAXIMIZE, CLOSE};
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-13 21:19:00 +00:00
|
|
|
Fluxbox::Fluxbox(int m_argc, char **m_argv, const char *dpy_name, const char *rc)
|
2002-08-14 23:03:07 +00:00
|
|
|
: BaseDisplay(m_argv[0], dpy_name), FbAtoms(getXDisplay()),
|
2002-01-20 02:19:16 +00:00
|
|
|
m_resourcemanager(), m_screen_rm(),
|
2002-01-18 01:23:54 +00:00
|
|
|
m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"),
|
|
|
|
m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"),
|
|
|
|
m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"),
|
|
|
|
m_rc_stylefile(m_resourcemanager, "", "session.styleFile", "Session.StyleFile"),
|
|
|
|
m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"),
|
|
|
|
m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"),
|
2002-05-29 06:22:31 +00:00
|
|
|
m_rc_slitlistfile(m_resourcemanager, "", "session.slitlistFile", "Session.SlitlistFile"),
|
2002-08-11 20:38:23 +00:00
|
|
|
m_rc_groupfile(m_resourcemanager, "", "session.groupFile", "Session.GroupFile"),
|
2002-03-01 15:28:56 +00:00
|
|
|
m_rc_titlebar_left(m_resourcemanager, TitlebarList(&m_titlebar_left[0], &m_titlebar_left[1]), "session.titlebar.left", "Session.Titlebar.Left"),
|
|
|
|
m_rc_titlebar_right(m_resourcemanager, TitlebarList(&m_titlebar_right[0], &m_titlebar_right[3]), "session.titlebar.right", "Session.Titlebar.Right"),
|
2002-01-18 01:23:54 +00:00
|
|
|
m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"),
|
|
|
|
m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"),
|
2002-03-19 00:16:44 +00:00
|
|
|
focused_window(0), masked_window(0),
|
|
|
|
timer(this),
|
2002-02-06 17:12:09 +00:00
|
|
|
no_focus(false),
|
2002-08-13 21:19:00 +00:00
|
|
|
rc_file(rc ? rc : ""),
|
2002-01-20 02:19:16 +00:00
|
|
|
argv(m_argv), argc(m_argc),
|
|
|
|
key(0)
|
2001-12-11 20:47:02 +00:00
|
|
|
{
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-08-13 21:19:00 +00:00
|
|
|
if (singleton != 0) {
|
|
|
|
cerr<<"Fatal! There can only one instance of fluxbox class."<<endl;
|
|
|
|
abort();
|
|
|
|
}
|
2002-08-14 00:01:10 +00:00
|
|
|
|
2002-10-25 21:17:15 +00:00
|
|
|
//catch system signals
|
2002-08-14 00:01:10 +00:00
|
|
|
SignalHandler *sigh = SignalHandler::instance();
|
|
|
|
|
|
|
|
sigh->registerHandler(SIGSEGV, this);
|
|
|
|
sigh->registerHandler(SIGFPE, this);
|
|
|
|
sigh->registerHandler(SIGTERM, this);
|
|
|
|
sigh->registerHandler(SIGINT, this);
|
|
|
|
sigh->registerHandler(SIGCHLD, this);
|
|
|
|
sigh->registerHandler(SIGHUP, this);
|
|
|
|
sigh->registerHandler(SIGUSR1, this);
|
|
|
|
sigh->registerHandler(SIGUSR2, this);
|
2002-08-13 21:19:00 +00:00
|
|
|
|
2002-08-18 11:01:52 +00:00
|
|
|
//setup cursor bitmaps
|
|
|
|
cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr);
|
|
|
|
cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur);
|
|
|
|
cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle);
|
|
|
|
cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle);
|
2002-10-25 21:17:15 +00:00
|
|
|
|
|
|
|
//singleton pointer
|
|
|
|
singleton = this;
|
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
// setup atom handlers
|
2002-10-25 21:17:15 +00:00
|
|
|
#ifdef USE_GNOME
|
2002-10-15 20:41:08 +00:00
|
|
|
m_atomhandler.push_back(new Gnome()); // for gnome 1 atom support
|
2002-10-25 21:17:15 +00:00
|
|
|
#endif //USE_GNOME
|
|
|
|
#ifdef USE_NEWWMSPEC
|
2002-10-16 20:02:00 +00:00
|
|
|
m_atomhandler.push_back(new Ewmh()); // for Extended window manager atom support
|
2002-10-25 21:17:15 +00:00
|
|
|
#endif // USE_NEWWMSPEC
|
2002-08-18 11:01:52 +00:00
|
|
|
|
2002-08-30 13:11:47 +00:00
|
|
|
grab();
|
2002-02-26 22:42:23 +00:00
|
|
|
|
|
|
|
setupConfigFiles();
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! XSupportsLocale())
|
2002-10-15 20:41:08 +00:00
|
|
|
cerr<<"Warning: X server does not support locale"<<endl;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 00:01:10 +00:00
|
|
|
if (XSetLocaleModifiers("") == 0)
|
2002-10-15 20:41:08 +00:00
|
|
|
cerr<<"Warning: cannot set locale modifiers"<<endl;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
// Set default values to member variables
|
|
|
|
|
|
|
|
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
masked = None;
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
#ifdef SLIT
|
|
|
|
#ifdef KDE
|
2001-12-11 20:47:02 +00:00
|
|
|
//For KDE dock applets
|
|
|
|
kwm1_dockwindow = XInternAtom(getXDisplay(), "KWM_DOCKWINDOW", False); //KDE v1.x
|
|
|
|
kwm2_dockwindow = XInternAtom(getXDisplay(), "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False); //KDE v2.x
|
2002-08-14 23:03:07 +00:00
|
|
|
#endif //KDE
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
#ifdef HAVE_GETPID
|
2002-01-18 01:23:54 +00:00
|
|
|
fluxbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
|
2002-08-14 23:03:07 +00:00
|
|
|
#endif // HAVE_GETPID
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
int i;
|
2002-01-20 02:19:16 +00:00
|
|
|
load_rc();
|
2002-01-18 01:23:54 +00:00
|
|
|
//allocate screens
|
2001-12-11 20:47:02 +00:00
|
|
|
for (i = 0; i < getNumberOfScreens(); i++) {
|
2002-01-20 02:19:16 +00:00
|
|
|
char scrname[128], altscrname[128];
|
|
|
|
sprintf(scrname, "session.screen%d", i);
|
|
|
|
sprintf(altscrname, "session.Screen%d", i);
|
2002-10-25 21:17:15 +00:00
|
|
|
BScreen *screen = new BScreen(m_screen_rm, scrname, altscrname, i);
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! screen->isScreenManaged()) {
|
2002-09-07 20:25:39 +00:00
|
|
|
delete screen;
|
2002-01-18 01:23:54 +00:00
|
|
|
continue;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-10-15 20:41:08 +00:00
|
|
|
screenList.push_back(screen);
|
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
// attach screen signals to this
|
|
|
|
screen->currentWorkspaceSig().attach(this);
|
|
|
|
screen->workspaceCountSig().attach(this);
|
|
|
|
screen->workspaceNamesSig().attach(this);
|
|
|
|
screen->clientListSig().attach(this);
|
|
|
|
|
|
|
|
// initiate atomhandler for screen specific stuff
|
|
|
|
for (size_t atomh=0; atomh<m_atomhandler.size(); ++atomh) {
|
2002-10-15 20:41:08 +00:00
|
|
|
m_atomhandler[atomh]->initForScreen(*screen);
|
2002-09-07 20:25:39 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-08-18 11:01:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
2002-04-09 12:09:03 +00:00
|
|
|
if (screenList.size() == 0) {
|
2001-12-11 20:47:02 +00:00
|
|
|
fprintf(stderr,
|
2002-01-18 01:23:54 +00:00
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::blackboxSet, FBNLS::blackboxNoManagableScreens,
|
2002-01-18 01:23:54 +00:00
|
|
|
"Fluxbox::Fluxbox: no managable screens found, aborting.\n"));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
throw static_cast<int>(3);
|
|
|
|
}
|
2002-08-18 11:01:52 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
XSynchronize(getXDisplay(), False);
|
|
|
|
XSync(getXDisplay(), False);
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
reconfigure_wait = reread_menu_wait = false;
|
2002-03-19 00:16:44 +00:00
|
|
|
|
|
|
|
timer.setTimeout(0);
|
|
|
|
timer.fireOnce(True);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
//create keybindings handler and load keys file
|
2002-10-23 22:00:46 +00:00
|
|
|
auto_ptr<Keys> tmp(new Keys(getXDisplay(), StringUtil::expandFilename(*m_rc_keyfile).c_str()));
|
|
|
|
key = tmp;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
ungrab();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
Fluxbox::~Fluxbox() {
|
|
|
|
// destroy atomhandlers
|
|
|
|
while (!m_atomhandler.empty()) {
|
|
|
|
delete m_atomhandler.back();
|
|
|
|
m_atomhandler.pop_back();
|
|
|
|
}
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin();
|
|
|
|
std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
MenuTimestamp *ts = *it;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (ts->filename)
|
|
|
|
delete [] ts->filename;
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
delete ts;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-02-26 22:42:23 +00:00
|
|
|
//---------- setupConfigFiles -----------
|
|
|
|
// setup the configutation files in
|
|
|
|
// home directory
|
|
|
|
//---------------------------------------
|
|
|
|
void Fluxbox::setupConfigFiles() {
|
|
|
|
|
|
|
|
bool createInit, createKeys, createMenu;
|
|
|
|
createInit = createKeys = createMenu = false;
|
|
|
|
|
|
|
|
string dirname = getenv("HOME")+string("/.")+string(RC_PATH) + "/";
|
2002-05-29 06:22:31 +00:00
|
|
|
string initFile, keysFile, menuFile, slitlistFile;
|
2002-02-26 22:42:23 +00:00
|
|
|
initFile = dirname+RC_INIT_FILE;
|
|
|
|
keysFile = dirname+"keys";
|
|
|
|
menuFile = dirname+"menu";
|
|
|
|
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
// is file/dir already there?
|
|
|
|
if (! stat(dirname.c_str(), &buf)) {
|
|
|
|
/*TODO: this
|
|
|
|
if (! (buf.st_mode & S_IFDIR)) {
|
|
|
|
cerr << dirname.c_str() << "!" << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// check if anything with those name exists, if not create new
|
|
|
|
if (stat(initFile.c_str(), &buf))
|
|
|
|
createInit = true;
|
|
|
|
if (stat(keysFile.c_str(), &buf))
|
|
|
|
createKeys = true;
|
|
|
|
if (stat(menuFile.c_str(), &buf))
|
|
|
|
createMenu = true;
|
|
|
|
|
|
|
|
} else {
|
2002-10-15 20:41:08 +00:00
|
|
|
#ifdef DEBUG
|
2002-02-26 22:42:23 +00:00
|
|
|
cerr <<__FILE__<<"("<<__LINE__<<"): Creating dir: " << dirname.c_str() << endl;
|
2002-10-15 20:41:08 +00:00
|
|
|
#endif // DEBUG
|
2002-02-26 22:42:23 +00:00
|
|
|
|
|
|
|
// create directory with perm 700
|
|
|
|
if (mkdir(dirname.c_str(), 0700)) {
|
|
|
|
cerr << "Can't create " << dirname << " directory!" << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mark creation of files
|
|
|
|
createInit = createKeys = createMenu = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// should we copy key configuraion?
|
|
|
|
if (createKeys) {
|
|
|
|
ifstream from(DEFAULTKEYSFILE);
|
|
|
|
ofstream to(keysFile.c_str());
|
|
|
|
|
|
|
|
if (! to.good()) {
|
|
|
|
cerr << "Can't write file" << endl;
|
|
|
|
} else if (from.good()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr << "Copying file: " << DEFAULTKEYSFILE << endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
to<<from.rdbuf(); //copy file
|
|
|
|
|
|
|
|
} else {
|
|
|
|
cerr<<"Can't copy default keys file."<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// should we copy menu configuraion?
|
|
|
|
if (createMenu) {
|
|
|
|
ifstream from(DEFAULTMENU);
|
|
|
|
ofstream to(menuFile.c_str());
|
|
|
|
|
|
|
|
if (! to.good()) {
|
|
|
|
cerr << "Can't open " << menuFile.c_str() << "for writing" << endl;
|
|
|
|
} else if (from.good()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr << "Copying file: " << DEFAULTMENU << endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
to<<from.rdbuf(); //copy file
|
|
|
|
|
|
|
|
} else {
|
|
|
|
cerr<<"Can't copy default menu file."<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// should we copy default init file?
|
|
|
|
if (createInit) {
|
|
|
|
ifstream from(DEFAULT_INITFILE);
|
|
|
|
ofstream to(initFile.c_str());
|
|
|
|
|
|
|
|
if (! to.good()) {
|
|
|
|
cerr << "Can't open " << initFile.c_str() << "for writing" << endl;
|
|
|
|
} else if (from.good()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr << "Copying file: " << DEFAULT_INITFILE << endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
to<<from.rdbuf(); //copy file
|
|
|
|
} else {
|
|
|
|
cerr<<"Can't copy default init file."<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-17 22:14:00 +00:00
|
|
|
void Fluxbox::handleEvent(XEvent * const e) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if ((masked == e->xany.window) && masked_window &&
|
2002-01-18 01:23:54 +00:00
|
|
|
(e->type == MotionNotify)) {
|
|
|
|
last_time = e->xmotion.time;
|
|
|
|
masked_window->motionNotifyEvent(&e->xmotion);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case ButtonRelease:
|
2002-02-06 17:12:09 +00:00
|
|
|
case ButtonPress:
|
|
|
|
handleButtonEvent(e->xbutton);
|
|
|
|
break;
|
|
|
|
case ConfigureRequest:
|
2001-12-11 20:47:02 +00:00
|
|
|
{
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
|
2002-08-04 15:00:50 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
Slit *slit = (Slit *) 0;
|
2002-08-04 15:00:50 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if ((win = searchWindow(e->xconfigurerequest.window))) {
|
|
|
|
win->configureRequestEvent(&e->xconfigurerequest);
|
|
|
|
|
2002-08-04 15:00:50 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
} else if ((slit = searchSlit(e->xconfigurerequest.window))) {
|
|
|
|
slit->configureRequestEvent(&e->xconfigurerequest);
|
2002-08-04 15:00:50 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
grab();
|
|
|
|
|
|
|
|
if (validateWindow(e->xconfigurerequest.window)) {
|
|
|
|
XWindowChanges xwc;
|
|
|
|
|
|
|
|
xwc.x = e->xconfigurerequest.x;
|
|
|
|
xwc.y = e->xconfigurerequest.y;
|
|
|
|
xwc.width = e->xconfigurerequest.width;
|
|
|
|
xwc.height = e->xconfigurerequest.height;
|
|
|
|
xwc.border_width = e->xconfigurerequest.border_width;
|
|
|
|
xwc.sibling = e->xconfigurerequest.above;
|
|
|
|
xwc.stack_mode = e->xconfigurerequest.detail;
|
|
|
|
|
|
|
|
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
|
|
|
|
e->xconfigurerequest.value_mask, &xwc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ungrab();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
case MapRequest:
|
|
|
|
{
|
2002-08-16 11:09:25 +00:00
|
|
|
#ifdef DEBUG
|
2002-01-18 01:23:54 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
I18n::instance()->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::blackboxSet, FBNLS::blackboxMapRequest,
|
2002-01-18 01:23:54 +00:00
|
|
|
"Fluxbox::process_event(): MapRequest for 0x%lx\n"),
|
2002-04-04 11:28:19 +00:00
|
|
|
e->xmaprequest.window);
|
2002-08-04 15:00:50 +00:00
|
|
|
#endif // DEBUG
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-08-04 15:00:50 +00:00
|
|
|
#ifdef SLIT
|
|
|
|
#ifdef KDE
|
2001-12-11 20:47:02 +00:00
|
|
|
//Check and see if client is KDE dock applet.
|
|
|
|
//If so add to Slit
|
2002-08-11 20:38:23 +00:00
|
|
|
bool iskdedockapp = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
Atom ajunk;
|
|
|
|
int ijunk;
|
|
|
|
unsigned long *data = (unsigned long *) 0, uljunk;
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
// Check if KDE v2.x dock applet
|
2001-12-11 20:47:02 +00:00
|
|
|
if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window,
|
|
|
|
getKWM2DockwindowAtom(), 0l, 1l, False,
|
|
|
|
XA_WINDOW, &ajunk, &ijunk, &uljunk,
|
|
|
|
&uljunk, (unsigned char **) &data) == Success) {
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
iskdedockapp = True;
|
|
|
|
XFree((char *) data);
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
// Check if KDE v1.x dock applet
|
2001-12-11 20:47:02 +00:00
|
|
|
if (!iskdedockapp) {
|
|
|
|
if (XGetWindowProperty(getXDisplay(), e->xmaprequest.window,
|
2002-01-18 01:23:54 +00:00
|
|
|
getKWM1DockwindowAtom(), 0l, 1l, False,
|
|
|
|
getKWM1DockwindowAtom(), &ajunk, &ijunk, &uljunk,
|
|
|
|
&uljunk, (unsigned char **) &data) == Success) {
|
2001-12-11 20:47:02 +00:00
|
|
|
iskdedockapp = (data && data[0] != 0);
|
|
|
|
XFree((char *) data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iskdedockapp) {
|
|
|
|
XSelectInput(getXDisplay(), e->xmaprequest.window, StructureNotifyMask);
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
2002-04-09 23:20:40 +00:00
|
|
|
for (; (*it) == screenList.back(); ++it) {
|
2002-04-09 12:09:03 +00:00
|
|
|
(*it)->getSlit()->addClient(e->xmaprequest.window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2002-08-04 15:00:50 +00:00
|
|
|
#endif //KDE
|
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
FluxboxWindow *win = searchWindow(e->xmaprequest.window);
|
|
|
|
|
|
|
|
if (! win) {
|
2002-02-11 11:33:14 +00:00
|
|
|
win = new FluxboxWindow(e->xmaprequest.window);
|
|
|
|
if (!win->isManaged()) {
|
2002-01-18 01:23:54 +00:00
|
|
|
delete win;
|
2002-09-07 20:25:39 +00:00
|
|
|
win = 0;
|
|
|
|
} else {
|
|
|
|
// attach signals
|
|
|
|
attachSignals(*win);
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
2002-02-11 11:33:14 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if ((win = searchWindow(e->xmaprequest.window)))
|
2002-02-06 17:12:09 +00:00
|
|
|
win->mapRequestEvent(&e->xmaprequest);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
case MapNotify:
|
2002-01-18 01:23:54 +00:00
|
|
|
{
|
|
|
|
FluxboxWindow *win = searchWindow(e->xmap.window);
|
2002-08-16 11:09:25 +00:00
|
|
|
if (win != 0)
|
2002-01-18 01:23:54 +00:00
|
|
|
win->mapNotifyEvent(&e->xmap);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
case UnmapNotify:
|
2002-08-16 11:09:25 +00:00
|
|
|
handleUnmapNotify(e->xunmap);
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-02-04 06:57:26 +00:00
|
|
|
case CreateNotify:
|
2002-08-16 11:09:25 +00:00
|
|
|
break;
|
|
|
|
case DestroyNotify: {
|
2002-01-18 01:23:54 +00:00
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
Slit *slit = 0;
|
2002-08-16 11:09:25 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if ((win = searchWindow(e->xdestroywindow.window))) {
|
2002-01-20 02:19:16 +00:00
|
|
|
if (win->destroyNotifyEvent(&e->xdestroywindow)) {
|
|
|
|
delete win;
|
|
|
|
win = 0;
|
|
|
|
}
|
2002-08-16 11:09:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
#ifdef SLIT
|
|
|
|
else if ((slit = searchSlit(e->xdestroywindow.window))) {
|
|
|
|
slit->removeClient(e->xdestroywindow.window, false);
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-08-16 11:09:25 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
case MotionNotify: {
|
2001-12-11 20:47:02 +00:00
|
|
|
last_time = e->xmotion.time;
|
|
|
|
|
|
|
|
FluxboxWindow *win = 0;
|
|
|
|
Basemenu *menu = 0;
|
|
|
|
Tab *tab = 0;
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
if ((win = searchWindow(e->xmotion.window)) !=0)
|
2001-12-11 20:47:02 +00:00
|
|
|
win->motionNotifyEvent(&e->xmotion);
|
2002-02-06 17:12:09 +00:00
|
|
|
else if ((menu = searchMenu(e->xmotion.window)) !=0)
|
2001-12-11 20:47:02 +00:00
|
|
|
menu->motionNotifyEvent(&e->xmotion);
|
2002-02-06 17:12:09 +00:00
|
|
|
else if ((tab = searchTab(e->xmotion.window)) !=0)
|
2001-12-11 20:47:02 +00:00
|
|
|
tab->motionNotifyEvent(&e->xmotion);
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
case PropertyNotify: {
|
2002-02-17 18:43:30 +00:00
|
|
|
|
|
|
|
last_time = e->xproperty.time;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
if (e->xproperty.state != PropertyDelete) {
|
|
|
|
FluxboxWindow *win = searchWindow(e->xproperty.window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
if (win)
|
|
|
|
win->propertyNotifyEvent(e->xproperty.atom);
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-17 18:43:30 +00:00
|
|
|
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
case EnterNotify: {
|
2001-12-11 20:47:02 +00:00
|
|
|
last_time = e->xcrossing.time;
|
|
|
|
|
|
|
|
BScreen *screen = (BScreen *) 0;
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
Basemenu *menu = (Basemenu *) 0;
|
|
|
|
Toolbar *tbar = (Toolbar *) 0;
|
|
|
|
Tab *tab = (Tab *) 0;
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef SLIT
|
|
|
|
Slit *slit = (Slit *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
if (e->xcrossing.mode == NotifyGrab)
|
|
|
|
break;
|
|
|
|
|
|
|
|
XEvent dummy;
|
|
|
|
scanargs sa;
|
|
|
|
sa.w = e->xcrossing.window;
|
|
|
|
sa.enter = sa.leave = False;
|
|
|
|
XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
|
|
|
|
|
|
|
|
if ((e->xcrossing.window == e->xcrossing.root) &&
|
|
|
|
(screen = searchScreen(e->xcrossing.window))) {
|
|
|
|
screen->getImageControl()->installRootColormap();
|
|
|
|
} else if ((win = searchWindow(e->xcrossing.window))) {
|
|
|
|
if ((win->getScreen()->isSloppyFocus() ||
|
|
|
|
win->getScreen()->isSemiSloppyFocus()) &&
|
|
|
|
(! win->isFocused()) && (! no_focus)) {
|
|
|
|
|
|
|
|
grab();
|
|
|
|
|
|
|
|
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
|
|
|
|
win->setInputFocus())
|
|
|
|
win->installColormap(True);
|
|
|
|
|
|
|
|
ungrab();
|
|
|
|
}
|
|
|
|
} else if ((menu = searchMenu(e->xcrossing.window)))
|
|
|
|
menu->enterNotifyEvent(&e->xcrossing);
|
|
|
|
else if ((tbar = searchToolbar(e->xcrossing.window)))
|
|
|
|
tbar->enterNotifyEvent(&e->xcrossing);
|
|
|
|
else if ((tab = searchTab(e->xcrossing.window))) {
|
|
|
|
win = tab->getWindow();
|
|
|
|
if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) &&
|
|
|
|
(! no_focus)) {
|
|
|
|
win->getScreen()->getWorkspace(win->getWorkspaceNumber())->raiseWindow(win);
|
|
|
|
|
|
|
|
grab();
|
|
|
|
|
|
|
|
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
|
|
|
|
win->setInputFocus())
|
|
|
|
win->installColormap(True);
|
|
|
|
|
|
|
|
ungrab();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
#ifdef SLIT
|
2002-01-18 01:23:54 +00:00
|
|
|
else if ((slit = searchSlit(e->xcrossing.window)))
|
|
|
|
slit->enterNotifyEvent(&e->xcrossing);
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // SLIT
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
case LeaveNotify:
|
|
|
|
{
|
|
|
|
last_time = e->xcrossing.time;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
Basemenu *menu = (Basemenu *) 0;
|
|
|
|
Toolbar *tbar = (Toolbar *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-21 02:04:23 +00:00
|
|
|
#ifdef SLIT
|
2002-01-18 01:23:54 +00:00
|
|
|
Slit *slit = (Slit *) 0;
|
2002-01-21 02:04:23 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if ((menu = searchMenu(e->xcrossing.window)))
|
|
|
|
menu->leaveNotifyEvent(&e->xcrossing);
|
|
|
|
else if ((win = searchWindow(e->xcrossing.window)))
|
|
|
|
win->installColormap(False);
|
|
|
|
else if ((tbar = searchToolbar(e->xcrossing.window)))
|
|
|
|
tbar->leaveNotifyEvent(&e->xcrossing);
|
2002-01-21 02:04:23 +00:00
|
|
|
#ifdef SLIT
|
2002-01-18 01:23:54 +00:00
|
|
|
else if ((slit = searchSlit(e->xcrossing.window)))
|
|
|
|
slit->leaveNotifyEvent(&e->xcrossing);
|
2002-01-21 02:04:23 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
case Expose:
|
|
|
|
{
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
Basemenu *menu = (Basemenu *) 0;
|
|
|
|
Toolbar *tbar = (Toolbar *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
Tab *tab = 0;
|
|
|
|
|
|
|
|
if ((win = searchWindow(e->xexpose.window)))
|
|
|
|
win->exposeEvent(&e->xexpose);
|
|
|
|
else if ((menu = searchMenu(e->xexpose.window)))
|
|
|
|
menu->exposeEvent(&e->xexpose);
|
|
|
|
else if ((tbar = searchToolbar(e->xexpose.window)))
|
|
|
|
tbar->exposeEvent(&e->xexpose);
|
|
|
|
else if ((tab = searchTab(e->xexpose.window)))
|
|
|
|
tab->exposeEvent(&e->xexpose);
|
|
|
|
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
handleKeyEvent(e->xkey);
|
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
case ColormapNotify: {
|
2002-02-06 17:12:09 +00:00
|
|
|
BScreen *screen = searchScreen(e->xcolormap.window);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
if (screen != 0) {
|
|
|
|
screen->setRootColormapInstalled((e->xcolormap.state ==
|
2002-02-06 17:12:09 +00:00
|
|
|
ColormapInstalled) ? True : False);
|
2002-08-16 11:09:25 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
case FocusIn: {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (e->xfocus.mode == NotifyUngrab ||
|
|
|
|
e->xfocus.detail == NotifyPointer)
|
|
|
|
break;
|
|
|
|
|
|
|
|
FluxboxWindow *win = searchWindow(e->xfocus.window);
|
|
|
|
if (win && ! win->isFocused())
|
|
|
|
setFocusedWindow(win);
|
2002-02-06 17:12:09 +00:00
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
} break;
|
2002-01-18 01:23:54 +00:00
|
|
|
case FocusOut:
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
case ClientMessage:
|
2002-02-06 17:12:09 +00:00
|
|
|
handleClientMessage(e->xclient);
|
|
|
|
break;
|
2002-08-16 11:09:25 +00:00
|
|
|
default: {
|
2002-02-04 06:57:26 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
#ifdef SHAPE
|
|
|
|
if (e->type == getShapeEventBase()) {
|
|
|
|
XShapeEvent *shape_event = (XShapeEvent *) e;
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
if ((win = searchWindow(e->xany.window)) ||
|
|
|
|
(shape_event->kind != ShapeBounding))
|
|
|
|
win->shapeEvent(shape_event);
|
|
|
|
}
|
|
|
|
#endif // SHAPE
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
void Fluxbox::handleButtonEvent(XButtonEvent &be) {
|
|
|
|
switch (be.type) {
|
|
|
|
case ButtonPress:
|
|
|
|
{
|
|
|
|
last_time = be.time;
|
|
|
|
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
Basemenu *menu = (Basemenu *) 0;
|
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
#ifdef SLIT
|
2002-02-06 17:12:09 +00:00
|
|
|
Slit *slit = (Slit *) 0;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // SLIT
|
2002-02-06 17:12:09 +00:00
|
|
|
|
|
|
|
Toolbar *tbar = (Toolbar *) 0;
|
|
|
|
Tab *tab = 0;
|
|
|
|
|
|
|
|
if ((win = searchWindow(be.window))) {
|
|
|
|
|
|
|
|
win->buttonPressEvent(&be);
|
|
|
|
|
|
|
|
if (be.button == 1)
|
|
|
|
win->installColormap(True);
|
2002-02-04 06:57:26 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
} else if ((menu = searchMenu(be.window))) {
|
|
|
|
menu->buttonPressEvent(&be);
|
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
#ifdef SLIT
|
2002-02-06 17:12:09 +00:00
|
|
|
} else if ((slit = searchSlit(be.window))) {
|
|
|
|
slit->buttonPressEvent(&be);
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // SLIT
|
2002-02-06 17:12:09 +00:00
|
|
|
|
|
|
|
} else if ((tbar = searchToolbar(be.window))) {
|
|
|
|
tbar->buttonPressEvent(&be);
|
|
|
|
} else if ((tab = searchTab(be.window))) {
|
|
|
|
tab->buttonPressEvent(&be);
|
|
|
|
} else {
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
|
|
|
ScreenList::iterator it_end = screenList.end();
|
2002-02-06 17:12:09 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2002-02-04 06:57:26 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
BScreen *screen = *it;
|
2002-02-06 17:12:09 +00:00
|
|
|
if (be.window != screen->getRootWindow())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (be.button == 1) {
|
|
|
|
if (! screen->isRootColormapInstalled())
|
|
|
|
screen->getImageControl()->installRootColormap();
|
|
|
|
|
|
|
|
if (screen->getWorkspacemenu()->isVisible())
|
|
|
|
screen->getWorkspacemenu()->hide();
|
|
|
|
if (screen->getRootmenu()->isVisible())
|
|
|
|
screen->getRootmenu()->hide();
|
2002-02-04 06:57:26 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
} else if (be.button == 2) {
|
|
|
|
int mx = be.x_root -
|
2002-04-08 22:36:30 +00:00
|
|
|
(screen->getWorkspacemenu()->width() / 2);
|
2002-02-06 17:12:09 +00:00
|
|
|
int my = be.y_root -
|
2002-04-08 22:36:30 +00:00
|
|
|
(screen->getWorkspacemenu()->titleHeight() / 2);
|
2002-02-06 17:12:09 +00:00
|
|
|
|
|
|
|
if (mx < 0) mx = 0;
|
|
|
|
if (my < 0) my = 0;
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
if (mx + screen->getWorkspacemenu()->width() >
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getWidth()) {
|
|
|
|
mx = screen->getWidth() -
|
2002-04-08 22:36:30 +00:00
|
|
|
screen->getWorkspacemenu()->width() -
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getBorderWidth();
|
|
|
|
}
|
2002-02-04 06:57:26 +00:00
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
if (my + screen->getWorkspacemenu()->height() >
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getHeight()) {
|
|
|
|
my = screen->getHeight() -
|
2002-04-08 22:36:30 +00:00
|
|
|
screen->getWorkspacemenu()->height() -
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getBorderWidth();
|
2002-02-04 06:57:26 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getWorkspacemenu()->move(mx, my);
|
2002-01-11 09:26:33 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
if (! screen->getWorkspacemenu()->isVisible()) {
|
|
|
|
screen->getWorkspacemenu()->removeParent();
|
|
|
|
screen->getWorkspacemenu()->show();
|
|
|
|
}
|
|
|
|
} else if (be.button == 3) {
|
|
|
|
//calculate placement of workspace menu
|
|
|
|
//and show/hide it
|
|
|
|
int mx = be.x_root -
|
2002-04-08 22:36:30 +00:00
|
|
|
(screen->getRootmenu()->width() / 2);
|
2002-02-06 17:12:09 +00:00
|
|
|
int my = be.y_root -
|
2002-04-08 22:36:30 +00:00
|
|
|
(screen->getRootmenu()->titleHeight() / 2);
|
2002-02-06 17:12:09 +00:00
|
|
|
|
|
|
|
if (mx < 0) mx = 0;
|
|
|
|
if (my < 0) my = 0;
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
if (mx + screen->getRootmenu()->width() > screen->getWidth()) {
|
2002-02-06 17:12:09 +00:00
|
|
|
mx = screen->getWidth() -
|
2002-04-08 22:36:30 +00:00
|
|
|
screen->getRootmenu()->width() -
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getBorderWidth();
|
|
|
|
}
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
if (my + screen->getRootmenu()->height() >
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getHeight()) {
|
|
|
|
my = screen->getHeight() -
|
2002-04-08 22:36:30 +00:00
|
|
|
screen->getRootmenu()->height() -
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->getBorderWidth();
|
|
|
|
}
|
|
|
|
screen->getRootmenu()->move(mx, my);
|
|
|
|
|
|
|
|
if (! screen->getRootmenu()->isVisible()) {
|
|
|
|
checkMenu();
|
|
|
|
screen->getRootmenu()->show();
|
|
|
|
}
|
2002-05-08 10:14:51 +00:00
|
|
|
} else if (screen->isDesktopWheeling() && be.button == 4) {
|
2002-04-17 06:57:10 +00:00
|
|
|
screen->nextWorkspace(1);
|
2002-05-08 10:14:51 +00:00
|
|
|
} else if (screen->isDesktopWheeling() && be.button == 5) {
|
2002-04-20 10:27:13 +00:00
|
|
|
screen->prevWorkspace(1);
|
2002-04-17 06:57:10 +00:00
|
|
|
}
|
2002-02-04 06:57:26 +00:00
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
{
|
|
|
|
last_time = be.time;
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0;
|
|
|
|
Basemenu *menu = (Basemenu *) 0;
|
|
|
|
Toolbar *tbar = (Toolbar *) 0;
|
|
|
|
Tab *tab = 0;
|
|
|
|
|
|
|
|
if ((win = searchWindow(be.window)))
|
|
|
|
win->buttonReleaseEvent(&be);
|
|
|
|
else if ((menu = searchMenu(be.window)))
|
|
|
|
menu->buttonReleaseEvent(&be);
|
|
|
|
else if ((tbar = searchToolbar(be.window)))
|
|
|
|
tbar->buttonReleaseEvent(&be);
|
|
|
|
else if ((tab = searchTab(be.window)))
|
|
|
|
tab->buttonReleaseEvent(&be);
|
|
|
|
}
|
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
default:
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow *win = 0;
|
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
#ifdef SLIT
|
2002-02-17 18:43:30 +00:00
|
|
|
Slit *slit = (Slit *) 0;
|
2002-08-16 11:09:25 +00:00
|
|
|
#endif // SLIT
|
2002-02-17 18:43:30 +00:00
|
|
|
BScreen *screen = searchScreen(ue.event);
|
|
|
|
|
|
|
|
if ( (ue.event != ue.window) && (screen != 0 || !ue.send_event))
|
|
|
|
return;
|
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
if ((win = searchWindow(ue.window)) != 0) {
|
2002-02-17 18:43:30 +00:00
|
|
|
|
2002-08-16 11:09:25 +00:00
|
|
|
if (win->unmapNotifyEvent(&ue)) {
|
2002-02-17 18:43:30 +00:00
|
|
|
delete win;
|
2002-08-16 11:09:25 +00:00
|
|
|
if (focused_window == win) // some extra checking
|
|
|
|
focused_window = 0;
|
|
|
|
win = 0;
|
|
|
|
}
|
2002-05-02 07:14:22 +00:00
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
}
|
2002-08-16 11:09:25 +00:00
|
|
|
#ifdef SLIT
|
2002-02-17 18:43:30 +00:00
|
|
|
else if ((slit = searchSlit(ue.window))!=0) {
|
|
|
|
slit->removeClient(ue.window);
|
|
|
|
}
|
2002-08-16 11:09:25 +00:00
|
|
|
#endif // SLIT
|
2002-02-17 18:43:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
//------------ handleClientMessage --------
|
|
|
|
// Handles XClientMessageEvent
|
|
|
|
//-----------------------------------------
|
|
|
|
void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
|
2002-08-04 15:00:50 +00:00
|
|
|
#ifdef DEBUG
|
2002-02-07 14:23:01 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<<hex<<ce.data.l[0]<<
|
2002-08-04 15:00:50 +00:00
|
|
|
" message_type=0x"<<ce.message_type<<dec<<endl;
|
2002-02-07 14:23:01 +00:00
|
|
|
|
2002-08-04 15:00:50 +00:00
|
|
|
#endif // DEBUG
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
if (ce.format != 32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ce.message_type == getWMChangeStateAtom()) {
|
|
|
|
FluxboxWindow *win = searchWindow(ce.window);
|
|
|
|
if (! win || ! win->validateClient())
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
if (ce.data.l[0] == IconicState)
|
|
|
|
win->iconify();
|
|
|
|
if (ce.data.l[0] == NormalState)
|
|
|
|
win->deiconify();
|
|
|
|
} else if (ce.message_type == getFluxboxChangeWorkspaceAtom()) {
|
|
|
|
BScreen *screen = searchScreen(ce.window);
|
|
|
|
|
|
|
|
if (screen && ce.data.l[0] >= 0 &&
|
2002-04-02 23:13:38 +00:00
|
|
|
ce.data.l[0] < (signed)screen->getCount())
|
2002-02-06 17:12:09 +00:00
|
|
|
screen->changeWorkspaceID(ce.data.l[0]);
|
|
|
|
|
|
|
|
} else if (ce.message_type == getFluxboxChangeWindowFocusAtom()) {
|
|
|
|
FluxboxWindow *win = searchWindow(ce.window);
|
|
|
|
if (win && win->isVisible() && win->setInputFocus())
|
|
|
|
win->installColormap(True);
|
|
|
|
} else if (ce.message_type == getFluxboxCycleWindowFocusAtom()) {
|
|
|
|
BScreen *screen = searchScreen(ce.window);
|
|
|
|
|
|
|
|
if (screen) {
|
|
|
|
if (! ce.data.l[0])
|
|
|
|
screen->prevFocus();
|
|
|
|
else
|
|
|
|
screen->nextFocus();
|
|
|
|
}
|
|
|
|
} else if (ce.message_type == getFluxboxChangeAttributesAtom()) {
|
|
|
|
|
|
|
|
FluxboxWindow *win = searchWindow(ce.window);
|
|
|
|
|
|
|
|
if (win && win->validateClient()) {
|
|
|
|
BlackboxHints net;
|
|
|
|
net.flags = ce.data.l[0];
|
|
|
|
net.attrib = ce.data.l[1];
|
|
|
|
net.workspace = ce.data.l[2];
|
|
|
|
net.stack = ce.data.l[3];
|
2002-04-04 14:23:54 +00:00
|
|
|
net.decoration = static_cast<int>(ce.data.l[4]);
|
2002-02-06 17:12:09 +00:00
|
|
|
win->changeBlackboxHints(&net);
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
} else {
|
2002-09-07 20:25:39 +00:00
|
|
|
FluxboxWindow *win = searchWindow(ce.window);
|
|
|
|
BScreen *screen = searchScreen(ce.window);
|
|
|
|
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
m_atomhandler[i]->checkClientMessage(ce, screen, win);
|
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
//----------- handleKeyEvent ---------------
|
|
|
|
// Handles KeyRelease and KeyPress events
|
|
|
|
//------------------------------------------
|
|
|
|
void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
|
|
|
|
switch (ke.type) {
|
|
|
|
case KeyPress:
|
|
|
|
{
|
|
|
|
Toolbar *tbar = searchToolbar(ke.window);
|
|
|
|
BScreen *screen = searchScreen(ke.window);
|
|
|
|
|
|
|
|
if (tbar && tbar->isEditing())
|
|
|
|
tbar->keyPressEvent(&ke);
|
|
|
|
else if (screen) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"KeyEvent"<<endl;
|
|
|
|
#endif
|
|
|
|
//find action
|
|
|
|
Keys::KeyAction action = key->getAction(&ke);
|
|
|
|
#ifdef DEBUG
|
|
|
|
const char *actionstr = key->getActionStr(action);
|
|
|
|
if (actionstr)
|
|
|
|
cerr<<"KeyAction("<<actionstr<<")"<<endl;
|
|
|
|
#endif
|
|
|
|
if (action==Keys::LASTKEYGRAB) //if action not found end case
|
|
|
|
break;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-30 14:07:38 +00:00
|
|
|
// what to allow if moving
|
|
|
|
if (focused_window && focused_window->isMoving()) {
|
|
|
|
int allowed = false;
|
|
|
|
switch (action) {
|
|
|
|
case Keys::WORKSPACE:
|
|
|
|
case Keys::SENDTOWORKSPACE:
|
|
|
|
case Keys::WORKSPACE1:
|
|
|
|
case Keys::WORKSPACE2:
|
|
|
|
case Keys::WORKSPACE3:
|
|
|
|
case Keys::WORKSPACE4:
|
|
|
|
case Keys::WORKSPACE5:
|
|
|
|
case Keys::WORKSPACE6:
|
|
|
|
case Keys::WORKSPACE7:
|
|
|
|
case Keys::WORKSPACE8:
|
|
|
|
case Keys::WORKSPACE9:
|
|
|
|
case Keys::WORKSPACE10:
|
|
|
|
case Keys::WORKSPACE11:
|
|
|
|
case Keys::WORKSPACE12:
|
|
|
|
case Keys::NEXTWORKSPACE:
|
|
|
|
case Keys::PREVWORKSPACE:
|
|
|
|
case Keys::LEFTWORKSPACE:
|
|
|
|
case Keys::RIGHTWORKSPACE:
|
|
|
|
allowed = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
allowed = false;
|
|
|
|
}
|
|
|
|
if (!allowed) break;
|
|
|
|
}
|
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
switch (action) {
|
2002-02-20 23:12:07 +00:00
|
|
|
case Keys::WORKSPACE:
|
2002-05-02 07:14:22 +00:00
|
|
|
// Workspace1 has id 0, hence -1
|
|
|
|
screen->changeWorkspaceID(key->getParam()-1);
|
2002-02-26 22:42:23 +00:00
|
|
|
break;
|
|
|
|
case Keys::SENDTOWORKSPACE:
|
2002-05-02 07:14:22 +00:00
|
|
|
// Workspace1 has id 0, hence -1
|
|
|
|
screen->sendToWorkspace(key->getParam()-1);
|
2002-02-20 23:12:07 +00:00
|
|
|
break;
|
2002-05-02 07:14:22 +00:00
|
|
|
// NOTE!!! The WORKSPACEn commands are not needed anymore
|
2002-02-06 17:12:09 +00:00
|
|
|
case Keys::WORKSPACE1:
|
|
|
|
screen->changeWorkspaceID(0);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE2:
|
|
|
|
screen->changeWorkspaceID(1);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE3:
|
|
|
|
screen->changeWorkspaceID(2);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE4:
|
|
|
|
screen->changeWorkspaceID(3);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE5:
|
|
|
|
screen->changeWorkspaceID(4);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE6:
|
|
|
|
screen->changeWorkspaceID(5);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE7:
|
|
|
|
screen->changeWorkspaceID(6);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE8:
|
|
|
|
screen->changeWorkspaceID(7);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE9:
|
|
|
|
screen->changeWorkspaceID(8);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE10:
|
|
|
|
screen->changeWorkspaceID(9);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE11:
|
|
|
|
screen->changeWorkspaceID(10);
|
|
|
|
break;
|
|
|
|
case Keys::WORKSPACE12:
|
|
|
|
screen->changeWorkspaceID(11);
|
|
|
|
break;
|
|
|
|
case Keys::NEXTWORKSPACE:
|
2002-02-20 23:12:07 +00:00
|
|
|
screen->nextWorkspace(key->getParam());
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::PREVWORKSPACE:
|
2002-02-20 23:12:07 +00:00
|
|
|
screen->prevWorkspace(key->getParam());
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::LEFTWORKSPACE:
|
2002-02-20 23:12:07 +00:00
|
|
|
screen->leftWorkspace(key->getParam());
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::RIGHTWORKSPACE:
|
2002-02-20 23:12:07 +00:00
|
|
|
screen->rightWorkspace(key->getParam());
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::KILLWINDOW: //kill the current window
|
2002-05-08 09:33:11 +00:00
|
|
|
if (focused_window) {
|
|
|
|
XKillClient(screen->getBaseDisplay()->getXDisplay(),
|
|
|
|
focused_window->getClientWindow());
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::NEXTWINDOW: //activate next window
|
2002-03-18 20:26:32 +00:00
|
|
|
screen->nextFocus(key->getParam());
|
2002-09-08 19:31:27 +00:00
|
|
|
if (focused_window && focused_window->getTab())
|
2002-05-08 09:33:11 +00:00
|
|
|
focused_window->getTab()->raise();
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::PREVWINDOW: //activate prev window
|
2002-03-18 20:26:32 +00:00
|
|
|
screen->prevFocus(key->getParam());
|
2002-09-08 19:31:27 +00:00
|
|
|
if (focused_window && focused_window->getTab())
|
2002-05-08 09:33:11 +00:00
|
|
|
focused_window->getTab()->raise();
|
2002-02-06 17:12:09 +00:00
|
|
|
break;
|
|
|
|
case Keys::NEXTTAB:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
Tab *tab = focused_window->getTab();
|
|
|
|
if (tab->next()) {
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->next()->getWindow());
|
|
|
|
tab->next()->getWindow()->setInputFocus();
|
|
|
|
} else {
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->first()->getWindow());
|
|
|
|
tab->first()->getWindow()->setInputFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys::PREVTAB:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
Tab *tab = focused_window->getTab();
|
|
|
|
if (tab->prev()) {
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->prev()->getWindow());
|
|
|
|
tab->prev()->getWindow()->setInputFocus();
|
|
|
|
} else {
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->last()->getWindow());
|
|
|
|
tab->last()->getWindow()->setInputFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-05-02 07:14:22 +00:00
|
|
|
case Keys::FIRSTTAB:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
Tab *tab = focused_window->getTab();
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->first()->getWindow());
|
|
|
|
tab->first()->getWindow()->setInputFocus();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys::LASTTAB:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
Tab *tab = focused_window->getTab();
|
|
|
|
screen->getCurrentWorkspace()->raiseWindow(
|
|
|
|
tab->last()->getWindow());
|
|
|
|
tab->last()->getWindow()->setInputFocus();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys::MOVETABPREV:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
focused_window->getTab()->movePrev();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys::MOVETABNEXT:
|
|
|
|
if (focused_window && focused_window->getTab()) {
|
|
|
|
focused_window->getTab()->moveNext();
|
|
|
|
}
|
|
|
|
break;
|
2002-02-06 17:12:09 +00:00
|
|
|
case Keys::EXECUTE: //execute command on keypress
|
|
|
|
{
|
|
|
|
#ifndef __EMX__
|
|
|
|
char displaystring[MAXPATHLEN];
|
|
|
|
sprintf(displaystring, "DISPLAY=%s",
|
|
|
|
DisplayString(getXDisplay()));
|
|
|
|
sprintf(displaystring + strlen(displaystring) - 1, "%d",
|
|
|
|
screen->getScreenNumber());
|
2002-10-15 20:41:08 +00:00
|
|
|
#ifdef DEBUG
|
2002-02-06 17:12:09 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): Executing:"<<key->getExecCommand().c_str()<<endl;
|
2002-10-15 20:41:08 +00:00
|
|
|
#endif // DEBUG
|
2002-02-06 17:12:09 +00:00
|
|
|
|
|
|
|
bexec(key->getExecCommand().c_str(), displaystring);
|
|
|
|
#else
|
|
|
|
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL);
|
|
|
|
#endif // !__EMX__
|
|
|
|
|
|
|
|
|
2002-04-09 09:42:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys::ROOTMENU: //show root menu
|
|
|
|
{
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
|
|
|
ScreenList::iterator it_end = screenList.end();
|
2002-04-09 09:42:16 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2002-04-09 09:42:16 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
BScreen *screen = (*it);
|
2002-04-09 09:42:16 +00:00
|
|
|
if (ke.window != screen->getRootWindow())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//calculate placement of workspace menu
|
|
|
|
//and show/hide it
|
|
|
|
int mx = ke.x_root -
|
|
|
|
(screen->getRootmenu()->width() / 2);
|
|
|
|
int my = ke.y_root -
|
|
|
|
(screen->getRootmenu()->titleHeight() / 2);
|
|
|
|
|
|
|
|
if (mx < 0) mx = 0;
|
|
|
|
if (my < 0) my = 0;
|
|
|
|
|
|
|
|
if (mx + screen->getRootmenu()->width() > screen->getWidth()) {
|
|
|
|
mx = screen->getWidth() -
|
|
|
|
screen->getRootmenu()->width() -
|
|
|
|
screen->getBorderWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (my + screen->getRootmenu()->height() >
|
|
|
|
screen->getHeight()) {
|
|
|
|
my = screen->getHeight() -
|
|
|
|
screen->getRootmenu()->height() -
|
|
|
|
screen->getBorderWidth();
|
|
|
|
}
|
|
|
|
screen->getRootmenu()->move(mx, my);
|
|
|
|
|
|
|
|
if (! screen->getRootmenu()->isVisible()) {
|
|
|
|
checkMenu();
|
|
|
|
screen->getRootmenu()->show();
|
|
|
|
}
|
|
|
|
}
|
2002-02-06 17:12:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: //try to see if its a window action
|
2002-02-20 23:12:07 +00:00
|
|
|
doWindowAction(action, key->getParam());
|
2002-02-06 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2002-02-20 23:12:07 +00:00
|
|
|
void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (!focused_window)
|
|
|
|
return;
|
2002-01-11 09:26:33 +00:00
|
|
|
|
|
|
|
unsigned int t_placement = focused_window->getScreen()->getTabPlacement();
|
|
|
|
unsigned int t_alignment = focused_window->getScreen()->getTabAlignment();
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
switch (action) {
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::ICONIFY:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->iconify();
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::RAISE:
|
2002-01-18 18:28:17 +00:00
|
|
|
if (focused_window->hasTab())
|
|
|
|
focused_window->getTab()->raise(); //raise the tabs if we have any
|
|
|
|
focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->raiseWindow(focused_window);
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::LOWER:
|
2002-01-18 18:28:17 +00:00
|
|
|
focused_window->getScreen()->getWorkspace(focused_window->getWorkspaceNumber())->lowerWindow(focused_window);
|
|
|
|
if (focused_window->hasTab())
|
|
|
|
focused_window->getTab()->lower(); //lower the tabs AND it's windows
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::CLOSE:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->close();
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::SHADE:
|
2002-02-15 22:16:09 +00:00
|
|
|
focused_window->shade(); // this has to be done in THIS order
|
2002-01-11 22:48:45 +00:00
|
|
|
if (focused_window->hasTab())
|
|
|
|
focused_window->getTab()->shade();
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::MAXIMIZE:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->maximize(0);
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::STICK:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->stick();
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::VERTMAX:
|
2002-01-04 21:21:43 +00:00
|
|
|
if (focused_window->isResizable())
|
2002-02-16 02:28:11 +00:00
|
|
|
focused_window->maximize(2); // maximize vertically, done with mouse2
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::HORIZMAX:
|
2002-01-04 21:21:43 +00:00
|
|
|
if (focused_window->isResizable())
|
2002-02-16 02:28:11 +00:00
|
|
|
focused_window->maximize(3); // maximize horisontally, done with mouse3
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::NUDGERIGHT:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
2002-02-20 23:12:07 +00:00
|
|
|
focused_window->getXFrame()+param, focused_window->getYFrame(),
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::NUDGELEFT:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
2002-02-20 23:12:07 +00:00
|
|
|
focused_window->getXFrame()-param, focused_window->getYFrame(),
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::NUDGEUP:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
2002-02-20 23:12:07 +00:00
|
|
|
focused_window->getXFrame(), focused_window->getYFrame()-param,
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::NUDGEDOWN:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
2002-02-20 23:12:07 +00:00
|
|
|
focused_window->getXFrame(), focused_window->getYFrame()+param,
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2002-05-02 07:14:22 +00:00
|
|
|
// NOTE !!! BIGNUDGExxxx is not needed, just use 10 as a parameter
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::BIGNUDGERIGHT:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame()+10, focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::BIGNUDGELEFT:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame()-10, focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::BIGNUDGEUP:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame()-10,
|
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::BIGNUDGEDOWN:
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame()+10,
|
|
|
|
focused_window->getWidth(), focused_window->getHeight());
|
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::HORIZINC:
|
2001-12-11 20:47:02 +00:00
|
|
|
if (focused_window->isResizable())
|
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth()+10, focused_window->getHeight());
|
2002-01-11 09:26:33 +00:00
|
|
|
|
|
|
|
if (focused_window->hasTab() &&
|
|
|
|
(t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) {
|
|
|
|
if (t_alignment == Tab::ARELATIVE)
|
|
|
|
focused_window->getTab()->calcIncrease();
|
|
|
|
if (t_alignment != Tab::PLEFT)
|
|
|
|
focused_window->getTab()->setPosition();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::VERTINC:
|
2001-12-11 20:47:02 +00:00
|
|
|
if (focused_window->isResizable())
|
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth(), focused_window->getHeight()+10);
|
2002-01-11 09:26:33 +00:00
|
|
|
|
|
|
|
if (focused_window->hasTab() &&
|
|
|
|
(t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) {
|
|
|
|
if (t_alignment == Tab::ARELATIVE)
|
|
|
|
focused_window->getTab()->calcIncrease();
|
|
|
|
if (t_alignment != Tab::PRIGHT)
|
|
|
|
focused_window->getTab()->setPosition();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::HORIZDEC:
|
2001-12-11 20:47:02 +00:00
|
|
|
if (focused_window->isResizable())
|
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth()-10, focused_window->getHeight());
|
2002-01-11 09:26:33 +00:00
|
|
|
|
|
|
|
if (focused_window->hasTab() &&
|
|
|
|
(t_placement == Tab::PTOP || t_placement == Tab::PBOTTOM)) {
|
|
|
|
if (t_alignment == Tab::ARELATIVE)
|
|
|
|
focused_window->getTab()->calcIncrease();
|
|
|
|
if (t_alignment != Tab::PLEFT)
|
|
|
|
focused_window->getTab()->setPosition();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2001-12-29 11:35:01 +00:00
|
|
|
case Keys::VERTDEC:
|
2001-12-11 20:47:02 +00:00
|
|
|
if (focused_window->isResizable())
|
|
|
|
focused_window->configure(
|
|
|
|
focused_window->getXFrame(), focused_window->getYFrame(),
|
|
|
|
focused_window->getWidth(), focused_window->getHeight()-10);
|
2002-01-11 09:26:33 +00:00
|
|
|
|
|
|
|
if (focused_window->hasTab() &&
|
|
|
|
(t_placement == Tab::PLEFT || t_placement == Tab::PRIGHT)) {
|
|
|
|
if (t_alignment == Tab::ARELATIVE)
|
|
|
|
focused_window->getTab()->calcIncrease();
|
|
|
|
if (t_alignment != Tab::PRIGHT)
|
|
|
|
focused_window->getTab()->setPosition();
|
|
|
|
}
|
2002-04-04 14:23:54 +00:00
|
|
|
break;
|
|
|
|
case Keys::TOGGLEDECOR:
|
|
|
|
focused_window->toggleDecoration();
|
2002-04-19 09:33:42 +00:00
|
|
|
break;
|
|
|
|
case Keys::TOGGLETAB:
|
|
|
|
focused_window->setTab(!focused_window->hasTab());
|
|
|
|
break;
|
2002-04-04 14:23:54 +00:00
|
|
|
default: //do nothing
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
// handle system signals here
|
2002-11-27 22:00:19 +00:00
|
|
|
void Fluxbox::handleSignal(int signum) {
|
2002-08-14 00:01:10 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
static int re_enter = 0;
|
|
|
|
|
2002-11-27 22:00:19 +00:00
|
|
|
switch (signum) {
|
2002-08-14 00:01:10 +00:00
|
|
|
case SIGCHLD: // we don't want the child process to kill us
|
|
|
|
waitpid(-1, 0, WNOHANG | WUNTRACED);
|
2002-01-18 01:23:54 +00:00
|
|
|
break;
|
2002-08-14 00:01:10 +00:00
|
|
|
case SIGHUP:
|
|
|
|
load_rc();
|
2002-01-18 01:23:54 +00:00
|
|
|
break;
|
2002-08-14 00:01:10 +00:00
|
|
|
case SIGUSR1:
|
|
|
|
reload_rc();
|
|
|
|
break;
|
|
|
|
case SIGUSR2:
|
|
|
|
rereadMenu();
|
2002-01-18 01:23:54 +00:00
|
|
|
break;
|
2002-08-14 00:01:10 +00:00
|
|
|
case SIGSEGV:
|
2002-08-16 11:09:25 +00:00
|
|
|
abort();
|
|
|
|
break;
|
2002-08-14 00:01:10 +00:00
|
|
|
case SIGFPE:
|
|
|
|
case SIGINT:
|
|
|
|
case SIGTERM:
|
|
|
|
shutdown();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
|
|
|
FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught,
|
|
|
|
"%s: signal %d caught\n"),
|
2002-11-27 22:00:19 +00:00
|
|
|
getApplicationName(), signum);
|
2002-08-14 00:01:10 +00:00
|
|
|
|
|
|
|
if (! isStartup() && ! re_enter) {
|
|
|
|
re_enter = 1;
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
|
|
|
FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown,
|
|
|
|
"shutting down\n"));
|
|
|
|
shutdown();
|
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-08-14 00:01:10 +00:00
|
|
|
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
|
|
|
FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting,
|
|
|
|
"aborting... dumping core\n"));
|
|
|
|
abort();
|
|
|
|
break;
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-09-07 20:25:39 +00:00
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-08-14 00:01:10 +00:00
|
|
|
|
2002-09-07 20:25:39 +00:00
|
|
|
void Fluxbox::update(FbTk::Subject *changedsub) {
|
2002-10-15 20:41:08 +00:00
|
|
|
//TODO: fix signaling, this does not look good
|
2002-09-07 20:25:39 +00:00
|
|
|
if (typeid(*changedsub) == typeid(FluxboxWindow)) {
|
|
|
|
FluxboxWindow::WinSubject *winsub = dynamic_cast<FluxboxWindow::WinSubject *>(changedsub);
|
|
|
|
FluxboxWindow &win = winsub->win();
|
|
|
|
if ((&(win.hintSig())) == changedsub) { // hint signal
|
|
|
|
#ifdef DEBUG
|
2002-09-08 19:31:27 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW hint signal from "<<&win<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
2002-09-08 19:31:27 +00:00
|
|
|
m_atomhandler[i]->updateHints(win);
|
2002-09-07 20:25:39 +00:00
|
|
|
}
|
|
|
|
} else if ((&(win.stateSig())) == changedsub) { // state signal
|
|
|
|
#ifdef DEBUG
|
2002-09-08 19:31:27 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW state signal from "<<&win<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
2002-09-08 19:31:27 +00:00
|
|
|
m_atomhandler[i]->updateState(win);
|
2002-09-07 20:25:39 +00:00
|
|
|
}
|
|
|
|
} else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
|
|
|
|
#ifdef DEBUG
|
2002-09-08 19:31:27 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<") WINDOW workspace signal from "<<&win<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
|
|
|
m_atomhandler[i]->updateWorkspace(win);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): WINDOW uncought signal from "<<&win<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (typeid(*changedsub) == typeid(BScreen::ScreenSubject)) {
|
|
|
|
BScreen::ScreenSubject *subj = dynamic_cast<BScreen::ScreenSubject *>(changedsub);
|
|
|
|
BScreen &screen = subj->screen();
|
|
|
|
if ((&(screen.workspaceCountSig())) == changedsub) {
|
|
|
|
#ifdef DEBUG
|
2002-10-11 10:23:54 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace count signal"<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
|
|
|
m_atomhandler[i]->updateWorkspaceCount(screen);
|
|
|
|
}
|
|
|
|
} else if ((&(screen.workspaceNamesSig())) == changedsub) {
|
|
|
|
#ifdef DEBUG
|
2002-10-11 10:23:54 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN workspace names signal"<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
|
|
|
m_atomhandler[i]->updateWorkspaceNames(screen);
|
|
|
|
}
|
|
|
|
} else if ((&(screen.currentWorkspaceSig())) == changedsub) {
|
|
|
|
#ifdef DEBUG
|
2002-10-11 10:23:54 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN current workspace signal"<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
|
|
|
m_atomhandler[i]->updateCurrentWorkspace(screen);
|
|
|
|
}
|
|
|
|
} else if ((&(screen.clientListSig())) == changedsub) {
|
|
|
|
#ifdef DEBUG
|
2002-10-11 10:23:54 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): SCREEN client list signal"<<endl;
|
2002-09-07 20:25:39 +00:00
|
|
|
#endif // DEBUG
|
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
if (m_atomhandler[i]->update())
|
|
|
|
m_atomhandler[i]->updateClientList(screen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fluxbox::attachSignals(FluxboxWindow &win) {
|
|
|
|
win.hintSig().attach(this);
|
|
|
|
win.stateSig().attach(this);
|
|
|
|
win.workspaceSig().attach(this);
|
2002-09-08 19:31:27 +00:00
|
|
|
for (size_t i=0; i<m_atomhandler.size(); ++i) {
|
|
|
|
m_atomhandler[i]->setupWindow(win);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BScreen *Fluxbox::searchScreen(Window window) {
|
2002-01-18 01:23:54 +00:00
|
|
|
BScreen *screen = (BScreen *) 0;
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
|
|
|
ScreenList::iterator it_end = screenList.end();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (*it) {
|
|
|
|
if ((*it)->getRootWindow() == window) {
|
|
|
|
screen = (*it);
|
2002-01-20 02:19:16 +00:00
|
|
|
return screen;
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-01-20 02:19:16 +00:00
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
return (BScreen *) 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow *Fluxbox::searchWindow(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, FluxboxWindow *>::iterator it = windowSearch.find(window);
|
|
|
|
return it == windowSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow *Fluxbox::searchGroup(Window window, FluxboxWindow *win) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, FluxboxWindow *>::iterator it = groupSearch.find(window);
|
|
|
|
return it == groupSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Basemenu *Fluxbox::searchMenu(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, Basemenu *>::iterator it = menuSearch.find(window);
|
|
|
|
return it == menuSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Toolbar *Fluxbox::searchToolbar(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, Toolbar *>::iterator it = toolbarSearch.find(window);
|
|
|
|
return it == toolbarSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Tab *Fluxbox::searchTab(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, Tab *>::iterator it = tabSearch.find(window);
|
|
|
|
return it == tabSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
Slit *Fluxbox::searchSlit(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::map<Window, Slit *>::iterator it = slitSearch.find(window);
|
|
|
|
return it == slitSearch.end() ? 0 : it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::saveWindowSearch(Window window, FluxboxWindow *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
windowSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::saveGroupSearch(Window window, FluxboxWindow *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
groupSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::saveMenuSearch(Window window, Basemenu *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
menuSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::saveToolbarSearch(Window window, Toolbar *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
toolbarSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::saveTabSearch(Window window, Tab *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
tabSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
void Fluxbox::saveSlitSearch(Window window, Slit *data) {
|
2002-04-09 12:09:03 +00:00
|
|
|
slitSearch[window] = data;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::removeWindowSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
windowSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::removeGroupSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
groupSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fluxbox::removeMenuSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
menuSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fluxbox::removeToolbarSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
toolbarSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::removeTabSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
tabSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
void Fluxbox::removeSlitSearch(Window window) {
|
2002-04-09 12:09:03 +00:00
|
|
|
slitSearch.erase(window);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
|
|
|
|
void Fluxbox::restart(const char *prog) {
|
2002-01-18 01:23:54 +00:00
|
|
|
shutdown();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (prog) {
|
|
|
|
execlp(prog, prog, NULL);
|
|
|
|
perror(prog);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
// fall back in case the above execlp doesn't work
|
|
|
|
execvp(argv[0], argv);
|
|
|
|
execvp(basename(argv[0]), argv);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::shutdown() {
|
2002-01-18 01:23:54 +00:00
|
|
|
BaseDisplay::shutdown();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-28 18:57:10 +00:00
|
|
|
//send shutdown to all screens
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
|
|
|
ScreenList::iterator it_end = screenList.end();
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2002-04-28 18:57:10 +00:00
|
|
|
if(*it)
|
2002-04-09 12:09:03 +00:00
|
|
|
(*it)->shutdown();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
XSync(getXDisplay(), False);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
//------ save_rc --------
|
2001-12-11 20:47:02 +00:00
|
|
|
//saves resources
|
2002-01-18 01:23:54 +00:00
|
|
|
//----------------------
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::save_rc() {
|
2002-02-11 11:33:14 +00:00
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
XrmDatabase new_blackboxrc = 0;
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
char rc_string[1024];
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
string dbfile(getRcFilename());
|
2002-01-20 02:19:16 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
if (dbfile.size() != 0) {
|
|
|
|
m_resourcemanager.save(dbfile.c_str(), dbfile.c_str());
|
|
|
|
m_screen_rm.save(dbfile.c_str(), dbfile.c_str());
|
2002-01-20 02:19:16 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
cerr<<"database filename is invalid!"<<endl;
|
2002-01-20 02:19:16 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(rc_string, "session.doubleClickInterval: %lu",
|
2001-12-11 20:47:02 +00:00
|
|
|
resource.double_click_interval);
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(rc_string, "session.autoRaiseDelay: %lu",
|
2001-12-11 20:47:02 +00:00
|
|
|
((resource.auto_raise_delay.tv_sec * 1000) +
|
|
|
|
(resource.auto_raise_delay.tv_usec / 1000)));
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator it = screenList.begin();
|
|
|
|
ScreenList::iterator it_end = screenList.end();
|
2002-01-21 02:04:23 +00:00
|
|
|
|
|
|
|
//Save screen resources
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
BScreen *screen = *it;
|
2001-12-11 20:47:02 +00:00
|
|
|
int screen_number = screen->getScreenNumber();
|
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
#ifdef SLIT
|
2002-01-21 02:04:23 +00:00
|
|
|
string slit_placement;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
switch (screen->getSlitPlacement()) {
|
2002-01-11 09:26:33 +00:00
|
|
|
case Slit::TOPLEFT: slit_placement = "TopLeft"; break;
|
|
|
|
case Slit::CENTERLEFT: slit_placement = "CenterLeft"; break;
|
|
|
|
case Slit::BOTTOMLEFT: slit_placement = "BottomLeft"; break;
|
|
|
|
case Slit::TOPCENTER: slit_placement = "TopCenter"; break;
|
|
|
|
case Slit::BOTTOMCENTER: slit_placement = "BottomCenter"; break;
|
|
|
|
case Slit::TOPRIGHT: slit_placement = "TopRight"; break;
|
|
|
|
case Slit::BOTTOMRIGHT: slit_placement = "BottomRight"; break;
|
|
|
|
case Slit::CENTERRIGHT: default: slit_placement = "CenterRight"; break;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.slit.placement: %s", screen_number,
|
2002-01-21 02:04:23 +00:00
|
|
|
slit_placement.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.slit.direction: %s", screen_number,
|
2002-01-21 02:04:23 +00:00
|
|
|
((screen->getSlitDirection() == Slit::HORIZONTAL) ? "Horizontal" :
|
|
|
|
"Vertical"));
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.slit.onTop: %s", screen_number,
|
2002-01-21 02:04:23 +00:00
|
|
|
((screen->getSlit()->isOnTop()) ? "True" : "False"));
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.slit.autoHide: %s", screen_number,
|
2002-01-21 02:04:23 +00:00
|
|
|
((screen->getSlit()->doAutoHide()) ? "True" : "False"));
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
|
|
#ifdef XINERAMA
|
|
|
|
sprintf(rc_string, "session.screen%d.slit.onHead: %d", screen_number,
|
|
|
|
screen->getSlitOnHead());
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2002-02-17 18:43:30 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number,
|
2002-01-11 09:26:33 +00:00
|
|
|
((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ?
|
|
|
|
"LeftToRight" : "RightToLeft"));
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.colPlacementDirection: %s", screen_number,
|
2002-01-11 09:26:33 +00:00
|
|
|
((screen->getColPlacementDirection() == BScreen::TOPBOTTOM) ?
|
2002-01-21 02:04:23 +00:00
|
|
|
"TopToBottom" : "BottomToTop"));
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
2002-01-21 02:04:23 +00:00
|
|
|
string placement;
|
2002-01-05 10:57:31 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
switch (screen->getPlacementPolicy()) {
|
2002-01-11 09:26:33 +00:00
|
|
|
case BScreen::CASCADEPLACEMENT:
|
2001-12-11 20:47:02 +00:00
|
|
|
placement = "CascadePlacement";
|
|
|
|
break;
|
|
|
|
|
2002-01-11 09:26:33 +00:00
|
|
|
case BScreen::COLSMARTPLACEMENT:
|
2001-12-11 20:47:02 +00:00
|
|
|
placement = "ColSmartPlacement";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-01-11 09:26:33 +00:00
|
|
|
case BScreen::ROWSMARTPLACEMENT:
|
2001-12-11 20:47:02 +00:00
|
|
|
placement = "RowSmartPlacement";
|
|
|
|
break;
|
|
|
|
}
|
2002-01-21 02:04:23 +00:00
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.windowPlacement: %s", screen_number,
|
|
|
|
placement.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
2002-01-20 02:19:16 +00:00
|
|
|
|
2002-01-21 02:04:23 +00:00
|
|
|
std::string focus_mode;
|
2001-12-11 20:47:02 +00:00
|
|
|
if (screen->isSloppyFocus() && screen->doAutoRaise())
|
|
|
|
focus_mode = "AutoRaiseSloppyFocus";
|
|
|
|
else if (screen->isSloppyFocus())
|
|
|
|
focus_mode = "SloppyFocus";
|
|
|
|
else if (screen->isSemiSloppyFocus() && screen->doAutoRaise())
|
|
|
|
focus_mode = "AutoRaiseSemiSloppyFocus";
|
|
|
|
else if (screen->isSemiSloppyFocus())
|
|
|
|
focus_mode = "SemiSloppyFocus";
|
|
|
|
else
|
|
|
|
focus_mode = "ClickToFocus";
|
|
|
|
|
|
|
|
sprintf(rc_string, "session.screen%d.focusModel: %s", screen_number,
|
2002-01-21 02:04:23 +00:00
|
|
|
focus_mode.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
2002-01-21 02:04:23 +00:00
|
|
|
// load_rc(screen);
|
2001-12-11 20:47:02 +00:00
|
|
|
// these are static, but may not be saved in the users resource file,
|
2002-01-18 01:23:54 +00:00
|
|
|
// writing these resources will allow the user to edit them at a later
|
2001-12-11 20:47:02 +00:00
|
|
|
// time... but loading the defaults before saving allows us to rewrite the
|
|
|
|
// users changes...
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
sprintf(rc_string, "session.screen%d.strftimeFormat: %s", screen_number,
|
|
|
|
screen->getStrftimeFormat());
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
#else // !HAVE_STRFTIME
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(rc_string, "session.screen%d.dateFormat: %s", screen_number,
|
2001-12-11 20:47:02 +00:00
|
|
|
((screen->getDateFormat() == B_EuropeanDate) ?
|
|
|
|
"European" : "American"));
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(rc_string, "session.screen%d.clockFormat: %d", screen_number,
|
2001-12-11 20:47:02 +00:00
|
|
|
((screen->isClock24Hour()) ? 24 : 12));
|
|
|
|
XrmPutLineResource(&new_blackboxrc, rc_string);
|
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
|
|
|
|
// write out the users workspace names
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(rc_string, "session.screen%d.workspaceNames: ", screen_number);
|
|
|
|
string workspaces_string(rc_string);
|
2002-02-17 18:43:30 +00:00
|
|
|
|
2002-04-02 23:13:38 +00:00
|
|
|
for (unsigned int workspace=0; workspace < screen->getCount(); workspace++) {
|
2002-04-09 23:20:40 +00:00
|
|
|
if (screen->getWorkspace(workspace)->name().size()!=0)
|
|
|
|
workspaces_string.append(screen->getWorkspace(workspace)->name());
|
2002-01-20 02:19:16 +00:00
|
|
|
else
|
|
|
|
workspaces_string.append("Null");
|
2002-02-17 18:43:30 +00:00
|
|
|
workspaces_string.append(",");
|
2002-01-20 02:19:16 +00:00
|
|
|
}
|
2002-01-21 02:04:23 +00:00
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
XrmPutLineResource(&new_blackboxrc, workspaces_string.c_str());
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
XrmMergeDatabases(new_blackboxrc, &old_blackboxrc); //merge database together
|
2002-08-14 23:03:07 +00:00
|
|
|
XrmPutFileDatabase(old_blackboxrc, dbfile.c_str());
|
2002-01-18 01:23:54 +00:00
|
|
|
XrmDestroyDatabase(old_blackboxrc);
|
2002-08-13 21:19:00 +00:00
|
|
|
#ifdef DEBUG
|
2002-01-21 02:04:23 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl;
|
2002-08-13 21:19:00 +00:00
|
|
|
#endif // DEBUG
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-08 00:29:12 +00:00
|
|
|
//-------- getRcFilename -------------
|
|
|
|
// Returns filename of resource file
|
|
|
|
//------------------------------------
|
2002-08-14 23:03:07 +00:00
|
|
|
string Fluxbox::getRcFilename() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
if (rc_file.size() == 0) { // set default filename
|
|
|
|
string defaultfile(getenv("HOME")+string("/.")+RC_PATH+string("/")+RC_INIT_FILE);
|
|
|
|
return defaultfile;
|
|
|
|
}
|
2002-01-11 09:26:33 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
return rc_file;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-05-29 06:22:31 +00:00
|
|
|
//-------- getDefaultDataFilename -------------
|
|
|
|
// Provides default filename of data file
|
|
|
|
//---------------------------------------------
|
|
|
|
void Fluxbox::getDefaultDataFilename(char *name, string &filename) {
|
|
|
|
filename = string(getenv("HOME")+string("/.")+RC_PATH+string("/")+name);
|
|
|
|
}
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::load_rc() {
|
2002-01-20 02:19:16 +00:00
|
|
|
XrmDatabaseHelper database;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
//get resource filename
|
2002-08-14 23:03:07 +00:00
|
|
|
string dbfile(getRcFilename());
|
|
|
|
|
|
|
|
if (dbfile.size() != 0) {
|
|
|
|
if (!m_resourcemanager.load(dbfile.c_str())) {
|
|
|
|
cerr<<"Faild to load database:"<<dbfile<<endl;
|
2002-01-18 01:23:54 +00:00
|
|
|
cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
if (!m_resourcemanager.load(DEFAULT_INITFILE))
|
|
|
|
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!m_resourcemanager.load(DEFAULT_INITFILE))
|
|
|
|
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
XrmValue value;
|
|
|
|
char *value_type;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (m_rc_menufile->size()) {
|
2002-08-14 23:03:07 +00:00
|
|
|
*m_rc_menufile = StringUtil::expandFilename(*m_rc_menufile);
|
2002-01-18 01:23:54 +00:00
|
|
|
if (!m_rc_menufile->size())
|
|
|
|
m_rc_menufile.setDefaultValue();
|
|
|
|
} else
|
|
|
|
m_rc_menufile.setDefaultValue();
|
2002-05-29 06:22:31 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
if (m_rc_slitlistfile->size() != 0) {
|
|
|
|
*m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile);
|
|
|
|
} else {
|
2002-05-29 06:22:31 +00:00
|
|
|
string filename;
|
|
|
|
getDefaultDataFilename("slitlist", filename);
|
|
|
|
m_rc_slitlistfile.setFromString(filename.c_str());
|
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
|
|
|
|
if (*m_rc_colors_per_channel < 2)
|
|
|
|
*m_rc_colors_per_channel = 2;
|
|
|
|
else if (*m_rc_colors_per_channel > 6)
|
|
|
|
*m_rc_colors_per_channel = 6;
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
if (m_rc_stylefile->size() == 0)
|
2002-01-18 01:23:54 +00:00
|
|
|
*m_rc_stylefile = DEFAULTSTYLE;
|
2002-08-14 23:03:07 +00:00
|
|
|
else // expand tilde
|
|
|
|
*m_rc_stylefile = StringUtil::expandFilename(*m_rc_stylefile);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
//load file
|
2002-08-14 23:03:07 +00:00
|
|
|
database = XrmGetFileDatabase(dbfile.c_str());
|
2002-01-20 02:19:16 +00:00
|
|
|
if (database==0) {
|
2002-08-14 23:03:07 +00:00
|
|
|
cerr<<"Fluxbox: Cant open "<<dbfile<<" !"<<endl;
|
2002-01-18 01:23:54 +00:00
|
|
|
cerr<<"Using: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
database = XrmGetFileDatabase(DEFAULT_INITFILE);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, "session.doubleClickInterval",
|
2001-12-11 20:47:02 +00:00
|
|
|
"Session.DoubleClickInterval", &value_type, &value)) {
|
|
|
|
if (sscanf(value.addr, "%lu", &resource.double_click_interval) != 1)
|
|
|
|
resource.double_click_interval = 250;
|
|
|
|
} else
|
|
|
|
resource.double_click_interval = 250;
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, "session.autoRaiseDelay", "Session.AutoRaiseDelay",
|
|
|
|
&value_type, &value)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (sscanf(value.addr, "%lu", &resource.auto_raise_delay.tv_usec) != 1)
|
|
|
|
resource.auto_raise_delay.tv_usec = 250;
|
|
|
|
} else
|
|
|
|
resource.auto_raise_delay.tv_usec = 250;
|
|
|
|
|
|
|
|
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000;
|
|
|
|
resource.auto_raise_delay.tv_usec -=
|
|
|
|
(resource.auto_raise_delay.tv_sec * 1000);
|
|
|
|
resource.auto_raise_delay.tv_usec *= 1000;
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
// expand tilde
|
|
|
|
*m_rc_groupfile = StringUtil::expandFilename(*m_rc_groupfile);
|
|
|
|
|
2002-08-11 20:38:23 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<": Loading groups ("<<*m_rc_groupfile<<")"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
if (!Workspace::loadGroups(*m_rc_groupfile)) {
|
|
|
|
cerr<<"Faild to load groupfile: "<<*m_rc_groupfile<<endl;
|
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fluxbox::load_rc(BScreen *screen) {
|
2002-01-20 02:19:16 +00:00
|
|
|
//get resource filename
|
2002-08-14 23:03:07 +00:00
|
|
|
string dbfile(getRcFilename());
|
|
|
|
if (dbfile.size() != 0) {
|
|
|
|
if (!m_screen_rm.load(dbfile.c_str())) {
|
|
|
|
cerr<<"Faild to load database:"<<dbfile<<endl;
|
2002-01-20 02:19:16 +00:00
|
|
|
cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
if (!m_screen_rm.load(DEFAULT_INITFILE))
|
|
|
|
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!m_screen_rm.load(DEFAULT_INITFILE))
|
|
|
|
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
XrmDatabaseHelper database;
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
database = XrmGetFileDatabase(dbfile.c_str());
|
2002-01-20 02:19:16 +00:00
|
|
|
if (database==0)
|
2002-01-18 01:23:54 +00:00
|
|
|
database = XrmGetFileDatabase(DEFAULT_INITFILE);
|
|
|
|
|
|
|
|
XrmValue value;
|
|
|
|
char *value_type, name_lookup[1024], class_lookup[1024];
|
|
|
|
int screen_number = screen->getScreenNumber();
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.rowPlacementDirection", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.RowPlacementDirection", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "righttoleft", value.size))
|
|
|
|
screen->saveRowPlacementDirection(BScreen::RIGHTLEFT);
|
2002-01-20 02:19:16 +00:00
|
|
|
else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveRowPlacementDirection(BScreen::LEFTRIGHT);
|
|
|
|
} else
|
|
|
|
screen->saveRowPlacementDirection(BScreen::LEFTRIGHT);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.colPlacementDirection", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.ColPlacementDirection", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-01-21 02:04:23 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "bottomtotop", value.size))
|
|
|
|
screen->saveColPlacementDirection(BScreen::BOTTOMTOP);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveColPlacementDirection(BScreen::TOPBOTTOM);
|
|
|
|
} else
|
|
|
|
screen->saveColPlacementDirection(BScreen::TOPBOTTOM);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->removeWorkspaceNames();
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.workspaceNames", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-01-21 02:04:23 +00:00
|
|
|
&value)) {
|
2002-08-14 23:03:07 +00:00
|
|
|
#ifdef DEBUG
|
2002-01-21 02:04:23 +00:00
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): Workspaces="<<screen->getNumberOfWorkspaces()<<endl;
|
2002-08-14 23:03:07 +00:00
|
|
|
#endif // DEBUG
|
2002-01-18 01:23:54 +00:00
|
|
|
char *search = StringUtil::strdup(value.addr);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < screen->getNumberOfWorkspaces(); i++) {
|
|
|
|
char *nn;
|
|
|
|
|
|
|
|
if (! i) nn = strtok(search, ",");
|
2002-08-14 23:03:07 +00:00
|
|
|
else nn = strtok(0, ",");
|
2002-01-18 01:23:54 +00:00
|
|
|
|
|
|
|
if (nn)
|
2001-12-11 20:47:02 +00:00
|
|
|
screen->addWorkspaceName(nn);
|
|
|
|
else break;
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete [] search;
|
|
|
|
}
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.focusModel", screen_number);
|
2001-12-11 20:47:02 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.FocusModel", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2001-12-11 20:47:02 +00:00
|
|
|
&value)) {
|
|
|
|
if (! strncasecmp(value.addr, "clicktofocus", value.size)) {
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveAutoRaise(false);
|
|
|
|
screen->saveSloppyFocus(false);
|
|
|
|
screen->saveSemiSloppyFocus(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
} else if (! strncasecmp(value.addr, "autoraisesloppyfocus", value.size)) {
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveSemiSloppyFocus(false);
|
|
|
|
screen->saveSloppyFocus(true);
|
|
|
|
screen->saveAutoRaise(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else if (! strncasecmp(value.addr, "autoraisesemisloppyfocus", value.size)) {
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveSloppyFocus(false);
|
|
|
|
screen->saveSemiSloppyFocus(true);
|
|
|
|
screen->saveAutoRaise(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
} else if (! strncasecmp(value.addr, "semisloppyfocus", value.size)) {
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveSloppyFocus(false);
|
|
|
|
screen->saveSemiSloppyFocus(true);
|
|
|
|
screen->saveAutoRaise(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveSemiSloppyFocus(false);
|
|
|
|
screen->saveSloppyFocus(true);
|
|
|
|
screen->saveAutoRaise(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-08-14 23:03:07 +00:00
|
|
|
screen->saveSemiSloppyFocus(false);
|
|
|
|
screen->saveSloppyFocus(true);
|
|
|
|
screen->saveAutoRaise(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.windowPlacement", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.WindowPlacement", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-08-14 23:03:07 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "RowSmartPlacement", value.size))
|
|
|
|
screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT);
|
|
|
|
else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size))
|
|
|
|
screen->savePlacementPolicy(BScreen::COLSMARTPLACEMENT);
|
|
|
|
else
|
|
|
|
screen->savePlacementPolicy(BScreen::CASCADEPLACEMENT);
|
2002-08-14 23:03:07 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->savePlacementPolicy(BScreen::ROWSMARTPLACEMENT);
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
sprintf(name_lookup, "session.screen%d.slit.placement", screen_number);
|
|
|
|
sprintf(class_lookup, "Session.Screen%d.Slit.Placement", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-08-14 23:03:07 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "TopLeft", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::TOPLEFT);
|
|
|
|
else if (! strncasecmp(value.addr, "CenterLeft", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::CENTERLEFT);
|
|
|
|
else if (! strncasecmp(value.addr, "BottomLeft", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::BOTTOMLEFT);
|
|
|
|
else if (! strncasecmp(value.addr, "TopCenter", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::TOPCENTER);
|
|
|
|
else if (! strncasecmp(value.addr, "BottomCenter", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::BOTTOMCENTER);
|
|
|
|
else if (! strncasecmp(value.addr, "TopRight", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::TOPRIGHT);
|
|
|
|
else if (! strncasecmp(value.addr, "BottomRight", value.size))
|
|
|
|
screen->saveSlitPlacement(Slit::BOTTOMRIGHT);
|
|
|
|
else
|
|
|
|
screen->saveSlitPlacement(Slit::CENTERRIGHT);
|
2002-08-14 23:03:07 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveSlitPlacement(Slit::CENTERRIGHT);
|
|
|
|
|
|
|
|
sprintf(name_lookup, "session.screen%d.slit.direction", screen_number);
|
|
|
|
sprintf(class_lookup, "Session.Screen%d.Slit.Direction", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-08-14 23:03:07 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "Horizontal", value.size))
|
|
|
|
screen->saveSlitDirection(Slit::HORIZONTAL);
|
|
|
|
else
|
|
|
|
screen->saveSlitDirection(Slit::VERTICAL);
|
2002-08-14 23:03:07 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveSlitDirection(Slit::VERTICAL);
|
|
|
|
|
|
|
|
sprintf(name_lookup, "session.screen%d.slit.onTop", screen_number);
|
|
|
|
sprintf(class_lookup, "Session.Screen%d.Slit.OnTop", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-08-14 23:03:07 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "True", value.size))
|
|
|
|
screen->saveSlitOnTop(True);
|
|
|
|
else
|
|
|
|
screen->saveSlitOnTop(False);
|
2002-08-14 23:03:07 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveSlitOnTop(False);
|
|
|
|
|
|
|
|
sprintf(name_lookup, "session.screen%d.slit.autoHide", screen_number);
|
|
|
|
sprintf(class_lookup, "Session.Screen%d.Slit.AutoHide", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
2002-08-14 23:03:07 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! strncasecmp(value.addr, "True", value.size))
|
|
|
|
screen->saveSlitAutoHide(True);
|
|
|
|
else
|
|
|
|
screen->saveSlitAutoHide(False);
|
2002-08-14 23:03:07 +00:00
|
|
|
} else
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveSlitAutoHide(False);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
|
|
#ifdef XINERAMA
|
|
|
|
int tmp_head;
|
|
|
|
sprintf(name_lookup, "session.screen%d.slit.onHead", screen_number);
|
|
|
|
sprintf(class_lookup, "Session.Screen%d.Slit.OnHead", screen_number);
|
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
|
|
|
&value)) {
|
|
|
|
if (sscanf(value.addr, "%d", &tmp_head) != 1)
|
|
|
|
tmp_head = 0;
|
|
|
|
} else
|
|
|
|
tmp_head = 0;
|
|
|
|
screen->saveSlitOnHead(tmp_head);
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // SLIT
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.strftimeFormat", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.StrftimeFormat", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
|
|
|
&value))
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveStrftimeFormat(value.addr);
|
|
|
|
else
|
|
|
|
screen->saveStrftimeFormat("%I:%M %p");
|
|
|
|
#else // HAVE_STRFTIME
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.dateFormat", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.DateFormat", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (strncasecmp(value.addr, "european", value.size))
|
|
|
|
screen->saveDateFormat(B_AmericanDate);
|
|
|
|
else
|
|
|
|
screen->saveDateFormat(B_EuropeanDate);
|
|
|
|
} else
|
|
|
|
screen->saveDateFormat(B_AmericanDate);
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.clockFormat", screen_number);
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.ClockFormat", screen_number);
|
2002-01-20 02:19:16 +00:00
|
|
|
if (XrmGetResource(*database, name_lookup, class_lookup, &value_type,
|
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
int clock;
|
2002-08-14 23:03:07 +00:00
|
|
|
if (sscanf(value.addr, "%d", &clock) != 1)
|
|
|
|
screen->saveClock24Hour(False);
|
|
|
|
else if (clock == 24)
|
|
|
|
screen->saveClock24Hour(True);
|
|
|
|
else
|
|
|
|
screen->saveClock24Hour(False);
|
2002-01-18 01:23:54 +00:00
|
|
|
} else
|
|
|
|
screen->saveClock24Hour(False);
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
|
2002-01-21 02:04:23 +00:00
|
|
|
//check size on toolbarwidth percent
|
|
|
|
if (screen->getToolbarWidthPercent() <= 0 ||
|
|
|
|
screen->getToolbarWidthPercent() > 100)
|
|
|
|
screen->saveToolbarWidthPercent(66);
|
|
|
|
|
2002-01-20 02:19:16 +00:00
|
|
|
if (screen->getTabWidth()>512)
|
|
|
|
screen->saveTabWidth(512);
|
|
|
|
else if (screen->getTabWidth()<0)
|
|
|
|
screen->saveTabWidth(64);
|
|
|
|
|
|
|
|
if (screen->getTabHeight()>512)
|
|
|
|
screen->saveTabHeight(512);
|
|
|
|
else if (screen->getTabHeight()<0)
|
|
|
|
screen->saveTabHeight(5);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
void Fluxbox::loadRootCommand(BScreen *screen) {
|
2002-01-10 12:51:21 +00:00
|
|
|
XrmDatabase database = (XrmDatabase) 0;
|
2002-01-11 09:26:33 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
string dbfile(getRcFilename());
|
2002-01-10 12:51:21 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
database = XrmGetFileDatabase(dbfile.c_str());
|
2002-01-10 12:51:21 +00:00
|
|
|
if (!database)
|
|
|
|
database = XrmGetFileDatabase(DEFAULT_INITFILE);
|
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
XrmValue value;
|
|
|
|
char *value_type, name_lookup[1024], class_lookup[1024];
|
2002-01-20 02:19:16 +00:00
|
|
|
sprintf(name_lookup, "session.screen%d.rootCommand", screen->getScreenNumber());
|
2002-01-18 01:23:54 +00:00
|
|
|
sprintf(class_lookup, "Session.Screen%d.RootCommand", screen->getScreenNumber());
|
|
|
|
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
|
2002-01-20 02:19:16 +00:00
|
|
|
&value)) {
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->saveRootCommand(value.addr==0 ? "": value.addr);
|
|
|
|
} else
|
|
|
|
screen->saveRootCommand("");
|
2002-01-10 12:51:21 +00:00
|
|
|
|
|
|
|
}
|
2002-01-11 09:26:33 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
void Fluxbox::reload_rc() {
|
2002-01-18 01:23:54 +00:00
|
|
|
load_rc();
|
|
|
|
reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
void Fluxbox::reconfigure() {
|
2002-02-06 17:12:09 +00:00
|
|
|
reconfigure_wait = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
if (! timer.isTiming())
|
|
|
|
timer.start();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
void Fluxbox::real_reconfigure() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XrmDatabase new_blackboxrc = (XrmDatabase) 0;
|
|
|
|
|
2002-08-14 23:03:07 +00:00
|
|
|
string dbfile(getRcFilename());
|
|
|
|
XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XrmMergeDatabases(new_blackboxrc, &old_blackboxrc);
|
2002-08-14 23:03:07 +00:00
|
|
|
XrmPutFileDatabase(old_blackboxrc, dbfile.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (old_blackboxrc)
|
|
|
|
XrmDestroyDatabase(old_blackboxrc);
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin();
|
|
|
|
std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
MenuTimestamp *ts = *it;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (ts) {
|
|
|
|
if (ts->filename)
|
|
|
|
delete [] ts->filename;
|
|
|
|
|
|
|
|
delete ts;
|
|
|
|
}
|
|
|
|
}
|
2002-04-09 12:09:03 +00:00
|
|
|
menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-02 07:14:22 +00:00
|
|
|
ScreenList::iterator sit = screenList.begin();
|
|
|
|
ScreenList::iterator sit_end = screenList.end();
|
2002-04-28 18:57:10 +00:00
|
|
|
for (; sit != sit_end; ++sit)
|
2002-04-09 12:09:03 +00:00
|
|
|
(*sit)->reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
//reconfigure keys
|
2002-08-14 23:03:07 +00:00
|
|
|
key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
//reconfigure tabs
|
|
|
|
reconfigureTabs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------- reconfigureTabs ----------
|
|
|
|
// Reconfigure all tabs size and increase steps
|
|
|
|
// ---------------------------------------
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::reconfigureTabs() {
|
2001-12-11 20:47:02 +00:00
|
|
|
//tab reconfiguring
|
2002-04-28 18:57:10 +00:00
|
|
|
TabList::iterator it = tabSearch.begin();
|
|
|
|
TabList::iterator it_end = tabSearch.end();
|
2001-12-11 20:47:02 +00:00
|
|
|
//setting all to unconfigured
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
it->second->setConfigured(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-04-09 12:09:03 +00:00
|
|
|
it = tabSearch.begin(); // resetting list and start configure tabs
|
2001-12-11 20:47:02 +00:00
|
|
|
//reconfiguring
|
2002-04-09 12:09:03 +00:00
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
Tab *tab = it->second;
|
2001-12-11 20:47:02 +00:00
|
|
|
if (!tab->configured()) {
|
|
|
|
tab->setConfigured(true);
|
|
|
|
tab->resizeGroup();
|
|
|
|
tab->calcIncrease();
|
|
|
|
tab->setPosition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::checkMenu() {
|
2002-01-18 01:23:54 +00:00
|
|
|
Bool reread = False;
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin();
|
|
|
|
std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end();
|
|
|
|
for (; it != it_end && (! reread); ++it) {
|
2002-01-18 01:23:54 +00:00
|
|
|
struct stat buf;
|
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
if (! stat((*it)->filename, &buf)) {
|
|
|
|
if ((*it)->timestamp != buf.st_ctime)
|
2002-01-18 01:23:54 +00:00
|
|
|
reread = True;
|
|
|
|
} else
|
|
|
|
reread = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reread) rereadMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::rereadMenu() {
|
2002-01-18 01:23:54 +00:00
|
|
|
reread_menu_wait = True;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-03-19 00:16:44 +00:00
|
|
|
if (! timer.isTiming()) timer.start();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::real_rereadMenu() {
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin();
|
|
|
|
std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
MenuTimestamp *ts = *it;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (ts) {
|
|
|
|
if (ts->filename)
|
2002-04-09 12:09:03 +00:00
|
|
|
delete [] ts->filename;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
delete ts;
|
|
|
|
}
|
|
|
|
}
|
2002-04-09 12:09:03 +00:00
|
|
|
menuTimestamps.erase(menuTimestamps.begin(), menuTimestamps.end());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-12 13:02:56 +00:00
|
|
|
ScreenList::iterator sit = screenList.begin();
|
|
|
|
ScreenList::iterator sit_end = screenList.end();
|
|
|
|
for (; sit != sit_end; ++sit) {
|
2002-04-09 12:09:03 +00:00
|
|
|
(*sit)->rereadMenu();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Fluxbox::saveMenuFilename(const char *filename) {
|
2002-01-18 01:23:54 +00:00
|
|
|
Bool found = False;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
std::list<MenuTimestamp *>::iterator it = menuTimestamps.begin();
|
|
|
|
std::list<MenuTimestamp *>::iterator it_end = menuTimestamps.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (! strcmp((*it)->filename, filename)) found = True;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! found) {
|
|
|
|
struct stat buf;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (! stat(filename, &buf)) {
|
|
|
|
MenuTimestamp *ts = new MenuTimestamp;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
ts->filename = StringUtil::strdup(filename);
|
|
|
|
ts->timestamp = buf.st_ctime;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-09 12:09:03 +00:00
|
|
|
menuTimestamps.push_back(ts);
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-15 20:41:08 +00:00
|
|
|
void Fluxbox::timeout() {
|
2002-01-18 01:23:54 +00:00
|
|
|
if (reconfigure_wait)
|
|
|
|
real_reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (reread_menu_wait)
|
|
|
|
real_rereadMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-06 17:12:09 +00:00
|
|
|
reconfigure_wait = reread_menu_wait = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 14:04:46 +00:00
|
|
|
// set focused window
|
2001-12-11 20:47:02 +00:00
|
|
|
void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
|
2002-02-06 17:12:09 +00:00
|
|
|
BScreen *old_screen = 0, *screen = 0;
|
|
|
|
FluxboxWindow *old_win = 0;
|
|
|
|
Toolbar *old_tbar = 0, *tbar = 0;
|
|
|
|
Workspace *old_wkspc = 0, *wkspc = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-07-13 14:04:46 +00:00
|
|
|
if (focused_window != 0) {
|
2002-01-18 01:23:54 +00:00
|
|
|
old_win = focused_window;
|
|
|
|
old_screen = old_win->getScreen();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
old_tbar = old_screen->getToolbar();
|
|
|
|
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
old_win->setFocusFlag(False);
|
2002-11-15 12:19:17 +00:00
|
|
|
old_wkspc->menu().setItemSelected(old_win->getWindowNumber(), false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
}
|
2002-08-13 21:19:00 +00:00
|
|
|
|
2002-01-18 01:23:54 +00:00
|
|
|
if (win && ! win->isIconic()) {
|
2002-07-13 14:04:46 +00:00
|
|
|
// make sure we have a valid win pointer with a valid screen
|
|
|
|
ScreenList::iterator winscreen =
|
|
|
|
std::find(screenList.begin(), screenList.end(),
|
|
|
|
win->getScreen());
|
2002-10-11 10:23:54 +00:00
|
|
|
if (winscreen == screenList.end()) {
|
2002-07-13 14:04:46 +00:00
|
|
|
focused_window = 0; // the window pointer wasn't valid, mark no window focused
|
2002-10-11 10:23:54 +00:00
|
|
|
} else {
|
2002-07-13 14:04:46 +00:00
|
|
|
screen = *winscreen;
|
|
|
|
tbar = screen->getToolbar();
|
|
|
|
wkspc = screen->getWorkspace(win->getWorkspaceNumber());
|
|
|
|
focused_window = win; // update focused window
|
|
|
|
win->setFocusFlag(True); // set focus flag
|
|
|
|
// select this window in workspace menu
|
2002-11-15 12:19:17 +00:00
|
|
|
wkspc->menu().setItemSelected(win->getWindowNumber(), true);
|
2002-07-13 14:04:46 +00:00
|
|
|
}
|
2002-01-18 01:23:54 +00:00
|
|
|
} else
|
2002-08-13 21:19:00 +00:00
|
|
|
focused_window = 0;
|
2002-01-18 01:23:54 +00:00
|
|
|
|
2002-07-13 14:04:46 +00:00
|
|
|
if (tbar != 0)
|
2002-01-18 01:23:54 +00:00
|
|
|
tbar->redrawWindowLabel(True);
|
2002-07-13 14:04:46 +00:00
|
|
|
if (screen != 0)
|
2002-01-18 01:23:54 +00:00
|
|
|
screen->updateNetizenWindowFocus();
|
|
|
|
|
|
|
|
if (old_tbar && old_tbar != tbar)
|
|
|
|
old_tbar->redrawWindowLabel(True);
|
|
|
|
if (old_screen && old_screen != screen)
|
|
|
|
old_screen->updateNetizenWindowFocus();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|