new i18n class using overloaded operator() instead of getMessage()

This commit is contained in:
Dana Jansens 2002-05-16 22:35:59 +00:00
parent 30136ab3e9
commit ae3dc273c4
18 changed files with 4153 additions and 4156 deletions

View file

@ -104,8 +104,9 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
char errtxt[128];
XGetErrorText(d, e->error_code, errtxt, 128);
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayXError,
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"),
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXError,
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"
),
base_display->getApplicationName(), errtxt, e->error_code,
e->request_code, e->minor_code, e->resourceid);
#endif // DEBUG
@ -122,502 +123,502 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
#ifndef HAVE_SIGACTION
static RETSIGTYPE signalhandler(int sig) {
#else // HAVE_SIGACTION
static void signalhandler(int sig) {
static void signalhandler(int sig) {
#endif // HAVE_SIGACTION
static int re_enter = 0;
static int re_enter = 0;
switch (sig) {
case SIGCHLD:
int status;
waitpid(-1, &status, WNOHANG | WUNTRACED);
#ifndef HAVE_SIGACTION
// assume broken, braindead sysv signal semantics
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
break;
default:
if (base_display->handleSignal(sig)) {
switch (sig) {
case SIGCHLD:
int status;
waitpid(-1, &status, WNOHANG | WUNTRACED);
#ifndef HAVE_SIGACTION
// assume broken, braindead sysv signal semantics
signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
return;
break;
default:
if (base_display->handleSignal(sig)) {
#ifndef HAVE_SIGACTION
// assume broken, braindead sysv signal semantics
signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
return;
}
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplaySignalCaught,
"%s: signal %d caught\n"),
base_display->getApplicationName(), sig);
if (! base_display->isStartup() && ! re_enter) {
internal_error = True;
re_enter = 1;
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayShuttingDown,
"shutting down\n"));
base_display->shutdown();
}
if (sig != SIGTERM && sig != SIGINT) {
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayAborting,
"aborting... dumping core\n"));
abort();
}
exit(0);
break;
}
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplaySignalCaught,
"%s: signal %d caught\n"),
base_display->getApplicationName(), sig);
if (! base_display->isStartup() && ! re_enter) {
internal_error = True;
re_enter = 1;
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayShuttingDown,
"shutting down\n"));
base_display->shutdown();
}
if (sig != SIGTERM && sig != SIGINT) {
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayAborting,
"aborting... dumping core\n"));
abort();
}
exit(0);
break;
}
}
// convenience functions
// convenience functions
#ifndef __EMX__
void bexec(const char *command, char* displaystring) {
if (! fork()) {
setsid();
putenv(displaystring);
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
exit(0);
void bexec(const char *command, char* displaystring) {
if (! fork()) {
setsid();
putenv(displaystring);
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
exit(0);
}
}
}
#endif // !__EMX__
char *bstrdup(const char *s) {
const int l = strlen(s) + 1;
char *n = new char[l];
strncpy(n, s, l);
return n;
}
BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
application_name = bstrdup(app_name);
_startup = True;
_shutdown = False;
server_grabs = 0;
last_bad_window = None;
::base_display = this;
#ifdef HAVE_SIGACTION
struct sigaction action;
action.sa_handler = signalhandler;
action.sa_mask = sigset_t();
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
sigaction(SIGPIPE, &action, NULL);
sigaction(SIGSEGV, &action, NULL);
sigaction(SIGFPE, &action, NULL);
sigaction(SIGTERM, &action, NULL);
sigaction(SIGINT, &action, NULL);
sigaction(SIGCHLD, &action, NULL);
sigaction(SIGHUP, &action, NULL);
sigaction(SIGUSR1, &action, NULL);
sigaction(SIGUSR2, &action, NULL);
#else // !HAVE_SIGACTION
signal(SIGPIPE, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGSEGV, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGFPE, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGTERM, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGUSR1, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGUSR2, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
if (! (display = XOpenDisplay(dpy_name))) {
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayXConnectFail,
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
::exit(2);
} else if (fcntl(ConnectionNumber(display), F_SETFD, 1) == -1) {
fprintf(stderr,
i18n->getMessage(BaseDisplaySet, BaseDisplayCloseOnExecFail,
"BaseDisplay::BaseDisplay: couldn't mark display connection "
"as close-on-exec\n"));
::exit(2);
char *bstrdup(const char *s) {
const int l = strlen(s) + 1;
char *n = new char[l];
strncpy(n, s, l);
return n;
}
display_name = XDisplayName(dpy_name);
BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
application_name = bstrdup(app_name);
_startup = True;
_shutdown = False;
server_grabs = 0;
last_bad_window = None;
::base_display = this;
#ifdef HAVE_SIGACTION
struct sigaction action;
action.sa_handler = signalhandler;
action.sa_mask = sigset_t();
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
sigaction(SIGPIPE, &action, NULL);
sigaction(SIGSEGV, &action, NULL);
sigaction(SIGFPE, &action, NULL);
sigaction(SIGTERM, &action, NULL);
sigaction(SIGINT, &action, NULL);
sigaction(SIGCHLD, &action, NULL);
sigaction(SIGHUP, &action, NULL);
sigaction(SIGUSR1, &action, NULL);
sigaction(SIGUSR2, &action, NULL);
#else // !HAVE_SIGACTION
signal(SIGPIPE, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGSEGV, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGFPE, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGTERM, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGUSR1, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGUSR2, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
if (! (display = XOpenDisplay(dpy_name))) {
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXConnectFail,
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
::exit(2);
} else if (fcntl(ConnectionNumber(display), F_SETFD, 1) == -1) {
fprintf(stderr,
i18n(BaseDisplaySet, BaseDisplayCloseOnExecFail,
"BaseDisplay::BaseDisplay: couldn't mark display connection "
"as close-on-exec\n"));
::exit(2);
}
display_name = XDisplayName(dpy_name);
#ifdef SHAPE
shape.extensions = XShapeQueryExtension(display, &shape.event_basep,
&shape.error_basep);
shape.extensions = XShapeQueryExtension(display, &shape.event_basep,
&shape.error_basep);
#else // !SHAPE
shape.extensions = False;
shape.extensions = False;
#endif // SHAPE
xa_wm_colormap_windows =
XInternAtom(display, "WM_COLORMAP_WINDOWS", False);
xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
xa_wm_state = XInternAtom(display, "WM_STATE", False);
xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
xa_wm_colormap_windows =
XInternAtom(display, "WM_COLORMAP_WINDOWS", False);
xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
xa_wm_state = XInternAtom(display, "WM_STATE", False);
xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
openbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False);
openbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
openbox_change_attributes =
XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False);
openbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False);
openbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
openbox_change_attributes =
XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False);
openbox_structure_messages =
XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False);
openbox_notify_startup =
XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False);
openbox_notify_window_add =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False);
openbox_notify_window_del =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False);
openbox_notify_current_workspace =
XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False);
openbox_notify_workspace_count =
XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False);
openbox_notify_window_focus =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False);
openbox_notify_window_raise =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False);
openbox_notify_window_lower =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False);
openbox_structure_messages =
XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False);
openbox_notify_startup =
XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False);
openbox_notify_window_add =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False);
openbox_notify_window_del =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False);
openbox_notify_current_workspace =
XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False);
openbox_notify_workspace_count =
XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False);
openbox_notify_window_focus =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False);
openbox_notify_window_raise =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False);
openbox_notify_window_lower =
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False);
openbox_change_workspace =
XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False);
openbox_change_window_focus =
XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False);
openbox_cycle_window_focus =
XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False);
openbox_change_workspace =
XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False);
openbox_change_window_focus =
XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False);
openbox_cycle_window_focus =
XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False);
#ifdef NEWWMSPEC
net_supported = XInternAtom(display, "_NET_SUPPORTED", False);
net_client_list = XInternAtom(display, "_NET_CLIENT_LIST", False);
net_client_list_stacking = XInternAtom(display, "_NET_CLIENT_LIST_STACKING", False);
net_number_of_desktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False);
net_desktop_geometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
net_desktop_viewport = XInternAtom(display, "_NET_DESKTOP_VIEWPORT", False);
net_current_desktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", False);
net_desktop_names = XInternAtom(display, "_NET_DESKTOP_NAMES", False);
net_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
net_workarea = XInternAtom(display, "_NET_WORKAREA", False);
net_supporting_wm_check = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
net_virtual_roots = XInternAtom(display, "_NET_VIRTUAL_ROOTS", False);
net_supported = XInternAtom(display, "_NET_SUPPORTED", False);
net_client_list = XInternAtom(display, "_NET_CLIENT_LIST", False);
net_client_list_stacking = XInternAtom(display, "_NET_CLIENT_LIST_STACKING", False);
net_number_of_desktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False);
net_desktop_geometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
net_desktop_viewport = XInternAtom(display, "_NET_DESKTOP_VIEWPORT", False);
net_current_desktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", False);
net_desktop_names = XInternAtom(display, "_NET_DESKTOP_NAMES", False);
net_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
net_workarea = XInternAtom(display, "_NET_WORKAREA", False);
net_supporting_wm_check = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
net_virtual_roots = XInternAtom(display, "_NET_VIRTUAL_ROOTS", False);
net_close_window = XInternAtom(display, "_NET_CLOSE_WINDOW", False);
net_wm_moveresize = XInternAtom(display, "_NET_WM_MOVERESIZE", False);
net_close_window = XInternAtom(display, "_NET_CLOSE_WINDOW", False);
net_wm_moveresize = XInternAtom(display, "_NET_WM_MOVERESIZE", False);
net_properties = XInternAtom(display, "_NET_PROPERTIES", False);
net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
net_wm_state = XInternAtom(display, "_NET_WM_STATE", False);
net_wm_strut = XInternAtom(display, "_NET_WM_STRUT", False);
net_wm_icon_geometry = XInternAtom(display, "_NET_WM_ICON_GEOMETRY", False);
net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
net_wm_pid = XInternAtom(display, "_NET_WM_PID", False);
net_wm_handled_icons = XInternAtom(display, "_NET_WM_HANDLED_ICONS", False);
net_properties = XInternAtom(display, "_NET_PROPERTIES", False);
net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
net_wm_state = XInternAtom(display, "_NET_WM_STATE", False);
net_wm_strut = XInternAtom(display, "_NET_WM_STRUT", False);
net_wm_icon_geometry = XInternAtom(display, "_NET_WM_ICON_GEOMETRY", False);
net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
net_wm_pid = XInternAtom(display, "_NET_WM_PID", False);
net_wm_handled_icons = XInternAtom(display, "_NET_WM_HANDLED_ICONS", False);
net_wm_ping = XInternAtom(display, "_NET_WM_PING", False);
net_wm_ping = XInternAtom(display, "_NET_WM_PING", False);
#endif // NEWWMSPEC
cursor.session = XCreateFontCursor(display, XC_left_ptr);
cursor.move = XCreateFontCursor(display, XC_fleur);
cursor.ll_angle = XCreateFontCursor(display, XC_ll_angle);
cursor.lr_angle = XCreateFontCursor(display, XC_lr_angle);
cursor.ul_angle = XCreateFontCursor(display, XC_ul_angle);
cursor.ur_angle = XCreateFontCursor(display, XC_ur_angle);
cursor.session = XCreateFontCursor(display, XC_left_ptr);
cursor.move = XCreateFontCursor(display, XC_fleur);
cursor.ll_angle = XCreateFontCursor(display, XC_ll_angle);
cursor.lr_angle = XCreateFontCursor(display, XC_lr_angle);
cursor.ul_angle = XCreateFontCursor(display, XC_ul_angle);
cursor.ur_angle = XCreateFontCursor(display, XC_ur_angle);
XSetErrorHandler((XErrorHandler) handleXErrors);
XSetErrorHandler((XErrorHandler) handleXErrors);
screenInfoList.reserve(numberOfScreens());
for (unsigned int s = 0; s < numberOfScreens(); s++)
screenInfoList.push_back(new ScreenInfo(*this, s));
screenInfoList.reserve(numberOfScreens());
for (unsigned int s = 0; s < numberOfScreens(); s++)
screenInfoList.push_back(new ScreenInfo(*this, s));
#ifndef NOCLOBBER
NumLockMask = ScrollLockMask = 0;
NumLockMask = ScrollLockMask = 0;
const XModifierKeymap* const modmap = XGetModifierMapping(display);
if (modmap && modmap->max_keypermod > 0) {
const int mask_table[] = {
ShiftMask, LockMask, ControlMask, Mod1Mask,
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
};
const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
modmap->max_keypermod;
// get the values of the keyboard lock modifiers
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
// since it doesn't need to be.
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
const KeyCode scroll_lock_code = XKeysymToKeycode(display, XK_Scroll_Lock);
for (size_t cnt = 0; cnt < size; ++cnt) {
if (! modmap->modifiermap[cnt]) continue;
const XModifierKeymap* const modmap = XGetModifierMapping(display);
if (modmap && modmap->max_keypermod > 0) {
const int mask_table[] = {
ShiftMask, LockMask, ControlMask, Mod1Mask,
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
};
const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
modmap->max_keypermod;
// get the values of the keyboard lock modifiers
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
// since it doesn't need to be.
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
const KeyCode scroll_lock_code = XKeysymToKeycode(display, XK_Scroll_Lock);
if (num_lock_code == modmap->modifiermap[cnt])
NumLockMask = mask_table[cnt / modmap->max_keypermod];
if (scroll_lock_code == modmap->modifiermap[cnt])
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
for (size_t cnt = 0; cnt < size; ++cnt) {
if (! modmap->modifiermap[cnt]) continue;
if (num_lock_code == modmap->modifiermap[cnt])
NumLockMask = mask_table[cnt / modmap->max_keypermod];
if (scroll_lock_code == modmap->modifiermap[cnt])
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
}
}
MaskList[0] = 0;
MaskList[1] = LockMask;
MaskList[2] = NumLockMask;
MaskList[3] = ScrollLockMask;
MaskList[4] = LockMask | NumLockMask;
MaskList[5] = NumLockMask | ScrollLockMask;
MaskList[6] = LockMask | ScrollLockMask;
MaskList[7] = LockMask | NumLockMask | ScrollLockMask;
MaskListLength = sizeof(MaskList) / sizeof(MaskList[0]);
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
#else
NumLockMask = Mod2Mask;
ScrollLockMask = Mod5Mask;
#endif // NOCLOBBER
}
MaskList[0] = 0;
MaskList[1] = LockMask;
MaskList[2] = NumLockMask;
MaskList[3] = ScrollLockMask;
MaskList[4] = LockMask | NumLockMask;
MaskList[5] = NumLockMask | ScrollLockMask;
MaskList[6] = LockMask | ScrollLockMask;
MaskList[7] = LockMask | NumLockMask | ScrollLockMask;
MaskListLength = sizeof(MaskList) / sizeof(MaskList[0]);
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
#else
NumLockMask = Mod2Mask;
ScrollLockMask = Mod5Mask;
#endif // NOCLOBBER
}
BaseDisplay::~BaseDisplay(void) {
std::for_each(screenInfoList.begin(), screenInfoList.end(),
PointerAssassin());
// we don't create the BTimers, we don't delete them
if (application_name != NULL)
delete [] application_name;
XCloseDisplay(display);
}
BaseDisplay::~BaseDisplay(void) {
std::for_each(screenInfoList.begin(), screenInfoList.end(),
PointerAssassin());
// we don't create the BTimers, we don't delete them
if (application_name != NULL)
delete [] application_name;
void BaseDisplay::eventLoop(void) {
run();
XCloseDisplay(display);
}
int xfd = ConnectionNumber(display);
while ((! _shutdown) && (! internal_error)) {
if (XPending(display)) {
XEvent e;
XNextEvent(display, &e);
void BaseDisplay::eventLoop(void) {
run();
int xfd = ConnectionNumber(display);
while ((! _shutdown) && (! internal_error)) {
if (XPending(display)) {
XEvent e;
XNextEvent(display, &e);
if (last_bad_window != None && e.xany.window == last_bad_window) {
if (last_bad_window != None && e.xany.window == last_bad_window) {
#ifdef DEBUG
fprintf(stderr, i18n->getMessage(BaseDisplaySet,
BaseDisplayBadWindowRemove,
"BaseDisplay::eventLoop(): removing bad window "
"from event queue\n"));
fprintf(stderr, i18n(BaseDisplaySet,
BaseDisplayBadWindowRemove,
"BaseDisplay::eventLoop(): removing bad window "
"from event queue\n"));
#endif // DEBUG
} else {
last_bad_window = None;
process_event(&e);
}
} else {
last_bad_window = None;
process_event(&e);
}
} else {
fd_set rfds;
timeval now, tm, *timeout = (timeval *) 0;
fd_set rfds;
timeval now, tm, *timeout = (timeval *) 0;
FD_ZERO(&rfds);
FD_SET(xfd, &rfds);
FD_ZERO(&rfds);
FD_SET(xfd, &rfds);
if (!timerList.empty()) {
if (!timerList.empty()) {
gettimeofday(&now, 0);
tm.tv_sec = tm.tv_usec = 0l;
BTimer *timer = timerList.front();
ASSERT(timer != NULL);
tm.tv_sec = timer->getStartTime().tv_sec +
timer->getTimeout().tv_sec - now.tv_sec;
tm.tv_usec = timer->getStartTime().tv_usec +
timer->getTimeout().tv_usec - now.tv_usec;
while (tm.tv_usec >= 1000000) {
tm.tv_sec++;
tm.tv_usec -= 1000000;
}
while (tm.tv_usec < 0) {
if (tm.tv_sec > 0) {
tm.tv_sec--;
tm.tv_usec += 1000000;
} else {
tm.tv_usec = 0;
break;
}
}
timeout = &tm;
}
select(xfd + 1, &rfds, 0, 0, timeout);
// check for timer timeout
gettimeofday(&now, 0);
tm.tv_sec = tm.tv_usec = 0l;
TimerList::iterator it;
for (it = timerList.begin(); it != timerList.end(); ++it) {
BTimer *timer = *it;
ASSERT(timer != NULL);
BTimer *timer = timerList.front();
ASSERT(timer != NULL);
tm.tv_sec = timer->getStartTime().tv_sec +
timer->getTimeout().tv_sec;
tm.tv_usec = timer->getStartTime().tv_usec +
timer->getTimeout().tv_usec;
tm.tv_sec = timer->getStartTime().tv_sec +
timer->getTimeout().tv_sec - now.tv_sec;
tm.tv_usec = timer->getStartTime().tv_usec +
timer->getTimeout().tv_usec - now.tv_usec;
while (tm.tv_usec >= 1000000) {
tm.tv_sec++;
tm.tv_usec -= 1000000;
}
while (tm.tv_usec < 0) {
if (tm.tv_sec > 0) {
tm.tv_sec--;
tm.tv_usec += 1000000;
} else {
tm.tv_usec = 0;
if ((now.tv_sec < tm.tv_sec) ||
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
break;
}
timer->fireTimeout();
// restart the current timer so that the start time is updated
if (! timer->doOnce()) {
// reorder
removeTimer(timer);
addTimer(timer);
timer->start();
} else
timer->stop();
it = timerList.begin(); // we no longer have any idea if the iterator is
// valid, but what was at the front() is no
// longer.
}
timeout = &tm;
}
select(xfd + 1, &rfds, 0, 0, timeout);
// check for timer timeout
gettimeofday(&now, 0);
TimerList::iterator it;
for (it = timerList.begin(); it != timerList.end(); ++it) {
BTimer *timer = *it;
ASSERT(timer != NULL);
tm.tv_sec = timer->getStartTime().tv_sec +
timer->getTimeout().tv_sec;
tm.tv_usec = timer->getStartTime().tv_usec +
timer->getTimeout().tv_usec;
if ((now.tv_sec < tm.tv_sec) ||
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
break;
timer->fireTimeout();
// restart the current timer so that the start time is updated
if (! timer->doOnce()) {
// reorder
removeTimer(timer);
addTimer(timer);
timer->start();
} else
timer->stop();
it = timerList.begin(); // we no longer have any idea if the iterator is
// valid, but what was at the front() is no
// longer.
}
}
}
}
const Bool BaseDisplay::validateWindow(Window window) {
XEvent event;
if (XCheckTypedWindowEvent(display, window, DestroyNotify, &event)) {
XPutBackEvent(display, &event);
const Bool BaseDisplay::validateWindow(Window window) {
XEvent event;
if (XCheckTypedWindowEvent(display, window, DestroyNotify, &event)) {
XPutBackEvent(display, &event);
return False;
return False;
}
return True;
}
return True;
}
void BaseDisplay::grab(void) {
if (! server_grabs++)
XGrabServer(display);
}
void BaseDisplay::ungrab(void) {
if (! --server_grabs)
XUngrabServer(display);
}
void BaseDisplay::addTimer(BTimer *timer) {
ASSERT(timer != (BTimer *) 0);
TimerList::iterator it;
for (it = timerList.begin(); it != timerList.end(); ++it) {
BTimer *tmp = *it;
if ((tmp->getTimeout().tv_sec > timer->getTimeout().tv_sec) ||
((tmp->getTimeout().tv_sec == timer->getTimeout().tv_sec) &&
(tmp->getTimeout().tv_usec >= timer->getTimeout().tv_usec)))
break;
void BaseDisplay::grab(void) {
if (! server_grabs++)
XGrabServer(display);
}
timerList.insert(it, timer);
}
void BaseDisplay::ungrab(void) {
if (! --server_grabs)
XUngrabServer(display);
}
void BaseDisplay::removeTimer(BTimer *timer) {
ASSERT(timer != (BTimer *) 0);
timerList.remove(timer);
}
void BaseDisplay::addTimer(BTimer *timer) {
ASSERT(timer != (BTimer *) 0);
TimerList::iterator it;
for (it = timerList.begin(); it != timerList.end(); ++it) {
BTimer *tmp = *it;
if ((tmp->getTimeout().tv_sec > timer->getTimeout().tv_sec) ||
((tmp->getTimeout().tv_sec == timer->getTimeout().tv_sec) &&
(tmp->getTimeout().tv_usec >= timer->getTimeout().tv_usec)))
break;
}
timerList.insert(it, timer);
}
/*
* Grabs a button, but also grabs the button in every possible combination with
* the keyboard lock keys, so that they do not cancel out the event.
*/
void BaseDisplay::grabButton(unsigned int button, unsigned int modifiers,
Window grab_window, Bool owner_events,
unsigned int event_mask, int pointer_mode,
int keybaord_mode, Window confine_to,
Cursor cursor) const
{
void BaseDisplay::removeTimer(BTimer *timer) {
ASSERT(timer != (BTimer *) 0);
timerList.remove(timer);
}
/*
* Grabs a button, but also grabs the button in every possible combination with
* the keyboard lock keys, so that they do not cancel out the event.
*/
void BaseDisplay::grabButton(unsigned int button, unsigned int modifiers,
Window grab_window, Bool owner_events,
unsigned int event_mask, int pointer_mode,
int keybaord_mode, Window confine_to,
Cursor cursor) const
{
#ifndef NOCLOBBER
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
XGrabButton(display, button, modifiers | MaskList[cnt], grab_window,
owner_events, event_mask, pointer_mode, keybaord_mode,
confine_to, cursor);
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
XGrabButton(display, button, modifiers | MaskList[cnt], grab_window,
owner_events, event_mask, pointer_mode, keybaord_mode,
confine_to, cursor);
#else // NOCLOBBER
XGrabButton(display, button, modifiers, grab_window,
owner_events, event_mask, pointer_mode, keybaord_mode,
confine_to, cursor);
#endif // NOCLOBBER
}
}
/*
* Releases the grab on a button, and ungrabs all possible combinations of the
* keyboard lock keys.
*/
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
Window grab_window) const {
/*
* Releases the grab on a button, and ungrabs all possible combinations of the
* keyboard lock keys.
*/
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
Window grab_window) const {
#ifndef NOCLOBBER
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
XUngrabButton(display, button, modifiers | MaskList[cnt], grab_window);
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
XUngrabButton(display, button, modifiers | MaskList[cnt], grab_window);
#else // NOCLOBBER
XUngrabButton(display, button, modifiers, grab_window);
#endif // NOCLOBBER
}
}
ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
screen_number(num)
{
{
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
screen_number)),
HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
screen_number)));
m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
screen_number)),
HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
screen_number)));
// search for a TrueColor Visual... if we can't find one... we will use the
// default visual for the screen
XVisualInfo vinfo_template, *vinfo_return;
int vinfo_nitems;
// search for a TrueColor Visual... if we can't find one... we will use the
// default visual for the screen
XVisualInfo vinfo_template, *vinfo_return;
int vinfo_nitems;
vinfo_template.screen = screen_number;
vinfo_template.c_class = TrueColor;
vinfo_template.screen = screen_number;
vinfo_template.c_class = TrueColor;
visual = (Visual *) 0;
visual = (Visual *) 0;
if ((vinfo_return = XGetVisualInfo(basedisplay.getXDisplay(),
VisualScreenMask | VisualClassMask,
&vinfo_template, &vinfo_nitems)) &&
vinfo_nitems > 0) {
for (int i = 0; i < vinfo_nitems; i++) {
if (depth < (vinfo_return + i)->depth) {
depth = (vinfo_return + i)->depth;
visual = (vinfo_return + i)->visual;
if ((vinfo_return = XGetVisualInfo(basedisplay.getXDisplay(),
VisualScreenMask | VisualClassMask,
&vinfo_template, &vinfo_nitems)) &&
vinfo_nitems > 0) {
for (int i = 0; i < vinfo_nitems; i++) {
if (depth < (vinfo_return + i)->depth) {
depth = (vinfo_return + i)->depth;
visual = (vinfo_return + i)->visual;
}
}
XFree(vinfo_return);
}
XFree(vinfo_return);
if (visual) {
colormap = XCreateColormap(basedisplay.getXDisplay(), root_window,
visual, AllocNone);
} else {
visual = DefaultVisual(basedisplay.getXDisplay(), screen_number);
colormap = DefaultColormap(basedisplay.getXDisplay(), screen_number);
}
}
if (visual) {
colormap = XCreateColormap(basedisplay.getXDisplay(), root_window,
visual, AllocNone);
} else {
visual = DefaultVisual(basedisplay.getXDisplay(), screen_number);
colormap = DefaultColormap(basedisplay.getXDisplay(), screen_number);
}
}

View file

@ -87,46 +87,46 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
menu.bevel_w = screen.getBevelWidth();
if (i18n->multibyte())
if (i18n.multibyte())
menu.width = menu.title_h = menu.item_w = menu.frame_h =
screen.getMenuStyle()->t_fontset_extents->max_ink_extent.height +
(menu.bevel_w * 2);
(menu.bevel_w * 2);
else
menu.width = menu.title_h = menu.item_w = menu.frame_h =
screen.getMenuStyle()->t_font->ascent +
screen.getMenuStyle()->t_font->descent + (menu.bevel_w * 2);
screen.getMenuStyle()->t_font->descent + (menu.bevel_w * 2);
menu.label = 0;
menu.sublevels =
menu.persub =
menu.minsub = 0;
MenuStyle *style = screen.getMenuStyle();
if (i18n->multibyte()) {
if (i18n.multibyte()) {
menu.item_h = style->f_fontset_extents->max_ink_extent.height +
(menu.bevel_w);
} else {
menu.item_h = style->f_font->ascent + style->f_font->descent +
(menu.bevel_w);
(menu.bevel_w);
}
menu.height = menu.title_h + screen.getBorderWidth() + menu.frame_h;
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
CWColormap | CWOverrideRedirect | CWEventMask;
CWColormap | CWOverrideRedirect | CWEventMask;
XSetWindowAttributes attrib;
attrib.background_pixmap = None;
attrib.background_pixel = attrib.border_pixel =
screen.getBorderColor()->getPixel();
screen.getBorderColor()->getPixel();
attrib.colormap = screen.getColormap();
attrib.override_redirect = True;
attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | ExposureMask;
ButtonMotionMask | ExposureMask;
menu.window =
XCreateWindow(display, screen.getRootWindow(), menu.x, menu.y, menu.width,
menu.height, screen.getBorderWidth(), screen.getDepth(),
menu.height, screen.getBorderWidth(), screen.getDepth(),
InputOutput, screen.getVisual(), attrib_mask, &attrib);
openbox.saveMenuSearch(menu.window, this);
@ -136,16 +136,16 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
menu.title =
XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0,
screen.getDepth(), InputOutput, screen.getVisual(),
attrib_mask, &attrib);
screen.getDepth(), InputOutput, screen.getVisual(),
attrib_mask, &attrib);
openbox.saveMenuSearch(menu.title, this);
attrib.event_mask |= PointerMotionMask;
menu.frame = XCreateWindow(display, menu.window, 0,
menu.title_h + screen.getBorderWidth(),
menu.width, menu.frame_h, 0,
screen.getDepth(), InputOutput,
screen.getVisual(), attrib_mask, &attrib);
menu.title_h + screen.getBorderWidth(),
menu.width, menu.frame_h, 0,
screen.getDepth(), InputOutput,
screen.getVisual(), attrib_mask, &attrib);
openbox.saveMenuSearch(menu.frame, this);
// even though this is the end of the constructor the menu is still not
@ -243,15 +243,15 @@ int Basemenu::remove(int index) {
Basemenu *tmp = (Basemenu *) item->submenu();
if (! tmp->internal_menu) {
delete tmp;
delete tmp;
} else {
tmp->internal_hide();
tmp->internal_hide();
}
}
if (item->label())
delete [] item->label();
if (item->exec())
delete [] item->exec();
@ -269,33 +269,33 @@ int Basemenu::remove(int index) {
void Basemenu::update(void) {
MenuStyle *style = screen.getMenuStyle();
if (i18n->multibyte()) {
if (i18n.multibyte()) {
menu.item_h = style->f_fontset_extents->max_ink_extent.height +
menu.bevel_w;
menu.bevel_w;
menu.title_h = style->t_fontset_extents->max_ink_extent.height +
(menu.bevel_w * 2);
(menu.bevel_w * 2);
} else {
menu.item_h = style->f_font->ascent + style->f_font->descent +
menu.bevel_w;
menu.bevel_w;
menu.title_h = style->t_font->ascent + style->t_font->descent +
(menu.bevel_w * 2);
(menu.bevel_w * 2);
}
if (title_vis) {
const char *s = (menu.label) ? menu.label :
i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
"Openbox Menu");
i18n(BasemenuSet, BasemenuOpenboxMenu,
"Openbox Menu");
int l = strlen(s);
if (i18n->multibyte()) {
if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen.getMenuStyle()->t_fontset, s, l, &ink, &logical);
menu.item_w = logical.width;
} else {
menu.item_w = XTextWidth(screen.getMenuStyle()->t_font, s, l);
}
menu.item_w += (menu.bevel_w * 2);
} else {
menu.item_w = 1;
@ -305,10 +305,10 @@ void Basemenu::update(void) {
menuitemList::const_iterator it = menuitems.begin();
for (; it != menuitems.end(); it++) {
const char *s = (((*it)->u && *(*it)->u) ? *(*it)->u :
(((*it)->l) ? (*it)->l : (const char *) 0));
(((*it)->l) ? (*it)->l : (const char *) 0));
int l = strlen(s);
if (i18n->multibyte()) {
if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen.getMenuStyle()->f_fontset, s, l, &ink, &logical);
ii = logical.width;
@ -324,8 +324,8 @@ void Basemenu::update(void) {
menu.sublevels = 1;
while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels)
+ menu.title_h + screen.getBorderWidth()) >
screen.size().h())
+ menu.title_h + screen.getBorderWidth()) >
screen.size().h())
menu.sublevels++;
if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
@ -342,7 +342,7 @@ void Basemenu::update(void) {
menu.frame_h = (menu.item_h * menu.persub);
menu.height = ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) +
menu.frame_h;
menu.frame_h;
if (! menu.frame_h) menu.frame_h = 1;
if (menu.height < 1) menu.height = 1;
@ -354,7 +354,7 @@ void Basemenu::update(void) {
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
menu.title_pixmap = None;
XSetWindowBackground(display, menu.title,
texture->getColor()->getPixel());
texture->getColor()->getPixel());
} else {
menu.title_pixmap =
image_ctrl->renderImage(menu.width, menu.title_h, texture);
@ -369,7 +369,7 @@ void Basemenu::update(void) {
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
menu.frame_pixmap = None;
XSetWindowBackground(display, menu.frame,
texture->getColor()->getPixel());
texture->getColor()->getPixel());
} else {
menu.frame_pixmap =
image_ctrl->renderImage(menu.width, menu.frame_h, texture);
@ -403,9 +403,9 @@ void Basemenu::update(void) {
XResizeWindow(display, menu.title, menu.width, menu.title_h);
XMoveResizeWindow(display, menu.frame, 0,
((title_vis) ? menu.title_h +
screen.getBorderWidth() : 0), menu.width,
menu.frame_h);
((title_vis) ? menu.title_h +
screen.getBorderWidth() : 0), menu.width,
menu.frame_h);
XClearWindow(display, menu.window);
XClearWindow(display, menu.title);
@ -436,7 +436,7 @@ void Basemenu::show(void) {
if (! parent) {
if (shown && (! shown->torn))
shown->hide();
shown->hide();
shown = this;
}
@ -487,12 +487,12 @@ void Basemenu::move(int x, int y) {
void Basemenu::redrawTitle(void) {
char *text = (char *) ((menu.label) ? menu.label :
i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
"Openbox Menu"));
i18n(BasemenuSet, BasemenuOpenboxMenu,
"Openbox Menu"));
int dx = menu.bevel_w, len = strlen(text);
unsigned int l;
if (i18n->multibyte()) {
if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen.getMenuStyle()->t_fontset, text, len, &ink, &logical);
l = logical.width;
@ -513,13 +513,13 @@ void Basemenu::redrawTitle(void) {
}
MenuStyle *style = screen.getMenuStyle();
if (i18n->multibyte())
if (i18n.multibyte())
XmbDrawString(display, menu.title, style->t_fontset, style->t_text_gc, dx,
(menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
text, len);
(menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
text, len);
else
XDrawString(display, menu.title, style->t_text_gc, dx,
(style->t_font->ascent + menu.bevel_w), text, len);
(style->t_font->ascent + menu.bevel_w), text, len);
}
@ -534,47 +534,47 @@ void Basemenu::drawSubmenu(int index) {
if (index >= 0 && index < (signed)menuitems.size()) {
BasemenuItem *item = menuitems[index];
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
item->isEnabled()) {
item->isEnabled()) {
if (item->submenu()->parent != this) item->submenu()->parent = this;
int sbl = index / menu.persub, i = index - (sbl * menu.persub),
x = menu.x +
((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
x = menu.x +
((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
if (alignment == AlignTop)
y = (((shifted) ? menu.y_shift : menu.y) +
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
((item->submenu()->title_vis) ?
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
y = (((shifted) ? menu.y_shift : menu.y) +
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
((item->submenu()->title_vis) ?
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
else
y = (((shifted) ? menu.y_shift : menu.y) +
(menu.item_h * i) +
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
((item->submenu()->title_vis) ?
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
y = (((shifted) ? menu.y_shift : menu.y) +
(menu.item_h * i) +
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
((item->submenu()->title_vis) ?
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
if (alignment == AlignBottom &&
(y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
menu.y) + menu.height)
y = (((shifted) ? menu.y_shift : menu.y) +
menu.height - item->submenu()->menu.height);
(y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
menu.y) + menu.height)
y = (((shifted) ? menu.y_shift : menu.y) +
menu.height - item->submenu()->menu.height);
if ((x + item->submenu()->getWidth()) > screen.size().w()) {
x = ((shifted) ? menu.x_shift : menu.x) -
item->submenu()->getWidth() - screen.getBorderWidth();
x = ((shifted) ? menu.x_shift : menu.x) -
item->submenu()->getWidth() - screen.getBorderWidth();
}
if (x < 0) x = 0;
if ((y + item->submenu()->getHeight()) > screen.size().h())
y = screen.size().h() - item->submenu()->getHeight() -
(screen.getBorderWidth() * 2);
y = screen.size().h() - item->submenu()->getHeight() -
(screen.getBorderWidth() * 2);
if (y < 0) y = 0;
item->submenu()->move(x, y);
if (! moving) drawItem(index, True);
if (! item->submenu()->isVisible())
item->submenu()->show();
item->submenu()->show();
item->submenu()->moving = moving;
which_sub = index;
} else {
@ -592,13 +592,13 @@ bool Basemenu::hasSubmenu(int index) {
void Basemenu::drawItem(int index, Bool highlight, Bool clear,
int x, int y, unsigned int w, unsigned int h)
int x, int y, unsigned int w, unsigned int h)
{
if (index < 0 || index > (signed)menuitems.size()) return;
BasemenuItem *item = menuitems[index];
if (! item) return;
Bool dotext = True, dohilite = True, dosel = True;
const char *text = (item->ulabel()) ? *item->ulabel() : item->label();
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
@ -606,62 +606,62 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0;
int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0;
unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0,
text_h = 0;
text_h = 0;
unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4;
if (text) {
if (i18n->multibyte()) {
if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen.getMenuStyle()->f_fontset,
text, len, &ink, &logical);
text, len, &ink, &logical);
text_w = logical.width;
text_y = item_y + (menu.bevel_w / 2) -
screen.getMenuStyle()->f_fontset_extents->max_ink_extent.y;
screen.getMenuStyle()->f_fontset_extents->max_ink_extent.y;
} else {
text_w = XTextWidth(screen.getMenuStyle()->f_font, text, len);
text_y = item_y +
screen.getMenuStyle()->f_font->ascent +
(menu.bevel_w / 2);
screen.getMenuStyle()->f_font->ascent +
(menu.bevel_w / 2);
}
switch(screen.getMenuStyle()->f_justify) {
case BScreen::LeftJustify:
text_x = item_x + menu.bevel_w + menu.item_h + 1;
break;
case BScreen::RightJustify:
text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
break;
case BScreen::CenterJustify:
text_x = item_x + ((menu.item_w + 1 - text_w) / 2);
break;
}
text_h = menu.item_h - menu.bevel_w;
}
GC gc =
((highlight || item->isSelected()) ? screen.getMenuStyle()->h_text_gc :
screen.getMenuStyle()->f_text_gc),
tgc =
tgc =
((highlight) ? screen.getMenuStyle()->h_text_gc :
((item->isEnabled()) ? screen.getMenuStyle()->f_text_gc :
screen.getMenuStyle()->d_text_gc));
sel_x = item_x;
if (screen.getMenuStyle()->bullet_pos == Right)
sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
sel_x += quarter_w;
sel_y = item_y + quarter_w;
if (clear) {
XClearArea(display, menu.frame, item_x, item_y, menu.item_w, menu.item_h,
False);
False);
} else if (! (x == y && y == -1 && w == h && h == 0)) {
// calculate the which part of the hilite to redraw
if (! (max(item_x, x) <= (signed) min(item_x + menu.item_w, x + w) &&
max(item_y, y) <= (signed) min(item_y + menu.item_h, y + h))) {
max(item_y, y) <= (signed) min(item_y + menu.item_h, y + h))) {
dohilite = False;
} else {
hilite_x = max(item_x, x);
@ -671,44 +671,44 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
hoff_x = hilite_x % menu.item_w;
hoff_y = hilite_y % menu.item_h;
}
// check if we need to redraw the text
int text_ry = item_y + (menu.bevel_w / 2);
if (! (max(text_x, x) <= (signed) min(text_x + text_w, x + w) &&
max(text_ry, y) <= (signed) min(text_ry + text_h, y + h)))
max(text_ry, y) <= (signed) min(text_ry + text_h, y + h)))
dotext = False;
// check if we need to redraw the select pixmap/menu bullet
if (! (max(sel_x, x) <= (signed) min(sel_x + half_w, x + w) &&
max(sel_y, y) <= (signed) min(sel_y + half_w, y + h)))
max(sel_y, y) <= (signed) min(sel_y + half_w, y + h)))
dosel = False;
}
if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
if (menu.hilite_pixmap)
XCopyArea(display, menu.hilite_pixmap, menu.frame,
screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
hilite_w, hilite_h, hilite_x, hilite_y);
screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
hilite_w, hilite_h, hilite_x, hilite_y);
else
XFillRectangle(display, menu.frame,
screen.getMenuStyle()->hilite_gc,
hilite_x, hilite_y, hilite_w, hilite_h);
screen.getMenuStyle()->hilite_gc,
hilite_x, hilite_y, hilite_w, hilite_h);
} else if (dosel && item->isSelected() &&
(menu.sel_pixmap != ParentRelative)) {
(menu.sel_pixmap != ParentRelative)) {
if (menu.sel_pixmap)
XCopyArea(display, menu.sel_pixmap, menu.frame,
screen.getMenuStyle()->hilite_gc, 0, 0,
half_w, half_w, sel_x, sel_y);
screen.getMenuStyle()->hilite_gc, 0, 0,
half_w, half_w, sel_x, sel_y);
else
XFillRectangle(display, menu.frame,
screen.getMenuStyle()->hilite_gc,
sel_x, sel_y, half_w, half_w);
screen.getMenuStyle()->hilite_gc,
sel_x, sel_y, half_w, half_w);
}
if (dotext && text) {
if (i18n->multibyte())
if (i18n.multibyte())
XmbDrawString(display, menu.frame, screen.getMenuStyle()->f_fontset,
tgc, text_x, text_y, text, len);
tgc, text_x, text_y, text, len);
else
XDrawString(display, menu.frame, tgc, text_x, text_y, text, len);
}
@ -724,24 +724,24 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
if (screen.getMenuStyle()->bullet_pos == Right) {
tri[0].x = sel_x + quarter_w - 2;
tri[0].y = sel_y + quarter_w - 2;
tri[0].y = sel_y + quarter_w - 2;
tri[1].x = 4;
tri[1].y = 2;
tri[1].y = 2;
tri[2].x = -4;
tri[2].y = 2;
tri[2].y = 2;
} else {
tri[0].x = sel_x + quarter_w - 2;
tri[0].y = item_y + half_w;
tri[0].y = item_y + half_w;
tri[1].x = 4;
tri[1].y = 2;
tri[1].y = 2;
tri[2].x = 0;
tri[2].y = -4;
tri[2].y = -4;
}
XFillPolygon(display, menu.frame, gc, tri, 3, Convex,
CoordModePrevious);
break;
case Diamond:
XPoint dia[4];
@ -825,9 +825,9 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
BasemenuItem *item = menuitems[w];
if (item->submenu())
drawSubmenu(w);
drawSubmenu(w);
else
drawItem(w, (item->isEnabled()), True);
drawItem(w, (item->isEnabled()), True);
}
} else {
menu.x_move = be->x_root - menu.x;
@ -840,34 +840,34 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
if (re->window == menu.title) {
if (moving) {
moving = False;
if (which_sub != -1)
drawSubmenu(which_sub);
drawSubmenu(which_sub);
}
if (re->x >= 0 && re->x <= (signed) menu.width &&
re->y >= 0 && re->y <= (signed) menu.title_h)
re->y >= 0 && re->y <= (signed) menu.title_h)
if (re->button == 3)
hide();
hide();
} else if (re->window == menu.frame &&
re->x >= 0 && re->x < (signed) menu.width &&
re->y >= 0 && re->y < (signed) menu.frame_h) {
re->x >= 0 && re->x < (signed) menu.width &&
re->y >= 0 && re->y < (signed) menu.frame_h) {
if (re->button == 3) {
hide();
} else {
int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h),
ix = sbl * menu.item_w, iy = i * menu.item_h,
w = (sbl * menu.persub) + i,
p = (which_sbl * menu.persub) + which_press;
ix = sbl * menu.item_w, iy = i * menu.item_h,
w = (sbl * menu.persub) + i,
p = (which_sbl * menu.persub) + which_press;
if (w < (signed)menuitems.size() && w >= 0) {
drawItem(p, (p == which_sub), True);
drawItem(p, (p == which_sub), True);
if (p == w && isItemEnabled(w)) {
if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
re->y > iy && re->y < (signed) (iy + menu.item_h)) {
itemSelected(re->button, w);
}
if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
re->y > iy && re->y < (signed) (iy + menu.item_h)) {
itemSelected(re->button, w);
}
}
} else
drawItem(p, False, True);
@ -880,44 +880,44 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
if (me->window == menu.title && (me->state & Button1Mask)) {
if (movable) {
if (! moving) {
if (parent && (! torn)) {
parent->drawItem(parent->which_sub, False, True);
parent->which_sub = -1;
}
if (parent && (! torn)) {
parent->drawItem(parent->which_sub, False, True);
parent->which_sub = -1;
}
moving = torn = True;
if (which_sub != -1)
drawSubmenu(which_sub);
if (which_sub != -1)
drawSubmenu(which_sub);
} else {
menu.x = me->x_root - menu.x_move,
menu.y = me->y_root - menu.y_move;
XMoveWindow(display, menu.window, menu.x, menu.y);
if (which_sub != -1)
drawSubmenu(which_sub);
menu.x = me->x_root - menu.x_move,
menu.y = me->y_root - menu.y_move;
XMoveWindow(display, menu.window, menu.x, menu.y);
if (which_sub != -1)
drawSubmenu(which_sub);
}
}
} else if ((! (me->state & Button1Mask)) && me->window == menu.frame &&
me->x >= 0 && me->x < (signed) menu.width &&
me->y >= 0 && me->y < (signed) menu.frame_h) {
me->x >= 0 && me->x < (signed) menu.width &&
me->y >= 0 && me->y < (signed) menu.frame_h) {
int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h),
w = (sbl * menu.persub) + i;
w = (sbl * menu.persub) + i;
if ((i != which_press || sbl != which_sbl) &&
(w < (signed)menuitems.size() && w >= 0)) {
(w < (signed)menuitems.size() && w >= 0)) {
if (which_press != -1 && which_sbl != -1) {
int p = (which_sbl * menu.persub) + which_press;
BasemenuItem *item = menuitems[p];
int p = (which_sbl * menu.persub) + which_press;
BasemenuItem *item = menuitems[p];
drawItem(p, False, True);
if (item->submenu())
if (item->submenu()->isVisible() &&
(! item->submenu()->isTorn())) {
item->submenu()->internal_hide();
which_sub = -1;
}
drawItem(p, False, True);
if (item->submenu())
if (item->submenu()->isVisible() &&
(! item->submenu()->isTorn())) {
item->submenu()->internal_hide();
which_sub = -1;
}
}
which_press = i;
@ -926,9 +926,9 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
BasemenuItem *itmp = menuitems[w];
if (itmp->submenu())
drawSubmenu(w);
drawSubmenu(w);
else
drawItem(w, (itmp->isEnabled()), True);
drawItem(w, (itmp->isEnabled()), True);
}
}
}
@ -943,10 +943,10 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
// items down in that sublevel
int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h),
// next... figure out how many sublevels over the redraw spans
sbl_d = ((ee->x + ee->width) / menu.item_w),
// then we see how many items down to redraw
id_d = ((ee->y + ee->height) / menu.item_h);
// next... figure out how many sublevels over the redraw spans
sbl_d = ((ee->x + ee->width) / menu.item_w),
// then we see how many items down to redraw
id_d = ((ee->y + ee->height) / menu.item_h);
if (id_d > menu.persub) id_d = menu.persub;
@ -957,10 +957,10 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
// set the iterator to the first item in the sublevel needing redrawing
it = menuitems.begin() + (id + (i * menu.persub));
for (ii = id; ii <= id_d && it != menuitems.end(); it++, ii++) {
int index = ii + (i * menu.persub);
// redraw the item
drawItem(index, (which_sub == index), False,
ee->x, ee->y, ee->width, ee->height);
int index = ii + (i * menu.persub);
// redraw the item
drawItem(index, (which_sub == index), False,
ee->x, ee->y, ee->width, ee->height);
}
}
}
@ -994,15 +994,15 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
if (which_sub != -1) {
BasemenuItem *tmp = menuitems[which_sub];
if (tmp->submenu()->isVisible()) {
int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
w = (sbl * menu.persub) + i;
int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
w = (sbl * menu.persub) + i;
if (w != which_sub && (! tmp->submenu()->isTorn())) {
tmp->submenu()->internal_hide();
if (w != which_sub && (! tmp->submenu()->isTorn())) {
tmp->submenu()->internal_hide();
drawItem(which_sub, False, True);
which_sub = -1;
}
drawItem(which_sub, False, True);
which_sub = -1;
}
}
}
}
@ -1031,9 +1031,9 @@ void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
void Basemenu::reconfigure(void) {
XSetWindowBackground(display, menu.window,
screen.getBorderColor()->getPixel());
screen.getBorderColor()->getPixel());
XSetWindowBorder(display, menu.window,
screen.getBorderColor()->getPixel());
screen.getBorderColor()->getPixel());
XSetWindowBorderWidth(display, menu.window, screen.getBorderWidth());
menu.bevel_w = screen.getBevelWidth();

View file

@ -39,29 +39,29 @@
Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
{
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuConfigOptions,
"Config options"));
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions,
"Config options"));
setInternalMenu();
focusmenu = new Focusmenu(this);
placementmenu = new Placementmenu(this);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
"Focus Model"), focusmenu);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
"Window Placement"), placementmenu);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuImageDithering,
"Image Dithering"), 1);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuOpaqueMove,
"Opaque Window Moving"), 2);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFullMax,
"Full Maximization"), 3);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusNew,
"Focus New Windows"), 4);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusLast,
"Focus Last Window on Workspace"), 5);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuHideToolbar,
"Hide toolbar"), 6);
insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
"Focus Model"), focusmenu);
insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
"Window Placement"), placementmenu);
insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
"Image Dithering"), 1);
insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove,
"Opaque Window Moving"), 2);
insert(i18n(ConfigmenuSet, ConfigmenuFullMax,
"Full Maximization"), 3);
insert(i18n(ConfigmenuSet, ConfigmenuFocusNew,
"Focus New Windows"), 4);
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
"Focus Last Window on Workspace"), 5);
insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar,
"Hide toolbar"), 6);
update();
setValues();
@ -145,16 +145,16 @@ void Configmenu::reconfigure() {
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) {
configmenu = cm;
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
"Focus Model"));
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel,
"Focus Model"));
setInternalMenu();
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickToFocus,
"Click To Focus"), 1);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSloppyFocus,
"Sloppy Focus"), 2);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuAutoRaise,
"Auto Raise"), 3);
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus,
"Click To Focus"), 1);
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus,
"Sloppy Focus"), 2);
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise,
"Auto Raise"), 3);
update();
setValues();
@ -207,37 +207,37 @@ void Configmenu::Focusmenu::itemSelected(int button, int index) {
}
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
Basemenu(cm->screen) {
Basemenu(cm->screen) {
configmenu = cm;
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
"Window Placement"));
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
"Window Placement"));
setInternalMenu();
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartRows,
"Smart Placement (Rows)"),
BScreen::RowSmartPlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartCols,
"Smart Placement (Columns)"),
BScreen::ColSmartPlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuCascade,
"Cascade Placement"), BScreen::CascadePlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBestFit,
"Best Fit Placement"), BScreen::BestFitPlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse,
"Under Mouse Placement"),
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows,
"Smart Placement (Rows)"),
BScreen::RowSmartPlacement);
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols,
"Smart Placement (Columns)"),
BScreen::ColSmartPlacement);
insert(i18n(ConfigmenuSet, ConfigmenuCascade,
"Cascade Placement"), BScreen::CascadePlacement);
insert(i18n(ConfigmenuSet, ConfigmenuBestFit,
"Best Fit Placement"), BScreen::BestFitPlacement);
insert(i18n(ConfigmenuSet, ConfigmenuUnderMouse,
"Under Mouse Placement"),
BScreen::UnderMousePlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickMouse,
"Click Mouse Placement"),
insert(i18n(ConfigmenuSet, ConfigmenuClickMouse,
"Click Mouse Placement"),
BScreen::ClickMousePlacement);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
"Left to Right"), BScreen::LeftRight);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
"Right to Left"), BScreen::RightLeft);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuTopBottom,
"Top to Bottom"), BScreen::TopBottom);
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBottomTop,
"Bottom to Top"), BScreen::BottomTop);
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight,
"Left to Right"), BScreen::LeftRight);
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft,
"Right to Left"), BScreen::RightLeft);
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom,
"Top to Bottom"), BScreen::TopBottom);
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop,
"Bottom to Top"), BScreen::BottomTop);
update();
setValues();
@ -253,9 +253,9 @@ void Configmenu::Placementmenu::setValues() {
setItemSelected(5, p == BScreen::ClickMousePlacement);
bool rl = (configmenu->screen.rowPlacementDirection() ==
BScreen::LeftRight),
tb = (configmenu->screen.colPlacementDirection() ==
BScreen::TopBottom);
BScreen::LeftRight),
tb = (configmenu->screen.colPlacementDirection() ==
BScreen::TopBottom);
setItemSelected(6, rl);
setItemEnabled(6, (p != BScreen::UnderMousePlacement &&

View file

@ -39,7 +39,7 @@
Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
setInternalMenu();
setLabel(i18n->getMessage(IconSet, IconIcons, "Icons"));
setLabel(i18n(IconSet, IconIcons, "Icons"));
update();
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -46,10 +46,10 @@
using std::ends;
Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()),
screen(scr), config(conf)
screen(scr), config(conf)
{
load();
display = screen.getBaseDisplay().getXDisplay();
frame.window = frame.pixmap = None;
@ -61,21 +61,21 @@ Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()),
XSetWindowAttributes attrib;
unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
CWColormap | CWOverrideRedirect | CWEventMask;
CWColormap | CWOverrideRedirect | CWEventMask;
attrib.background_pixmap = None;
attrib.background_pixel = attrib.border_pixel =
screen.getBorderColor()->getPixel();
attrib.colormap = screen.getColormap();
attrib.override_redirect = True;
attrib.event_mask = SubstructureRedirectMask | ButtonPressMask |
EnterWindowMask | LeaveWindowMask;
EnterWindowMask | LeaveWindowMask;
frame.area = Rect(0, 0, 1, 1);
frame.window =
XCreateWindow(display, screen.getRootWindow(),
frame.area.x(), frame.area.y(),
frame.area.w(), frame.area.h(), screen.getBorderWidth(),
frame.area.w(), frame.area.h(), screen.getBorderWidth(),
screen.getDepth(), InputOutput, screen.getVisual(),
create_mask, &attrib);
openbox.saveSlitSearch(frame.window, this);
@ -91,7 +91,7 @@ Slit::~Slit() {
delete timer;
clientList.clear();
delete slitmenu;
screen.getImageControl()->removeImage(frame.pixmap);
@ -115,16 +115,16 @@ void Slit::addClient(Window w) {
if (wmhints) {
if ((wmhints->flags & IconWindowHint) &&
(wmhints->icon_window != None)) {
XMoveWindow(display, client->client_window, screen.size().w() + 10,
screen.size().h() + 10);
XMapWindow(display, client->client_window);
(wmhints->icon_window != None)) {
XMoveWindow(display, client->client_window, screen.size().w() + 10,
screen.size().h() + 10);
XMapWindow(display, client->client_window);
client->icon_window = wmhints->icon_window;
client->window = client->icon_window;
client->icon_window = wmhints->icon_window;
client->window = client->icon_window;
} else {
client->icon_window = None;
client->window = client->client_window;
client->icon_window = None;
client->window = client->client_window;
}
XFree(wmhints);
@ -151,7 +151,7 @@ void Slit::addClient(Window w) {
XChangeSaveSet(display, client->window, SetModeInsert);
XSelectInput(display, frame.window, SubstructureRedirectMask |
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
XSelectInput(display, client->window, StructureNotifyMask |
SubstructureNotifyMask | EnterWindowMask);
XFlush(display);
@ -179,10 +179,10 @@ void Slit::removeClient(SlitClient *client, Bool remap) {
XSelectInput(display, frame.window, NoEventMask);
XSelectInput(display, client->window, NoEventMask);
XReparentWindow(display, client->window, screen.getRootWindow(),
client->x, client->y);
client->x, client->y);
XChangeSaveSet(display, client->window, SetModeDelete);
XSelectInput(display, frame.window, SubstructureRedirectMask |
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
XFlush(display);
}
@ -302,7 +302,7 @@ void Slit::load() {
m_direction = Vertical;
} else
m_direction = Vertical;
rname.seekp(0); rclass.seekp(0);
rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
rname << rscreen.str() << "slit.onTop" << ends;
@ -390,10 +390,10 @@ void Slit::reconfigure(void) {
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
frame.pixmap = None;
XSetWindowBackground(display, frame.window,
texture->getColor()->getPixel());
texture->getColor()->getPixel());
} else {
frame.pixmap = image_ctrl->renderImage(frame.area.w(), frame.area.h(),
texture);
texture);
XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap);
}
if (tmp) image_ctrl->removeImage(tmp);
@ -560,9 +560,9 @@ void Slit::reposition(void) {
Toolbar *tbar = screen.getToolbar();
int sw = frame.area.w() + (screen.getBorderWidth() * 2),
sh = frame.area.h() + (screen.getBorderWidth() * 2),
tw = tbar->area().w() + screen.getBorderWidth(),
th = tbar->area().h() + screen.getBorderWidth();
sh = frame.area.h() + (screen.getBorderWidth() * 2),
tw = tbar->area().w() + screen.getBorderWidth(),
th = tbar->area().h() + screen.getBorderWidth();
if (tbar->area().x() < frame.area.x() + sw &&
tbar->area().x() + tw > frame.area.x() &&
@ -573,22 +573,22 @@ void Slit::reposition(void) {
if (m_direction == Vertical)
frame.hidden.setY(frame.hidden.y() + tbar->getExposedHeight());
else
frame.hidden.setY(frame.area.y());
frame.hidden.setY(frame.area.y());
} else {
frame.area.setY(frame.area.y() - tbar->getExposedHeight());
if (m_direction == Vertical)
frame.hidden.setY(frame.area.y() - tbar->getExposedHeight());
else
frame.hidden.setY(frame.area.y());
frame.hidden.setY(frame.area.y());
}
}
if (m_hidden)
XMoveResizeWindow(display, frame.window, frame.hidden.x(),
frame.hidden.y(), frame.area.w(), frame.area.h());
frame.hidden.y(), frame.area.w(), frame.area.h());
else
XMoveResizeWindow(display, frame.window, frame.area.x(),
frame.area.y(), frame.area.w(), frame.area.h());
frame.area.y(), frame.area.w(), frame.area.h());
}
@ -703,18 +703,18 @@ void Slit::timeout(void) {
Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen), slit(sl) {
setLabel(i18n->getMessage(SlitSet, SlitSlitTitle, "Slit"));
setLabel(i18n(SlitSet, SlitSlitTitle, "Slit"));
setInternalMenu();
directionmenu = new Directionmenu(*this);
placementmenu = new Placementmenu(*this);
insert(i18n->getMessage(CommonSet, CommonDirectionTitle, "Direction"),
directionmenu);
insert(i18n->getMessage(CommonSet, CommonPlacementTitle, "Placement"),
placementmenu);
insert(i18n->getMessage(CommonSet, CommonAlwaysOnTop, "Always on top"), 1);
insert(i18n->getMessage(CommonSet, CommonAutoHide, "Auto hide"), 2);
insert(i18n(CommonSet, CommonDirectionTitle, "Direction"),
directionmenu);
insert(i18n(CommonSet, CommonPlacementTitle, "Placement"),
placementmenu);
insert(i18n(CommonSet, CommonAlwaysOnTop, "Always on top"), 1);
insert(i18n(CommonSet, CommonAutoHide, "Auto hide"), 2);
update();
@ -779,18 +779,18 @@ void Slitmenu::reconfigure(void) {
Slitmenu::Directionmenu::Directionmenu(Slitmenu &sm)
: Basemenu(sm.slit.screen), slitmenu(sm) {
setLabel(i18n->getMessage(SlitSet, SlitSlitDirection, "Slit Direction"));
setInternalMenu();
setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction"));
setInternalMenu();
insert(i18n->getMessage(CommonSet, CommonDirectionHoriz, "Horizontal"),
Slit::Horizontal);
insert(i18n->getMessage(CommonSet, CommonDirectionVert, "Vertical"),
Slit::Vertical);
insert(i18n(CommonSet, CommonDirectionHoriz, "Horizontal"),
Slit::Horizontal);
insert(i18n(CommonSet, CommonDirectionVert, "Vertical"),
Slit::Vertical);
update();
update();
setValues();
}
setValues();
}
void Slitmenu::Directionmenu::setValues() {
@ -831,33 +831,33 @@ void Slitmenu::Directionmenu::itemSelected(int button, int index) {
Slitmenu::Placementmenu::Placementmenu(Slitmenu &sm)
: Basemenu(sm.slit.screen), slitmenu(sm) {
setLabel(i18n->getMessage(SlitSet, SlitSlitPlacement, "Slit Placement"));
setMinimumSublevels(3);
setInternalMenu();
setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement"));
setMinimumSublevels(3);
setInternalMenu();
insert(i18n->getMessage(CommonSet, CommonPlacementTopLeft, "Top Left"),
Slit::TopLeft);
insert(i18n->getMessage(CommonSet, CommonPlacementCenterLeft, "Center Left"),
Slit::CenterLeft);
insert(i18n->getMessage(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
Slit::BottomLeft);
insert(i18n->getMessage(CommonSet, CommonPlacementTopCenter, "Top Center"),
Slit::TopCenter);
insert("");
insert(i18n->getMessage(CommonSet, CommonPlacementBottomCenter,
"Bottom Center"),
Slit::BottomCenter);
insert(i18n->getMessage(CommonSet, CommonPlacementTopRight, "Top Right"),
Slit::TopRight);
insert(i18n->getMessage(CommonSet, CommonPlacementCenterRight,
"Center Right"),
Slit::CenterRight);
insert(i18n->getMessage(CommonSet, CommonPlacementBottomRight,
"Bottom Right"),
Slit::BottomRight);
insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"),
Slit::TopLeft);
insert(i18n(CommonSet, CommonPlacementCenterLeft, "Center Left"),
Slit::CenterLeft);
insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
Slit::BottomLeft);
insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"),
Slit::TopCenter);
insert("");
insert(i18n(CommonSet, CommonPlacementBottomCenter,
"Bottom Center"),
Slit::BottomCenter);
insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"),
Slit::TopRight);
insert(i18n(CommonSet, CommonPlacementCenterRight,
"Center Right"),
Slit::CenterRight);
insert(i18n(CommonSet, CommonPlacementBottomRight,
"Bottom Right"),
Slit::BottomRight);
update();
}
update();
}
void Slitmenu::Placementmenu::itemSelected(int button, int index) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -43,7 +43,7 @@
Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
window(win), screen(*win.getScreen())
window(win), screen(*win.getScreen())
{
setTitleVisibility(False);
@ -51,24 +51,24 @@ Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
setInternalMenu();
sendToMenu = new SendtoWorkspacemenu(*this);
insert(i18n->getMessage(WindowmenuSet, WindowmenuSendTo, "Send To ..."),
sendToMenu);
insert(i18n->getMessage(WindowmenuSet, WindowmenuShade, "Shade"),
BScreen::WindowShade);
insert(i18n->getMessage(WindowmenuSet, WindowmenuIconify, "Iconify"),
BScreen::WindowIconify);
insert(i18n->getMessage(WindowmenuSet, WindowmenuMaximize, "Maximize"),
BScreen::WindowMaximize);
insert(i18n->getMessage(WindowmenuSet, WindowmenuRaise,"Raise"),
BScreen::WindowRaise);
insert(i18n->getMessage(WindowmenuSet, WindowmenuLower, "Lower"),
BScreen::WindowLower);
insert(i18n->getMessage(WindowmenuSet, WindowmenuStick, "Stick"),
BScreen::WindowStick);
insert(i18n->getMessage(WindowmenuSet, WindowmenuKillClient, "Kill Client"),
BScreen::WindowKill);
insert(i18n->getMessage(WindowmenuSet, WindowmenuClose, "Close"),
BScreen::WindowClose);
insert(i18n(WindowmenuSet, WindowmenuSendTo, "Send To ..."),
sendToMenu);
insert(i18n(WindowmenuSet, WindowmenuShade, "Shade"),
BScreen::WindowShade);
insert(i18n(WindowmenuSet, WindowmenuIconify, "Iconify"),
BScreen::WindowIconify);
insert(i18n(WindowmenuSet, WindowmenuMaximize, "Maximize"),
BScreen::WindowMaximize);
insert(i18n(WindowmenuSet, WindowmenuRaise,"Raise"),
BScreen::WindowRaise);
insert(i18n(WindowmenuSet, WindowmenuLower, "Lower"),
BScreen::WindowLower);
insert(i18n(WindowmenuSet, WindowmenuStick, "Stick"),
BScreen::WindowStick);
insert(i18n(WindowmenuSet, WindowmenuKillClient, "Kill Client"),
BScreen::WindowKill);
insert(i18n(WindowmenuSet, WindowmenuClose, "Close"),
BScreen::WindowClose);
update();
@ -159,11 +159,11 @@ void Windowmenu::reconfigure(void) {
Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu &w)
: Basemenu(w.screen), windowmenu(w) {
setTitleVisibility(False);
setMovable(False);
setInternalMenu();
update();
}
setTitleVisibility(False);
setMovable(False);
setInternalMenu();
update();
}
void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, int index) {

View file

@ -111,10 +111,10 @@ int Workspace::removeWindow(OpenboxWindow *w) {
if (w->isFocused()) {
if (w == _last)
_last = (OpenboxWindow *) 0;
OpenboxWindow *fw = (OpenboxWindow *) 0;
if (w->isTransient() && w->getTransientFor() &&
w->getTransientFor()->isVisible())
w->getTransientFor()->isVisible())
fw = w->getTransientFor();
else if (screen.sloppyFocus()) // sloppy focus
fw = (OpenboxWindow *) 0;
@ -124,7 +124,7 @@ int Workspace::removeWindow(OpenboxWindow *w) {
if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus()))
screen.getOpenbox().focusWindow(0);
}
_windows.erase(_windows.begin() + w->getWindowNumber());
clientmenu->remove(w->getWindowNumber());
clientmenu->update();
@ -303,10 +303,10 @@ void Workspace::setName(const char *new_name) {
name = bstrdup(new_name);
} else {
name = new char[128];
sprintf(name, i18n->getMessage(WorkspaceSet, WorkspaceDefaultNameFormat,
"Workspace %d"), id + 1);
sprintf(name, i18n(WorkspaceSet, WorkspaceDefaultNameFormat,
"Workspace %d"), id + 1);
}
clientmenu->setLabel(name);
clientmenu->update();
screen.saveWorkspaceNames();
@ -359,49 +359,49 @@ static rectList calcSpace(const Rect &win, const rectList &spaces) {
bool rowRLBT(const Rect &first, const Rect &second){
if (first.y()+first.h()==second.y()+second.h())
return first.x()+first.w()>second.x()+second.w();
return first.x()+first.w()>second.x()+second.w();
return first.y()+first.h()>second.y()+second.h();
}
bool rowRLTB(const Rect &first, const Rect &second){
if (first.y()==second.y())
return first.x()+first.w()>second.x()+second.w();
return first.x()+first.w()>second.x()+second.w();
return first.y()<second.y();
}
bool rowLRBT(const Rect &first, const Rect &second){
if (first.y()+first.h()==second.y()+second.h())
return first.x()<second.x();
return first.x()<second.x();
return first.y()+first.h()>second.y()+second.h();
}
bool rowLRTB(const Rect &first, const Rect &second){
if (first.y()==second.y())
return first.x()<second.x();
return first.x()<second.x();
return first.y()<second.y();
}
bool colLRTB(const Rect &first, const Rect &second){
if (first.x()==second.x())
return first.y()<second.y();
return first.y()<second.y();
return first.x()<second.x();
}
bool colLRBT(const Rect &first, const Rect &second){
if (first.x()==second.x())
return first.y()+first.h()>second.y()+second.h();
return first.y()+first.h()>second.y()+second.h();
return first.x()<second.x();
}
bool colRLTB(const Rect &first, const Rect &second){
if (first.x()+first.w()==second.x()+second.w())
return first.y()<second.y();
return first.y()<second.y();
return first.x()+first.w()>second.x()+second.w();
}
bool colRLBT(const Rect &first, const Rect &second){
if (first.x()+first.w()==second.x()+second.w())
return first.y()+first.h()>second.y()+second.h();
return first.y()+first.h()>second.y()+second.h();
return first.x()+first.w()>second.x()+second.w();
}
@ -414,13 +414,13 @@ Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) {
rectList spaces;
rectList::const_iterator siter;
spaces.push_back(space); //initially the entire screen is free
//Find Free Spaces
winVect::iterator it;
for (it = _windows.begin(); it != _windows.end(); ++it)
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
//Find first space that fits the window
best = NULL;
for (siter=spaces.begin(); siter!=spaces.end(); ++siter) {
@ -469,23 +469,23 @@ Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space) {
rectList::const_iterator siter;
spaces.push_back(space); //initially the entire screen is free
//Find Free Spaces
winVect::iterator it;
for (it = _windows.begin(); it != _windows.end(); ++it)
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
//Sort spaces by preference
if(screen.rowPlacementDirection() == BScreen::RightLeft)
if(screen.colPlacementDirection() == BScreen::TopBottom)
sort(spaces.begin(),spaces.end(),rowRLTB);
else
sort(spaces.begin(),spaces.end(),rowRLBT);
if(screen.colPlacementDirection() == BScreen::TopBottom)
sort(spaces.begin(),spaces.end(),rowRLTB);
else
sort(spaces.begin(),spaces.end(),rowRLBT);
else
if(screen.colPlacementDirection() == BScreen::TopBottom)
sort(spaces.begin(),spaces.end(),rowLRTB);
else
sort(spaces.begin(),spaces.end(),rowLRBT);
if(screen.colPlacementDirection() == BScreen::TopBottom)
sort(spaces.begin(),spaces.end(),rowLRTB);
else
sort(spaces.begin(),spaces.end(),rowLRBT);
best = NULL;
for (siter=spaces.begin(); siter!=spaces.end(); ++siter)
if ((siter->w() >= win_size.w()) && (siter->h() >= win_size.h())) {
@ -510,23 +510,23 @@ Point *Workspace::colSmartPlacement(const Size &win_size, const Rect &space) {
rectList::const_iterator siter;
spaces.push_back(space); //initially the entire screen is free
//Find Free Spaces
winVect::iterator it;
for (it = _windows.begin(); it != _windows.end(); ++it)
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
spaces);
//Sort spaces by user preference
if(screen.colPlacementDirection() == BScreen::TopBottom)
if(screen.rowPlacementDirection() == BScreen::LeftRight)
sort(spaces.begin(),spaces.end(),colLRTB);
else
sort(spaces.begin(),spaces.end(),colRLTB);
if(screen.rowPlacementDirection() == BScreen::LeftRight)
sort(spaces.begin(),spaces.end(),colLRTB);
else
sort(spaces.begin(),spaces.end(),colRLTB);
else
if(screen.rowPlacementDirection() == BScreen::LeftRight)
sort(spaces.begin(),spaces.end(),colLRBT);
else
sort(spaces.begin(),spaces.end(),colRLBT);
if(screen.rowPlacementDirection() == BScreen::LeftRight)
sort(spaces.begin(),spaces.end(),colLRBT);
else
sort(spaces.begin(),spaces.end(),colRLBT);
//Find first space that fits the window
best = NULL;
@ -591,7 +591,7 @@ void Workspace::placeWindow(OpenboxWindow &win) {
if (place == NULL)
place = cascadePlacement(win, space);
ASSERT(place != NULL);
if (place->x() + window_size.w() > (signed) space.x() + space.w())
place->setX(((signed) space.x() + space.w() - window_size.w()) / 2);

View file

@ -41,12 +41,12 @@
Workspacemenu::Workspacemenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
setInternalMenu();
setLabel(i18n->getMessage(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
"Workspaces"));
insert(i18n->getMessage(WorkspacemenuSet, WorkspacemenuNewWorkspace,
"New Workspace"));
insert(i18n->getMessage(WorkspacemenuSet, WorkspacemenuRemoveLast,
"Remove Last"));
setLabel(i18n(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
"Workspaces"));
insert(i18n(WorkspacemenuSet, WorkspacemenuNewWorkspace,
"New Workspace"));
insert(i18n(WorkspacemenuSet, WorkspacemenuRemoveLast,
"Remove Last"));
}
@ -59,7 +59,7 @@ void Workspacemenu::itemSelected(int button, int index) {
else if (index == 1)
screen.removeLastWorkspace();
else if ((screen.getCurrentWorkspace()->getWorkspaceID() !=
(index - 2)) && ((index - 2) < screen.getWorkspaceCount()))
(index - 2)) && ((index - 2) < screen.getWorkspaceCount()))
screen.changeWorkspaceID(index - 2);
if (! (screen.getWorkspacemenu()->isTorn() || isTorn()))

View file

@ -42,14 +42,36 @@
#include <algorithm>
using std::cerr;
using std::endl;
std::string XDisplay::_app_name;
Window XDisplay::_last_bad_window = None;
/*
* X error handler to handle all X errors while the application is
* running.
*/
int XDisplay::XErrorHandler(Display *d, XErrorEvent *e) {
d=d;e=e;
return 0;
#ifdef DEBUG
char errtxt[128];
XGetErrorText(d, e->error_code, errtxt, sizeof(errtxt)/sizeof(char));
cerr << _app_name.c_str() << ": X error: " <<
errtxt << "(" << e->error_code << ") opcodes " <<
e->request_code << "/" << e->minor_code << endl;
cerr.flags(std::ios_base::hex);
cerr << " resource 0x" << e->resourceid << endl;
cerr.flags(std::ios_base::dec);
#endif
if (e->error_code == BadWindow)
_last_bad_window = e->resourceid;
return False;
}
XDisplay::XDisplay(const char *dpyname) {
XDisplay::XDisplay(const std::string &application_name, const char *dpyname) {
_app_name = application_name;
_grabs = 0;
_hasshape = false;

View file

@ -41,8 +41,11 @@ private:
typedef std::vector<XScreen*> XScreenList;
XScreenList _screens;
// X error handling
static int XErrorHandler(Display *d, XErrorEvent *e);
static std::string _app_name;
static Window _last_bad_window;
// no copying!!
XDisplay(const XDisplay &);
@ -52,7 +55,7 @@ protected:
virtual void process_event(XEvent *) = 0;
public:
XDisplay(const char *dpyname = 0);
XDisplay(const std::string &application_name, const char *dpyname = 0);
virtual ~XDisplay();
XScreen *screen(unsigned int s) const;

View file

@ -1,5 +1,6 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
// i18n.cc for Openbox
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
@ -20,52 +21,37 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// stupid macros needed to access some functions in version 2 of the GNU C
// library
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif // _GNU_SOURCE
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H
#include "i18n.h"
extern "C" {
#include <X11/Xlocale.h>
#ifdef HAVE_STDLIB_H
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif // HAVE_STDLIB_H
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
# include <string.h>
#endif // HAVE_STRING_H
#ifdef HAVE_STDIO_H
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif // HAVE_STDIO_H
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif // HAVE_LOCALE_H
// the rest of bb source uses True and False from X, so we continue that
#define True true
#define False false
static I18n static_i18n;
I18n *i18n;
void NLSInit(const char *catalog) {
i18n = &static_i18n;
i18n->openCatalog(catalog);
}
#include <string>
using std::string;
I18n::I18n(void) {
mb = False;
#include "i18n.h"
I18n::I18n(const char *catalog) {
mb = false;
#ifdef HAVE_SETLOCALE
locale = setlocale(LC_ALL, "");
if (! locale) {
@ -76,7 +62,7 @@ I18n::I18n(void) {
} else {
// MB_CUR_MAX returns the size of a char in the current locale
if (MB_CUR_MAX > 1)
mb = True;
mb = true;
// truncate any encoding off the end of the locale
char *l = strchr(locale, '@');
if (l) *l = '\0';
@ -88,14 +74,12 @@ I18n::I18n(void) {
catalog_fd = (nl_catd) -1;
#endif
#endif // HAVE_SETLOCALE
catalog_filename = (char *) 0;
if (catalog)
openCatalog(catalog);
}
I18n::~I18n(void) {
delete [] catalog_filename;
I18n::~I18n() {
#if defined(NLS) && defined(HAVE_CATCLOSE)
if (catalog_fd != (nl_catd) -1)
catclose(catalog_fd);
@ -105,35 +89,27 @@ I18n::~I18n(void) {
void I18n::openCatalog(const char *catalog) {
#if defined(NLS) && defined(HAVE_CATOPEN)
int lp = strlen(LOCALEPATH), lc = strlen(locale),
ct = strlen(catalog), len = lp + lc + ct + 3;
catalog_filename = new char[len];
strncpy(catalog_filename, LOCALEPATH, lp);
*(catalog_filename + lp) = '/';
strncpy(catalog_filename + lp + 1, locale, lc);
*(catalog_filename + lp + lc + 1) = '/';
strncpy(catalog_filename + lp + lc + 2, catalog, ct + 1);
string catalog_filename = LOCALEPATH;
catalog_filename += '/';
catalog_filename += locale;
catalog_filename += '/';
catalog_filename += catalog;
# ifdef MCLoadBySet
catalog_fd = catopen(catalog_filename, MCLoadBySet);
catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet);
# else // !MCLoadBySet
catalog_fd = catopen(catalog_filename, NL_CAT_LOCALE);
catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE);
# endif // MCLoadBySet
if (catalog_fd == (nl_catd) -1)
fprintf(stderr, "failed to open catalog, using default messages\n");
#else // !HAVE_CATOPEN
catalog_filename = (char *) 0;
#endif // HAVE_CATOPEN
}
const char *I18n::getMessage(int set, int msg, const char *msgString) const {
const char* I18n::operator()(int set, int msg, const char *msgString) const {
#if defined(NLS) && defined(HAVE_CATGETS)
if (catalog_fd != (nl_catd) -1)
return (const char *) catgets(catalog_fd, set, msg, msgString);
return catgets(catalog_fd, set, msg, msgString);
else
#endif
return msgString;

View file

@ -1,5 +1,6 @@
// i18n.h for Openbox
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
// -*- mode: C++; indent-tabs-mode: nil; -*-
// i18n.hh for Openbox
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
@ -28,39 +29,35 @@
// add ifdefs to every call to getMessage
#include "../nls/openbox-nls.h"
extern "C" {
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif // HAVE_LOCALE_H
#ifdef HAVE_NL_TYPES_H
extern "C" {
# include <nl_types.h>
}
#endif // HAVE_NL_TYPES_H
}
class I18n {
private:
char *locale, *catalog_filename;
char *locale;
bool mb;
#ifdef HAVE_NL_TYPES_H
nl_catd catalog_fd;
#endif
public:
I18n(void);
~I18n(void);
I18n(const char *catalog = 0);
~I18n();
inline bool multibyte(void) const { return mb; }
const char *getMessage(int set, int msg, const char *msgString) const;
const char* operator()(int set, int msg, const char *msgString) const;
void openCatalog(const char *catalog);
};
extern I18n *i18n;
extern void NLSInit(const char *);
extern I18n i18n; // located in main.cc
#endif // __i18n_h

View file

@ -32,9 +32,6 @@
# include "../config.h"
#endif // HAVE_CONFIG_H
#include "i18n.h"
#include "openbox.h"
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif // HAVE_STDIO_H
@ -59,68 +56,72 @@
#define MAXPATHLEN 255
#endif // MAXPATHLEN
#include "openbox.h"
#include "i18n.h"
I18n i18n("openbox.cat");
static void showHelp(int exitval) {
// print program usage and command line options
printf(i18n->getMessage(mainSet, mainUsage,
"Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n\n"
"\t\t\t 1997 - 2000 Brad Hughes\n\n"
" -display <string>\t\tuse display connection.\n"
" -rc <string>\t\t\tuse alternate resource file.\n"
" -menu <string>\t\t\tuse alternate menu file.\n"
" -version\t\t\tdisplay version and exit.\n"
" -help\t\t\t\tdisplay this help text and exit.\n\n"),
__openbox_version);
printf(i18n(mainSet, mainUsage,
"Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n\n"
"\t\t\t 1997 - 2000 Brad Hughes\n\n"
" -display <string>\t\tuse display connection.\n"
" -rc <string>\t\t\tuse alternate resource file.\n"
" -menu <string>\t\t\tuse alternate menu file.\n"
" -version\t\t\tdisplay version and exit.\n"
" -help\t\t\t\tdisplay this help text and exit.\n\n"),
__openbox_version);
// some people have requested that we print out compile options
// as well
fprintf(stdout,i18n->getMessage(mainSet, mainCompileOptions,
"Compile time options:\n"
" Debugging:\t\t\t%s\n"
" Interlacing:\t\t\t%s\n"
" Shape:\t\t\t%s\n"
" Slit:\t\t\t\t%s\n"
" 8bpp Ordered Dithering:\t%s\n"
" Event Clobbering:\t\t%s\n\n"),
fprintf(stdout,i18n(mainSet, mainCompileOptions,
"Compile time options:\n"
" Debugging:\t\t\t%s\n"
" Interlacing:\t\t\t%s\n"
" Shape:\t\t\t%s\n"
" Slit:\t\t\t\t%s\n"
" 8bpp Ordered Dithering:\t%s\n"
" Event Clobbering:\t\t%s\n\n"),
#ifdef DEBUG
i18n->getMessage(CommonSet, CommonYes, "yes"),
i18n(CommonSet, CommonYes, "yes"),
#else // !DEBUG
i18n->getMessage(CommonSet, CommonNo, "no"),
i18n(CommonSet, CommonNo, "no"),
#endif // DEBUG
#ifdef INTERLACE
i18n->getMessage(CommonSet, CommonYes, "yes"),
i18n(CommonSet, CommonYes, "yes"),
#else // !INTERLACE
i18n->getMessage(CommonSet, CommonNo, "no"),
i18n(CommonSet, CommonNo, "no"),
#endif // INTERLACE
#ifdef SHAPE
i18n->getMessage(CommonSet, CommonYes, "yes"),
i18n(CommonSet, CommonYes, "yes"),
#else // !SHAPE
i18n->getMessage(CommonSet, CommonNo, "no"),
i18n(CommonSet, CommonNo, "no"),
#endif // SHAPE
#ifdef SLIT
i18n->getMessage(CommonSet, CommonYes, "yes"),
i18n(CommonSet, CommonYes, "yes"),
#else // !SLIT
i18n->getMessage(CommonSet, CommonNo, "no"),
i18n(CommonSet, CommonNo, "no"),
#endif // SLIT
#ifdef ORDEREDPSEUDO
i18n->getMessage(CommonSet, CommonYes, "yes"),
i18n(CommonSet, CommonYes, "yes"),
#else // !ORDEREDPSEUDO
i18n->getMessage(CommonSet, CommonNo, "no"),
i18n(CommonSet, CommonNo, "no"),
#endif // ORDEREDPSEUDO
#ifndef NOCLOBBER
i18n->getMessage(CommonSet, CommonYes, "yes")
i18n(CommonSet, CommonYes, "yes")
#else // !NOCLOBBER
i18n->getMessage(CommonSet, CommonNo, "no")
i18n(CommonSet, CommonNo, "no")
#endif // NOCLOBBER
);
);
::exit(exitval);
::exit(exitval);
}
int main(int argc, char **argv) {
@ -128,16 +129,14 @@ int main(int argc, char **argv) {
char *rc_file = (char *) 0;
char *menu_file = (char *) 0;
NLSInit("openbox.cat");
for (int i = 1; i < argc; ++i) {
if (! strcmp(argv[i], "-rc")) {
// look for alternative rc file to use
if ((++i) >= argc) {
fprintf(stderr,
i18n->getMessage(mainSet, mainRCRequiresArg,
"error: '-rc' requires and argument\n"));
i18n(mainSet, mainRCRequiresArg,
"error: '-rc' requires and argument\n"));
::exit(1);
}
@ -148,8 +147,8 @@ int main(int argc, char **argv) {
if ((++i) >= argc) {
fprintf(stderr,
i18n->getMessage(mainSet, mainMENURequiresArg,
"error: '-menu' requires and argument\n"));
i18n(mainSet, mainMENURequiresArg,
"error: '-menu' requires and argument\n"));
::exit(1);
}
@ -160,11 +159,11 @@ int main(int argc, char **argv) {
// set by the environment variable DISPLAY
if ((++i) >= argc) {
fprintf(stderr,
i18n->getMessage(mainSet, mainDISPLAYRequiresArg,
"error: '-display' requires an argument\n"));
fprintf(stderr,
i18n(mainSet, mainDISPLAYRequiresArg,
"error: '-display' requires an argument\n"));
::exit(1);
::exit(1);
}
session_display = argv[i];
@ -172,16 +171,15 @@ int main(int argc, char **argv) {
sprintf(dtmp, "DISPLAY=%s", session_display);
if (putenv(dtmp)) {
fprintf(stderr,
i18n->
getMessage(mainSet, mainWarnDisplaySet,
"warning: couldn't set environment variable 'DISPLAY'\n"));
perror("putenv()");
fprintf(stderr,
i18n(mainSet, mainWarnDisplaySet,
"warning: couldn't set environment variable 'DISPLAY'\n"));
perror("putenv()");
}
} else if (! strcmp(argv[i], "-version")) {
// print current version string
printf("Openbox %s : (c) 1997 - 2000 Brad Hughes\n"
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n",
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n",
__openbox_version);
::exit(0);

View file

@ -153,94 +153,94 @@ Openbox *openbox;
Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
char *menu) : BaseDisplay(m_argv[0], dpy_name) {
grab();
grab();
if (! XSupportsLocale())
fprintf(stderr, "X server does not support locale\n");
if (! XSupportsLocale())
fprintf(stderr, "X server does not support locale\n");
if (XSetLocaleModifiers("") == NULL)
fprintf(stderr, "cannot set locale modifiers\n");
if (XSetLocaleModifiers("") == NULL)
fprintf(stderr, "cannot set locale modifiers\n");
::openbox = this;
argc = m_argc;
argv = m_argv;
if (rc == NULL || menu == NULL) {
char *homedir = getenv("HOME");
char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
sprintf(configdir, "%s/.openbox", homedir);
// try to make sure the ~/.openbox directory exists
mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH);
::openbox = this;
argc = m_argc;
argv = m_argv;
if (rc == NULL || menu == NULL) {
char *homedir = getenv("HOME");
char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
sprintf(configdir, "%s/.openbox", homedir);
// try to make sure the ~/.openbox directory exists
mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH);
if (rc == NULL) {
rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
sprintf(rc_file, "%s/rc", configdir);
} else
rc_file = bstrdup(rc);
if (menu == NULL) {
menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
sprintf(menu_file, "%s/menu", configdir);
} else
menu_file = bstrdup(menu);
if (rc == NULL) {
rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
sprintf(rc_file, "%s/rc", configdir);
} else
rc_file = bstrdup(rc);
delete [] configdir;
}
config.setFile(rc_file);
no_focus = False;
if (menu == NULL) {
menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
sprintf(menu_file, "%s/menu", configdir);
} else
menu_file = bstrdup(menu);
resource.style_file = NULL;
resource.titlebar_layout = NULL;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
delete [] configdir;
}
config.setFile(rc_file);
current_screen = (BScreen *) 0;
masked_window = (OpenboxWindow *) 0;
masked = None;
no_focus = False;
load();
resource.style_file = NULL;
resource.titlebar_layout = NULL;
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
current_screen = (BScreen *) 0;
masked_window = (OpenboxWindow *) 0;
masked = None;
load();
#ifdef HAVE_GETPID
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
#endif // HAVE_GETPID
for (unsigned int s = 0; s < numberOfScreens(); s++) {
BScreen *screen = new BScreen(*this, s, config);
for (unsigned int s = 0; s < numberOfScreens(); s++) {
BScreen *screen = new BScreen(*this, s, config);
if (! screen->isScreenManaged()) {
delete screen;
continue;
}
if (! screen->isScreenManaged()) {
delete screen;
continue;
}
screenList.push_back(screen);
}
screenList.push_back(screen);
}
if (screenList.empty()) {
fprintf(stderr,
i18n->getMessage(openboxSet, openboxNoManagableScreens,
"Openbox::Openbox: no managable screens found, aborting.\n"));
::exit(3);
}
current_screen = screenList.front();
if (screenList.empty()) {
fprintf(stderr,
i18n(openboxSet, openboxNoManagableScreens,
"Openbox::Openbox: no managable screens found, aborting.\n"));
::exit(3);
}
current_screen = screenList.front();
// save current settings and default values
save();
XSynchronize(getXDisplay(), False);
XSync(getXDisplay(), False);
// save current settings and default values
save();
reconfigure_wait = reread_menu_wait = False;
XSynchronize(getXDisplay(), False);
XSync(getXDisplay(), False);
timer = new BTimer(*this, *this);
timer->setTimeout(0);
timer->fireOnce(True);
reconfigure_wait = reread_menu_wait = False;
ungrab();
timer = new BTimer(*this, *this);
timer->setTimeout(0);
timer->fireOnce(True);
focusWindow(0);
}
ungrab();
focusWindow(0);
}
Openbox::~Openbox() {
@ -291,7 +291,7 @@ void Openbox::process_event(XEvent *e) {
win->buttonPressEvent(&e->xbutton);
if (e->xbutton.button == 1)
win->installColormap(True);
win->installColormap(True);
} else if ((menu = searchMenu(e->xbutton.window))) {
menu->buttonPressEvent(&e->xbutton);
@ -306,68 +306,68 @@ void Openbox::process_event(XEvent *e) {
ScreenList::iterator it;
for (it = screenList.begin(); it != screenList.end(); ++it) {
BScreen *screen = *it;
if (e->xbutton.window == screen->getRootWindow()) {
if (e->xbutton.button == 1) {
if (e->xbutton.window == screen->getRootWindow()) {
if (e->xbutton.button == 1) {
if (! screen->isRootColormapInstalled())
screen->getImageControl()->installRootColormap();
screen->getImageControl()->installRootColormap();
if (screen->getWorkspacemenu()->isVisible())
screen->getWorkspacemenu()->hide();
if (screen->getWorkspacemenu()->isVisible())
screen->getWorkspacemenu()->hide();
if (screen->getRootmenu()->isVisible())
screen->getRootmenu()->hide();
} else if (e->xbutton.button == 2) {
int mx = e->xbutton.x_root -
(screen->getWorkspacemenu()->getWidth() / 2);
int my = e->xbutton.y_root -
(screen->getWorkspacemenu()->getTitleHeight() / 2);
int mx = e->xbutton.x_root -
(screen->getWorkspacemenu()->getWidth() / 2);
int my = e->xbutton.y_root -
(screen->getWorkspacemenu()->getTitleHeight() / 2);
if (mx < 0) mx = 0;
if (my < 0) my = 0;
if (mx < 0) mx = 0;
if (my < 0) my = 0;
if (mx + screen->getWorkspacemenu()->getWidth() >
screen->size().w())
mx = screen->size().w() -
screen->getWorkspacemenu()->getWidth() -
screen->getBorderWidth();
if (mx + screen->getWorkspacemenu()->getWidth() >
screen->size().w())
mx = screen->size().w() -
screen->getWorkspacemenu()->getWidth() -
screen->getBorderWidth();
if (my + screen->getWorkspacemenu()->getHeight() >
screen->size().h())
my = screen->size().h() -
screen->getWorkspacemenu()->getHeight() -
screen->getBorderWidth();
if (my + screen->getWorkspacemenu()->getHeight() >
screen->size().h())
my = screen->size().h() -
screen->getWorkspacemenu()->getHeight() -
screen->getBorderWidth();
screen->getWorkspacemenu()->move(mx, my);
screen->getWorkspacemenu()->move(mx, my);
if (! screen->getWorkspacemenu()->isVisible()) {
screen->getWorkspacemenu()->removeParent();
screen->getWorkspacemenu()->show();
}
} else if (e->xbutton.button == 3) {
int mx = e->xbutton.x_root -
(screen->getRootmenu()->getWidth() / 2);
int my = e->xbutton.y_root -
(screen->getRootmenu()->getTitleHeight() / 2);
if (! screen->getWorkspacemenu()->isVisible()) {
screen->getWorkspacemenu()->removeParent();
screen->getWorkspacemenu()->show();
}
} else if (e->xbutton.button == 3) {
int mx = e->xbutton.x_root -
(screen->getRootmenu()->getWidth() / 2);
int my = e->xbutton.y_root -
(screen->getRootmenu()->getTitleHeight() / 2);
if (mx < 0) mx = 0;
if (my < 0) my = 0;
if (mx < 0) mx = 0;
if (my < 0) my = 0;
if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
mx = screen->size().w() -
screen->getRootmenu()->getWidth() -
screen->getBorderWidth();
if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
mx = screen->size().w() -
screen->getRootmenu()->getWidth() -
screen->getBorderWidth();
if (my + screen->getRootmenu()->getHeight() > screen->size().h())
my = screen->size().h() -
screen->getRootmenu()->getHeight() -
screen->getBorderWidth();
if (my + screen->getRootmenu()->getHeight() > screen->size().h())
my = screen->size().h() -
screen->getRootmenu()->getHeight() -
screen->getBorderWidth();
screen->getRootmenu()->move(mx, my);
screen->getRootmenu()->move(mx, my);
if (! screen->getRootmenu()->isVisible()) {
checkMenu();
screen->getRootmenu()->show();
}
if (! screen->getRootmenu()->isVisible()) {
checkMenu();
screen->getRootmenu()->show();
}
} else if (e->xbutton.button == 4) {
if ((screen->getCurrentWorkspaceID() + 1) >
screen->getWorkspaceCount() - 1)
@ -426,18 +426,18 @@ void Openbox::process_event(XEvent *e) {
grab();
if (validateWindow(e->xconfigurerequest.window)) {
XWindowChanges xwc;
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;
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);
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
e->xconfigurerequest.value_mask, &xwc);
}
ungrab();
@ -449,9 +449,9 @@ void Openbox::process_event(XEvent *e) {
case MapRequest: {
#ifdef DEBUG
fprintf(stderr,
i18n->getMessage(openboxSet, openboxMapRequest,
"Openbox::process_event(): MapRequest for 0x%lx\n"),
e->xmaprequest.window);
i18n(openboxSet, openboxMapRequest,
"Openbox::process_event(): MapRequest for 0x%lx\n"),
e->xmaprequest.window);
#endif // DEBUG
OpenboxWindow *win = searchWindow(e->xmaprequest.window);
@ -471,7 +471,7 @@ void Openbox::process_event(XEvent *e) {
if (win)
win->mapNotifyEvent(&e->xmap);
break;
break;
}
case UnmapNotify: {
@ -514,7 +514,7 @@ void Openbox::process_event(XEvent *e) {
case MotionNotify: {
// strip the lock key modifiers
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
last_time = e->xmotion.time;
OpenboxWindow *win = (OpenboxWindow *) 0;
@ -535,7 +535,7 @@ void Openbox::process_event(XEvent *e) {
OpenboxWindow *win = searchWindow(e->xproperty.window);
if (win)
win->propertyNotifyEvent(e->xproperty.atom);
win->propertyNotifyEvent(e->xproperty.atom);
}
break;
@ -562,16 +562,16 @@ void Openbox::process_event(XEvent *e) {
XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
if ((e->xcrossing.window == e->xcrossing.root) &&
(screen = searchScreen(e->xcrossing.window))) {
(screen = searchScreen(e->xcrossing.window))) {
screen->getImageControl()->installRootColormap();
} else if ((win = searchWindow(e->xcrossing.window))) {
if (win->getScreen()->sloppyFocus() &&
(! win->isFocused()) && (! no_focus)) {
grab();
(! win->isFocused()) && (! no_focus)) {
grab();
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
win->setInputFocus())
win->installColormap(True);
win->installColormap(True);
ungrab();
}
@ -641,7 +641,7 @@ void Openbox::process_event(XEvent *e) {
if (screen)
screen->setRootColormapInstalled((e->xcolormap.state ==
ColormapInstalled) ? True : False);
ColormapInstalled) ? True : False);
break;
}
@ -667,19 +667,19 @@ void Openbox::process_event(XEvent *e) {
if (! win || ! win->validateClient()) return;
if (e->xclient.data.l[0] == IconicState)
win->iconify();
win->iconify();
if (e->xclient.data.l[0] == NormalState)
win->deiconify();
} else if (e->xclient.message_type == getOpenboxChangeWorkspaceAtom()) {
BScreen *screen = searchScreen(e->xclient.window);
BScreen *screen = searchScreen(e->xclient.window);
if (screen && e->xclient.data.l[0] >= 0 &&
e->xclient.data.l[0] < screen->getWorkspaceCount())
screen->changeWorkspaceID(e->xclient.data.l[0]);
if (screen && e->xclient.data.l[0] >= 0 &&
e->xclient.data.l[0] < screen->getWorkspaceCount())
screen->changeWorkspaceID(e->xclient.data.l[0]);
} else if (e->xclient.message_type == getOpenboxChangeWindowFocusAtom()) {
OpenboxWindow *win = searchWindow(e->xclient.window);
OpenboxWindow *win = searchWindow(e->xclient.window);
if (win && win->isVisible() && win->setInputFocus())
if (win && win->isVisible() && win->setInputFocus())
win->installColormap(True);
} else if (e->xclient.message_type == getOpenboxCycleWindowFocusAtom()) {
BScreen *screen = searchScreen(e->xclient.window);
@ -689,20 +689,20 @@ void Openbox::process_event(XEvent *e) {
screen->prevFocus();
else
screen->nextFocus();
}
}
} else if (e->xclient.message_type == getOpenboxChangeAttributesAtom()) {
OpenboxWindow *win = searchWindow(e->xclient.window);
OpenboxWindow *win = searchWindow(e->xclient.window);
if (win && win->validateClient()) {
OpenboxHints net;
net.flags = e->xclient.data.l[0];
net.attrib = e->xclient.data.l[1];
net.workspace = e->xclient.data.l[2];
net.stack = e->xclient.data.l[3];
net.decoration = e->xclient.data.l[4];
if (win && win->validateClient()) {
OpenboxHints net;
net.flags = e->xclient.data.l[0];
net.attrib = e->xclient.data.l[1];
net.workspace = e->xclient.data.l[2];
net.stack = e->xclient.data.l[3];
net.decoration = e->xclient.data.l[4];
win->changeOpenboxHints(&net);
}
win->changeOpenboxHints(&net);
}
}
}
@ -717,8 +717,8 @@ void Openbox::process_event(XEvent *e) {
OpenboxWindow *win = (OpenboxWindow *) 0;
if ((win = searchWindow(e->xany.window)) ||
(shape_event->kind != ShapeBounding))
win->shapeEvent(shape_event);
(shape_event->kind != ShapeBounding))
win->shapeEvent(shape_event);
}
#endif // SHAPE
@ -880,17 +880,17 @@ void Openbox::shutdown() {
std::mem_fun(&BScreen::shutdown));
focusWindow(0);
XSync(getXDisplay(), False);
}
void Openbox::save() {
config.setAutoSave(false);
// save all values as they are so that the defaults will be written to the rc
// file
config.setValue("session.colorsPerChannel",
resource.colors_per_channel);
config.setValue("session.styleFile", resource.style_file);
@ -898,8 +898,8 @@ void Openbox::save() {
config.setValue("session.doubleClickInterval",
(long)resource.double_click_interval);
config.setValue("session.autoRaiseDelay",
((resource.auto_raise_delay.tv_sec * 1000) +
(resource.auto_raise_delay.tv_usec / 1000)));
((resource.auto_raise_delay.tv_sec * 1000) +
(resource.auto_raise_delay.tv_usec / 1000)));
config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
config.setValue("session.cacheMax", (long)resource.cache_max);
@ -916,7 +916,7 @@ void Openbox::load() {
std::string s;
long l;
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
l))
resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
@ -976,7 +976,7 @@ void Openbox::real_reconfigure() {
grab();
load();
for_each(menuTimestamps.begin(), menuTimestamps.end(),
PointerAssassin());
menuTimestamps.clear();
@ -1091,7 +1091,7 @@ void Openbox::focusWindow(OpenboxWindow *win) {
wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
win->setFocusFlag(true);
wkspc->focusWindow(win);
if (tbar)
tbar->redrawWindowLabel(true);
current_screen->updateNetizenWindowFocus();