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
#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);
+ 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);
+ // assume broken, braindead sysv signal semantics
+ signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
- break;
+ break;
- default:
- if (base_display->handleSignal(sig)) {
+ default:
+ if (base_display->handleSignal(sig)) {
#ifndef HAVE_SIGACTION
- // assume broken, braindead sysv signal semantics
- signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
+ // assume broken, braindead sysv signal semantics
+ signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
#endif // HAVE_SIGACTION
- return;
- }
+ return;
+ }
- fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplaySignalCaught,
- "%s: signal %d caught\n"),
- base_display->getApplicationName(), sig);
+ fprintf(stderr, i18n(BaseDisplaySet, BaseDisplaySignalCaught,
+ "%s: signal %d caught\n"),
+ base_display->getApplicationName(), sig);
- if (! base_display->isStartup() && ! re_enter) {
- internal_error = True;
+ if (! base_display->isStartup() && ! re_enter) {
+ internal_error = True;
- re_enter = 1;
- fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayShuttingDown,
- "shutting down\n"));
- base_display->shutdown();
- }
+ re_enter = 1;
+ fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayShuttingDown,
+ "shutting down\n"));
+ base_display->shutdown();
+ }
- if (sig != SIGTERM && sig != SIGINT) {
- fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayAborting,
- "aborting... dumping core\n"));
- abort();
- }
+ if (sig != SIGTERM && sig != SIGINT) {
+ fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayAborting,
+ "aborting... dumping core\n"));
+ abort();
+ }
- exit(0);
+ exit(0);
- break;
+ 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;
-}
+ 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);
+ 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;
+ _startup = True;
+ _shutdown = False;
+ server_grabs = 0;
+ last_bad_window = None;
- ::base_display = this;
+ ::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);
+ 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);
+ 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);
- }
+ 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);
+ 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);
-
- 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_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);
+ 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_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);
#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_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_wm_ping = XInternAtom(display, "_NET_WM_PING", 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_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);
#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;
-
- 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;
-
- 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];
+ 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;
+
+ 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));
+ 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;
+ 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;
+ BaseDisplay::~BaseDisplay(void) {
+ std::for_each(screenInfoList.begin(), screenInfoList.end(),
+ PointerAssassin());
+ // we don't create the BTimers, we don't delete them
- XCloseDisplay(display);
-}
+ if (application_name != NULL)
+ delete [] application_name;
+
+ XCloseDisplay(display);
+ }
-void BaseDisplay::eventLoop(void) {
- run();
+ void BaseDisplay::eventLoop(void) {
+ run();
- int xfd = ConnectionNumber(display);
+ int xfd = ConnectionNumber(display);
- while ((! _shutdown) && (! internal_error)) {
- if (XPending(display)) {
- XEvent e;
- XNextEvent(display, &e);
+ 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()) {
- gettimeofday(&now, 0);
+ if (!timerList.empty()) {
+ gettimeofday(&now, 0);
- tm.tv_sec = tm.tv_usec = 0l;
+ tm.tv_sec = tm.tv_usec = 0l;
- BTimer *timer = timerList.front();
- ASSERT(timer != NULL);
+ 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;
+ 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 >= 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;
+ 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;
}
- 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;
- 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.
+ 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::grab(void) {
- if (! server_grabs++)
- XGrabServer(display);
-}
+ void BaseDisplay::ungrab(void) {
+ if (! --server_grabs)
+ XUngrabServer(display);
+ }
-void BaseDisplay::ungrab(void) {
- if (! --server_grabs)
- XUngrabServer(display);
-}
+ void BaseDisplay::addTimer(BTimer *timer) {
+ ASSERT(timer != (BTimer *) 0);
-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::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);
}
- timerList.insert(it, timer);
-}
-
-void BaseDisplay::removeTimer(BTimer *timer) {
- ASSERT(timer != (BTimer *) 0);
- timerList.remove(timer);
-}
+ 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
-{
+ /*
+ * 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);
-
- 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;
-
- vinfo_template.screen = screen_number;
- vinfo_template.c_class = TrueColor;
-
- 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;
+ {
+
+ 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)));
+
+ // 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;
+
+ 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;
+ }
}
- }
- 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);
+ }
}
-}
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);
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
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();
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;
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;
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;
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;
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);
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);
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);
if (! parent) {
if (shown && (! shown->torn))
- shown->hide();
+ shown->hide();
shown = this;
}
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;
}
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);
}
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 {
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);
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);
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);
}
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];
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;
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);
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];
-
- drawItem(p, False, True);
- if (item->submenu())
- if (item->submenu()->isVisible() &&
- (! item->submenu()->isTorn())) {
- item->submenu()->internal_hide();
- which_sub = -1;
- }
+ 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;
+ }
}
which_press = i;
BasemenuItem *itmp = menuitems[w];
if (itmp->submenu())
- drawSubmenu(w);
+ drawSubmenu(w);
else
- drawItem(w, (itmp->isEnabled()), True);
+ drawItem(w, (itmp->isEnabled()), True);
}
}
}
// 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;
// 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);
}
}
}
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;
+ }
}
}
}
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();
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();
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();
}
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();
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 &&
Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
setInternalMenu();
- setLabel(i18n->getMessage(IconSet, IconIcons, "Icons"));
+ setLabel(i18n(IconSet, IconIcons, "Icons"));
update();
}
cpccpc = cpc * cpc;
control.getColorTables(&red_table, &green_table, &blue_table,
- &red_offset, &green_offset, &blue_offset,
- &red_bits, &green_bits, &blue_bits);
+ &red_offset, &green_offset, &blue_offset,
+ &red_bits, &green_bits, &blue_bits);
if (control.getVisual()->c_class != TrueColor)
control.getXColorTable(&colors, &ncolors);
Pixmap BImage::render_solid(BTexture *texture) {
Pixmap pixmap = XCreatePixmap(control.getBaseDisplay().getXDisplay(),
- control.getDrawable(), width,
- height, control.getDepth());
+ control.getDrawable(), width,
+ height, control.getDepth());
if (pixmap == None) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageErrorCreatingSolidPixmap,
- "BImage::render_solid: error creating pixmap\n"));
+ fprintf(stderr, i18n(ImageSet, ImageErrorCreatingSolidPixmap,
+ "BImage::render_solid: error creating pixmap\n"));
return None;
}
gcv.foreground = texture->getColor()->getPixel();
gcv.fill_style = FillSolid;
gc = XCreateGC(control.getBaseDisplay().getXDisplay(), pixmap,
- GCForeground | GCFillStyle, &gcv);
+ GCForeground | GCFillStyle, &gcv);
gcv.foreground = texture->getHiColor()->getPixel();
hgc = XCreateGC(control.getBaseDisplay().getXDisplay(), pixmap,
- GCForeground, &gcv);
+ GCForeground, &gcv);
gcv.foreground = texture->getLoColor()->getPixel();
lgc = XCreateGC(control.getBaseDisplay().getXDisplay(), pixmap,
- GCForeground, &gcv);
+ GCForeground, &gcv);
XFillRectangle(control.getBaseDisplay().getXDisplay(), pixmap, gc, 0, 0,
- width, height);
+ width, height);
#ifdef INTERLACE
if (texture->getTexture() & BImage_Interlaced) {
gcv.foreground = texture->getColorTo()->getPixel();
GC igc = XCreateGC(control.getBaseDisplay().getXDisplay(), pixmap,
- GCForeground, &gcv);
+ GCForeground, &gcv);
register unsigned int i = 0;
for (; i < height; i += 2)
XDrawLine(control.getBaseDisplay().getXDisplay(), pixmap, igc,
- 0, i, width, i);
+ 0, i, width, i);
XFreeGC(control.getBaseDisplay().getXDisplay(), igc);
}
Pixmap BImage::render_gradient(BTexture *texture) {
- int inverted = 0;
+ int inverted = 0;
#ifdef INTERLACE
interlaced = texture->getTexture() & BImage_Interlaced;
width, height, 32, 0);
if (! image) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageErrorCreatingXImage,
- "BImage::renderXImage: error creating XImage\n"));
+ fprintf(stderr, i18n(ImageSet, ImageErrorCreatingXImage,
+ "BImage::renderXImage: error creating XImage\n"));
return (XImage *) 0;
}
if (control.doDither() && width > 1 && height > 1) {
unsigned char dither4[4][4] = { {0, 4, 1, 5},
- {6, 2, 7, 3},
- {1, 5, 0, 4},
- {7, 3, 6, 2} };
+ {6, 2, 7, 3},
+ {1, 5, 0, 4},
+ {7, 3, 6, 2} };
#ifdef ORDEREDPSEUDO
- unsigned char dither8[8][8] = { { 0, 32, 8, 40, 2, 34, 10, 42 },
- { 48, 16, 56, 24, 50, 18, 58, 26 },
- { 12, 44, 4, 36, 14, 46, 6, 38 },
- { 60, 28, 52, 20, 62, 30, 54, 22 },
- { 3, 35, 11, 43, 1, 33, 9, 41 },
- { 51, 19, 59, 27, 49, 17, 57, 25 },
- { 15, 47, 7, 39, 13, 45, 5, 37 },
- { 63, 31, 55, 23, 61, 29, 53, 21 } };
+ unsigned char dither8[8][8] = { { 0, 32, 8, 40, 2, 34, 10, 42 },
+ { 48, 16, 56, 24, 50, 18, 58, 26 },
+ { 12, 44, 4, 36, 14, 46, 6, 38 },
+ { 60, 28, 52, 20, 62, 30, 54, 22 },
+ { 3, 35, 11, 43, 1, 33, 9, 41 },
+ { 51, 19, 59, 27, 49, 17, 57, 25 },
+ { 15, 47, 7, 39, 13, 45, 5, 37 },
+ { 63, 31, 55, 23, 61, 29, 53, 21 } };
#endif // ORDEREDPSEUDO
- switch (control.getVisual()->c_class) {
- case TrueColor:
- // algorithm: ordered dithering... many many thanks to rasterman
- // (raster@rasterman.com) for telling me about this... portions of this
- // code is based off of his code in Imlib
- for (y = 0, offset = 0; y < height; y++) {
- dithy = y & 0x3;
-
- for (x = 0; x < width; x++, offset++) {
- dithx = x & 0x3;
- r = red[offset];
- g = green[offset];
- b = blue[offset];
-
- er = r & (red_bits - 1);
- eg = g & (green_bits - 1);
- eb = b & (blue_bits - 1);
-
- r = red_table[r];
- g = green_table[g];
- b = blue_table[b];
-
- if ((dither4[dithy][dithx] < er) && (r < red_table[255])) r++;
- if ((dither4[dithy][dithx] < eg) && (g < green_table[255])) g++;
- if ((dither4[dithy][dithx] < eb) && (b < blue_table[255])) b++;
-
- pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset);
-
- switch (o) {
- case 8: // 8bpp
- *pixel_data++ = pixel;
- break;
-
- case 16: // 16bpp LSB
- *pixel_data++ = pixel;
- *pixel_data++ = pixel >> 8;
- break;
-
- case 17: // 16bpp MSB
- *pixel_data++ = pixel >> 8;
- *pixel_data++ = pixel;
- break;
-
- case 24: // 24bpp LSB
- *pixel_data++ = pixel;
- *pixel_data++ = pixel >> 8;
- *pixel_data++ = pixel >> 16;
- break;
-
- case 25: // 24bpp MSB
- *pixel_data++ = pixel >> 16;
- *pixel_data++ = pixel >> 8;
- *pixel_data++ = pixel;
- break;
-
- case 32: // 32bpp LSB
- *pixel_data++ = pixel;
- *pixel_data++ = pixel >> 8;
- *pixel_data++ = pixel >> 16;
- *pixel_data++ = pixel >> 24;
- break;
-
- case 33: // 32bpp MSB
- *pixel_data++ = pixel >> 24;
- *pixel_data++ = pixel >> 16;
- *pixel_data++ = pixel >> 8;
- *pixel_data++ = pixel;
- break;
+ switch (control.getVisual()->c_class) {
+ case TrueColor:
+ // algorithm: ordered dithering... many many thanks to rasterman
+ // (raster@rasterman.com) for telling me about this... portions of this
+ // code is based off of his code in Imlib
+ for (y = 0, offset = 0; y < height; y++) {
+ dithy = y & 0x3;
+
+ for (x = 0; x < width; x++, offset++) {
+ dithx = x & 0x3;
+ r = red[offset];
+ g = green[offset];
+ b = blue[offset];
+
+ er = r & (red_bits - 1);
+ eg = g & (green_bits - 1);
+ eb = b & (blue_bits - 1);
+
+ r = red_table[r];
+ g = green_table[g];
+ b = blue_table[b];
+
+ if ((dither4[dithy][dithx] < er) && (r < red_table[255])) r++;
+ if ((dither4[dithy][dithx] < eg) && (g < green_table[255])) g++;
+ if ((dither4[dithy][dithx] < eb) && (b < blue_table[255])) b++;
+
+ pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset);
+
+ switch (o) {
+ case 8: // 8bpp
+ *pixel_data++ = pixel;
+ break;
+
+ case 16: // 16bpp LSB
+ *pixel_data++ = pixel;
+ *pixel_data++ = pixel >> 8;
+ break;
+
+ case 17: // 16bpp MSB
+ *pixel_data++ = pixel >> 8;
+ *pixel_data++ = pixel;
+ break;
+
+ case 24: // 24bpp LSB
+ *pixel_data++ = pixel;
+ *pixel_data++ = pixel >> 8;
+ *pixel_data++ = pixel >> 16;
+ break;
+
+ case 25: // 24bpp MSB
+ *pixel_data++ = pixel >> 16;
+ *pixel_data++ = pixel >> 8;
+ *pixel_data++ = pixel;
+ break;
+
+ case 32: // 32bpp LSB
+ *pixel_data++ = pixel;
+ *pixel_data++ = pixel >> 8;
+ *pixel_data++ = pixel >> 16;
+ *pixel_data++ = pixel >> 24;
+ break;
+
+ case 33: // 32bpp MSB
+ *pixel_data++ = pixel >> 24;
+ *pixel_data++ = pixel >> 16;
+ *pixel_data++ = pixel >> 8;
+ *pixel_data++ = pixel;
+ break;
+ }
+ }
+
+ pixel_data = (ppixel_data += image->bytes_per_line);
}
- }
- pixel_data = (ppixel_data += image->bytes_per_line);
- }
-
- break;
+ break;
- case StaticColor:
- case PseudoColor: {
+ case StaticColor:
+ case PseudoColor: {
#ifndef ORDEREDPSEUDO
- short *terr,
- *rerr = new short[width + 2],
- *gerr = new short[width + 2],
- *berr = new short[width + 2],
- *nrerr = new short[width + 2],
- *ngerr = new short[width + 2],
- *nberr = new short[width + 2];
- int rr, gg, bb, rer, ger, ber;
- int dd = 255 / control.getColorsPerChannel();
-
- for (x = 0; x < width; x++) {
- *(rerr + x) = *(red + x);
- *(gerr + x) = *(green + x);
- *(berr + x) = *(blue + x);
- }
+ short *terr,
+ *rerr = new short[width + 2],
+ *gerr = new short[width + 2],
+ *berr = new short[width + 2],
+ *nrerr = new short[width + 2],
+ *ngerr = new short[width + 2],
+ *nberr = new short[width + 2];
+ int rr, gg, bb, rer, ger, ber;
+ int dd = 255 / control.getColorsPerChannel();
+
+ for (x = 0; x < width; x++) {
+ *(rerr + x) = *(red + x);
+ *(gerr + x) = *(green + x);
+ *(berr + x) = *(blue + x);
+ }
- *(rerr + x) = *(gerr + x) = *(berr + x) = 0;
+ *(rerr + x) = *(gerr + x) = *(berr + x) = 0;
#endif // ORDEREDPSEUDO
- for (y = 0, offset = 0; y < height; y++) {
+ for (y = 0, offset = 0; y < height; y++) {
#ifdef ORDEREDPSEUDO
- dithy = y & 7;
+ dithy = y & 7;
- for (x = 0; x < width; x++, offset++) {
- dithx = x & 7;
+ for (x = 0; x < width; x++, offset++) {
+ dithx = x & 7;
- r = red[offset];
- g = green[offset];
- b = blue[offset];
+ r = red[offset];
+ g = green[offset];
+ b = blue[offset];
- er = r & (red_bits - 1);
- eg = g & (green_bits - 1);
- eb = b & (blue_bits - 1);
+ er = r & (red_bits - 1);
+ eg = g & (green_bits - 1);
+ eb = b & (blue_bits - 1);
- r = red_table[r];
- g = green_table[g];
- b = blue_table[b];
+ r = red_table[r];
+ g = green_table[g];
+ b = blue_table[b];
- if ((dither8[dithy][dithx] < er) && (r < red_table[255])) r++;
- if ((dither8[dithy][dithx] < eg) && (g < green_table[255])) g++;
- if ((dither8[dithy][dithx] < eb) && (b < blue_table[255])) b++;
+ if ((dither8[dithy][dithx] < er) && (r < red_table[255])) r++;
+ if ((dither8[dithy][dithx] < eg) && (g < green_table[255])) g++;
+ if ((dither8[dithy][dithx] < eb) && (b < blue_table[255])) b++;
- pixel = (r * cpccpc) + (g * cpc) + b;
- *(pixel_data++) = colors[pixel].pixel;
- }
+ pixel = (r * cpccpc) + (g * cpc) + b;
+ *(pixel_data++) = colors[pixel].pixel;
+ }
- pixel_data = (ppixel_data += image->bytes_per_line);
- }
+ pixel_data = (ppixel_data += image->bytes_per_line);
+ }
#else // !ORDEREDPSEUDO
- if (y < (height - 1)) {
- int i = offset + width;
- for (x = 0; x < width; x++, i++) {
- *(nrerr + x) = *(red + i);
- *(ngerr + x) = *(green + i);
- *(nberr + x) = *(blue + i);
- }
-
- *(nrerr + x) = *(red + (--i));
- *(ngerr + x) = *(green + i);
- *(nberr + x) = *(blue + i);
- }
+ if (y < (height - 1)) {
+ int i = offset + width;
+ for (x = 0; x < width; x++, i++) {
+ *(nrerr + x) = *(red + i);
+ *(ngerr + x) = *(green + i);
+ *(nberr + x) = *(blue + i);
+ }
+
+ *(nrerr + x) = *(red + (--i));
+ *(ngerr + x) = *(green + i);
+ *(nberr + x) = *(blue + i);
+ }
- for (x = 0; x < width; x++) {
- rr = rerr[x];
- gg = gerr[x];
- bb = berr[x];
-
- if (rr > 255) rr = 255; else if (rr < 0) rr = 0;
- if (gg > 255) gg = 255; else if (gg < 0) gg = 0;
- if (bb > 255) bb = 255; else if (bb < 0) bb = 0;
-
- r = red_table[rr];
- g = green_table[gg];
- b = blue_table[bb];
-
- rer = rerr[x] - r*dd;
- ger = gerr[x] - g*dd;
- ber = berr[x] - b*dd;
-
- pixel = (r * cpccpc) + (g * cpc) + b;
- *pixel_data++ = colors[pixel].pixel;
-
- r = rer >> 1;
- g = ger >> 1;
- b = ber >> 1;
- rerr[x+1] += r;
- gerr[x+1] += g;
- berr[x+1] += b;
- nrerr[x] += r;
- ngerr[x] += g;
- nberr[x] += b;
- }
+ for (x = 0; x < width; x++) {
+ rr = rerr[x];
+ gg = gerr[x];
+ bb = berr[x];
+
+ if (rr > 255) rr = 255; else if (rr < 0) rr = 0;
+ if (gg > 255) gg = 255; else if (gg < 0) gg = 0;
+ if (bb > 255) bb = 255; else if (bb < 0) bb = 0;
+
+ r = red_table[rr];
+ g = green_table[gg];
+ b = blue_table[bb];
+
+ rer = rerr[x] - r*dd;
+ ger = gerr[x] - g*dd;
+ ber = berr[x] - b*dd;
+
+ pixel = (r * cpccpc) + (g * cpc) + b;
+ *pixel_data++ = colors[pixel].pixel;
+
+ r = rer >> 1;
+ g = ger >> 1;
+ b = ber >> 1;
+ rerr[x+1] += r;
+ gerr[x+1] += g;
+ berr[x+1] += b;
+ nrerr[x] += r;
+ ngerr[x] += g;
+ nberr[x] += b;
+ }
- offset += width;
+ offset += width;
- pixel_data = (ppixel_data += image->bytes_per_line);
+ pixel_data = (ppixel_data += image->bytes_per_line);
- terr = rerr;
- rerr = nrerr;
- nrerr = terr;
+ terr = rerr;
+ rerr = nrerr;
+ nrerr = terr;
- terr = gerr;
- gerr = ngerr;
- ngerr = terr;
+ terr = gerr;
+ gerr = ngerr;
+ ngerr = terr;
- terr = berr;
- berr = nberr;
- nberr = terr;
- }
+ terr = berr;
+ berr = nberr;
+ nberr = terr;
+ }
- delete [] rerr;
- delete [] gerr;
- delete [] berr;
- delete [] nrerr;
- delete [] ngerr;
- delete [] nberr;
+ delete [] rerr;
+ delete [] gerr;
+ delete [] berr;
+ delete [] nrerr;
+ delete [] ngerr;
+ delete [] nberr;
#endif // ORDEREDPSUEDO
- break; }
+ break; }
- default:
- fprintf(stderr, i18n->getMessage(ImageSet, ImageUnsupVisual,
- "BImage::renderXImage: unsupported visual\n"));
- delete [] d;
- XDestroyImage(image);
- return (XImage *) 0;
- }
- } else {
- switch (control.getVisual()->c_class) {
- case StaticColor:
- case PseudoColor:
- for (y = 0, offset = 0; y < height; y++) {
- for (x = 0; x < width; x++, offset++) {
- r = red_table[red[offset]];
- g = green_table[green[offset]];
- b = blue_table[blue[offset]];
-
- pixel = (r * cpccpc) + (g * cpc) + b;
- *pixel_data++ = colors[pixel].pixel;
- }
+ default:
+ fprintf(stderr, i18n(ImageSet, ImageUnsupVisual,
+ "BImage::renderXImage: unsupported visual\n"));
+ delete [] d;
+ XDestroyImage(image);
+ return (XImage *) 0;
+ }
+} else {
+ switch (control.getVisual()->c_class) {
+ case StaticColor:
+ case PseudoColor:
+ for (y = 0, offset = 0; y < height; y++) {
+ for (x = 0; x < width; x++, offset++) {
+ r = red_table[red[offset]];
+ g = green_table[green[offset]];
+ b = blue_table[blue[offset]];
- pixel_data = (ppixel_data += image->bytes_per_line);
+ pixel = (r * cpccpc) + (g * cpc) + b;
+ *pixel_data++ = colors[pixel].pixel;
}
- break;
+ pixel_data = (ppixel_data += image->bytes_per_line);
+ }
+
+ break;
case TrueColor:
for (y = 0, offset = 0; y < height; y++) {
for (x = 0; x < width; x++, offset++) {
- r = red_table[red[offset]];
- g = green_table[green[offset]];
- b = blue_table[blue[offset]];
+ r = red_table[red[offset]];
+ g = green_table[green[offset]];
+ b = blue_table[blue[offset]];
- pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset);
+ pixel = (r << red_offset) | (g << green_offset) | (b << blue_offset);
switch (o) {
- case 8: // 8bpp
- *pixel_data++ = pixel;
- break;
+ case 8: // 8bpp
+ *pixel_data++ = pixel;
+ break;
case 16: // 16bpp LSB
*pixel_data++ = pixel;
case GrayScale:
for (y = 0, offset = 0; y < height; y++) {
for (x = 0; x < width; x++, offset++) {
- r = *(red_table + *(red + offset));
- g = *(green_table + *(green + offset));
- b = *(blue_table + *(blue + offset));
+ r = *(red_table + *(red + offset));
+ g = *(green_table + *(green + offset));
+ b = *(blue_table + *(blue + offset));
- g = ((r * 30) + (g * 59) + (b * 11)) / 100;
- *pixel_data++ = colors[g].pixel;
+ g = ((r * 30) + (g * 59) + (b * 11)) / 100;
+ *pixel_data++ = colors[g].pixel;
}
pixel_data = (ppixel_data += image->bytes_per_line);
break;
default:
- fprintf(stderr, i18n->getMessage(ImageSet, ImageUnsupVisual,
- "BImage::renderXImage: unsupported visual\n"));
+ fprintf(stderr, i18n(ImageSet, ImageUnsupVisual,
+ "BImage::renderXImage: unsupported visual\n"));
delete [] d;
XDestroyImage(image);
return (XImage *) 0;
}
}
- image->data = (char *) d;
- return image;
+image->data = (char *) d;
+return image;
}
control.getDrawable(), width, height, control.getDepth());
if (pixmap == None) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageErrorCreatingPixmap,
- "BImage::renderPixmap: error creating pixmap\n"));
+ fprintf(stderr, i18n(ImageSet, ImageErrorCreatingPixmap,
+ "BImage::renderPixmap: error creating pixmap\n"));
return None;
}
}
XPutImage(control.getBaseDisplay().getXDisplay(), pixmap,
- DefaultGC(control.getBaseDisplay().getXDisplay(),
- control.getScreenInfo().getScreenNumber()),
+ DefaultGC(control.getBaseDisplay().getXDisplay(),
+ control.getScreenInfo().getScreenNumber()),
image, 0, 0, 0, 0, width, height);
if (image->data) {
void BImage::bevel2(void) {
if (width > 4 && height > 4) {
unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1,
- *pg = green + width + 1, *pb = blue + width + 1;
+ *pg = green + width + 1, *pb = blue + width + 1;
unsigned int w = width - 2, h = height - 1, wh = width * (height - 3);
while (--w) {
// modified for interlacing by Brad Hughes
float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0,
- xr = (float) from->getRed(),
- xg = (float) from->getGreen(),
- xb = (float) from->getBlue();
+ xr = (float) from->getRed(),
+ xg = (float) from->getGreen(),
+ xb = (float) from->getBlue();
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int w = width * 2, h = height * 2, *xt = xtable, *yt = ytable;
void BImage::hgradient(void) {
float drx, dgx, dbx,
- xr = (float) from->getRed(),
- xg = (float) from->getGreen(),
- xb = (float) from->getBlue();
+ xr = (float) from->getRed(),
+ xg = (float) from->getGreen(),
+ xb = (float) from->getBlue();
unsigned char *pr = red, *pg = green, *pb = blue;
register unsigned int x, y;
void BImage::vgradient(void) {
float dry, dgy, dby,
- yr = (float) from->getRed(),
- yg = (float) from->getGreen(),
- yb = (float) from->getBlue();
+ yr = (float) from->getRed(),
+ yg = (float) from->getGreen(),
+ yb = (float) from->getBlue();
unsigned char *pr = red, *pg = green, *pb = blue;
register unsigned int y;
// adapted from kde sources for Openbox by Brad Hughes
float yr, yg, yb, drx, dgx, dbx, dry, dgy, dby,
- xr, xg, xb;
+ xr, xg, xb;
int rsign, gsign, bsign;
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int tr = to->getRed(), tg = to->getGreen(), tb = to->getBlue(),
- *xt = xtable, *yt = ytable;
+ *xt = xtable, *yt = ytable;
register unsigned int x, y;
int rsign, gsign, bsign;
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int tr = to->getRed(), tg = to->getGreen(), tb = to->getBlue(),
- *xt = xtable, *yt = ytable;
+ *xt = xtable, *yt = ytable;
register unsigned int x, y;
int rsign, gsign, bsign;
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int *xt = xtable, *yt = ytable,
- tr = (unsigned long) to->getRed(),
- tg = (unsigned long) to->getGreen(),
- tb = (unsigned long) to->getBlue();
+ tr = (unsigned long) to->getRed(),
+ tg = (unsigned long) to->getGreen(),
+ tb = (unsigned long) to->getBlue();
register unsigned int x, y;
*(pr++) = channel2;
channel = (unsigned char)
- (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1))));
+ (tg - (gsign * control.getSqrt(*(xt++) + *(yt + 1))));
channel2 = channel + (channel >> 3);
if (channel2 < channel) channel2 = ~0;
*(pg++) = channel2;
int rsign, gsign, bsign;
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int *xt = xtable, *yt = ytable,
- tr = to->getRed(),
- tg = to->getGreen(),
- tb = to->getBlue();
+ tr = to->getRed(),
+ tg = to->getGreen(),
+ tb = to->getBlue();
register unsigned int x, y;
// adapted from kde sources for Openbox by Brad Hughes
float drx, dgx, dbx, dry, dgy, dby, yr = 0.0, yg = 0.0, yb = 0.0,
- xr = (float) from->getRed(),
- xg = (float) from->getGreen(),
- xb = (float) from->getBlue();
+ xr = (float) from->getRed(),
+ xg = (float) from->getGreen(),
+ xb = (float) from->getBlue();
unsigned char *pr = red, *pg = green, *pb = blue;
unsigned int w = width * 2, h = height * 2, *xt, *yt;
BImageControl::BImageControl(BaseDisplay &dpy, ScreenInfo &scrn, Bool _dither,
int _cpc, unsigned long cache_timeout,
unsigned long cmax) : basedisplay(dpy),
- screeninfo(scrn)
+screeninfo(scrn)
{
setDither(_dither);
setColorsPerChannel(_cpc);
bits_per_pixel = 0;
for (int i = 0; i < count; i++)
if (pmv[i].depth == screen_depth) {
- bits_per_pixel = pmv[i].bits_per_pixel;
- break;
+ bits_per_pixel = pmv[i].bits_per_pixel;
+ break;
}
XFree(pmv);
// compute color tables
unsigned long red_mask = getVisual()->red_mask,
- green_mask = getVisual()->green_mask,
- blue_mask = getVisual()->blue_mask;
+ green_mask = getVisual()->green_mask,
+ blue_mask = getVisual()->blue_mask;
while (! (red_mask & 1)) { red_offset++; red_mask >>= 1; }
while (! (green_mask & 1)) { green_offset++; green_mask >>= 1; }
blue_bits = 255 / blue_mask;
for (i = 0; i < 256; i++) {
- red_color_table[i] = i / red_bits;
+ red_color_table[i] = i / red_bits;
green_color_table[i] = i / green_bits;
blue_color_table[i] = i / blue_bits;
}
ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
if (ncolors > (1 << screen_depth)) {
- colors_per_channel = (1 << screen_depth) / 3;
- ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
+ colors_per_channel = (1 << screen_depth) / 3;
+ ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
}
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageInvalidColormapSize,
- "BImageControl::BImageControl: invalid colormap size %d "
- "(%d/%d/%d) - reducing"),
+ fprintf(stderr, i18n(ImageSet, ImageInvalidColormapSize,
+ "BImageControl::BImageControl: invalid colormap size %d "
+ "(%d/%d/%d) - reducing"),
ncolors, colors_per_channel, colors_per_channel,
colors_per_channel);
colors = new XColor[ncolors];
if (! colors) {
- fprintf(stderr, i18n->getMessage(ImageSet,
- ImageErrorAllocatingColormap,
- "BImageControl::BImageControl: error allocating "
- "colormap\n"));
- exit(1);
+ fprintf(stderr, i18n(ImageSet,
+ ImageErrorAllocatingColormap,
+ "BImageControl::BImageControl: error allocating "
+ "colormap\n"));
+ exit(1);
}
int i = 0, ii, p, r, g, b,
#ifdef ORDEREDPSEUDO
- bits = 256 / colors_per_channel;
+ bits = 256 / colors_per_channel;
#else // !ORDEREDPSEUDO
- bits = 255 / (colors_per_channel - 1);
+ bits = 255 / (colors_per_channel - 1);
#endif // ORDEREDPSEUDO
red_bits = green_bits = blue_bits = bits;
for (i = 0; i < 256; i++)
- red_color_table[i] = green_color_table[i] = blue_color_table[i] =
- i / bits;
+ red_color_table[i] = green_color_table[i] = blue_color_table[i] =
+ i / bits;
for (r = 0, i = 0; r < colors_per_channel; r++)
- for (g = 0; g < colors_per_channel; g++)
- for (b = 0; b < colors_per_channel; b++, i++) {
- colors[i].red = (r * 0xffff) / (colors_per_channel - 1);
- colors[i].green = (g * 0xffff) / (colors_per_channel - 1);
- colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);;
- colors[i].flags = DoRed|DoGreen|DoBlue;
- }
+ for (g = 0; g < colors_per_channel; g++)
+ for (b = 0; b < colors_per_channel; b++, i++) {
+ colors[i].red = (r * 0xffff) / (colors_per_channel - 1);
+ colors[i].green = (g * 0xffff) / (colors_per_channel - 1);
+ colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);;
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+ }
basedisplay.grab();
for (i = 0; i < ncolors; i++)
- if (! XAllocColor(basedisplay.getXDisplay(), colormap, &colors[i])) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageColorAllocFail,
- "couldn't alloc color %i %i %i\n"),
- colors[i].red, colors[i].green, colors[i].blue);
- colors[i].flags = 0;
- } else
- colors[i].flags = DoRed|DoGreen|DoBlue;
-
- basedisplay.ungrab();
-
- XColor icolors[256];
- int incolors = (((1 << screen_depth) > 256) ? 256 : (1 << screen_depth));
-
- for (i = 0; i < incolors; i++)
- icolors[i].pixel = i;
-
- XQueryColors(basedisplay.getXDisplay(), colormap, icolors, incolors);
- for (i = 0; i < ncolors; i++) {
- if (! colors[i].flags) {
- unsigned long chk = 0xffffffff, pixel, close = 0;
-
- p = 2;
- while (p--) {
- for (ii = 0; ii < incolors; ii++) {
- r = (colors[i].red - icolors[i].red) >> 8;
- g = (colors[i].green - icolors[i].green) >> 8;
- b = (colors[i].blue - icolors[i].blue) >> 8;
- pixel = (r * r) + (g * g) + (b * b);
-
- if (pixel < chk) {
- chk = pixel;
- close = ii;
- }
-
- colors[i].red = icolors[close].red;
- colors[i].green = icolors[close].green;
- colors[i].blue = icolors[close].blue;
-
- if (XAllocColor(basedisplay.getXDisplay(), colormap,
- &colors[i])) {
- colors[i].flags = DoRed|DoGreen|DoBlue;
- break;
- }
- }
- }
- }
- }
+ if (! XAllocColor(basedisplay.getXDisplay(), colormap, &colors[i])) {
+ fprintf(stderr, i18n(ImageSet, ImageColorAllocFail,
+ "couldn't alloc color %i %i %i\n"),
+ colors[i].red, colors[i].green, colors[i].blue);
+ colors[i].flags = 0;
+ } else
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+
+ basedisplay.ungrab();
+
+ XColor icolors[256];
+ int incolors = (((1 << screen_depth) > 256) ? 256 : (1 << screen_depth));
+
+ for (i = 0; i < incolors; i++)
+ icolors[i].pixel = i;
+
+ XQueryColors(basedisplay.getXDisplay(), colormap, icolors, incolors);
+ for (i = 0; i < ncolors; i++) {
+ if (! colors[i].flags) {
+ unsigned long chk = 0xffffffff, pixel, close = 0;
+
+ p = 2;
+ while (p--) {
+ for (ii = 0; ii < incolors; ii++) {
+ r = (colors[i].red - icolors[i].red) >> 8;
+ g = (colors[i].green - icolors[i].green) >> 8;
+ b = (colors[i].blue - icolors[i].blue) >> 8;
+ pixel = (r * r) + (g * g) + (b * b);
+
+ if (pixel < chk) {
+ chk = pixel;
+ close = ii;
+ }
+
+ colors[i].red = icolors[close].red;
+ colors[i].green = icolors[close].green;
+ colors[i].blue = icolors[close].blue;
+
+ if (XAllocColor(basedisplay.getXDisplay(), colormap,
+ &colors[i])) {
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+ break;
+ }
+ }
+ }
+ }
+ }
- break;
+ break;
}
case GrayScale:
{
if (getVisual()->c_class == StaticGray) {
- ncolors = 1 << screen_depth;
+ ncolors = 1 << screen_depth;
} else {
- ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
+ ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
- if (ncolors > (1 << screen_depth)) {
- colors_per_channel = (1 << screen_depth) / 3;
- ncolors =
- colors_per_channel * colors_per_channel * colors_per_channel;
- }
+ if (ncolors > (1 << screen_depth)) {
+ colors_per_channel = (1 << screen_depth) / 3;
+ ncolors =
+ colors_per_channel * colors_per_channel * colors_per_channel;
+ }
}
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageInvalidColormapSize,
- "BImageControl::BImageControl: invalid colormap size %d "
- "(%d/%d/%d) - reducing"),
- ncolors, colors_per_channel, colors_per_channel,
- colors_per_channel);
+ fprintf(stderr, i18n(ImageSet, ImageInvalidColormapSize,
+ "BImageControl::BImageControl: invalid colormap size %d "
+ "(%d/%d/%d) - reducing"),
+ ncolors, colors_per_channel, colors_per_channel,
+ colors_per_channel);
- colors_per_channel = (1 << screen_depth) / 3;
+ colors_per_channel = (1 << screen_depth) / 3;
}
colors = new XColor[ncolors];
if (! colors) {
- fprintf(stderr, i18n->getMessage(ImageSet,
- ImageErrorAllocatingColormap,
- "BImageControl::BImageControl: error allocating "
- "colormap\n"));
- exit(1);
+ fprintf(stderr, i18n(ImageSet,
+ ImageErrorAllocatingColormap,
+ "BImageControl::BImageControl: error allocating "
+ "colormap\n"));
+ exit(1);
}
int i = 0, ii, p, bits = 255 / (colors_per_channel - 1);
red_bits = green_bits = blue_bits = bits;
for (i = 0; i < 256; i++)
- red_color_table[i] = green_color_table[i] = blue_color_table[i] =
- i / bits;
+ red_color_table[i] = green_color_table[i] = blue_color_table[i] =
+ i / bits;
basedisplay.grab();
for (i = 0; i < ncolors; i++) {
- colors[i].red = (i * 0xffff) / (colors_per_channel - 1);
- colors[i].green = (i * 0xffff) / (colors_per_channel - 1);
- colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
- colors[i].flags = DoRed|DoGreen|DoBlue;
-
- if (! XAllocColor(basedisplay.getXDisplay(), colormap,
- &colors[i])) {
- fprintf(stderr, i18n->getMessage(ImageSet, ImageColorAllocFail,
- "couldn't alloc color %i %i %i\n"),
- colors[i].red, colors[i].green, colors[i].blue);
- colors[i].flags = 0;
- } else
- colors[i].flags = DoRed|DoGreen|DoBlue;
+ colors[i].red = (i * 0xffff) / (colors_per_channel - 1);
+ colors[i].green = (i * 0xffff) / (colors_per_channel - 1);
+ colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+
+ if (! XAllocColor(basedisplay.getXDisplay(), colormap,
+ &colors[i])) {
+ fprintf(stderr, i18n(ImageSet, ImageColorAllocFail,
+ "couldn't alloc color %i %i %i\n"),
+ colors[i].red, colors[i].green, colors[i].blue);
+ colors[i].flags = 0;
+ } else
+ colors[i].flags = DoRed|DoGreen|DoBlue;
}
basedisplay.ungrab();
XColor icolors[256];
int incolors = (((1 << screen_depth) > 256) ? 256 :
- (1 << screen_depth));
+ (1 << screen_depth));
for (i = 0; i < incolors; i++)
- icolors[i].pixel = i;
+ icolors[i].pixel = i;
XQueryColors(basedisplay.getXDisplay(), colormap, icolors, incolors);
for (i = 0; i < ncolors; i++) {
- if (! colors[i].flags) {
- unsigned long chk = 0xffffffff, pixel, close = 0;
-
- p = 2;
- while (p--) {
- for (ii = 0; ii < incolors; ii++) {
- int r = (colors[i].red - icolors[i].red) >> 8;
- int g = (colors[i].green - icolors[i].green) >> 8;
- int b = (colors[i].blue - icolors[i].blue) >> 8;
- pixel = (r * r) + (g * g) + (b * b);
-
- if (pixel < chk) {
- chk = pixel;
- close = ii;
- }
-
- colors[i].red = icolors[close].red;
- colors[i].green = icolors[close].green;
- colors[i].blue = icolors[close].blue;
-
- if (XAllocColor(basedisplay.getXDisplay(), colormap,
- &colors[i])) {
- colors[i].flags = DoRed|DoGreen|DoBlue;
- break;
- }
- }
- }
- }
+ if (! colors[i].flags) {
+ unsigned long chk = 0xffffffff, pixel, close = 0;
+
+ p = 2;
+ while (p--) {
+ for (ii = 0; ii < incolors; ii++) {
+ int r = (colors[i].red - icolors[i].red) >> 8;
+ int g = (colors[i].green - icolors[i].green) >> 8;
+ int b = (colors[i].blue - icolors[i].blue) >> 8;
+ pixel = (r * r) + (g * g) + (b * b);
+
+ if (pixel < chk) {
+ chk = pixel;
+ close = ii;
+ }
+
+ colors[i].red = icolors[close].red;
+ colors[i].green = icolors[close].green;
+ colors[i].blue = icolors[close].blue;
+
+ if (XAllocColor(basedisplay.getXDisplay(), colormap,
+ &colors[i])) {
+ colors[i].flags = DoRed|DoGreen|DoBlue;
+ break;
+ }
+ }
+ }
+ }
}
break;
}
default:
- fprintf(stderr, i18n->getMessage(ImageSet, ImageUnsupVisual,
- "BImageControl::BImageControl: unsupported visual %d\n"),
- getVisual()->c_class);
+ fprintf(stderr, i18n(ImageSet, ImageUnsupVisual,
+ "BImageControl::BImageControl: unsupported visual %d\n"),
+ getVisual()->c_class);
exit(1);
}
}
if (!cache.empty()) {
int i, n = cache.size();
- fprintf(stderr, i18n->getMessage(ImageSet, ImagePixmapRelease,
- "BImageContol::~BImageControl: pixmap cache - "
- "releasing %d pixmaps\n"), n);
+ fprintf(stderr, i18n(ImageSet, ImagePixmapRelease,
+ "BImageContol::~BImageControl: pixmap cache - "
+ "releasing %d pixmaps\n"), n);
for (i = 0; i < n; i++) {
Cache *tmp = cache.front();
Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
- unsigned long texture,
- BColor *c1, BColor *c2) {
+ unsigned long texture,
+ BColor *c1, BColor *c2) {
if (!cache.empty()) {
CacheList::iterator it;
Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
- BTexture *texture) {
+ BTexture *texture) {
if (texture->getTexture() & BImage_ParentRelative) return ParentRelative;
Pixmap pixmap = searchCache(width, height, texture->getTexture(),
- texture->getColor(), texture->getColorTo());
+ texture->getColor(), texture->getColorTo());
if (pixmap) return pixmap;
BImage image(*this, width, height);
if ((unsigned) cache.size() > cache_max) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(ImageSet, ImagePixmapCacheLarge,
- "BImageControl::renderImage: cache is large, "
- "forcing cleanout\n"));
+ fprintf(stderr, i18n(ImageSet, ImagePixmapCacheLarge,
+ "BImageControl::renderImage: cache is large, "
+ "forcing cleanout\n"));
#endif // DEBUG
timeout();
Cache *tmp = *it;
if (tmp->pixmap == pixmap) {
if (tmp->count) {
- tmp->count--;
+ tmp->count--;
#ifdef TIMEDCACHE
- if (! timer) timeout();
+ if (! timer) timeout();
#else // !TIMEDCACHE
- if (! tmp->count) timeout();
+ if (! tmp->count) timeout();
#endif // TIMEDCACHE
}
- return;
+ return;
}
}
}
unsigned long BImageControl::getColor(const char *colorname,
- unsigned char *r, unsigned char *g,
- unsigned char *b)
+ unsigned char *r, unsigned char *g,
+ unsigned char *b)
{
XColor color;
color.pixel = 0;
if (! XParseColor(basedisplay.getXDisplay(), colormap, colorname, &color))
fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n",
- colorname);
+ colorname);
else if (! XAllocColor(basedisplay.getXDisplay(), colormap, &color))
fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n",
- colorname);
+ colorname);
if (color.red == 65535) *r = 0xff;
else *r = (unsigned char) (color.red / 0xff);
if (! XParseColor(basedisplay.getXDisplay(), colormap, colorname, &color))
fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n",
- colorname);
+ colorname);
else if (! XAllocColor(basedisplay.getXDisplay(), colormap, &color))
fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n",
- colorname);
+ colorname);
return color.pixel;
}
void BImageControl::getColorTables(unsigned char **rmt, unsigned char **gmt,
- unsigned char **bmt,
- int *roff, int *goff, int *boff,
+ unsigned char **bmt,
+ int *roff, int *goff, int *boff,
int *rbit, int *gbit, int *bbit) {
if (rmt) *rmt = red_color_table;
if (gmt) *gmt = green_color_table;
void BImageControl::getGradientBuffers(unsigned int w,
- unsigned int h,
- unsigned int **xbuf,
- unsigned int **ybuf)
+ unsigned int h,
+ unsigned int **xbuf,
+ unsigned int **ybuf)
{
if (w > grad_buffer_width) {
if (grad_xbuffer) {
if (cmaps) {
for (i = 0; i < ncmap; i++)
if (*(cmaps + i) == colormap)
- install = False;
+ install = False;
if (install)
XInstallColormap(basedisplay.getXDisplay(), colormap);
else if (strstr(ts, "gradient")) {
texture->addTexture(BImage_Gradient);
if (strstr(ts, "crossdiagonal"))
- texture->addTexture(BImage_CrossDiagonal);
+ texture->addTexture(BImage_CrossDiagonal);
else if (strstr(ts, "rectangle"))
- texture->addTexture(BImage_Rectangle);
+ texture->addTexture(BImage_Rectangle);
else if (strstr(ts, "pyramid"))
- texture->addTexture(BImage_Pyramid);
+ texture->addTexture(BImage_Pyramid);
else if (strstr(ts, "pipecross"))
- texture->addTexture(BImage_PipeCross);
+ texture->addTexture(BImage_PipeCross);
else if (strstr(ts, "elliptic"))
- texture->addTexture(BImage_Elliptic);
+ texture->addTexture(BImage_Elliptic);
else if (strstr(ts, "diagonal"))
- texture->addTexture(BImage_Diagonal);
+ texture->addTexture(BImage_Diagonal);
else if (strstr(ts, "horizontal"))
- texture->addTexture(BImage_Horizontal);
+ texture->addTexture(BImage_Horizontal);
else if (strstr(ts, "vertical"))
- texture->addTexture(BImage_Vertical);
+ texture->addTexture(BImage_Vertical);
else
- texture->addTexture(BImage_Diagonal);
+ texture->addTexture(BImage_Diagonal);
} else
texture->addTexture(BImage_Solid);
if (! (texture->getTexture() & BImage_Flat))
if (strstr(ts, "bevel2"))
- texture->addTexture(BImage_Bevel2);
+ texture->addTexture(BImage_Bevel2);
else
- texture->addTexture(BImage_Bevel1);
+ texture->addTexture(BImage_Bevel1);
#ifdef INTERLACE
if (strstr(ts, "interlaced"))
static Bool running = True;
static int anotherWMRunning(Display *display, XErrorEvent *) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenAnotherWMRunning,
- "BScreen::BScreen: an error occured while querying the X server.\n"
- " another window manager already running on display %s.\n"),
+ fprintf(stderr, i18n(ScreenSet, ScreenAnotherWMRunning,
+ "BScreen::BScreen: an error occured while querying the X server.\n"
+ " another window manager already running on display %s.\n"),
DisplayString(display));
running = False;
for (p=pattern; 1; p++) {
if (!*p) {
if (p2!=NULL && n>1 && n<72) {
- *size = n; return p2+1;
+ *size = n; return p2+1;
} else {
- *size = 16; return NULL;
+ *size = 16; return NULL;
}
} else if (*p=='-') {
if (n>1 && n<72 && p2!=NULL) {
- *size = n;
- return p2+1;
+ *size = n;
+ return p2+1;
}
p2=p; n=0;
} else if (*p>='0' && *p<='9' && p2!=NULL) {
BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
- openbox(ob), config(conf)
+openbox(ob), config(conf)
{
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
- SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
- ButtonPressMask | ButtonReleaseMask;
+ SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
+ ButtonPressMask | ButtonReleaseMask;
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), event_mask);
managed = running;
if (! managed) return;
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenManagingScreen,
- "BScreen::BScreen: managing screen %d "
- "using visual 0x%lx, depth %d\n"),
- getScreenNumber(), XVisualIDFromVisual(getVisual()),
+ fprintf(stderr, i18n(ScreenSet, ScreenManagingScreen,
+ "BScreen::BScreen: managing screen %d "
+ "using visual 0x%lx, depth %d\n"),
+ getScreenNumber(), XVisualIDFromVisual(getVisual()),
getDepth());
rootmenu = 0;
XGCValues gcv;
unsigned long gc_value_mask = GCForeground;
- if (! i18n->multibyte()) gc_value_mask |= GCFont;
+ if (! i18n.multibyte()) gc_value_mask |= GCFont;
gcv.foreground = WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber())
- ^ BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber());
+ getScreenNumber())
+ ^ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber());
gcv.function = GXxor;
gcv.subwindow_mode = IncludeInferiors;
opGC = XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
gcv.font = resource.wstyle.font->fid;
resource.wstyle.l_text_focus_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.wstyle.l_text_unfocus.getPixel();
if (resource.wstyle.font)
gcv.font = resource.wstyle.font->fid;
resource.wstyle.l_text_unfocus_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.wstyle.b_pic_focus.getPixel();
resource.wstyle.b_pic_focus_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- GCForeground, &gcv);
+ GCForeground, &gcv);
gcv.foreground = resource.wstyle.b_pic_unfocus.getPixel();
resource.wstyle.b_pic_unfocus_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- GCForeground, &gcv);
+ GCForeground, &gcv);
gcv.foreground = resource.mstyle.t_text.getPixel();
if (resource.mstyle.t_font)
gcv.font = resource.mstyle.t_font->fid;
resource.mstyle.t_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.mstyle.f_text.getPixel();
if (resource.mstyle.f_font)
gcv.font = resource.mstyle.f_font->fid;
resource.mstyle.f_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.mstyle.h_text.getPixel();
resource.mstyle.h_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.mstyle.d_text.getPixel();
resource.mstyle.d_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.mstyle.hilite.getColor()->getPixel();
resource.mstyle.hilite_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.tstyle.l_text.getPixel();
if (resource.tstyle.font)
gcv.font = resource.tstyle.font->fid;
resource.tstyle.l_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.tstyle.w_text.getPixel();
resource.tstyle.w_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.tstyle.c_text.getPixel();
resource.tstyle.c_text_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
gcv.foreground = resource.tstyle.b_pic.getPixel();
resource.tstyle.b_pic_gc =
XCreateGC(getBaseDisplay().getXDisplay(), getRootWindow(),
- gc_value_mask, &gcv);
+ gc_value_mask, &gcv);
- const char *s = i18n->getMessage(ScreenSet, ScreenPositionLength,
- "0: 0000 x 0: 0000");
+ const char *s = i18n(ScreenSet, ScreenPositionLength,
+ "0: 0000 x 0: 0000");
int l = strlen(s);
- if (i18n->multibyte()) {
+ if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(resource.wstyle.fontset, s, l, &ink, &logical);
geom_w = logical.width;
geom_h = resource.wstyle.fontset_extents->max_ink_extent.height;
} else {
geom_h = resource.wstyle.font->ascent +
- resource.wstyle.font->descent;
+ resource.wstyle.font->descent;
geom_w = XTextWidth(resource.wstyle.font, s, l);
}
if (resource.wstyle.l_focus.getTexture() & BImage_ParentRelative) {
if (resource.wstyle.t_focus.getTexture() ==
- (BImage_Flat | BImage_Solid)) {
+ (BImage_Flat | BImage_Solid)) {
geom_pixmap = None;
XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.t_focus.getColor()->getPixel());
+ resource.wstyle.t_focus.getColor()->getPixel());
} else {
geom_pixmap = image_control->renderImage(geom_w, geom_h,
- &resource.wstyle.t_focus);
+ &resource.wstyle.t_focus);
XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
- geom_window, geom_pixmap);
+ geom_window, geom_pixmap);
}
} else {
if (resource.wstyle.l_focus.getTexture() ==
- (BImage_Flat | BImage_Solid)) {
+ (BImage_Flat | BImage_Solid)) {
geom_pixmap = None;
XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.l_focus.getColor()->getPixel());
+ resource.wstyle.l_focus.getColor()->getPixel());
} else {
geom_pixmap = image_control->renderImage(geom_w, geom_h,
- &resource.wstyle.l_focus);
+ &resource.wstyle.l_focus);
XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
- geom_window, geom_pixmap);
+ geom_window, geom_pixmap);
}
}
}
saveWorkspaceNames();
- workspacemenu->insert(i18n->getMessage(IconSet, IconIcons, "Icons"),
- iconmenu);
+ workspacemenu->insert(i18n(IconSet, IconIcons, "Icons"),
+ iconmenu);
workspacemenu->update();
current_workspace = workspacesList.front();
unsigned int nchild;
Window r, p, *children;
XQueryTree(getBaseDisplay().getXDisplay(), getRootWindow(), &r, &p,
- &children, &nchild);
+ &children, &nchild);
// preen the window list of all icon windows... for better dockapp support
for (i = 0; i < (int) nchild; i++) {
if (children[i] == None) continue;
XWMHints *wmhints = XGetWMHints(getBaseDisplay().getXDisplay(),
- children[i]);
+ children[i]);
if (wmhints) {
if ((wmhints->flags & IconWindowHint) &&
- (wmhints->icon_window != children[i]))
+ (wmhints->icon_window != children[i]))
for (int j = 0; j < (int) nchild; j++)
if (children[j] == wmhints->icon_window) {
children[j] = None;
XMapRequestEvent mre;
mre.window = children[i];
win->restoreAttributes();
- win->mapRequestEvent(&mre);
+ win->mapRequestEvent(&mre);
}
}
}
XFreeGC(getBaseDisplay().getXDisplay(), opGC);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.wstyle.l_text_focus_gc);
+ resource.wstyle.l_text_focus_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.wstyle.l_text_unfocus_gc);
+ resource.wstyle.l_text_unfocus_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.wstyle.b_pic_focus_gc);
+ resource.wstyle.b_pic_focus_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.wstyle.b_pic_unfocus_gc);
+ resource.wstyle.b_pic_unfocus_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.mstyle.t_text_gc);
+ resource.mstyle.t_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.mstyle.f_text_gc);
+ resource.mstyle.f_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.mstyle.h_text_gc);
+ resource.mstyle.h_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.mstyle.d_text_gc);
+ resource.mstyle.d_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.mstyle.hilite_gc);
+ resource.mstyle.hilite_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.tstyle.l_text_gc);
+ resource.tstyle.l_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.tstyle.w_text_gc);
+ resource.tstyle.w_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.tstyle.c_text_gc);
+ resource.tstyle.c_text_gc);
XFreeGC(getBaseDisplay().getXDisplay(),
- resource.tstyle.b_pic_gc);
+ resource.tstyle.b_pic_gc);
}
void BScreen::readDatabaseTexture(const char *rname, const char *rclass,
- BTexture *texture,
- unsigned long default_pixel)
+ BTexture *texture,
+ unsigned long default_pixel)
{
std::string s;
-
+
if (resource.styleconfig.getValue(rname, rclass, s))
image_control->parseTexture(texture, s.c_str());
else
sprintf(colorname, "%s.color", rname);
readDatabaseColor(colorname, colorclass, texture->getColor(),
- default_pixel);
+ default_pixel);
#ifdef INTERLACE
sprintf(colorclass, "%s.ColorTo", rclass);
delete [] colorname;
if ((! texture->getColor()->isAllocated()) ||
- (texture->getTexture() & BImage_Flat))
+ (texture->getTexture() & BImage_Flat))
return;
XColor xcol;
xcol.red = (unsigned int) (texture->getColor()->getRed() +
- (texture->getColor()->getRed() >> 1));
+ (texture->getColor()->getRed() >> 1));
if (xcol.red >= 0xff) xcol.red = 0xffff;
else xcol.red *= 0xff;
xcol.green = (unsigned int) (texture->getColor()->getGreen() +
- (texture->getColor()->getGreen() >> 1));
+ (texture->getColor()->getGreen() >> 1));
if (xcol.green >= 0xff) xcol.green = 0xffff;
else xcol.green *= 0xff;
xcol.blue = (unsigned int) (texture->getColor()->getBlue() +
- (texture->getColor()->getBlue() >> 1));
+ (texture->getColor()->getBlue() >> 1));
if (xcol.blue >= 0xff) xcol.blue = 0xffff;
else xcol.blue *= 0xff;
if (! XAllocColor(getBaseDisplay().getXDisplay(),
- getColormap(), &xcol))
+ getColormap(), &xcol))
xcol.pixel = 0;
texture->getHiColor()->setPixel(xcol.pixel);
xcol.red =
(unsigned int) ((texture->getColor()->getRed() >> 2) +
- (texture->getColor()->getRed() >> 1)) * 0xff;
+ (texture->getColor()->getRed() >> 1)) * 0xff;
xcol.green =
(unsigned int) ((texture->getColor()->getGreen() >> 2) +
- (texture->getColor()->getGreen() >> 1)) * 0xff;
+ (texture->getColor()->getGreen() >> 1)) * 0xff;
xcol.blue =
(unsigned int) ((texture->getColor()->getBlue() >> 2) +
- (texture->getColor()->getBlue() >> 1)) * 0xff;
+ (texture->getColor()->getBlue() >> 1)) * 0xff;
if (! XAllocColor(getBaseDisplay().getXDisplay(),
- getColormap(), &xcol))
+ getColormap(), &xcol))
xcol.pixel = 0;
texture->getLoColor()->setPixel(xcol.pixel);
int clen = strlen(rclass) + 10, nlen = strlen(rname) + 10;
char *colorclass = new char[clen], *colorname = new char[nlen],
- *colortoclass = new char[clen], *colortoname = new char[nlen];
+ *colortoclass = new char[clen], *colortoname = new char[nlen];
sprintf(colorclass, "%s.Color", rclass);
sprintf(colorname, "%s.color", rname);
sprintf(colortoname, "%s.colorTo", rname);
readDatabaseColor(colorname, colorclass, texture->getColor(),
- default_pixel);
+ default_pixel);
readDatabaseColor(colortoname, colortoclass, texture->getColorTo(),
- default_pixel);
+ default_pixel);
delete [] colorclass;
delete [] colorname;
BColor *color, unsigned long default_pixel)
{
std::string s;
-
+
if (resource.styleconfig.getValue(rname, rclass, s))
image_control->parseColor(color, s.c_str());
else {
void BScreen::readDatabaseFontSet(const char *rname, const char *rclass,
- XFontSet *fontset) {
+ XFontSet *fontset) {
if (! fontset) return;
static char *defaultFont = "fixed";
*fontset = createFontSet(defaultFont);
if (! *fontset) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenDefaultFontLoadFail,
- "BScreen::LoadStyle(): couldn't load default font.\n"));
+ fprintf(stderr, i18n(ScreenSet, ScreenDefaultFontLoadFail,
+ "BScreen::LoadStyle(): couldn't load default font.\n"));
exit(2);
}
}
if (resource.styleconfig.getValue(rname, rclass, s)) {
if ((*font = XLoadQueryFont(getBaseDisplay().getXDisplay(),
- s.c_str())) == NULL) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenFontLoadFail,
- "BScreen::LoadStyle(): couldn't load font '%s'\n"),
- s.c_str());
+ s.c_str())) == NULL) {
+ fprintf(stderr, i18n(ScreenSet, ScreenFontLoadFail,
+ "BScreen::LoadStyle(): couldn't load font '%s'\n"),
+ s.c_str());
load_default = true;
}
} else
if (load_default) {
if ((*font = XLoadQueryFont(getBaseDisplay().getXDisplay(),
- defaultFont)) == NULL) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenDefaultFontLoadFail,
- "BScreen::LoadStyle(): couldn't load default font.\n"));
+ defaultFont)) == NULL) {
+ fprintf(stderr, i18n(ScreenSet, ScreenDefaultFontLoadFail,
+ "BScreen::LoadStyle(): couldn't load default font.\n"));
exit(2);
}
}
char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE];
fs = XCreateFontSet(getBaseDisplay().getXDisplay(),
- fontname, &missing, &nmissing, &def);
+ fontname, &missing, &nmissing, &def);
if (fs && (! nmissing)) return fs;
#ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, "C");
fs = XCreateFontSet(getBaseDisplay().getXDisplay(), fontname,
- &missing, &nmissing, &def);
+ &missing, &nmissing, &def);
setlocale(LC_CTYPE, "");
}
#endif // HAVE_SETLOCALE
}
getFontElement(fontname, weight, FONT_ELEMENT_SIZE,
- "-medium-", "-bold-", "-demibold-", "-regular-", NULL);
+ "-medium-", "-bold-", "-demibold-", "-regular-", NULL);
getFontElement(fontname, slant, FONT_ELEMENT_SIZE,
- "-r-", "-i-", "-o-", "-ri-", "-ro-", NULL);
+ "-r-", "-i-", "-o-", "-ri-", "-ro-", NULL);
getFontSize(fontname, &pixel_size);
if (! strcmp(weight, "*")) strncpy(weight, "medium", FONT_ELEMENT_SIZE);
buf_size = strlen(fontname) + (FONT_ELEMENT_SIZE * 2) + 64;
char *pattern2 = new char[buf_size];
snprintf(pattern2, buf_size - 1,
- "%s,"
- "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*,"
- "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*",
- fontname, weight, slant, pixel_size, pixel_size);
+ "%s,"
+ "-*-*-%s-%s-*-*-%d-*-*-*-*-*-*-*,"
+ "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*,*",
+ fontname, weight, slant, pixel_size, pixel_size);
fontname = pattern2;
if (nmissing) XFreeStringList(missing);
if (fs) XFreeFontSet(getBaseDisplay().getXDisplay(), fs);
fs = XCreateFontSet(getBaseDisplay().getXDisplay(), fontname,
- &missing, &nmissing, &def);
+ &missing, &nmissing, &def);
delete [] pattern2;
return fs;
s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
config.setValue(s.str(),
(resource.sloppy_focus ?
- (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
- : "ClickToFocus"));
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
s.rdbuf()->freeze(0);
}
s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
config.setValue(s.str(),
(resource.sloppy_focus ?
- (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
- : "ClickToFocus"));
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
s.rdbuf()->freeze(0);
}
void BScreen::setRootCommand(const char *cmd) {
-if (resource.root_command != NULL)
+ if (resource.root_command != NULL)
delete [] resource.root_command;
if (cmd != NULL)
resource.root_command = bstrdup(cmd);
setClock24Hour(resource.clock24hour);
#endif // HAVE_STRFTIME
setHideToolbar(resource.hide_toolbar);
-
+
toolbar->save();
#ifdef SLIT
slit->save();
++it;
}
}
-
+
rname.seekp(0); rclass.seekp(0);
rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
rname << rscreen.str() << "focusModel" << ends;
resource.sloppy_focus = true;
resource.auto_raise = false;
}
- } else {
- resource.sloppy_focus = true;
- resource.auto_raise = false;
- }
-
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "windowZones" << ends;
- rclass << rscreen.str() << "WindowZones" << ends;
- if (config.getValue(rname.str(), rclass.str(), l))
- resource.zones = (l == 1 || l == 2 || l == 4) ? l : 1;
- else
- resource.zones = 4;
+ } else {
+ resource.sloppy_focus = true;
+ resource.auto_raise = false;
+ }
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "windowPlacement" << ends;
- rclass << rscreen.str() << "WindowPlacement" << ends;
- if (config.getValue(rname.str(), rclass.str(), s)) {
- if (0 == strncasecmp(s.c_str(), "RowSmartPlacement", s.length()))
- resource.placement_policy = RowSmartPlacement;
- else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length()))
- resource.placement_policy = ColSmartPlacement;
- else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
- resource.placement_policy = BestFitPlacement;
- else if (0 == strncasecmp(s.c_str(), "UnderMousePlacement", s.length()))
- resource.placement_policy = UnderMousePlacement;
- else if (0 == strncasecmp(s.c_str(), "ClickMousePlacement", s.length()))
- resource.placement_policy = ClickMousePlacement;
- else //if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "windowZones" << ends;
+ rclass << rscreen.str() << "WindowZones" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l))
+ resource.zones = (l == 1 || l == 2 || l == 4) ? l : 1;
+ else
+ resource.zones = 4;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "windowPlacement" << ends;
+ rclass << rscreen.str() << "WindowPlacement" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (0 == strncasecmp(s.c_str(), "RowSmartPlacement", s.length()))
+ resource.placement_policy = RowSmartPlacement;
+ else if (0 == strncasecmp(s.c_str(), "ColSmartPlacement", s.length()))
+ resource.placement_policy = ColSmartPlacement;
+ else if (0 == strncasecmp(s.c_str(), "BestFitPlacement", s.length()))
+ resource.placement_policy = BestFitPlacement;
+ else if (0 == strncasecmp(s.c_str(), "UnderMousePlacement", s.length()))
+ resource.placement_policy = UnderMousePlacement;
+ else if (0 == strncasecmp(s.c_str(), "ClickMousePlacement", s.length()))
+ resource.placement_policy = ClickMousePlacement;
+ else //if (0 == strncasecmp(s.c_str(), "CascadePlacement", s.length()))
+ resource.placement_policy = CascadePlacement;
+ } else
resource.placement_policy = CascadePlacement;
- } else
- resource.placement_policy = CascadePlacement;
#ifdef HAVE_STRFTIME
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "strftimeFormat" << ends;
- rclass << rscreen.str() << "StrftimeFormat" << ends;
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "strftimeFormat" << ends;
+ rclass << rscreen.str() << "StrftimeFormat" << ends;
- if (resource.strftime_format != NULL)
- delete [] resource.strftime_format;
+ if (resource.strftime_format != NULL)
+ delete [] resource.strftime_format;
- if (config.getValue(rname.str(), rclass.str(), s))
- resource.strftime_format = bstrdup(s.c_str());
- else
- resource.strftime_format = bstrdup("%I:%M %p");
+ if (config.getValue(rname.str(), rclass.str(), s))
+ resource.strftime_format = bstrdup(s.c_str());
+ else
+ resource.strftime_format = bstrdup("%I:%M %p");
#else // !HAVE_STRFTIME
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "dateFormat" << ends;
- rclass << rscreen.str() << "DateFormat" << ends;
- if (config.getValue(rname.str(), rclass.str(), s)) {
- if (strncasecmp(s.c_str(), "European", s.length()))
- resource.date_format = B_EuropeanDate;
- else //if (strncasecmp(s.c_str(), "American", s.length()))
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "dateFormat" << ends;
+ rclass << rscreen.str() << "DateFormat" << ends;
+ if (config.getValue(rname.str(), rclass.str(), s)) {
+ if (strncasecmp(s.c_str(), "European", s.length()))
+ resource.date_format = B_EuropeanDate;
+ else //if (strncasecmp(s.c_str(), "American", s.length()))
+ resource.date_format = B_AmericanDate;
+ } else
resource.date_format = B_AmericanDate;
- } else
- resource.date_format = B_AmericanDate;
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "clockFormat" << ends;
- rclass << rscreen.str() << "ClockFormat" << ends;
- if (config.getValue(rname.str(), rclass.str(), l)) {
- if (clock == 24)
- resource.clock24hour = true;
- else if (clock == 12)
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "clockFormat" << ends;
+ rclass << rscreen.str() << "ClockFormat" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l)) {
+ if (clock == 24)
+ resource.clock24hour = true;
+ else if (clock == 12)
+ resource.clock24hour = false;
+ } else
resource.clock24hour = false;
- } else
- resource.clock24hour = false;
#endif // HAVE_STRFTIME
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "edgeSnapThreshold" << ends;
- rclass << rscreen.str() << "EdgeSnapThreshold" << ends;
- if (config.getValue(rname.str(), rclass.str(), l))
- resource.edge_snap_threshold = l;
- else
- resource.edge_snap_threshold = 4;
-
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "imageDither" << ends;
- rclass << rscreen.str() << "ImageDither" << ends;
- if (config.getValue(rname.str(), rclass.str(), b))
- image_control->setDither(b);
- else
- image_control->setDither(true);
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "edgeSnapThreshold" << ends;
+ rclass << rscreen.str() << "EdgeSnapThreshold" << ends;
+ if (config.getValue(rname.str(), rclass.str(), l))
+ resource.edge_snap_threshold = l;
+ else
+ resource.edge_snap_threshold = 4;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "imageDither" << ends;
+ rclass << rscreen.str() << "ImageDither" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ image_control->setDither(b);
+ else
+ image_control->setDither(true);
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "rootCommand" << ends;
- rclass << rscreen.str() << "RootCommand" << ends;
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "rootCommand" << ends;
+ rclass << rscreen.str() << "RootCommand" << ends;
- if (resource.root_command != NULL)
- delete [] resource.root_command;
-
- if (config.getValue(rname.str(), rclass.str(), s))
- resource.root_command = bstrdup(s.c_str());
- else
- resource.root_command = NULL;
+ if (resource.root_command != NULL)
+ delete [] resource.root_command;
- rname.seekp(0); rclass.seekp(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
- rname << rscreen.str() << "opaqueMove" << ends;
- rclass << rscreen.str() << "OpaqueMove" << ends;
- if (config.getValue(rname.str(), rclass.str(), b))
- resource.opaque_move = b;
- else
- resource.opaque_move = false;
+ if (config.getValue(rname.str(), rclass.str(), s))
+ resource.root_command = bstrdup(s.c_str());
+ else
+ resource.root_command = NULL;
+
+ rname.seekp(0); rclass.seekp(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ rname << rscreen.str() << "opaqueMove" << ends;
+ rclass << rscreen.str() << "OpaqueMove" << ends;
+ if (config.getValue(rname.str(), rclass.str(), b))
+ resource.opaque_move = b;
+ else
+ resource.opaque_move = false;
- rscreen.rdbuf()->freeze(0);
- rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
-}
+ rscreen.rdbuf()->freeze(0);
+ rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
+ }
-void BScreen::reconfigure(void) {
- load();
- toolbar->load();
+ void BScreen::reconfigure(void) {
+ load();
+ toolbar->load();
#ifdef SLIT
- slit->load();
+ slit->load();
#endif // SLIT
- LoadStyle();
-
- XGCValues gcv;
- unsigned long gc_value_mask = GCForeground;
- if (! i18n->multibyte()) gc_value_mask |= GCFont;
-
- gcv.foreground = WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber());
- gcv.function = GXinvert;
- gcv.subwindow_mode = IncludeInferiors;
- XChangeGC(getBaseDisplay().getXDisplay(), opGC,
- GCForeground | GCFunction | GCSubwindowMode, &gcv);
-
- gcv.foreground = resource.wstyle.l_text_focus.getPixel();
- if (resource.wstyle.font)
- gcv.font = resource.wstyle.font->fid;
- XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.l_text_focus_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.wstyle.l_text_unfocus.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.l_text_unfocus_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.wstyle.b_pic_focus.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.b_pic_focus_gc,
- GCForeground, &gcv);
-
- gcv.foreground = resource.wstyle.b_pic_unfocus.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.b_pic_unfocus_gc,
- GCForeground, &gcv);
-
- gcv.foreground = resource.mstyle.t_text.getPixel();
- if (resource.mstyle.t_font)
- gcv.font = resource.mstyle.t_font->fid;
- XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.t_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.mstyle.f_text.getPixel();
- if (resource.mstyle.f_font)
- gcv.font = resource.mstyle.f_font->fid;
- XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.f_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.mstyle.h_text.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.h_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.mstyle.d_text.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.d_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.mstyle.hilite.getColor()->getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.hilite_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.tstyle.l_text.getPixel();
- if (resource.tstyle.font)
- gcv.font = resource.tstyle.font->fid;
- XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.l_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.tstyle.w_text.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.w_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.tstyle.c_text.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.c_text_gc,
- gc_value_mask, &gcv);
-
- gcv.foreground = resource.tstyle.b_pic.getPixel();
- XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.b_pic_gc,
- gc_value_mask, &gcv);
-
- const char *s = i18n->getMessage(ScreenSet, ScreenPositionLength,
- "0: 0000 x 0: 0000");
- int l = strlen(s);
-
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(resource.wstyle.fontset, s, l, &ink, &logical);
- geom_w = logical.width;
-
- geom_h = resource.wstyle.fontset_extents->max_ink_extent.height;
- } else {
- geom_w = XTextWidth(resource.wstyle.font, s, l);
+ LoadStyle();
+
+ XGCValues gcv;
+ unsigned long gc_value_mask = GCForeground;
+ if (! i18n.multibyte()) gc_value_mask |= GCFont;
+
+ gcv.foreground = WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber());
+ gcv.function = GXinvert;
+ gcv.subwindow_mode = IncludeInferiors;
+ XChangeGC(getBaseDisplay().getXDisplay(), opGC,
+ GCForeground | GCFunction | GCSubwindowMode, &gcv);
+
+ gcv.foreground = resource.wstyle.l_text_focus.getPixel();
+ if (resource.wstyle.font)
+ gcv.font = resource.wstyle.font->fid;
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.l_text_focus_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.wstyle.l_text_unfocus.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.l_text_unfocus_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.wstyle.b_pic_focus.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.b_pic_focus_gc,
+ GCForeground, &gcv);
+
+ gcv.foreground = resource.wstyle.b_pic_unfocus.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.wstyle.b_pic_unfocus_gc,
+ GCForeground, &gcv);
+
+ gcv.foreground = resource.mstyle.t_text.getPixel();
+ if (resource.mstyle.t_font)
+ gcv.font = resource.mstyle.t_font->fid;
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.t_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.mstyle.f_text.getPixel();
+ if (resource.mstyle.f_font)
+ gcv.font = resource.mstyle.f_font->fid;
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.f_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.mstyle.h_text.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.h_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.mstyle.d_text.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.d_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.mstyle.hilite.getColor()->getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.mstyle.hilite_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.tstyle.l_text.getPixel();
+ if (resource.tstyle.font)
+ gcv.font = resource.tstyle.font->fid;
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.l_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.tstyle.w_text.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.w_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.tstyle.c_text.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.c_text_gc,
+ gc_value_mask, &gcv);
+
+ gcv.foreground = resource.tstyle.b_pic.getPixel();
+ XChangeGC(getBaseDisplay().getXDisplay(), resource.tstyle.b_pic_gc,
+ gc_value_mask, &gcv);
+
+ const char *s = i18n(ScreenSet, ScreenPositionLength,
+ "0: 0000 x 0: 0000");
+ int l = strlen(s);
+
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(resource.wstyle.fontset, s, l, &ink, &logical);
+ geom_w = logical.width;
+
+ geom_h = resource.wstyle.fontset_extents->max_ink_extent.height;
+ } else {
+ geom_w = XTextWidth(resource.wstyle.font, s, l);
- geom_h = resource.wstyle.font->ascent +
- resource.wstyle.font->descent;
- }
+ geom_h = resource.wstyle.font->ascent +
+ resource.wstyle.font->descent;
+ }
- geom_w += (resource.bevel_width * 2);
- geom_h += (resource.bevel_width * 2);
+ geom_w += (resource.bevel_width * 2);
+ geom_h += (resource.bevel_width * 2);
- Pixmap tmp = geom_pixmap;
- if (resource.wstyle.l_focus.getTexture() & BImage_ParentRelative) {
- if (resource.wstyle.t_focus.getTexture() ==
- (BImage_Flat | BImage_Solid)) {
- geom_pixmap = None;
- XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.t_focus.getColor()->getPixel());
+ Pixmap tmp = geom_pixmap;
+ if (resource.wstyle.l_focus.getTexture() & BImage_ParentRelative) {
+ if (resource.wstyle.t_focus.getTexture() ==
+ (BImage_Flat | BImage_Solid)) {
+ geom_pixmap = None;
+ XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.t_focus.getColor()->getPixel());
+ } else {
+ geom_pixmap = image_control->renderImage(geom_w, geom_h,
+ &resource.wstyle.t_focus);
+ XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
+ geom_window, geom_pixmap);
+ }
} else {
- geom_pixmap = image_control->renderImage(geom_w, geom_h,
- &resource.wstyle.t_focus);
- XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
- geom_window, geom_pixmap);
+ if (resource.wstyle.l_focus.getTexture() ==
+ (BImage_Flat | BImage_Solid)) {
+ geom_pixmap = None;
+ XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.l_focus.getColor()->getPixel());
+ } else {
+ geom_pixmap = image_control->renderImage(geom_w, geom_h,
+ &resource.wstyle.l_focus);
+ XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
+ geom_window, geom_pixmap);
+ }
}
- } else {
- if (resource.wstyle.l_focus.getTexture() ==
- (BImage_Flat | BImage_Solid)) {
- geom_pixmap = None;
- XSetWindowBackground(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.l_focus.getColor()->getPixel());
- } else {
- geom_pixmap = image_control->renderImage(geom_w, geom_h,
- &resource.wstyle.l_focus);
- XSetWindowBackgroundPixmap(getBaseDisplay().getXDisplay(),
- geom_window, geom_pixmap);
+ if (tmp) image_control->removeImage(tmp);
+
+ XSetWindowBorderWidth(getBaseDisplay().getXDisplay(), geom_window,
+ resource.border_width);
+ XSetWindowBorder(getBaseDisplay().getXDisplay(), geom_window,
+ resource.border_color.getPixel());
+
+ workspacemenu->reconfigure();
+ iconmenu->reconfigure();
+
+ {
+ int remember_sub = rootmenu->getCurrentSubmenu();
+ InitMenu();
+ raiseWindows(0, 0);
+ rootmenu->reconfigure();
+ rootmenu->drawSubmenu(remember_sub);
}
- }
- if (tmp) image_control->removeImage(tmp);
- XSetWindowBorderWidth(getBaseDisplay().getXDisplay(), geom_window,
- resource.border_width);
- XSetWindowBorder(getBaseDisplay().getXDisplay(), geom_window,
- resource.border_color.getPixel());
+ configmenu->reconfigure();
- workspacemenu->reconfigure();
- iconmenu->reconfigure();
-
- {
- int remember_sub = rootmenu->getCurrentSubmenu();
- InitMenu();
- raiseWindows(0, 0);
- rootmenu->reconfigure();
- rootmenu->drawSubmenu(remember_sub);
- }
-
- configmenu->reconfigure();
-
- toolbar->reconfigure();
+ toolbar->reconfigure();
#ifdef SLIT
- slit->reconfigure();
+ slit->reconfigure();
#endif // SLIT
- std::for_each(workspacesList.begin(), workspacesList.end(),
- std::mem_fun(&Workspace::reconfigure));
+ std::for_each(workspacesList.begin(), workspacesList.end(),
+ std::mem_fun(&Workspace::reconfigure));
- for (winList::iterator it = iconList.begin(); it != iconList.end(); ++it)
- if ((*it)->validateClient())
- (*it)->reconfigure();
+ for (winList::iterator it = iconList.begin(); it != iconList.end(); ++it)
+ if ((*it)->validateClient())
+ (*it)->reconfigure();
- image_control->timeout();
-}
+ image_control->timeout();
+ }
-void BScreen::rereadMenu(void) {
- InitMenu();
- raiseWindows(0, 0);
+ void BScreen::rereadMenu(void) {
+ InitMenu();
+ raiseWindows(0, 0);
- rootmenu->reconfigure();
-}
+ rootmenu->reconfigure();
+ }
-void BScreen::removeWorkspaceNames(void) {
- workspaceNames.clear();
-}
+ void BScreen::removeWorkspaceNames(void) {
+ workspaceNames.clear();
+ }
-void BScreen::LoadStyle(void) {
- Resource &conf = resource.styleconfig;
-
- const char *sfile = openbox.getStyleFilename();
- bool loaded = false;
- if (sfile != NULL) {
- conf.setFile(sfile);
- loaded = conf.load();
- }
- if (!loaded) {
- conf.setFile(DEFAULTSTYLE);
- if (!conf.load()) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenDefaultStyleLoadFail,
- "BScreen::LoadStyle(): couldn't load "
- "default style.\n"));
- exit(2);
+ void BScreen::LoadStyle(void) {
+ Resource &conf = resource.styleconfig;
+
+ const char *sfile = openbox.getStyleFilename();
+ bool loaded = false;
+ if (sfile != NULL) {
+ conf.setFile(sfile);
+ loaded = conf.load();
+ }
+ if (!loaded) {
+ conf.setFile(DEFAULTSTYLE);
+ if (!conf.load()) {
+ fprintf(stderr, i18n(ScreenSet, ScreenDefaultStyleLoadFail,
+ "BScreen::LoadStyle(): couldn't load "
+ "default style.\n"));
+ exit(2);
+ }
}
- }
- std::string s;
- long l;
-
- // load fonts/fontsets
-
- if (i18n->multibyte()) {
- readDatabaseFontSet("window.font", "Window.Font",
- &resource.wstyle.fontset);
- readDatabaseFontSet("toolbar.font", "Toolbar.Font",
- &resource.tstyle.fontset);
- readDatabaseFontSet("menu.title.font", "Menu.Title.Font",
- &resource.mstyle.t_fontset);
- readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font",
- &resource.mstyle.f_fontset);
-
- resource.mstyle.t_fontset_extents =
- XExtentsOfFontSet(resource.mstyle.t_fontset);
- resource.mstyle.f_fontset_extents =
- XExtentsOfFontSet(resource.mstyle.f_fontset);
- resource.tstyle.fontset_extents =
- XExtentsOfFontSet(resource.tstyle.fontset);
- resource.wstyle.fontset_extents =
- XExtentsOfFontSet(resource.wstyle.fontset);
- } else {
- readDatabaseFont("window.font", "Window.Font",
- &resource.wstyle.font);
- readDatabaseFont("menu.title.font", "Menu.Title.Font",
- &resource.mstyle.t_font);
- readDatabaseFont("menu.frame.font", "Menu.Frame.Font",
- &resource.mstyle.f_font);
- readDatabaseFont("toolbar.font", "Toolbar.Font",
- &resource.tstyle.font);
- }
+ std::string s;
+ long l;
+
+ // load fonts/fontsets
+
+ if (i18n.multibyte()) {
+ readDatabaseFontSet("window.font", "Window.Font",
+ &resource.wstyle.fontset);
+ readDatabaseFontSet("toolbar.font", "Toolbar.Font",
+ &resource.tstyle.fontset);
+ readDatabaseFontSet("menu.title.font", "Menu.Title.Font",
+ &resource.mstyle.t_fontset);
+ readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font",
+ &resource.mstyle.f_fontset);
+
+ resource.mstyle.t_fontset_extents =
+ XExtentsOfFontSet(resource.mstyle.t_fontset);
+ resource.mstyle.f_fontset_extents =
+ XExtentsOfFontSet(resource.mstyle.f_fontset);
+ resource.tstyle.fontset_extents =
+ XExtentsOfFontSet(resource.tstyle.fontset);
+ resource.wstyle.fontset_extents =
+ XExtentsOfFontSet(resource.wstyle.fontset);
+ } else {
+ readDatabaseFont("window.font", "Window.Font",
+ &resource.wstyle.font);
+ readDatabaseFont("menu.title.font", "Menu.Title.Font",
+ &resource.mstyle.t_font);
+ readDatabaseFont("menu.frame.font", "Menu.Frame.Font",
+ &resource.mstyle.f_font);
+ readDatabaseFont("toolbar.font", "Toolbar.Font",
+ &resource.tstyle.font);
+ }
- // load window config
- readDatabaseTexture("window.title.focus", "Window.Title.Focus",
- &resource.wstyle.t_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus",
- &resource.wstyle.t_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.label.focus", "Window.Label.Focus",
- &resource.wstyle.l_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus",
- &resource.wstyle.l_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.handle.focus", "Window.Handle.Focus",
- &resource.wstyle.h_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus",
- &resource.wstyle.h_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.grip.focus", "Window.Grip.Focus",
- &resource.wstyle.g_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus",
- &resource.wstyle.g_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.button.focus", "Window.Button.Focus",
- &resource.wstyle.b_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus",
- &resource.wstyle.b_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("window.button.pressed", "Window.Button.Pressed",
- &resource.wstyle.b_pressed,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.frame.focusColor",
- "Window.Frame.FocusColor",
- &resource.wstyle.f_focus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.frame.unfocusColor",
- "Window.Frame.UnfocusColor",
- &resource.wstyle.f_unfocus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.label.focus.textColor",
- "Window.Label.Focus.TextColor",
- &resource.wstyle.l_text_focus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.label.unfocus.textColor",
- "Window.Label.Unfocus.TextColor",
- &resource.wstyle.l_text_unfocus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.button.focus.picColor",
- "Window.Button.Focus.PicColor",
- &resource.wstyle.b_pic_focus,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("window.button.unfocus.picColor",
- "Window.Button.Unfocus.PicColor",
- &resource.wstyle.b_pic_unfocus,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
-
- if (conf.getValue("window.justify", "Window.Justify", s)) {
- if (0 == strncasecmp(s.c_str(), "right", s.length()))
- resource.wstyle.justify = BScreen::RightJustify;
- else if (0 == strncasecmp(s.c_str(), "center", s.length()))
- resource.wstyle.justify = BScreen::CenterJustify;
- else
+ // load window config
+ readDatabaseTexture("window.title.focus", "Window.Title.Focus",
+ &resource.wstyle.t_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus",
+ &resource.wstyle.t_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.label.focus", "Window.Label.Focus",
+ &resource.wstyle.l_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus",
+ &resource.wstyle.l_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.handle.focus", "Window.Handle.Focus",
+ &resource.wstyle.h_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus",
+ &resource.wstyle.h_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.grip.focus", "Window.Grip.Focus",
+ &resource.wstyle.g_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus",
+ &resource.wstyle.g_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.focus", "Window.Button.Focus",
+ &resource.wstyle.b_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus",
+ &resource.wstyle.b_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.pressed", "Window.Button.Pressed",
+ &resource.wstyle.b_pressed,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.frame.focusColor",
+ "Window.Frame.FocusColor",
+ &resource.wstyle.f_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.frame.unfocusColor",
+ "Window.Frame.UnfocusColor",
+ &resource.wstyle.f_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.label.focus.textColor",
+ "Window.Label.Focus.TextColor",
+ &resource.wstyle.l_text_focus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.label.unfocus.textColor",
+ "Window.Label.Unfocus.TextColor",
+ &resource.wstyle.l_text_unfocus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.button.focus.picColor",
+ "Window.Button.Focus.PicColor",
+ &resource.wstyle.b_pic_focus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.button.unfocus.picColor",
+ "Window.Button.Unfocus.PicColor",
+ &resource.wstyle.b_pic_unfocus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ if (conf.getValue("window.justify", "Window.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.wstyle.justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.wstyle.justify = BScreen::CenterJustify;
+ else
+ resource.wstyle.justify = BScreen::LeftJustify;
+ } else
resource.wstyle.justify = BScreen::LeftJustify;
- } else
- resource.wstyle.justify = BScreen::LeftJustify;
-
- // load toolbar config
- readDatabaseTexture("toolbar", "Toolbar",
- &resource.tstyle.toolbar,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.label", "Toolbar.Label",
- &resource.tstyle.label,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
- &resource.tstyle.window,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.button", "Toolbar.Button",
- &resource.tstyle.button,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
- &resource.tstyle.pressed,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
- &resource.tstyle.clock,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
- &resource.tstyle.l_text,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.windowLabel.textColor",
- "Toolbar.WindowLabel.TextColor",
- &resource.tstyle.w_text,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
- &resource.tstyle.c_text,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
- &resource.tstyle.b_pic,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
-
- if (conf.getValue("toolbar.justify", "Toolbar.Justify", s)) {
- if (0 == strncasecmp(s.c_str(), "right", s.length()))
- resource.tstyle.justify = BScreen::RightJustify;
- else if (0 == strncasecmp(s.c_str(), "center", s.length()))
- resource.tstyle.justify = BScreen::CenterJustify;
- else
+
+ // load toolbar config
+ readDatabaseTexture("toolbar", "Toolbar",
+ &resource.tstyle.toolbar,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.label", "Toolbar.Label",
+ &resource.tstyle.label,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
+ &resource.tstyle.window,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.button", "Toolbar.Button",
+ &resource.tstyle.button,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
+ &resource.tstyle.pressed,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
+ &resource.tstyle.clock,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
+ &resource.tstyle.l_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.windowLabel.textColor",
+ "Toolbar.WindowLabel.TextColor",
+ &resource.tstyle.w_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
+ &resource.tstyle.c_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
+ &resource.tstyle.b_pic,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ if (conf.getValue("toolbar.justify", "Toolbar.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.tstyle.justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.tstyle.justify = BScreen::CenterJustify;
+ else
+ resource.tstyle.justify = BScreen::LeftJustify;
+ } else
resource.tstyle.justify = BScreen::LeftJustify;
- } else
- resource.tstyle.justify = BScreen::LeftJustify;
-
- // load menu config
- readDatabaseTexture("menu.title", "Menu.Title",
- &resource.mstyle.title,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("menu.frame", "Menu.Frame",
- &resource.mstyle.frame,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("menu.hilite", "Menu.Hilite",
- &resource.mstyle.hilite,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor",
- &resource.mstyle.t_text,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor",
- &resource.mstyle.f_text,
- WhitePixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor",
- &resource.mstyle.d_text,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor",
- &resource.mstyle.h_text,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
-
- if (conf.getValue("menu.title.justify", "Menu.Title.Justify", s)) {
- if (0 == strncasecmp(s.c_str(), "right", s.length()))
- resource.mstyle.t_justify = BScreen::RightJustify;
- else if (0 == strncasecmp(s.c_str(), "center", s.length()))
- resource.mstyle.t_justify = BScreen::CenterJustify;
- else
+
+ // load menu config
+ readDatabaseTexture("menu.title", "Menu.Title",
+ &resource.mstyle.title,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("menu.frame", "Menu.Frame",
+ &resource.mstyle.frame,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("menu.hilite", "Menu.Hilite",
+ &resource.mstyle.hilite,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("menu.title.textColor", "Menu.Title.TextColor",
+ &resource.mstyle.t_text,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("menu.frame.textColor", "Menu.Frame.TextColor",
+ &resource.mstyle.f_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("menu.frame.disableColor", "Menu.Frame.DisableColor",
+ &resource.mstyle.d_text,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("menu.hilite.textColor", "Menu.Hilite.TextColor",
+ &resource.mstyle.h_text,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ if (conf.getValue("menu.title.justify", "Menu.Title.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.mstyle.t_justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.mstyle.t_justify = BScreen::CenterJustify;
+ else
+ resource.mstyle.t_justify = BScreen::LeftJustify;
+ } else
resource.mstyle.t_justify = BScreen::LeftJustify;
- } else
- resource.mstyle.t_justify = BScreen::LeftJustify;
- if (conf.getValue("menu.frame.justify", "Menu.Frame.Justify", s)) {
- if (0 == strncasecmp(s.c_str(), "right", s.length()))
- resource.mstyle.f_justify = BScreen::RightJustify;
- else if (0 == strncasecmp(s.c_str(), "center", s.length()))
- resource.mstyle.f_justify = BScreen::CenterJustify;
- else
+ if (conf.getValue("menu.frame.justify", "Menu.Frame.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.mstyle.f_justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.mstyle.f_justify = BScreen::CenterJustify;
+ else
+ resource.mstyle.f_justify = BScreen::LeftJustify;
+ } else
resource.mstyle.f_justify = BScreen::LeftJustify;
- } else
- resource.mstyle.f_justify = BScreen::LeftJustify;
-
- if (conf.getValue("menu.bullet", "Menu.Bullet", s)) {
- if (0 == strncasecmp(s.c_str(), "empty", s.length()))
- resource.mstyle.bullet = Basemenu::Empty;
- else if (0 == strncasecmp(s.c_str(), "square", s.length()))
- resource.mstyle.bullet = Basemenu::Square;
- else if (0 == strncasecmp(s.c_str(), "diamond", s.length()))
- resource.mstyle.bullet = Basemenu::Diamond;
- else
+
+ if (conf.getValue("menu.bullet", "Menu.Bullet", s)) {
+ if (0 == strncasecmp(s.c_str(), "empty", s.length()))
+ resource.mstyle.bullet = Basemenu::Empty;
+ else if (0 == strncasecmp(s.c_str(), "square", s.length()))
+ resource.mstyle.bullet = Basemenu::Square;
+ else if (0 == strncasecmp(s.c_str(), "diamond", s.length()))
+ resource.mstyle.bullet = Basemenu::Diamond;
+ else
+ resource.mstyle.bullet = Basemenu::Triangle;
+ } else
resource.mstyle.bullet = Basemenu::Triangle;
- } else
- resource.mstyle.bullet = Basemenu::Triangle;
- if (conf.getValue("menu.bullet.position", "Menu.Bullet.Position", s)) {
- if (0 == strncasecmp(s.c_str(), "right", s.length()))
- resource.mstyle.bullet_pos = Basemenu::Right;
- else
+ if (conf.getValue("menu.bullet.position", "Menu.Bullet.Position", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.mstyle.bullet_pos = Basemenu::Right;
+ else
+ resource.mstyle.bullet_pos = Basemenu::Left;
+ } else
resource.mstyle.bullet_pos = Basemenu::Left;
- } else
- resource.mstyle.bullet_pos = Basemenu::Left;
- readDatabaseColor("borderColor", "BorderColor", &resource.border_color,
- BlackPixel(getBaseDisplay().getXDisplay(),
- getScreenNumber()));
-
- // load bevel, border and handle widths
- if (conf.getValue("handleWidth", "HandleWidth", l)) {
- if (l <= (signed)size().w() / 2 && l != 0)
- resource.handle_width = l;
- else
+ readDatabaseColor("borderColor", "BorderColor", &resource.border_color,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ // load bevel, border and handle widths
+ if (conf.getValue("handleWidth", "HandleWidth", l)) {
+ if (l <= (signed)size().w() / 2 && l != 0)
+ resource.handle_width = l;
+ else
+ resource.handle_width = 6;
+ } else
resource.handle_width = 6;
- } else
- resource.handle_width = 6;
- if (conf.getValue("borderWidth", "BorderWidth", l))
- resource.border_width = l;
- else
- resource.border_width = 1;
-
- if (conf.getValue("bevelWidth", "BevelWidth", l)) {
- if (l <= (signed)size().w() / 2 && l != 0)
- resource.bevel_width = l;
+ if (conf.getValue("borderWidth", "BorderWidth", l))
+ resource.border_width = l;
else
+ resource.border_width = 1;
+
+ if (conf.getValue("bevelWidth", "BevelWidth", l)) {
+ if (l <= (signed)size().w() / 2 && l != 0)
+ resource.bevel_width = l;
+ else
+ resource.bevel_width = 3;
+ } else
resource.bevel_width = 3;
- } else
- resource.bevel_width = 3;
- if (conf.getValue("frameWidth", "FrameWidth", l)) {
- if (l <= (signed)size().w() / 2)
- resource.frame_width = l;
- else
+ if (conf.getValue("frameWidth", "FrameWidth", l)) {
+ if (l <= (signed)size().w() / 2)
+ resource.frame_width = l;
+ else
+ resource.frame_width = resource.bevel_width;
+ } else
resource.frame_width = resource.bevel_width;
- } else
- resource.frame_width = resource.bevel_width;
- const char *cmd = resource.root_command;
- if (cmd != NULL || conf.getValue("rootCommand", "RootCommand", s)) {
- if (cmd == NULL)
- cmd = s.c_str(); // not specified by the screen, so use the one from the
- // style file
+ const char *cmd = resource.root_command;
+ if (cmd != NULL || conf.getValue("rootCommand", "RootCommand", s)) {
+ if (cmd == NULL)
+ cmd = s.c_str(); // not specified by the screen, so use the one from the
+ // style file
#ifndef __EMX__
- char displaystring[MAXPATHLEN];
- sprintf(displaystring, "DISPLAY=%s",
- DisplayString(getBaseDisplay().getXDisplay()));
- sprintf(displaystring + strlen(displaystring) - 1, "%d",
- getScreenNumber());
+ char displaystring[MAXPATHLEN];
+ sprintf(displaystring, "DISPLAY=%s",
+ DisplayString(getBaseDisplay().getXDisplay()));
+ sprintf(displaystring + strlen(displaystring) - 1, "%d",
+ getScreenNumber());
- bexec(cmd, displaystring);
+ bexec(cmd, displaystring);
#else // __EMX__
- spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", cmd, NULL);
+ spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", cmd, NULL);
#endif // !__EMX__
+ }
}
-}
-void BScreen::addIcon(OpenboxWindow *w) {
- if (! w) return;
+ void BScreen::addIcon(OpenboxWindow *w) {
+ if (! w) return;
- w->setWorkspace(-1);
- w->setWindowNumber(iconList.size());
+ w->setWorkspace(-1);
+ w->setWindowNumber(iconList.size());
- iconList.push_back(w);
+ iconList.push_back(w);
- iconmenu->insert((const char **) w->getIconTitle());
- iconmenu->update();
-}
+ iconmenu->insert((const char **) w->getIconTitle());
+ iconmenu->update();
+ }
-void BScreen::removeIcon(OpenboxWindow *w) {
- if (! w) return;
+ void BScreen::removeIcon(OpenboxWindow *w) {
+ if (! w) return;
- iconList.remove(w);
+ iconList.remove(w);
- iconmenu->remove(w->getWindowNumber());
- iconmenu->update();
+ iconmenu->remove(w->getWindowNumber());
+ iconmenu->update();
- winList::iterator it = iconList.begin();
- for (int i = 0; it != iconList.end(); ++it, ++i)
- (*it)->setWindowNumber(i);
-}
+ winList::iterator it = iconList.begin();
+ for (int i = 0; it != iconList.end(); ++it, ++i)
+ (*it)->setWindowNumber(i);
+ }
-OpenboxWindow *BScreen::getIcon(int index) {
- if (index < 0 || index >= (signed)iconList.size())
- return (OpenboxWindow *) 0;
+ OpenboxWindow *BScreen::getIcon(int index) {
+ if (index < 0 || index >= (signed)iconList.size())
+ return (OpenboxWindow *) 0;
- winList::iterator it = iconList.begin();
- for (; index > 0; --index, ++it); // increment to index
- return *it;
-}
+ winList::iterator it = iconList.begin();
+ for (; index > 0; --index, ++it); // increment to index
+ return *it;
+ }
-int BScreen::addWorkspace(void) {
- Workspace *wkspc = new Workspace(*this, workspacesList.size());
- workspacesList.push_back(wkspc);
- setWorkspaceCount(workspaceCount()+1);
- saveWorkspaceNames();
+ int BScreen::addWorkspace(void) {
+ Workspace *wkspc = new Workspace(*this, workspacesList.size());
+ workspacesList.push_back(wkspc);
+ setWorkspaceCount(workspaceCount()+1);
+ saveWorkspaceNames();
- workspacemenu->insert(wkspc->getName(), wkspc->getMenu(),
- wkspc->getWorkspaceID() + 2);
- workspacemenu->update();
+ workspacemenu->insert(wkspc->getName(), wkspc->getMenu(),
+ wkspc->getWorkspaceID() + 2);
+ workspacemenu->update();
- toolbar->reconfigure();
+ toolbar->reconfigure();
- updateNetizenWorkspaceCount();
+ updateNetizenWorkspaceCount();
- return workspacesList.size();
-}
+ return workspacesList.size();
+ }
-int BScreen::removeLastWorkspace(void) {
- if (workspacesList.size() == 1)
- return 0;
+ int BScreen::removeLastWorkspace(void) {
+ if (workspacesList.size() == 1)
+ return 0;
- Workspace *wkspc = workspacesList.back();
+ Workspace *wkspc = workspacesList.back();
- if (current_workspace->getWorkspaceID() == wkspc->getWorkspaceID())
- changeWorkspaceID(current_workspace->getWorkspaceID() - 1);
+ if (current_workspace->getWorkspaceID() == wkspc->getWorkspaceID())
+ changeWorkspaceID(current_workspace->getWorkspaceID() - 1);
- wkspc->removeAll();
+ wkspc->removeAll();
- workspacemenu->remove(wkspc->getWorkspaceID() + 2);
- workspacemenu->update();
+ workspacemenu->remove(wkspc->getWorkspaceID() + 2);
+ workspacemenu->update();
- workspacesList.pop_back();
- delete wkspc;
-
- setWorkspaceCount(workspaceCount()-1);
- saveWorkspaceNames();
+ workspacesList.pop_back();
+ delete wkspc;
- toolbar->reconfigure();
+ setWorkspaceCount(workspaceCount()-1);
+ saveWorkspaceNames();
- updateNetizenWorkspaceCount();
+ toolbar->reconfigure();
- return workspacesList.size();
-}
+ updateNetizenWorkspaceCount();
+ return workspacesList.size();
+ }
-void BScreen::changeWorkspaceID(int id) {
- if (! current_workspace) return;
- if (id != current_workspace->getWorkspaceID()) {
- current_workspace->hideAll();
+ void BScreen::changeWorkspaceID(int id) {
+ if (! current_workspace) return;
- workspacemenu->setItemSelected(current_workspace->getWorkspaceID() + 2,
- False);
+ if (id != current_workspace->getWorkspaceID()) {
+ current_workspace->hideAll();
- if (openbox.focusedWindow() &&
- openbox.focusedWindow()->getScreen() == this &&
- (! openbox.focusedWindow()->isStuck())) {
- openbox.focusWindow(0);
- }
+ workspacemenu->setItemSelected(current_workspace->getWorkspaceID() + 2,
+ False);
+
+ if (openbox.focusedWindow() &&
+ openbox.focusedWindow()->getScreen() == this &&
+ (! openbox.focusedWindow()->isStuck())) {
+ openbox.focusWindow(0);
+ }
- current_workspace = getWorkspace(id);
+ current_workspace = getWorkspace(id);
- workspacemenu->setItemSelected(current_workspace->getWorkspaceID() + 2,
- True);
- toolbar->redrawWorkspaceLabel(True);
+ workspacemenu->setItemSelected(current_workspace->getWorkspaceID() + 2,
+ True);
+ toolbar->redrawWorkspaceLabel(True);
- current_workspace->showAll();
+ current_workspace->showAll();
- if (resource.focus_last && current_workspace->lastFocusedWindow()) {
- XSync(openbox.getXDisplay(), False);
- current_workspace->lastFocusedWindow()->setInputFocus();
+ if (resource.focus_last && current_workspace->lastFocusedWindow()) {
+ XSync(openbox.getXDisplay(), False);
+ current_workspace->lastFocusedWindow()->setInputFocus();
+ }
}
+
+ updateNetizenCurrentWorkspace();
}
- updateNetizenCurrentWorkspace();
-}
+ void BScreen::addNetizen(Netizen *n) {
+ netizenList.push_back(n);
-void BScreen::addNetizen(Netizen *n) {
- netizenList.push_back(n);
+ n->sendWorkspaceCount();
+ n->sendCurrentWorkspace();
- n->sendWorkspaceCount();
- n->sendCurrentWorkspace();
+ wkspList::iterator it;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it) {
+ for (int i = 0; i < (*it)->getCount(); i++)
+ n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(),
+ (*it)->getWorkspaceID());
+ }
- wkspList::iterator it;
- for (it = workspacesList.begin(); it != workspacesList.end(); ++it) {
- for (int i = 0; i < (*it)->getCount(); i++)
- n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(),
- (*it)->getWorkspaceID());
+ Window f = ((openbox.focusedWindow()) ?
+ openbox.focusedWindow()->getClientWindow() : None);
+ n->sendWindowFocus(f);
}
- Window f = ((openbox.focusedWindow()) ?
- openbox.focusedWindow()->getClientWindow() : None);
- n->sendWindowFocus(f);
-}
-
-void BScreen::removeNetizen(Window w) {
- netList::iterator it;
+ void BScreen::removeNetizen(Window w) {
+ netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- if ((*it)->getWindowID() == w) {
- Netizen *tmp = *it;
- netizenList.erase(it);
- delete tmp;
- break;
- }
-}
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ if ((*it)->getWindowID() == w) {
+ Netizen *tmp = *it;
+ netizenList.erase(it);
+ delete tmp;
+ break;
+ }
+ }
-void BScreen::updateNetizenCurrentWorkspace(void) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendCurrentWorkspace();
-}
+ void BScreen::updateNetizenCurrentWorkspace(void) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendCurrentWorkspace();
+ }
-void BScreen::updateNetizenWorkspaceCount(void) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWorkspaceCount();
-}
+ void BScreen::updateNetizenWorkspaceCount(void) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWorkspaceCount();
+ }
-void BScreen::updateNetizenWindowFocus(void) {
- Window f = ((openbox.focusedWindow()) ?
- openbox.focusedWindow()->getClientWindow() : None);
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWindowFocus(f);
-}
+ void BScreen::updateNetizenWindowFocus(void) {
+ Window f = ((openbox.focusedWindow()) ?
+ openbox.focusedWindow()->getClientWindow() : None);
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWindowFocus(f);
+ }
-void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWindowAdd(w, p);
-}
+ void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWindowAdd(w, p);
+ }
-void BScreen::updateNetizenWindowDel(Window w) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWindowDel(w);
-}
+ void BScreen::updateNetizenWindowDel(Window w) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWindowDel(w);
+ }
-void BScreen::updateNetizenWindowRaise(Window w) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWindowRaise(w);
-}
+ void BScreen::updateNetizenWindowRaise(Window w) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWindowRaise(w);
+ }
-void BScreen::updateNetizenWindowLower(Window w) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendWindowLower(w);
-}
+ void BScreen::updateNetizenWindowLower(Window w) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendWindowLower(w);
+ }
-void BScreen::updateNetizenConfigNotify(XEvent *e) {
- netList::iterator it;
- for (it = netizenList.begin(); it != netizenList.end(); ++it)
- (*it)->sendConfigNotify(e);
-}
+ void BScreen::updateNetizenConfigNotify(XEvent *e) {
+ netList::iterator it;
+ for (it = netizenList.begin(); it != netizenList.end(); ++it)
+ (*it)->sendConfigNotify(e);
+ }
-void BScreen::raiseWindows(Window *workspace_stack, int num) {
- Window *session_stack = new
- Window[(num + workspacesList.size() + rootmenuList.size() + 13)];
- int i = 0, k = num;
+ void BScreen::raiseWindows(Window *workspace_stack, int num) {
+ Window *session_stack = new
+ Window[(num + workspacesList.size() + rootmenuList.size() + 13)];
+ int i = 0, k = num;
- XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID());
- *(session_stack + i++) = iconmenu->getWindowID();
+ XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID());
+ *(session_stack + i++) = iconmenu->getWindowID();
- wkspList::iterator it;
- for (it = workspacesList.begin(); it != workspacesList.end(); ++it)
- *(session_stack + i++) = (*it)->getMenu()->getWindowID();
+ wkspList::iterator it;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it)
+ *(session_stack + i++) = (*it)->getMenu()->getWindowID();
- *(session_stack + i++) = workspacemenu->getWindowID();
+ *(session_stack + i++) = workspacemenu->getWindowID();
- *(session_stack + i++) = configmenu->getFocusmenu()->getWindowID();
- *(session_stack + i++) = configmenu->getPlacementmenu()->getWindowID();
- *(session_stack + i++) = configmenu->getWindowID();
+ *(session_stack + i++) = configmenu->getFocusmenu()->getWindowID();
+ *(session_stack + i++) = configmenu->getPlacementmenu()->getWindowID();
+ *(session_stack + i++) = configmenu->getWindowID();
#ifdef SLIT
- *(session_stack + i++) = slit->getMenu()->getDirectionmenu()->getWindowID();
- *(session_stack + i++) = slit->getMenu()->getPlacementmenu()->getWindowID();
- *(session_stack + i++) = slit->getMenu()->getWindowID();
+ *(session_stack + i++) = slit->getMenu()->getDirectionmenu()->getWindowID();
+ *(session_stack + i++) = slit->getMenu()->getPlacementmenu()->getWindowID();
+ *(session_stack + i++) = slit->getMenu()->getWindowID();
#endif // SLIT
- *(session_stack + i++) =
- toolbar->getMenu()->getPlacementmenu()->getWindowID();
- *(session_stack + i++) = toolbar->getMenu()->getWindowID();
+ *(session_stack + i++) =
+ toolbar->getMenu()->getPlacementmenu()->getWindowID();
+ *(session_stack + i++) = toolbar->getMenu()->getWindowID();
- menuList::iterator rit;
- for (rit = rootmenuList.begin(); rit != rootmenuList.end(); ++rit)
- *(session_stack + i++) = (*rit)->getWindowID();
- *(session_stack + i++) = rootmenu->getWindowID();
+ menuList::iterator rit;
+ for (rit = rootmenuList.begin(); rit != rootmenuList.end(); ++rit)
+ *(session_stack + i++) = (*rit)->getWindowID();
+ *(session_stack + i++) = rootmenu->getWindowID();
- if (toolbar->onTop())
- *(session_stack + i++) = toolbar->getWindowID();
+ if (toolbar->onTop())
+ *(session_stack + i++) = toolbar->getWindowID();
#ifdef SLIT
- if (slit->onTop())
- *(session_stack + i++) = slit->getWindowID();
+ if (slit->onTop())
+ *(session_stack + i++) = slit->getWindowID();
#endif // SLIT
- while (k--)
- *(session_stack + i++) = *(workspace_stack + k);
+ while (k--)
+ *(session_stack + i++) = *(workspace_stack + k);
- XRestackWindows(getBaseDisplay().getXDisplay(), session_stack, i);
+ XRestackWindows(getBaseDisplay().getXDisplay(), session_stack, i);
- delete [] session_stack;
-}
+ delete [] session_stack;
+ }
-void BScreen::addWorkspaceName(const char *name) {
- workspaceNames.push_back(name);
-}
+ void BScreen::addWorkspaceName(const char *name) {
+ workspaceNames.push_back(name);
+ }
-const char *BScreen::getNameOfWorkspace(int id) {
- if (id < 0 || id >= (signed)workspaceNames.size())
- return (const char *) 0;
- return workspaceNames[id].c_str();
-}
+ const char *BScreen::getNameOfWorkspace(int id) {
+ if (id < 0 || id >= (signed)workspaceNames.size())
+ return (const char *) 0;
+ return workspaceNames[id].c_str();
+ }
-void BScreen::reassociateWindow(OpenboxWindow *w, int wkspc_id, Bool ignore_sticky) {
- if (! w) return;
+ void BScreen::reassociateWindow(OpenboxWindow *w, int wkspc_id, Bool ignore_sticky) {
+ if (! w) return;
- if (wkspc_id == -1)
- wkspc_id = current_workspace->getWorkspaceID();
+ if (wkspc_id == -1)
+ wkspc_id = current_workspace->getWorkspaceID();
- if (w->getWorkspaceNumber() == wkspc_id)
- return;
+ if (w->getWorkspaceNumber() == wkspc_id)
+ return;
- if (w->isIconic()) {
- removeIcon(w);
- getWorkspace(wkspc_id)->addWindow(w);
- } else if (ignore_sticky || ! w->isStuck()) {
- getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
- getWorkspace(wkspc_id)->addWindow(w);
+ if (w->isIconic()) {
+ removeIcon(w);
+ getWorkspace(wkspc_id)->addWindow(w);
+ } else if (ignore_sticky || ! w->isStuck()) {
+ getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
+ getWorkspace(wkspc_id)->addWindow(w);
+ }
}
-}
-void BScreen::nextFocus(void) {
- Bool have_focused = False;
- int focused_window_number = -1;
- OpenboxWindow *next;
+ void BScreen::nextFocus(void) {
+ Bool have_focused = False;
+ int focused_window_number = -1;
+ OpenboxWindow *next;
- if (openbox.focusedWindow()) {
- if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
- getScreenNumber()) {
- have_focused = True;
- focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ if (openbox.focusedWindow()) {
+ if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
+ getScreenNumber()) {
+ have_focused = True;
+ focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ }
}
- }
- if ((getCurrentWorkspace()->getCount() > 1) && have_focused) {
- int next_window_number = focused_window_number;
- do {
- if ((++next_window_number) >= getCurrentWorkspace()->getCount())
- next_window_number = 0;
+ if ((getCurrentWorkspace()->getCount() > 1) && have_focused) {
+ int next_window_number = focused_window_number;
+ do {
+ if ((++next_window_number) >= getCurrentWorkspace()->getCount())
+ next_window_number = 0;
- next = getCurrentWorkspace()->getWindow(next_window_number);
- } while ((! next->setInputFocus()) && (next_window_number !=
- focused_window_number));
+ next = getCurrentWorkspace()->getWindow(next_window_number);
+ } while ((! next->setInputFocus()) && (next_window_number !=
+ focused_window_number));
- if (next_window_number != focused_window_number)
- getCurrentWorkspace()->raiseWindow(next);
- } else if (getCurrentWorkspace()->getCount() >= 1) {
- next = current_workspace->getWindow(0);
+ if (next_window_number != focused_window_number)
+ getCurrentWorkspace()->raiseWindow(next);
+ } else if (getCurrentWorkspace()->getCount() >= 1) {
+ next = current_workspace->getWindow(0);
- current_workspace->raiseWindow(next);
- next->setInputFocus();
+ current_workspace->raiseWindow(next);
+ next->setInputFocus();
+ }
}
-}
-void BScreen::prevFocus(void) {
- Bool have_focused = False;
- int focused_window_number = -1;
- OpenboxWindow *prev;
+ void BScreen::prevFocus(void) {
+ Bool have_focused = False;
+ int focused_window_number = -1;
+ OpenboxWindow *prev;
- if (openbox.focusedWindow()) {
- if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
- getScreenNumber()) {
- have_focused = True;
- focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ if (openbox.focusedWindow()) {
+ if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
+ getScreenNumber()) {
+ have_focused = True;
+ focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ }
}
- }
- if ((getCurrentWorkspace()->getCount() > 1) && have_focused) {
- int prev_window_number = focused_window_number;
- do {
- if ((--prev_window_number) < 0)
- prev_window_number = getCurrentWorkspace()->getCount() - 1;
+ if ((getCurrentWorkspace()->getCount() > 1) && have_focused) {
+ int prev_window_number = focused_window_number;
+ do {
+ if ((--prev_window_number) < 0)
+ prev_window_number = getCurrentWorkspace()->getCount() - 1;
- prev = getCurrentWorkspace()->getWindow(prev_window_number);
- } while ((! prev->setInputFocus()) && (prev_window_number !=
- focused_window_number));
+ prev = getCurrentWorkspace()->getWindow(prev_window_number);
+ } while ((! prev->setInputFocus()) && (prev_window_number !=
+ focused_window_number));
- if (prev_window_number != focused_window_number)
- getCurrentWorkspace()->raiseWindow(prev);
- } else if (getCurrentWorkspace()->getCount() >= 1) {
- prev = current_workspace->getWindow(0);
+ if (prev_window_number != focused_window_number)
+ getCurrentWorkspace()->raiseWindow(prev);
+ } else if (getCurrentWorkspace()->getCount() >= 1) {
+ prev = current_workspace->getWindow(0);
- current_workspace->raiseWindow(prev);
- prev->setInputFocus();
+ current_workspace->raiseWindow(prev);
+ prev->setInputFocus();
+ }
}
-}
-void BScreen::raiseFocus(void) {
- Bool have_focused = False;
- int focused_window_number = -1;
+ void BScreen::raiseFocus(void) {
+ Bool have_focused = False;
+ int focused_window_number = -1;
- if (openbox.focusedWindow()) {
- if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
- getScreenNumber()) {
- have_focused = True;
- focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ if (openbox.focusedWindow()) {
+ if (openbox.focusedWindow()->getScreen()->getScreenNumber() ==
+ getScreenNumber()) {
+ have_focused = True;
+ focused_window_number = openbox.focusedWindow()->getWindowNumber();
+ }
}
- }
- if ((getCurrentWorkspace()->getCount() > 1) && have_focused)
- getWorkspace(openbox.focusedWindow()->getWorkspaceNumber())->
- raiseWindow(openbox.focusedWindow());
-}
+ if ((getCurrentWorkspace()->getCount() > 1) && have_focused)
+ getWorkspace(openbox.focusedWindow()->getWorkspaceNumber())->
+ raiseWindow(openbox.focusedWindow());
+ }
-void BScreen::InitMenu(void) {
- if (rootmenu) {
- rootmenuList.clear();
- while (rootmenu->getCount())
- rootmenu->remove(0);
- } else {
- rootmenu = new Rootmenu(*this);
- }
- bool defaultMenu = true;
+ void BScreen::InitMenu(void) {
+ if (rootmenu) {
+ rootmenuList.clear();
+ while (rootmenu->getCount())
+ rootmenu->remove(0);
+ } else {
+ rootmenu = new Rootmenu(*this);
+ }
+ bool defaultMenu = true;
- FILE *menu_file;
- const char *menu_filename = openbox.getMenuFilename();
+ FILE *menu_file;
+ const char *menu_filename = openbox.getMenuFilename();
- if (!(menu_file = fopen(menu_filename, "r"))) {
- perror(menu_filename);
- menu_filename = (char *) 0;
- }
- if (menu_filename == (char *) 0) {
- // opening the menu file failed, try the DEFAULTMENU
- menu_filename = DEFAULTMENU;
if (!(menu_file = fopen(menu_filename, "r"))) {
perror(menu_filename);
menu_filename = (char *) 0;
}
+ if (menu_filename == (char *) 0) {
+ // opening the menu file failed, try the DEFAULTMENU
+ menu_filename = DEFAULTMENU;
+ if (!(menu_file = fopen(menu_filename, "r"))) {
+ perror(menu_filename);
+ menu_filename = (char *) 0;
+ }
+ }
+
+ if (menu_filename) {
+ if (feof(menu_file)) {
+ fprintf(stderr, i18n(ScreenSet, ScreenEmptyMenuFile,
+ "%s: Empty menu file"), menu_filename);
+ menu_filename = (char *) 0;
+ } else {
+ // successsfully opened a menu file
+ char line[1024], label[1024];
+ memset(line, 0, 1024);
+ memset(label, 0, 1024);
+
+ while (fgets(line, 1024, menu_file) && ! feof(menu_file)) {
+ if (line[0] != '#') {
+ int i, key = 0, index = -1, len = strlen(line);
+
+ key = 0;
+ for (i = 0; i < len; i++) {
+ if (line[i] == '[') index = 0;
+ else if (line[i] == ']') break;
+ else if (line[i] != ' ')
+ if (index++ >= 0)
+ key += tolower(line[i]);
+ }
+
+ if (key == 517) {
+ index = -1;
+ for (i = index; i < len; i++) {
+ if (line[i] == '(') index = 0;
+ else if (line[i] == ')') break;
+ else if (index++ >= 0) {
+ if (line[i] == '\\' && i < len - 1) i++;
+ label[index - 1] = line[i];
+ }
+ }
+
+ if (index == -1) index = 0;
+ label[index] = '\0';
+
+ rootmenu->setLabel(label);
+ defaultMenu = parseMenuFile(menu_file, rootmenu);
+ if (!defaultMenu)
+ openbox.addMenuTimestamp(menu_filename);
+ break;
+ }
+ }
+ }
+ }
+ fclose(menu_file);
+ }
+
+ if (defaultMenu) {
+ rootmenu->setInternalMenu();
+ rootmenu->insert(i18n(ScreenSet, Screenxterm, "xterm"),
+ BScreen::Execute,
+ i18n(ScreenSet, Screenxterm, "xterm"));
+ rootmenu->insert(i18n(ScreenSet, ScreenRestart, "Restart"),
+ BScreen::Restart);
+ rootmenu->insert(i18n(ScreenSet, ScreenExit, "Exit"),
+ BScreen::Exit);
+ }
}
-
- if (menu_filename) {
- if (feof(menu_file)) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEmptyMenuFile,
- "%s: Empty menu file"), menu_filename);
- menu_filename = (char *) 0;
- } else {
- // successsfully opened a menu file
- char line[1024], label[1024];
+
+
+ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
+ char line[1024], label[1024], command[1024];
+
+ while (! feof(file)) {
memset(line, 0, 1024);
memset(label, 0, 1024);
+ memset(command, 0, 1024);
- while (fgets(line, 1024, menu_file) && ! feof(menu_file)) {
+ if (fgets(line, 1024, file)) {
if (line[0] != '#') {
- int i, key = 0, index = -1, len = strlen(line);
+ register int i, key = 0, parse = 0, index = -1,
+ line_length = strlen(line),
+ label_length = 0, command_length = 0;
+ // determine the keyword
key = 0;
- for (i = 0; i < len; i++) {
- if (line[i] == '[') index = 0;
+ for (i = 0; i < line_length; i++) {
+ if (line[i] == '[') parse = 1;
else if (line[i] == ']') break;
else if (line[i] != ' ')
- if (index++ >= 0)
+ if (parse)
key += tolower(line[i]);
}
- if (key == 517) {
- index = -1;
- for (i = index; i < len; i++) {
- if (line[i] == '(') index = 0;
- else if (line[i] == ')') break;
- else if (index++ >= 0) {
- if (line[i] == '\\' && i < len - 1) i++;
- label[index - 1] = line[i];
- }
+ // get the label enclosed in ()'s
+ parse = 0;
+
+ for (i = 0; i < line_length; i++) {
+ if (line[i] == '(') {
+ index = 0;
+ parse = 1;
+ } else if (line[i] == ')') break;
+ else if (index++ >= 0) {
+ if (line[i] == '\\' && i < line_length - 1) i++;
+ label[index - 1] = line[i];
}
+ }
- if (index == -1) index = 0;
+ if (parse) {
label[index] = '\0';
+ label_length = index;
+ } else {
+ label[0] = '\0';
+ label_length = 0;
+ }
- rootmenu->setLabel(label);
- defaultMenu = parseMenuFile(menu_file, rootmenu);
- if (!defaultMenu)
- openbox.addMenuTimestamp(menu_filename);
- break;
+ // get the command enclosed in {}'s
+ parse = 0;
+ index = -1;
+ for (i = 0; i < line_length; i++) {
+ if (line[i] == '{') {
+ index = 0;
+ parse = 1;
+ } else if (line[i] == '}') break;
+ else if (index++ >= 0) {
+ if (line[i] == '\\' && i < line_length - 1) i++;
+ command[index - 1] = line[i];
+ }
}
- }
- }
- }
- fclose(menu_file);
- }
- if (defaultMenu) {
- rootmenu->setInternalMenu();
- rootmenu->insert(i18n->getMessage(ScreenSet, Screenxterm, "xterm"),
- BScreen::Execute,
- i18n->getMessage(ScreenSet, Screenxterm, "xterm"));
- rootmenu->insert(i18n->getMessage(ScreenSet, ScreenRestart, "Restart"),
- BScreen::Restart);
- rootmenu->insert(i18n->getMessage(ScreenSet, ScreenExit, "Exit"),
- BScreen::Exit);
- }
-}
+ if (parse) {
+ command[index] = '\0';
+ command_length = index;
+ } else {
+ command[0] = '\0';
+ command_length = 0;
+ }
+ switch (key) {
+ case 311: //end
+ return ((menu->getCount() == 0) ? True : False);
-Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
- char line[1024], label[1024], command[1024];
-
- while (! feof(file)) {
- memset(line, 0, 1024);
- memset(label, 0, 1024);
- memset(command, 0, 1024);
-
- if (fgets(line, 1024, file)) {
- if (line[0] != '#') {
- register int i, key = 0, parse = 0, index = -1,
- line_length = strlen(line),
- label_length = 0, command_length = 0;
-
- // determine the keyword
- key = 0;
- for (i = 0; i < line_length; i++) {
- if (line[i] == '[') parse = 1;
- else if (line[i] == ']') break;
- else if (line[i] != ' ')
- if (parse)
- key += tolower(line[i]);
- }
-
- // get the label enclosed in ()'s
- parse = 0;
-
- for (i = 0; i < line_length; i++) {
- if (line[i] == '(') {
- index = 0;
- parse = 1;
- } else if (line[i] == ')') break;
- else if (index++ >= 0) {
- if (line[i] == '\\' && i < line_length - 1) i++;
- label[index - 1] = line[i];
- }
- }
-
- if (parse) {
- label[index] = '\0';
- label_length = index;
- } else {
- label[0] = '\0';
- label_length = 0;
- }
-
- // get the command enclosed in {}'s
- parse = 0;
- index = -1;
- for (i = 0; i < line_length; i++) {
- if (line[i] == '{') {
- index = 0;
- parse = 1;
- } else if (line[i] == '}') break;
- else if (index++ >= 0) {
- if (line[i] == '\\' && i < line_length - 1) i++;
- command[index - 1] = line[i];
- }
- }
-
- if (parse) {
- command[index] = '\0';
- command_length = index;
- } else {
- command[0] = '\0';
- command_length = 0;
- }
-
- switch (key) {
- case 311: //end
- return ((menu->getCount() == 0) ? True : False);
-
- break;
-
- case 333: // nop
- menu->insert(label);
-
- break;
-
- case 421: // exec
- if ((! *label) && (! *command)) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEXECError,
- "BScreen::parseMenuFile: [exec] error, "
- "no menu label and/or command defined\n"));
- continue;
- }
-
- menu->insert(label, BScreen::Execute, command);
-
- break;
-
- case 442: // exit
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenEXITError,
- "BScreen::parseMenuFile: [exit] error, "
- "no menu label defined\n"));
- continue;
- }
-
- menu->insert(label, BScreen::Exit);
-
- break;
-
- case 561: // style
- {
- if ((! *label) || (! *command)) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenSTYLEError,
- "BScreen::parseMenuFile: [style] error, "
- "no menu label and/or filename defined\n"));
- continue;
- }
-
- char style[MAXPATHLEN];
-
- // perform shell style ~ home directory expansion
- char *homedir = 0;
- int homedir_len = 0;
- if (*command == '~' && *(command + 1) == '/') {
- homedir = getenv("HOME");
- homedir_len = strlen(homedir);
- }
-
- if (homedir && homedir_len != 0) {
- strncpy(style, homedir, homedir_len);
-
- strncpy(style + homedir_len, command + 1,
- command_length - 1);
- *(style + command_length + homedir_len - 1) = '\0';
- } else {
- strncpy(style, command, command_length);
- *(style + command_length) = '\0';
- }
-
- menu->insert(label, BScreen::SetStyle, style);
- }
-
- break;
-
- case 630: // config
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenCONFIGError,
- "BScreen::parseMenufile: [config] error, "
- "no label defined"));
- continue;
- }
-
- menu->insert(label, configmenu);
-
- break;
-
- case 740: // include
- {
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenINCLUDEError,
- "BScreen::parseMenuFile: [include] error, "
- "no filename defined\n"));
- continue;
- }
-
- char newfile[MAXPATHLEN];
-
- // perform shell style ~ home directory expansion
- char *homedir = 0;
- int homedir_len = 0;
- if (*label == '~' && *(label + 1) == '/') {
- homedir = getenv("HOME");
- homedir_len = strlen(homedir);
- }
-
- if (homedir && homedir_len != 0) {
- strncpy(newfile, homedir, homedir_len);
-
- strncpy(newfile + homedir_len, label + 1,
- label_length - 1);
- *(newfile + label_length + homedir_len - 1) = '\0';
- } else {
- strncpy(newfile, label, label_length);
- *(newfile + label_length) = '\0';
- }
-
- if (newfile) {
- FILE *submenufile = fopen(newfile, "r");
-
- if (submenufile) {
- struct stat buf;
- if (fstat(fileno(submenufile), &buf) ||
- (! S_ISREG(buf.st_mode))) {
- fprintf(stderr,
- i18n->getMessage(ScreenSet, ScreenINCLUDEErrorReg,
- "BScreen::parseMenuFile: [include] error: "
- "'%s' is not a regular file\n"), newfile);
- break;
- }
+ break;
+
+ case 333: // nop
+ menu->insert(label);
+
+ break;
- if (! feof(submenufile)) {
- if (!parseMenuFile(submenufile, menu))
- openbox.addMenuTimestamp(newfile);
- fclose(submenufile);
- }
- } else
- perror(newfile);
- }
- }
-
- break;
-
- case 767: // submenu
- {
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenSUBMENUError,
- "BScreen::parseMenuFile: [submenu] error, "
- "no menu label defined\n"));
- continue;
- }
-
- Rootmenu *submenu = new Rootmenu(*this);
-
- if (*command)
- submenu->setLabel(command);
- else
- submenu->setLabel(label);
-
- parseMenuFile(file, submenu);
- submenu->update();
- menu->insert(label, submenu);
- rootmenuList.push_back(submenu);
- }
-
- break;
-
- case 773: // restart
- {
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenRESTARTError,
- "BScreen::parseMenuFile: [restart] error, "
- "no menu label defined\n"));
- continue;
- }
-
- if (*command)
- menu->insert(label, BScreen::RestartOther, command);
- else
- menu->insert(label, BScreen::Restart);
- }
-
- break;
-
- case 845: // reconfig
- {
- if (! *label) {
- fprintf(stderr, i18n->getMessage(ScreenSet, ScreenRECONFIGError,
- "BScreen::parseMenuFile: [reconfig] error, "
- "no menu label defined\n"));
- continue;
- }
-
- menu->insert(label, BScreen::Reconfigure);
- }
-
- break;
-
- case 995: // stylesdir
- case 1113: // stylesmenu
- {
- Bool newmenu = ((key == 1113) ? True : False);
-
- if ((! *label) || ((! *command) && newmenu)) {
- fprintf(stderr,
- i18n->getMessage(ScreenSet, ScreenSTYLESDIRError,
- "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
- " error, no directory defined\n"));
+ case 421: // exec
+ if ((! *label) && (! *command)) {
+ fprintf(stderr, i18n(ScreenSet, ScreenEXECError,
+ "BScreen::parseMenuFile: [exec] error, "
+ "no menu label and/or command defined\n"));
continue;
}
- char stylesdir[MAXPATHLEN];
-
- char *directory = ((newmenu) ? command : label);
- int directory_length = ((newmenu) ? command_length : label_length);
+ menu->insert(label, BScreen::Execute, command);
- // perform shell style ~ home directory expansion
- char *homedir = 0;
- int homedir_len = 0;
+ break;
- if (*directory == '~' && *(directory + 1) == '/') {
- homedir = getenv("HOME");
- homedir_len = strlen(homedir);
+ case 442: // exit
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenEXITError,
+ "BScreen::parseMenuFile: [exit] error, "
+ "no menu label defined\n"));
+ continue;
}
- if (homedir && homedir_len != 0) {
- strncpy(stylesdir, homedir, homedir_len);
+ menu->insert(label, BScreen::Exit);
+
+ break;
+
+ case 561: // style
+ {
+ if ((! *label) || (! *command)) {
+ fprintf(stderr, i18n(ScreenSet, ScreenSTYLEError,
+ "BScreen::parseMenuFile: [style] error, "
+ "no menu label and/or filename defined\n"));
+ continue;
+ }
+
+ char style[MAXPATHLEN];
+
+ // perform shell style ~ home directory expansion
+ char *homedir = 0;
+ int homedir_len = 0;
+ if (*command == '~' && *(command + 1) == '/') {
+ homedir = getenv("HOME");
+ homedir_len = strlen(homedir);
+ }
+
+ if (homedir && homedir_len != 0) {
+ strncpy(style, homedir, homedir_len);
+
+ strncpy(style + homedir_len, command + 1,
+ command_length - 1);
+ *(style + command_length + homedir_len - 1) = '\0';
+ } else {
+ strncpy(style, command, command_length);
+ *(style + command_length) = '\0';
+ }
- strncpy(stylesdir + homedir_len, directory + 1,
- directory_length - 1);
- *(stylesdir + directory_length + homedir_len - 1) = '\0';
- } else {
- strncpy(stylesdir, directory, directory_length);
- *(stylesdir + directory_length) = '\0';
+ menu->insert(label, BScreen::SetStyle, style);
}
- struct stat statbuf;
+ break;
- if (! stat(stylesdir, &statbuf)) {
- if (S_ISDIR(statbuf.st_mode)) {
- Rootmenu *stylesmenu;
+ case 630: // config
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenCONFIGError,
+ "BScreen::parseMenufile: [config] error, "
+ "no label defined"));
+ continue;
+ }
- if (newmenu)
- stylesmenu = new Rootmenu(*this);
- else
- stylesmenu = menu;
+ menu->insert(label, configmenu);
- DIR *d = opendir(stylesdir);
- int entries = 0;
- struct dirent *p;
+ break;
- // get the total number of directory entries
- while ((p = readdir(d))) entries++;
- rewinddir(d);
+ case 740: // include
+ {
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenINCLUDEError,
+ "BScreen::parseMenuFile: [include] error, "
+ "no filename defined\n"));
+ continue;
+ }
- char **ls = new char* [entries];
- int index = 0;
- while ((p = readdir(d)))
- ls[index++] = bstrdup(p->d_name);
+ char newfile[MAXPATHLEN];
- closedir(d);
+ // perform shell style ~ home directory expansion
+ char *homedir = 0;
+ int homedir_len = 0;
+ if (*label == '~' && *(label + 1) == '/') {
+ homedir = getenv("HOME");
+ homedir_len = strlen(homedir);
+ }
- std::sort(ls, ls + entries, dcmp());
+ if (homedir && homedir_len != 0) {
+ strncpy(newfile, homedir, homedir_len);
- int n, slen = strlen(stylesdir);
- for (n = 0; n < entries; n++) {
- if (ls[n][strlen(ls[n])-1] != '~') {
- int nlen = strlen(ls[n]);
- char style[MAXPATHLEN + 1];
+ strncpy(newfile + homedir_len, label + 1,
+ label_length - 1);
+ *(newfile + label_length + homedir_len - 1) = '\0';
+ } else {
+ strncpy(newfile, label, label_length);
+ *(newfile + label_length) = '\0';
+ }
- strncpy(style, stylesdir, slen);
- *(style + slen) = '/';
- strncpy(style + slen + 1, ls[n], nlen + 1);
+ if (newfile) {
+ FILE *submenufile = fopen(newfile, "r");
+
+ if (submenufile) {
+ struct stat buf;
+ if (fstat(fileno(submenufile), &buf) ||
+ (! S_ISREG(buf.st_mode))) {
+ fprintf(stderr,
+ i18n(ScreenSet, ScreenINCLUDEErrorReg,
+ "BScreen::parseMenuFile: [include] error: "
+ "'%s' is not a regular file\n"), newfile);
+ break;
+ }
- if ((! stat(style, &statbuf)) && S_ISREG(statbuf.st_mode))
- stylesmenu->insert(ls[n], BScreen::SetStyle, style);
+ if (! feof(submenufile)) {
+ if (!parseMenuFile(submenufile, menu))
+ openbox.addMenuTimestamp(newfile);
+ fclose(submenufile);
}
+ } else
+ perror(newfile);
+ }
+ }
- delete [] ls[n];
- }
+ break;
+
+ case 767: // submenu
+ {
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenSUBMENUError,
+ "BScreen::parseMenuFile: [submenu] error, "
+ "no menu label defined\n"));
+ continue;
+ }
+
+ Rootmenu *submenu = new Rootmenu(*this);
+
+ if (*command)
+ submenu->setLabel(command);
+ else
+ submenu->setLabel(label);
+
+ parseMenuFile(file, submenu);
+ submenu->update();
+ menu->insert(label, submenu);
+ rootmenuList.push_back(submenu);
+ }
+
+ break;
+
+ case 773: // restart
+ {
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenRESTARTError,
+ "BScreen::parseMenuFile: [restart] error, "
+ "no menu label defined\n"));
+ continue;
+ }
+
+ if (*command)
+ menu->insert(label, BScreen::RestartOther, command);
+ else
+ menu->insert(label, BScreen::Restart);
+ }
+
+ break;
+
+ case 845: // reconfig
+ {
+ if (! *label) {
+ fprintf(stderr, i18n(ScreenSet, ScreenRECONFIGError,
+ "BScreen::parseMenuFile: [reconfig] error, "
+ "no menu label defined\n"));
+ continue;
+ }
+
+ menu->insert(label, BScreen::Reconfigure);
+ }
+
+ break;
+
+ case 995: // stylesdir
+ case 1113: // stylesmenu
+ {
+ Bool newmenu = ((key == 1113) ? True : False);
+
+ if ((! *label) || ((! *command) && newmenu)) {
+ fprintf(stderr,
+ i18n(ScreenSet, ScreenSTYLESDIRError,
+ "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
+ " error, no directory defined\n"));
+ continue;
+ }
+
+ char stylesdir[MAXPATHLEN];
- delete [] ls;
+ char *directory = ((newmenu) ? command : label);
+ int directory_length = ((newmenu) ? command_length : label_length);
- stylesmenu->update();
+ // perform shell style ~ home directory expansion
+ char *homedir = 0;
+ int homedir_len = 0;
- if (newmenu) {
- stylesmenu->setLabel(label);
- menu->insert(label, stylesmenu);
- rootmenuList.push_back(stylesmenu);
+ if (*directory == '~' && *(directory + 1) == '/') {
+ homedir = getenv("HOME");
+ homedir_len = strlen(homedir);
+ }
+
+ if (homedir && homedir_len != 0) {
+ strncpy(stylesdir, homedir, homedir_len);
+
+ strncpy(stylesdir + homedir_len, directory + 1,
+ directory_length - 1);
+ *(stylesdir + directory_length + homedir_len - 1) = '\0';
+ } else {
+ strncpy(stylesdir, directory, directory_length);
+ *(stylesdir + directory_length) = '\0';
+ }
+
+ struct stat statbuf;
+
+ if (! stat(stylesdir, &statbuf)) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ Rootmenu *stylesmenu;
+
+ if (newmenu)
+ stylesmenu = new Rootmenu(*this);
+ else
+ stylesmenu = menu;
+
+ DIR *d = opendir(stylesdir);
+ int entries = 0;
+ struct dirent *p;
+
+ // get the total number of directory entries
+ while ((p = readdir(d))) entries++;
+ rewinddir(d);
+
+ char **ls = new char* [entries];
+ int index = 0;
+ while ((p = readdir(d)))
+ ls[index++] = bstrdup(p->d_name);
+
+ closedir(d);
+
+ std::sort(ls, ls + entries, dcmp());
+
+ int n, slen = strlen(stylesdir);
+ for (n = 0; n < entries; n++) {
+ if (ls[n][strlen(ls[n])-1] != '~') {
+ int nlen = strlen(ls[n]);
+ char style[MAXPATHLEN + 1];
+
+ strncpy(style, stylesdir, slen);
+ *(style + slen) = '/';
+ strncpy(style + slen + 1, ls[n], nlen + 1);
+
+ if ((! stat(style, &statbuf)) && S_ISREG(statbuf.st_mode))
+ stylesmenu->insert(ls[n], BScreen::SetStyle, style);
+ }
+
+ delete [] ls[n];
+ }
+
+ delete [] ls;
+
+ stylesmenu->update();
+
+ if (newmenu) {
+ stylesmenu->setLabel(label);
+ menu->insert(label, stylesmenu);
+ rootmenuList.push_back(stylesmenu);
+ }
+ openbox.addMenuTimestamp(stylesdir);
+ } else {
+ fprintf(stderr, i18n(ScreenSet,
+ ScreenSTYLESDIRErrorNotDir,
+ "BScreen::parseMenuFile:"
+ " [stylesdir/stylesmenu] error, %s is not a"
+ " directory\n"), stylesdir);
}
- openbox.addMenuTimestamp(stylesdir);
} else {
- fprintf(stderr, i18n->getMessage(ScreenSet,
- ScreenSTYLESDIRErrorNotDir,
- "BScreen::parseMenuFile:"
- " [stylesdir/stylesmenu] error, %s is not a"
- " directory\n"), stylesdir);
+ fprintf(stderr,
+ i18n(ScreenSet, ScreenSTYLESDIRErrorNoExist,
+ "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
+ " error, %s does not exist\n"), stylesdir);
}
- } else {
- fprintf(stderr,
- i18n->getMessage(ScreenSet, ScreenSTYLESDIRErrorNoExist,
- "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
- " error, %s does not exist\n"), stylesdir);
+
+ break;
}
- break;
- }
+ case 1090: // workspaces
+ {
+ if (! *label) {
+ fprintf(stderr,
+ i18n(ScreenSet, ScreenWORKSPACESError,
+ "BScreen:parseMenuFile: [workspaces] error, "
+ "no menu label defined\n"));
+ continue;
+ }
- case 1090: // workspaces
- {
- if (! *label) {
- fprintf(stderr,
- i18n->getMessage(ScreenSet, ScreenWORKSPACESError,
- "BScreen:parseMenuFile: [workspaces] error, "
- "no menu label defined\n"));
- continue;
- }
-
- menu->insert(label, workspacemenu);
-
- break;
- }
- }
+ menu->insert(label, workspacemenu);
+
+ break;
+ }
+ }
+ }
}
}
+
+ return ((menu->getCount() == 0) ? True : False);
}
- return ((menu->getCount() == 0) ? True : False);
-}
+ void BScreen::shutdown(void) {
+ openbox.grab();
-void BScreen::shutdown(void) {
- openbox.grab();
+ XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), NoEventMask);
+ XSync(getBaseDisplay().getXDisplay(), False);
- XSelectInput(getBaseDisplay().getXDisplay(), getRootWindow(), NoEventMask);
- XSync(getBaseDisplay().getXDisplay(), False);
+ std::for_each(workspacesList.begin(), workspacesList.end(),
+ std::mem_fun(&Workspace::shutdown));
- std::for_each(workspacesList.begin(), workspacesList.end(),
- std::mem_fun(&Workspace::shutdown));
-
- while (!iconList.empty())
- iconList.front()->restore();
+ while (!iconList.empty())
+ iconList.front()->restore();
#ifdef SLIT
- slit->shutdown();
+ slit->shutdown();
#endif // SLIT
- openbox.ungrab();
-}
+ openbox.ungrab();
+ }
-void BScreen::showPosition(int x, int y) {
- if (! geom_visible) {
- XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
- (size().w() - geom_w) / 2,
- (size().h() - geom_h) / 2, geom_w, geom_h);
- XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
- XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
+ void BScreen::showPosition(int x, int y) {
+ if (! geom_visible) {
+ XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
+ (size().w() - geom_w) / 2,
+ (size().h() - geom_h) / 2, geom_w, geom_h);
+ XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
+ XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
- geom_visible = True;
- }
+ geom_visible = True;
+ }
- char label[1024];
+ char label[1024];
- sprintf(label, i18n->getMessage(ScreenSet, ScreenPositionFormat,
- "X: %4d x Y: %4d"), x, y);
+ sprintf(label, i18n(ScreenSet, ScreenPositionFormat,
+ "X: %4d x Y: %4d"), x, y);
- XClearWindow(getBaseDisplay().getXDisplay(), geom_window);
+ XClearWindow(getBaseDisplay().getXDisplay(), geom_window);
- if (i18n->multibyte()) {
- XmbDrawString(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.fontset, resource.wstyle.l_text_focus_gc,
- resource.bevel_width, resource.bevel_width -
- resource.wstyle.fontset_extents->max_ink_extent.y,
- label, strlen(label));
- } else {
- XDrawString(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.l_text_focus_gc,
- resource.bevel_width,
- resource.wstyle.font->ascent +
- resource.bevel_width, label, strlen(label));
+ if (i18n.multibyte()) {
+ XmbDrawString(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.fontset, resource.wstyle.l_text_focus_gc,
+ resource.bevel_width, resource.bevel_width -
+ resource.wstyle.fontset_extents->max_ink_extent.y,
+ label, strlen(label));
+ } else {
+ XDrawString(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.l_text_focus_gc,
+ resource.bevel_width,
+ resource.wstyle.font->ascent +
+ resource.bevel_width, label, strlen(label));
+ }
}
-}
-void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
- if (! geom_visible) {
- XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
- (size().w() - geom_w) / 2,
- (size().h() - geom_h) / 2, geom_w, geom_h);
- XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
- XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
+ void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
+ if (! geom_visible) {
+ XMoveResizeWindow(getBaseDisplay().getXDisplay(), geom_window,
+ (size().w() - geom_w) / 2,
+ (size().h() - geom_h) / 2, geom_w, geom_h);
+ XMapWindow(getBaseDisplay().getXDisplay(), geom_window);
+ XRaiseWindow(getBaseDisplay().getXDisplay(), geom_window);
- geom_visible = True;
- }
+ geom_visible = True;
+ }
- char label[1024];
+ char label[1024];
- sprintf(label, i18n->getMessage(ScreenSet, ScreenGeometryFormat,
- "W: %4d x H: %4d"), gx, gy);
+ sprintf(label, i18n(ScreenSet, ScreenGeometryFormat,
+ "W: %4d x H: %4d"), gx, gy);
- XClearWindow(getBaseDisplay().getXDisplay(), geom_window);
+ XClearWindow(getBaseDisplay().getXDisplay(), geom_window);
- if (i18n->multibyte()) {
- XmbDrawString(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.fontset, resource.wstyle.l_text_focus_gc,
- resource.bevel_width, resource.bevel_width -
- resource.wstyle.fontset_extents->max_ink_extent.y,
- label, strlen(label));
- } else {
- XDrawString(getBaseDisplay().getXDisplay(), geom_window,
- resource.wstyle.l_text_focus_gc,
- resource.bevel_width,
- resource.wstyle.font->ascent +
- resource.bevel_width, label, strlen(label));
+ if (i18n.multibyte()) {
+ XmbDrawString(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.fontset, resource.wstyle.l_text_focus_gc,
+ resource.bevel_width, resource.bevel_width -
+ resource.wstyle.fontset_extents->max_ink_extent.y,
+ label, strlen(label));
+ } else {
+ XDrawString(getBaseDisplay().getXDisplay(), geom_window,
+ resource.wstyle.l_text_focus_gc,
+ resource.bevel_width,
+ resource.wstyle.font->ascent +
+ resource.bevel_width, label, strlen(label));
+ }
}
-}
-void BScreen::hideGeometry(void) {
- if (geom_visible) {
- XUnmapWindow(getBaseDisplay().getXDisplay(), geom_window);
- geom_visible = False;
+ void BScreen::hideGeometry(void) {
+ if (geom_visible) {
+ XUnmapWindow(getBaseDisplay().getXDisplay(), geom_window);
+ geom_visible = False;
+ }
}
-}
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;
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);
delete timer;
clientList.clear();
-
+
delete slitmenu;
screen.getImageControl()->removeImage(frame.pixmap);
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);
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);
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);
}
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;
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);
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() &&
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());
}
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();
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() {
Slitmenu::Placementmenu::Placementmenu(Slitmenu &sm)
: Basemenu(sm.slit.screen), slitmenu(sm) {
- setLabel(i18n->getMessage(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);
-
- update();
-}
+ setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement"));
+ setMinimumSublevels(3);
+ setInternalMenu();
+
+ 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();
+ }
void Slitmenu::Placementmenu::itemSelected(int button, int index) {
using std::ends;
Toolbar::Toolbar(BScreen &scrn, Resource &conf) : openbox(scrn.getOpenbox()),
- screen(scrn), config(conf)
+screen(scrn), config(conf)
{
load();
display = openbox.getXDisplay();
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 = ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask;
+ EnterWindowMask | LeaveWindowMask;
frame.window =
XCreateWindow(display, screen.getRootWindow(), 0, 0, 1, 1, 0,
- screen.getDepth(), InputOutput, screen.getVisual(),
- create_mask, &attrib);
+ screen.getDepth(), InputOutput, screen.getVisual(),
+ create_mask, &attrib);
openbox.saveToolbarSearch(frame.window, this);
attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask |
- KeyPressMask | EnterWindowMask;
+ KeyPressMask | EnterWindowMask;
frame.workspace_label =
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen.getDepth(),
- InputOutput, screen.getVisual(), create_mask, &attrib);
+ InputOutput, screen.getVisual(), create_mask, &attrib);
openbox.saveToolbarSearch(frame.workspace_label, this);
frame.window_label =
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen.getDepth(),
- InputOutput, screen.getVisual(), create_mask, &attrib);
+ InputOutput, screen.getVisual(), create_mask, &attrib);
openbox.saveToolbarSearch(frame.window_label, this);
frame.clock =
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen.getDepth(),
- InputOutput, screen.getVisual(), create_mask, &attrib);
+ InputOutput, screen.getVisual(), create_mask, &attrib);
openbox.saveToolbarSearch(frame.clock, this);
frame.psbutton =
m_placement = BottomCenter;
} else
m_placement = BottomCenter;
-
+
rname.seekp(0); rclass.seekp(0);
rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
rname << rscreen.str() << "toolbar.onTop" << ends;
frame.bevel_w = screen.getBevelWidth();
frame.width = screen.size().w() * m_width_percent / 100;
-
- if (i18n->multibyte())
+
+ if (i18n.multibyte())
frame.height =
screen.getToolbarStyle()->fontset_extents->max_ink_extent.height;
else
frame.height = screen.getToolbarStyle()->font->ascent +
- screen.getToolbarStyle()->font->descent;
+ screen.getToolbarStyle()->font->descent;
frame.button_w = frame.height;
frame.height += 2;
frame.label_h = frame.height;
frame.height += (frame.bevel_w * 2);
-
+
switch (m_placement) {
case TopLeft:
frame.x = 0;
frame.y = 0;
frame.x_hidden = 0;
frame.y_hidden = screen.getBevelWidth() - screen.getBorderWidth()
- - frame.height;
+ - frame.height;
break;
case BottomLeft:
- (screen.getBorderWidth() * 2);
frame.x_hidden = 0;
frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- - screen.getBorderWidth();
+ - screen.getBorderWidth();
break;
case TopCenter:
frame.y = 0;
frame.x_hidden = frame.x;
frame.y_hidden = screen.getBevelWidth() - screen.getBorderWidth()
- - frame.height;
+ - frame.height;
break;
case BottomCenter:
- (screen.getBorderWidth() * 2);
frame.x_hidden = frame.x;
frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- - screen.getBorderWidth();
+ - screen.getBorderWidth();
break;
case TopRight:
frame.y = 0;
frame.x_hidden = frame.x;
frame.y_hidden = screen.getBevelWidth() - screen.getBorderWidth()
- - frame.height;
+ - frame.height;
break;
case BottomRight:
- (screen.getBorderWidth() * 2);
frame.x_hidden = frame.x;
frame.y_hidden = screen.size().h() - screen.getBevelWidth()
- - screen.getBorderWidth();
+ - screen.getBorderWidth();
break;
}
t[len++] = 'A'; // add size to the string for padding
t[len] = '\0';
- if (i18n->multibyte()) {
+ if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen.getToolbarStyle()->fontset, t, len, &ink,
&logical);
//frame.clock_w = screen.getToolbarStyle()->font->max_bounds.width * len;
}
frame.clock_w += (frame.bevel_w * 4);
-
+
delete [] time_string;
} else {
frame.clock_w = 0;
#else // !HAVE_STRFTIME
frame.clock_w =
XTextWidth(screen.getToolbarStyle()->font,
- i18n->getMessage(ToolbarSet, ToolbarNoStrftimeLength,
- "00:00000"),
- strlen(i18n->getMessage(ToolbarSet, ToolbarNoStrftimeLength,
- "00:00000"))) + (frame.bevel_w * 4);
+ i18n(ToolbarSet, ToolbarNoStrftimeLength,
+ "00:00000"),
+ strlen(i18n(ToolbarSet, ToolbarNoStrftimeLength,
+ "00:00000"))) + (frame.bevel_w * 4);
#endif // HAVE_STRFTIME
- int i;
- unsigned int w = 0;
- frame.workspace_label_w = 0;
-
- for (i = 0; i < screen.getWorkspaceCount(); i++) {
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- screen.getWorkspace(i)->getName(),
- strlen(screen.getWorkspace(i)->getName()),
- &ink, &logical);
- w = logical.width;
- } else {
- w = XTextWidth(screen.getToolbarStyle()->font,
- screen.getWorkspace(i)->getName(),
- strlen(screen.getWorkspace(i)->getName()));
- }
- w += (frame.bevel_w * 4);
-
- if (w > frame.workspace_label_w) frame.workspace_label_w = w;
- }
-
- if (frame.workspace_label_w < frame.clock_w)
- frame.workspace_label_w = frame.clock_w;
- else if (frame.workspace_label_w > frame.clock_w)
- frame.clock_w = frame.workspace_label_w;
-
- frame.window_label_w =
- (frame.width - (frame.clock_w + (frame.button_w * 4) +
- frame.workspace_label_w + (frame.bevel_w * 8) + 6));
-
- if (m_hidden) {
- XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden,
- frame.width, frame.height);
- } else {
- XMoveResizeWindow(display, frame.window, frame.x, frame.y,
- frame.width, frame.height);
- }
-
- XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w,
- frame.bevel_w, frame.workspace_label_w,
- frame.label_h);
- XMoveResizeWindow(display, frame.psbutton, (frame.bevel_w * 2) +
- frame.workspace_label_w + 1, frame.bevel_w + 1,
- frame.button_w, frame.button_w);
- XMoveResizeWindow(display ,frame.nsbutton, (frame.bevel_w * 3) +
- frame.workspace_label_w + frame.button_w + 2,
- frame.bevel_w + 1, frame.button_w, frame.button_w);
- XMoveResizeWindow(display, frame.window_label, (frame.bevel_w * 4) +
- (frame.button_w * 2) + frame.workspace_label_w + 3,
- frame.bevel_w, frame.window_label_w, frame.label_h);
- XMoveResizeWindow(display, frame.pwbutton, (frame.bevel_w * 5) +
- (frame.button_w * 2) + frame.workspace_label_w +
- frame.window_label_w + 4, frame.bevel_w + 1,
- frame.button_w, frame.button_w);
- XMoveResizeWindow(display, frame.nwbutton, (frame.bevel_w * 6) +
- (frame.button_w * 3) + frame.workspace_label_w +
- frame.window_label_w + 5, frame.bevel_w + 1,
- frame.button_w, frame.button_w);
- XMoveResizeWindow(display, frame.clock, frame.width - frame.clock_w -
- frame.bevel_w, frame.bevel_w, frame.clock_w,
- frame.label_h);
-
- Pixmap tmp = frame.base;
- BTexture *texture = &(screen.getToolbarStyle()->toolbar);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.base = None;
- XSetWindowBackground(display, frame.window,
- texture->getColor()->getPixel());
- } else {
- frame.base =
- image_ctrl->renderImage(frame.width, frame.height, texture);
- XSetWindowBackgroundPixmap(display, frame.window, frame.base);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- tmp = frame.label;
- texture = &(screen.getToolbarStyle()->window);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.label = None;
- XSetWindowBackground(display, frame.window_label,
- texture->getColor()->getPixel());
- } else {
- frame.label =
- image_ctrl->renderImage(frame.window_label_w, frame.label_h, texture);
- XSetWindowBackgroundPixmap(display, frame.window_label, frame.label);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- tmp = frame.wlabel;
- texture = &(screen.getToolbarStyle()->label);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.wlabel = None;
- XSetWindowBackground(display, frame.workspace_label,
- texture->getColor()->getPixel());
- } else {
- frame.wlabel =
- image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
- XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- tmp = frame.clk;
- texture = &(screen.getToolbarStyle()->clock);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.clk = None;
- XSetWindowBackground(display, frame.clock,
- texture->getColor()->getPixel());
- } else {
- frame.clk =
- image_ctrl->renderImage(frame.clock_w, frame.label_h, texture);
- XSetWindowBackgroundPixmap(display, frame.clock, frame.clk);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- tmp = frame.button;
- texture = &(screen.getToolbarStyle()->button);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.button = None;
-
- frame.button_pixel = texture->getColor()->getPixel();
- XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
- XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
- XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
- XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
- } else {
- frame.button =
- image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
-
- XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
- XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
- XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
- XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- tmp = frame.pbutton;
- texture = &(screen.getToolbarStyle()->pressed);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.pbutton = None;
- frame.pbutton_pixel = texture->getColor()->getPixel();
- } else {
- frame.pbutton =
- image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- XSetWindowBorder(display, frame.window,
- screen.getBorderColor()->getPixel());
- XSetWindowBorderWidth(display, frame.window, screen.getBorderWidth());
-
- XClearWindow(display, frame.window);
- XClearWindow(display, frame.workspace_label);
- XClearWindow(display, frame.window_label);
- XClearWindow(display, frame.clock);
- XClearWindow(display, frame.psbutton);
- XClearWindow(display, frame.nsbutton);
- XClearWindow(display, frame.pwbutton);
- XClearWindow(display, frame.nwbutton);
-
- redrawWindowLabel();
- redrawWorkspaceLabel();
- redrawPrevWorkspaceButton();
- redrawNextWorkspaceButton();
- redrawPrevWindowButton();
- redrawNextWindowButton();
- checkClock(True);
-
- toolbarmenu->reconfigure();
+ int i;
+ unsigned int w = 0;
+ frame.workspace_label_w = 0;
+
+ for (i = 0; i < screen.getWorkspaceCount(); i++) {
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ screen.getWorkspace(i)->getName(),
+ strlen(screen.getWorkspace(i)->getName()),
+ &ink, &logical);
+ w = logical.width;
+ } else {
+ w = XTextWidth(screen.getToolbarStyle()->font,
+ screen.getWorkspace(i)->getName(),
+ strlen(screen.getWorkspace(i)->getName()));
+ }
+ w += (frame.bevel_w * 4);
+
+ if (w > frame.workspace_label_w) frame.workspace_label_w = w;
+ }
+
+ if (frame.workspace_label_w < frame.clock_w)
+ frame.workspace_label_w = frame.clock_w;
+ else if (frame.workspace_label_w > frame.clock_w)
+ frame.clock_w = frame.workspace_label_w;
+
+ frame.window_label_w =
+ (frame.width - (frame.clock_w + (frame.button_w * 4) +
+ frame.workspace_label_w + (frame.bevel_w * 8) + 6));
+
+ if (m_hidden) {
+ XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden,
+ frame.width, frame.height);
+ } else {
+ XMoveResizeWindow(display, frame.window, frame.x, frame.y,
+ frame.width, frame.height);
+ }
+
+ XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w,
+ frame.bevel_w, frame.workspace_label_w,
+ frame.label_h);
+ XMoveResizeWindow(display, frame.psbutton, (frame.bevel_w * 2) +
+ frame.workspace_label_w + 1, frame.bevel_w + 1,
+ frame.button_w, frame.button_w);
+ XMoveResizeWindow(display ,frame.nsbutton, (frame.bevel_w * 3) +
+ frame.workspace_label_w + frame.button_w + 2,
+ frame.bevel_w + 1, frame.button_w, frame.button_w);
+ XMoveResizeWindow(display, frame.window_label, (frame.bevel_w * 4) +
+ (frame.button_w * 2) + frame.workspace_label_w + 3,
+ frame.bevel_w, frame.window_label_w, frame.label_h);
+ XMoveResizeWindow(display, frame.pwbutton, (frame.bevel_w * 5) +
+ (frame.button_w * 2) + frame.workspace_label_w +
+ frame.window_label_w + 4, frame.bevel_w + 1,
+ frame.button_w, frame.button_w);
+ XMoveResizeWindow(display, frame.nwbutton, (frame.bevel_w * 6) +
+ (frame.button_w * 3) + frame.workspace_label_w +
+ frame.window_label_w + 5, frame.bevel_w + 1,
+ frame.button_w, frame.button_w);
+ XMoveResizeWindow(display, frame.clock, frame.width - frame.clock_w -
+ frame.bevel_w, frame.bevel_w, frame.clock_w,
+ frame.label_h);
+
+ Pixmap tmp = frame.base;
+ BTexture *texture = &(screen.getToolbarStyle()->toolbar);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.base = None;
+ XSetWindowBackground(display, frame.window,
+ texture->getColor()->getPixel());
+ } else {
+ frame.base =
+ image_ctrl->renderImage(frame.width, frame.height, texture);
+ XSetWindowBackgroundPixmap(display, frame.window, frame.base);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ tmp = frame.label;
+ texture = &(screen.getToolbarStyle()->window);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.label = None;
+ XSetWindowBackground(display, frame.window_label,
+ texture->getColor()->getPixel());
+ } else {
+ frame.label =
+ image_ctrl->renderImage(frame.window_label_w, frame.label_h, texture);
+ XSetWindowBackgroundPixmap(display, frame.window_label, frame.label);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ tmp = frame.wlabel;
+ texture = &(screen.getToolbarStyle()->label);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.wlabel = None;
+ XSetWindowBackground(display, frame.workspace_label,
+ texture->getColor()->getPixel());
+ } else {
+ frame.wlabel =
+ image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
+ XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ tmp = frame.clk;
+ texture = &(screen.getToolbarStyle()->clock);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.clk = None;
+ XSetWindowBackground(display, frame.clock,
+ texture->getColor()->getPixel());
+ } else {
+ frame.clk =
+ image_ctrl->renderImage(frame.clock_w, frame.label_h, texture);
+ XSetWindowBackgroundPixmap(display, frame.clock, frame.clk);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ tmp = frame.button;
+ texture = &(screen.getToolbarStyle()->button);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.button = None;
+
+ frame.button_pixel = texture->getColor()->getPixel();
+ XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
+ XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
+ XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
+ XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
+ } else {
+ frame.button =
+ image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
+
+ XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
+ XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
+ XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
+ XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ tmp = frame.pbutton;
+ texture = &(screen.getToolbarStyle()->pressed);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.pbutton = None;
+ frame.pbutton_pixel = texture->getColor()->getPixel();
+ } else {
+ frame.pbutton =
+ image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ XSetWindowBorder(display, frame.window,
+ screen.getBorderColor()->getPixel());
+ XSetWindowBorderWidth(display, frame.window, screen.getBorderWidth());
+
+ XClearWindow(display, frame.window);
+ XClearWindow(display, frame.workspace_label);
+ XClearWindow(display, frame.window_label);
+ XClearWindow(display, frame.clock);
+ XClearWindow(display, frame.psbutton);
+ XClearWindow(display, frame.nsbutton);
+ XClearWindow(display, frame.pwbutton);
+ XClearWindow(display, frame.nwbutton);
+
+ redrawWindowLabel();
+ redrawWorkspaceLabel();
+ redrawPrevWorkspaceButton();
+ redrawNextWorkspaceButton();
+ redrawPrevWindowButton();
+ redrawNextWindowButton();
+ checkClock(True);
+
+ toolbarmenu->reconfigure();
}
#ifdef HAVE_STRFTIME
void Toolbar::checkClock(Bool redraw) {
#else // !HAVE_STRFTIME
-void Toolbar::checkClock(Bool redraw, Bool date) {
+ void Toolbar::checkClock(Bool redraw, Bool date) {
#endif // HAVE_STRFTIME
- time_t tmp = 0;
- struct tm *tt = 0;
-
- if ((tmp = time(NULL)) != -1) {
- if (! (tt = localtime(&tmp))) return;
- if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) {
- frame.hour = tt->tm_hour;
- frame.minute = tt->tm_min;
- XClearWindow(display, frame.clock);
- redraw = True;
+ time_t tmp = 0;
+ struct tm *tt = 0;
+
+ if ((tmp = time(NULL)) != -1) {
+ if (! (tt = localtime(&tmp))) return;
+ if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) {
+ frame.hour = tt->tm_hour;
+ frame.minute = tt->tm_min;
+ XClearWindow(display, frame.clock);
+ redraw = True;
+ }
}
- }
- if (redraw) {
+ if (redraw) {
#ifdef HAVE_STRFTIME
- char t[1024];
- if (! strftime(t, 1024, screen.strftimeFormat(), tt))
- return;
+ char t[1024];
+ if (! strftime(t, 1024, screen.strftimeFormat(), tt))
+ return;
#else // !HAVE_STRFTIME
- char t[9];
- if (date) {
- // format the date... with special consideration for y2k ;)
- if (screen.getDateFormat() == Openbox::B_EuropeanDate)
- sprintf(t, 18n->getMessage(ToolbarSet, ToolbarNoStrftimeDateFormatEu,
- "%02d.%02d.%02d"),
- tt->tm_mday, tt->tm_mon + 1,
- (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
- else
- sprintf(t, i18n->getMessage(ToolbarSet, ToolbarNoStrftimeDateFormat,
- "%02d/%02d/%02d"),
- tt->tm_mon + 1, tt->tm_mday,
- (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
- } else {
- if (screen.isClock24Hour())
- sprintf(t, i18n->getMessage(ToolbarSet, ToolbarNoStrftimeTimeFormat24,
- " %02d:%02d "),
- frame.hour, frame.minute);
- else
- sprintf(t, i18n->getMessage(ToolbarSet, ToolbarNoStrftimeTimeFormat12,
- "%02d:%02d %sm"),
- ((frame.hour > 12) ? frame.hour - 12 :
- ((frame.hour == 0) ? 12 : frame.hour)), frame.minute,
- ((frame.hour >= 12) ?
- i18n->getMessage(ToolbarSet,
- ToolbarNoStrftimeTimeFormatP, "p") :
- i18n->getMessage(ToolbarSet,
- ToolbarNoStrftimeTimeFormatA, "a")));
- }
+ char t[9];
+ if (date) {
+ // format the date... with special consideration for y2k ;)
+ if (screen.getDateFormat() == Openbox::B_EuropeanDate)
+ sprintf(t, 18n->getMessage(ToolbarSet, ToolbarNoStrftimeDateFormatEu,
+ "%02d.%02d.%02d"),
+ tt->tm_mday, tt->tm_mon + 1,
+ (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
+ else
+ sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeDateFormat,
+ "%02d/%02d/%02d"),
+ tt->tm_mon + 1, tt->tm_mday,
+ (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
+ } else {
+ if (screen.isClock24Hour())
+ sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeTimeFormat24,
+ " %02d:%02d "),
+ frame.hour, frame.minute);
+ else
+ sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeTimeFormat12,
+ "%02d:%02d %sm"),
+ ((frame.hour > 12) ? frame.hour - 12 :
+ ((frame.hour == 0) ? 12 : frame.hour)), frame.minute,
+ ((frame.hour >= 12) ?
+ i18n(ToolbarSet,
+ ToolbarNoStrftimeTimeFormatP, "p") :
+ i18n(ToolbarSet,
+ ToolbarNoStrftimeTimeFormatA, "a")));
+ }
#endif // HAVE_STRFTIME
- int dx = (frame.bevel_w * 2), dlen = strlen(t);
- unsigned int l;
+ int dx = (frame.bevel_w * 2), dlen = strlen(t);
+ unsigned int l;
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- t, dlen, &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getToolbarStyle()->font, t, dlen);
- }
-
- l += (frame.bevel_w * 4);
-
- if (l > frame.clock_w) {
- for (; dlen >= 0; dlen--) {
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- t, dlen, &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getToolbarStyle()->font, t, dlen);
- }
- l+= (frame.bevel_w * 4);
-
- if (l < frame.clock_w)
- break;
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ t, dlen, &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getToolbarStyle()->font, t, dlen);
}
- }
- switch (screen.getToolbarStyle()->justify) {
- case BScreen::RightJustify:
- dx += frame.clock_w - l;
- break;
- case BScreen::CenterJustify:
- dx += (frame.clock_w - l) / 2;
- break;
- }
+ l += (frame.bevel_w * 4);
+
+ if (l > frame.clock_w) {
+ for (; dlen >= 0; dlen--) {
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ t, dlen, &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getToolbarStyle()->font, t, dlen);
+ }
+ l+= (frame.bevel_w * 4);
+
+ if (l < frame.clock_w)
+ break;
+ }
+ }
+ switch (screen.getToolbarStyle()->justify) {
+ case BScreen::RightJustify:
+ dx += frame.clock_w - l;
+ break;
+
+ case BScreen::CenterJustify:
+ dx += (frame.clock_w - l) / 2;
+ break;
+ }
- ToolbarStyle *style = screen.getToolbarStyle();
- if (i18n->multibyte())
- XmbDrawString(display, frame.clock, style->fontset, style->c_text_gc,
- dx, (1 - style->fontset_extents->max_ink_extent.y),
- t, dlen);
- else
- XDrawString(display, frame.clock, style->c_text_gc, dx,
- (style->font->ascent + 1), t, dlen);
+ ToolbarStyle *style = screen.getToolbarStyle();
+ if (i18n.multibyte())
+ XmbDrawString(display, frame.clock, style->fontset, style->c_text_gc,
+ dx, (1 - style->fontset_extents->max_ink_extent.y),
+ t, dlen);
+ else
+ XDrawString(display, frame.clock, style->c_text_gc, dx,
+ (style->font->ascent + 1), t, dlen);
+ }
}
-}
-void Toolbar::redrawWindowLabel(Bool redraw) {
- OpenboxWindow *foc = screen.getOpenbox().focusedWindow();
- if (foc == (OpenboxWindow *) 0) {
- XClearWindow(display, frame.window_label);
- } else {
- if (redraw)
+ void Toolbar::redrawWindowLabel(Bool redraw) {
+ OpenboxWindow *foc = screen.getOpenbox().focusedWindow();
+ if (foc == (OpenboxWindow *) 0) {
XClearWindow(display, frame.window_label);
+ } else {
+ if (redraw)
+ XClearWindow(display, frame.window_label);
- if (foc->getScreen() != &screen) return;
+ if (foc->getScreen() != &screen) return;
- int dx = (frame.bevel_w * 2), dlen = strlen(*foc->getTitle());
- unsigned int l;
+ int dx = (frame.bevel_w * 2), dlen = strlen(*foc->getTitle());
+ unsigned int l;
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset, *foc->getTitle(),
- dlen, &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getToolbarStyle()->font, *foc->getTitle(), dlen);
- }
- l += (frame.bevel_w * 4);
-
- if (l > frame.window_label_w) {
- for (; dlen >= 0; dlen--) {
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- *foc->getTitle(), dlen, &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getToolbarStyle()->font,
- *foc->getTitle(), dlen);
- }
- l += (frame.bevel_w * 4);
-
- if (l < frame.window_label_w)
- break;
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset, *foc->getTitle(),
+ dlen, &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getToolbarStyle()->font, *foc->getTitle(), dlen);
+ }
+ l += (frame.bevel_w * 4);
+
+ if (l > frame.window_label_w) {
+ for (; dlen >= 0; dlen--) {
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ *foc->getTitle(), dlen, &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getToolbarStyle()->font,
+ *foc->getTitle(), dlen);
+ }
+ l += (frame.bevel_w * 4);
+
+ if (l < frame.window_label_w)
+ break;
+ }
+ }
+ switch (screen.getToolbarStyle()->justify) {
+ case BScreen::RightJustify:
+ dx += frame.window_label_w - l;
+ break;
+
+ case BScreen::CenterJustify:
+ dx += (frame.window_label_w - l) / 2;
+ break;
}
- }
- switch (screen.getToolbarStyle()->justify) {
- case BScreen::RightJustify:
- dx += frame.window_label_w - l;
- break;
- case BScreen::CenterJustify:
- dx += (frame.window_label_w - l) / 2;
- break;
+ ToolbarStyle *style = screen.getToolbarStyle();
+ if (i18n.multibyte())
+ XmbDrawString(display, frame.window_label, style->fontset,
+ style->w_text_gc, dx,
+ (1 - style->fontset_extents->max_ink_extent.y),
+ *foc->getTitle(), dlen);
+ else
+ XDrawString(display, frame.window_label, style->w_text_gc, dx,
+ (style->font->ascent + 1), *foc->getTitle(), dlen);
}
-
- ToolbarStyle *style = screen.getToolbarStyle();
- if (i18n->multibyte())
- XmbDrawString(display, frame.window_label, style->fontset,
- style->w_text_gc, dx,
- (1 - style->fontset_extents->max_ink_extent.y),
- *foc->getTitle(), dlen);
- else
- XDrawString(display, frame.window_label, style->w_text_gc, dx,
- (style->font->ascent + 1), *foc->getTitle(), dlen);
}
-}
-
-
-void Toolbar::redrawWorkspaceLabel(Bool redraw) {
- if (screen.getCurrentWorkspace()->getName()) {
- if (redraw)
- XClearWindow(display, frame.workspace_label);
-
- int dx = (frame.bevel_w * 2), dlen =
- strlen(screen.getCurrentWorkspace()->getName());
- unsigned int l;
-
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- screen.getCurrentWorkspace()->getName(), dlen,
- &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getToolbarStyle()->font,
- screen.getCurrentWorkspace()->getName(), dlen);
- }
- l += (frame.bevel_w * 4);
-
- if (l > frame.workspace_label_w) {
- for (; dlen >= 0; dlen--) {
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- screen.getCurrentWorkspace()->getName(), dlen,
- &ink, &logical);
- l = logical.width;
- } else {
- l = XTextWidth(screen.getWindowStyle()->font,
- screen.getCurrentWorkspace()->getName(), dlen);
- }
- l += (frame.bevel_w * 4);
-
- if (l < frame.workspace_label_w)
- break;
- }
- }
- switch (screen.getToolbarStyle()->justify) {
- case BScreen::RightJustify:
- dx += frame.workspace_label_w - l;
- break;
- case BScreen::CenterJustify:
- dx += (frame.workspace_label_w - l) / 2;
- break;
- }
- ToolbarStyle *style = screen.getToolbarStyle();
- if (i18n->multibyte())
- XmbDrawString(display, frame.workspace_label, style->fontset,
- style->l_text_gc, dx,
- (1 - style->fontset_extents->max_ink_extent.y),
- (char *) screen.getCurrentWorkspace()->getName(), dlen);
- else
- XDrawString(display, frame.workspace_label, style->l_text_gc, dx,
- (style->font->ascent + 1),
- (char *) screen.getCurrentWorkspace()->getName(), dlen);
- }
-}
+ void Toolbar::redrawWorkspaceLabel(Bool redraw) {
+ if (screen.getCurrentWorkspace()->getName()) {
+ if (redraw)
+ XClearWindow(display, frame.workspace_label);
+ int dx = (frame.bevel_w * 2), dlen =
+ strlen(screen.getCurrentWorkspace()->getName());
+ unsigned int l;
-void Toolbar::redrawPrevWorkspaceButton(Bool pressed, Bool redraw) {
- if (redraw) {
- if (pressed) {
- if (frame.pbutton)
- XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton);
- else
- XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel);
- } else {
- if (frame.button)
- XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ screen.getCurrentWorkspace()->getName(), dlen,
+ &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getToolbarStyle()->font,
+ screen.getCurrentWorkspace()->getName(), dlen);
+ }
+ l += (frame.bevel_w * 4);
+
+ if (l > frame.workspace_label_w) {
+ for (; dlen >= 0; dlen--) {
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ screen.getCurrentWorkspace()->getName(), dlen,
+ &ink, &logical);
+ l = logical.width;
+ } else {
+ l = XTextWidth(screen.getWindowStyle()->font,
+ screen.getCurrentWorkspace()->getName(), dlen);
+ }
+ l += (frame.bevel_w * 4);
+
+ if (l < frame.workspace_label_w)
+ break;
+ }
+ }
+ switch (screen.getToolbarStyle()->justify) {
+ case BScreen::RightJustify:
+ dx += frame.workspace_label_w - l;
+ break;
+
+ case BScreen::CenterJustify:
+ dx += (frame.workspace_label_w - l) / 2;
+ break;
+ }
+
+ ToolbarStyle *style = screen.getToolbarStyle();
+ if (i18n.multibyte())
+ XmbDrawString(display, frame.workspace_label, style->fontset,
+ style->l_text_gc, dx,
+ (1 - style->fontset_extents->max_ink_extent.y),
+ (char *) screen.getCurrentWorkspace()->getName(), dlen);
else
- XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
+ XDrawString(display, frame.workspace_label, style->l_text_gc, dx,
+ (style->font->ascent + 1),
+ (char *) screen.getCurrentWorkspace()->getName(), dlen);
}
- XClearWindow(display, frame.psbutton);
}
- int hh = frame.button_w / 2, hw = frame.button_w / 2;
- XPoint pts[3];
- pts[0].x = hw - 2; pts[0].y = hh;
- pts[1].x = 4; pts[1].y = 2;
- pts[2].x = 0; pts[2].y = -4;
+ void Toolbar::redrawPrevWorkspaceButton(Bool pressed, Bool redraw) {
+ if (redraw) {
+ if (pressed) {
+ if (frame.pbutton)
+ XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton);
+ else
+ XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel);
+ } else {
+ if (frame.button)
+ XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
+ else
+ XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
+ }
+ XClearWindow(display, frame.psbutton);
+ }
- XFillPolygon(display, frame.psbutton, screen.getToolbarStyle()->b_pic_gc,
- pts, 3, Convex, CoordModePrevious);
-}
+ int hh = frame.button_w / 2, hw = frame.button_w / 2;
+ XPoint pts[3];
+ pts[0].x = hw - 2; pts[0].y = hh;
+ pts[1].x = 4; pts[1].y = 2;
+ pts[2].x = 0; pts[2].y = -4;
-void Toolbar::redrawNextWorkspaceButton(Bool pressed, Bool redraw) {
- if (redraw) {
- if (pressed) {
- if (frame.pbutton)
- XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton);
- else
- XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel);
- } else {
- if (frame.button)
- XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
- else
- XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
- }
- XClearWindow(display, frame.nsbutton);
+ XFillPolygon(display, frame.psbutton, screen.getToolbarStyle()->b_pic_gc,
+ pts, 3, Convex, CoordModePrevious);
}
- int hh = frame.button_w / 2, hw = frame.button_w / 2;
- XPoint pts[3];
- pts[0].x = hw - 2; pts[0].y = hh - 2;
- pts[1].x = 4; pts[1].y = 2;
- pts[2].x = -4; pts[2].y = 2;
+ void Toolbar::redrawNextWorkspaceButton(Bool pressed, Bool redraw) {
+ if (redraw) {
+ if (pressed) {
+ if (frame.pbutton)
+ XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton);
+ else
+ XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel);
+ } else {
+ if (frame.button)
+ XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
+ else
+ XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
+ }
+ XClearWindow(display, frame.nsbutton);
+ }
- XFillPolygon(display, frame.nsbutton, screen.getToolbarStyle()->b_pic_gc,
- pts, 3, Convex, CoordModePrevious);
-}
+ int hh = frame.button_w / 2, hw = frame.button_w / 2;
+ XPoint pts[3];
+ pts[0].x = hw - 2; pts[0].y = hh - 2;
+ pts[1].x = 4; pts[1].y = 2;
+ pts[2].x = -4; pts[2].y = 2;
-void Toolbar::redrawPrevWindowButton(Bool pressed, Bool redraw) {
- if (redraw) {
- if (pressed) {
- if (frame.pbutton)
- XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton);
- else
- XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel);
- } else {
- if (frame.button)
- XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
- else
- XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
- }
- XClearWindow(display, frame.pwbutton);
+ XFillPolygon(display, frame.nsbutton, screen.getToolbarStyle()->b_pic_gc,
+ pts, 3, Convex, CoordModePrevious);
}
- int hh = frame.button_w / 2, hw = frame.button_w / 2;
- XPoint pts[3];
- pts[0].x = hw - 2; pts[0].y = hh;
- pts[1].x = 4; pts[1].y = 2;
- pts[2].x = 0; pts[2].y = -4;
+ void Toolbar::redrawPrevWindowButton(Bool pressed, Bool redraw) {
+ if (redraw) {
+ if (pressed) {
+ if (frame.pbutton)
+ XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton);
+ else
+ XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel);
+ } else {
+ if (frame.button)
+ XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
+ else
+ XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
+ }
+ XClearWindow(display, frame.pwbutton);
+ }
- XFillPolygon(display, frame.pwbutton, screen.getToolbarStyle()->b_pic_gc,
- pts, 3, Convex, CoordModePrevious);
-}
+ int hh = frame.button_w / 2, hw = frame.button_w / 2;
+ XPoint pts[3];
+ pts[0].x = hw - 2; pts[0].y = hh;
+ pts[1].x = 4; pts[1].y = 2;
+ pts[2].x = 0; pts[2].y = -4;
-void Toolbar::redrawNextWindowButton(Bool pressed, Bool redraw) {
- if (redraw) {
- if (pressed) {
- if (frame.pbutton)
- XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton);
- else
- XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel);
- } else {
- if (frame.button)
- XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
- else
- XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
- }
- XClearWindow(display, frame.nwbutton);
+ XFillPolygon(display, frame.pwbutton, screen.getToolbarStyle()->b_pic_gc,
+ pts, 3, Convex, CoordModePrevious);
}
- int hh = frame.button_w / 2, hw = frame.button_w / 2;
- XPoint pts[3];
- pts[0].x = hw - 2; pts[0].y = hh - 2;
- pts[1].x = 4; pts[1].y = 2;
- pts[2].x = -4; pts[2].y = 2;
+ void Toolbar::redrawNextWindowButton(Bool pressed, Bool redraw) {
+ if (redraw) {
+ if (pressed) {
+ if (frame.pbutton)
+ XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton);
+ else
+ XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel);
+ } else {
+ if (frame.button)
+ XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
+ else
+ XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
+ }
+ XClearWindow(display, frame.nwbutton);
+ }
- XFillPolygon(display, frame.nwbutton, screen.getToolbarStyle()->b_pic_gc,
- pts, 3, Convex, CoordModePrevious);
-}
+ int hh = frame.button_w / 2, hw = frame.button_w / 2;
+ XPoint pts[3];
+ pts[0].x = hw - 2; pts[0].y = hh - 2;
+ pts[1].x = 4; pts[1].y = 2;
+ pts[2].x = -4; pts[2].y = 2;
-void Toolbar::edit() {
- Window window;
- int foo;
-
- m_editing = True;
- if (XGetInputFocus(display, &window, &foo) &&
- window == frame.workspace_label)
- return;
-
- XSetInputFocus(display, frame.workspace_label,
- RevertToPointerRoot, CurrentTime);
- XClearWindow(display, frame.workspace_label);
-
- openbox.setNoFocus(True);
- if (openbox.focusedWindow())
- openbox.focusedWindow()->setFocusFlag(False);
-
- XDrawRectangle(display, frame.workspace_label,
- screen.getWindowStyle()->l_text_focus_gc,
- frame.workspace_label_w / 2, 0, 1,
- frame.label_h - 1);
-
- // change the background of the window to that of an active window label
- Pixmap tmp = frame.wlabel;
- BTexture *texture = &(screen.getWindowStyle()->l_focus);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.wlabel = None;
- XSetWindowBackground(display, frame.workspace_label,
- texture->getColor()->getPixel());
- } else {
- frame.wlabel =
- image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
- XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
+ XFillPolygon(display, frame.nwbutton, screen.getToolbarStyle()->b_pic_gc,
+ pts, 3, Convex, CoordModePrevious);
}
- if (tmp) image_ctrl->removeImage(tmp);
-}
-void Toolbar::buttonPressEvent(XButtonEvent *be) {
- if (be->button == 1) {
- if (be->window == frame.psbutton)
- redrawPrevWorkspaceButton(True, True);
- else if (be->window == frame.nsbutton)
- redrawNextWorkspaceButton(True, True);
- else if (be->window == frame.pwbutton)
- redrawPrevWindowButton(True, True);
- else if (be->window == frame.nwbutton)
- redrawNextWindowButton(True, True);
-#ifndef HAVE_STRFTIME
- else if (be->window == frame.clock) {
- XClearWindow(display, frame.clock);
- checkClock(True, True);
+ void Toolbar::edit() {
+ Window window;
+ int foo;
+
+ m_editing = True;
+ if (XGetInputFocus(display, &window, &foo) &&
+ window == frame.workspace_label)
+ return;
+
+ XSetInputFocus(display, frame.workspace_label,
+ RevertToPointerRoot, CurrentTime);
+ XClearWindow(display, frame.workspace_label);
+
+ openbox.setNoFocus(True);
+ if (openbox.focusedWindow())
+ openbox.focusedWindow()->setFocusFlag(False);
+
+ XDrawRectangle(display, frame.workspace_label,
+ screen.getWindowStyle()->l_text_focus_gc,
+ frame.workspace_label_w / 2, 0, 1,
+ frame.label_h - 1);
+
+ // change the background of the window to that of an active window label
+ Pixmap tmp = frame.wlabel;
+ BTexture *texture = &(screen.getWindowStyle()->l_focus);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.wlabel = None;
+ XSetWindowBackground(display, frame.workspace_label,
+ texture->getColor()->getPixel());
+ } else {
+ frame.wlabel =
+ image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
+ XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
}
+ if (tmp) image_ctrl->removeImage(tmp);
+ }
+
+
+ void Toolbar::buttonPressEvent(XButtonEvent *be) {
+ if (be->button == 1) {
+ if (be->window == frame.psbutton)
+ redrawPrevWorkspaceButton(True, True);
+ else if (be->window == frame.nsbutton)
+ redrawNextWorkspaceButton(True, True);
+ else if (be->window == frame.pwbutton)
+ redrawPrevWindowButton(True, True);
+ else if (be->window == frame.nwbutton)
+ redrawNextWindowButton(True, True);
+#ifndef HAVE_STRFTIME
+ else if (be->window == frame.clock) {
+ XClearWindow(display, frame.clock);
+ checkClock(True, True);
+ }
#endif // HAVE_STRFTIME
- else if (! m_ontop) {
- Window w[1] = { frame.window };
- screen.raiseWindows(w, 1);
+ else if (! m_ontop) {
+ Window w[1] = { frame.window };
+ screen.raiseWindows(w, 1);
+ }
+ } else if (be->button == 2 && (! m_ontop)) {
+ XLowerWindow(display, frame.window);
+ } else if (be->button == 3) {
+ if (! toolbarmenu->isVisible()) {
+ int x, y;
+
+ x = be->x_root - (toolbarmenu->getWidth() / 2);
+ y = be->y_root - (toolbarmenu->getHeight() / 2);
+
+ if (x < 0)
+ x = 0;
+ else if (x + toolbarmenu->getWidth() > screen.size().w())
+ x = screen.size().w() - toolbarmenu->getWidth();
+
+ if (y < 0)
+ y = 0;
+ else if (y + toolbarmenu->getHeight() > screen.size().h())
+ y = screen.size().h() - toolbarmenu->getHeight();
+
+ toolbarmenu->move(x, y);
+ toolbarmenu->show();
+ } else
+ toolbarmenu->hide();
}
- } else if (be->button == 2 && (! m_ontop)) {
- XLowerWindow(display, frame.window);
- } else if (be->button == 3) {
- if (! toolbarmenu->isVisible()) {
- int x, y;
-
- x = be->x_root - (toolbarmenu->getWidth() / 2);
- y = be->y_root - (toolbarmenu->getHeight() / 2);
-
- if (x < 0)
- x = 0;
- else if (x + toolbarmenu->getWidth() > screen.size().w())
- x = screen.size().w() - toolbarmenu->getWidth();
-
- if (y < 0)
- y = 0;
- else if (y + toolbarmenu->getHeight() > screen.size().h())
- y = screen.size().h() - toolbarmenu->getHeight();
-
- toolbarmenu->move(x, y);
- toolbarmenu->show();
- } else
- toolbarmenu->hide();
}
-}
-
-void Toolbar::buttonReleaseEvent(XButtonEvent *re) {
- if (re->button == 1) {
- if (re->window == frame.psbutton) {
- redrawPrevWorkspaceButton(False, True);
- if (re->x >= 0 && re->x < (signed) frame.button_w &&
- re->y >= 0 && re->y < (signed) frame.button_w)
- if (screen.getCurrentWorkspace()->getWorkspaceID() > 0)
- screen.changeWorkspaceID(screen.getCurrentWorkspace()->
- getWorkspaceID() - 1);
- else
- screen.changeWorkspaceID(screen.getWorkspaceCount() - 1);
- } else if (re->window == frame.nsbutton) {
- redrawNextWorkspaceButton(False, True);
-
- if (re->x >= 0 && re->x < (signed) frame.button_w &&
- re->y >= 0 && re->y < (signed) frame.button_w)
- if (screen.getCurrentWorkspace()->getWorkspaceID() <
- screen.getWorkspaceCount() - 1)
- screen.changeWorkspaceID(screen.getCurrentWorkspace()->
- getWorkspaceID() + 1);
- else
- screen.changeWorkspaceID(0);
- } else if (re->window == frame.pwbutton) {
- redrawPrevWindowButton(False, True);
-
- if (re->x >= 0 && re->x < (signed) frame.button_w &&
- re->y >= 0 && re->y < (signed) frame.button_w)
- screen.prevFocus();
- } else if (re->window == frame.nwbutton) {
- redrawNextWindowButton(False, True);
-
- if (re->x >= 0 && re->x < (signed) frame.button_w &&
- re->y >= 0 && re->y < (signed) frame.button_w)
- screen.nextFocus();
- } else if (re->window == frame.window_label)
- screen.raiseFocus();
+ void Toolbar::buttonReleaseEvent(XButtonEvent *re) {
+ if (re->button == 1) {
+ if (re->window == frame.psbutton) {
+ redrawPrevWorkspaceButton(False, True);
+
+ if (re->x >= 0 && re->x < (signed) frame.button_w &&
+ re->y >= 0 && re->y < (signed) frame.button_w)
+ if (screen.getCurrentWorkspace()->getWorkspaceID() > 0)
+ screen.changeWorkspaceID(screen.getCurrentWorkspace()->
+ getWorkspaceID() - 1);
+ else
+ screen.changeWorkspaceID(screen.getWorkspaceCount() - 1);
+ } else if (re->window == frame.nsbutton) {
+ redrawNextWorkspaceButton(False, True);
+
+ if (re->x >= 0 && re->x < (signed) frame.button_w &&
+ re->y >= 0 && re->y < (signed) frame.button_w)
+ if (screen.getCurrentWorkspace()->getWorkspaceID() <
+ screen.getWorkspaceCount() - 1)
+ screen.changeWorkspaceID(screen.getCurrentWorkspace()->
+ getWorkspaceID() + 1);
+ else
+ screen.changeWorkspaceID(0);
+ } else if (re->window == frame.pwbutton) {
+ redrawPrevWindowButton(False, True);
+
+ if (re->x >= 0 && re->x < (signed) frame.button_w &&
+ re->y >= 0 && re->y < (signed) frame.button_w)
+ screen.prevFocus();
+ } else if (re->window == frame.nwbutton) {
+ redrawNextWindowButton(False, True);
+
+ if (re->x >= 0 && re->x < (signed) frame.button_w &&
+ re->y >= 0 && re->y < (signed) frame.button_w)
+ screen.nextFocus();
+ } else if (re->window == frame.window_label)
+ screen.raiseFocus();
#ifndef HAVE_STRFTIME
- else if (re->window == frame.clock) {
- XClearWindow(display, frame.clock);
- checkClock(True);
- }
+ else if (re->window == frame.clock) {
+ XClearWindow(display, frame.clock);
+ checkClock(True);
+ }
#endif // HAVE_STRFTIME
+ }
}
-}
-void Toolbar::enterNotifyEvent(XCrossingEvent *) {
- if (! m_autohide)
- return;
+ void Toolbar::enterNotifyEvent(XCrossingEvent *) {
+ if (! m_autohide)
+ return;
- if (m_hidden) {
- if (! hide_timer->isTiming()) hide_timer->start();
- } else {
- if (hide_timer->isTiming()) hide_timer->stop();
+ if (m_hidden) {
+ if (! hide_timer->isTiming()) hide_timer->start();
+ } else {
+ if (hide_timer->isTiming()) hide_timer->stop();
+ }
}
-}
-void Toolbar::leaveNotifyEvent(XCrossingEvent *) {
- if (! m_autohide)
- return;
+ void Toolbar::leaveNotifyEvent(XCrossingEvent *) {
+ if (! m_autohide)
+ return;
- if (m_hidden) {
- if (hide_timer->isTiming()) hide_timer->stop();
- } else if (! toolbarmenu->isVisible()) {
- if (! hide_timer->isTiming()) hide_timer->start();
+ if (m_hidden) {
+ if (hide_timer->isTiming()) hide_timer->stop();
+ } else if (! toolbarmenu->isVisible()) {
+ if (! hide_timer->isTiming()) hide_timer->start();
+ }
}
-}
-
-
-void Toolbar::exposeEvent(XExposeEvent *ee) {
- if (ee->window == frame.clock) checkClock(True);
- else if (ee->window == frame.workspace_label && (! m_editing))
- redrawWorkspaceLabel();
- else if (ee->window == frame.window_label) redrawWindowLabel();
- else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton();
- else if (ee->window == frame.nsbutton) redrawNextWorkspaceButton();
- else if (ee->window == frame.pwbutton) redrawPrevWindowButton();
- else if (ee->window == frame.nwbutton) redrawNextWindowButton();
-}
-
-void Toolbar::keyPressEvent(XKeyEvent *ke) {
- if (ke->window == frame.workspace_label && m_editing) {
- openbox.grab();
- if (! new_workspace_name) {
- new_workspace_name = new char[128];
- new_name_pos = 0;
-
- if (! new_workspace_name) return;
- }
+ void Toolbar::exposeEvent(XExposeEvent *ee) {
+ if (ee->window == frame.clock) checkClock(True);
+ else if (ee->window == frame.workspace_label && (! m_editing))
+ redrawWorkspaceLabel();
+ else if (ee->window == frame.window_label) redrawWindowLabel();
+ else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton();
+ else if (ee->window == frame.nsbutton) redrawNextWorkspaceButton();
+ else if (ee->window == frame.pwbutton) redrawPrevWindowButton();
+ else if (ee->window == frame.nwbutton) redrawNextWindowButton();
+ }
- KeySym ks;
- char keychar[1];
- XLookupString(ke, keychar, 1, &ks, 0);
- // either we are told to end with a return or we hit the end of the buffer
- if (ks == XK_Return || new_name_pos == 127) {
- *(new_workspace_name + new_name_pos) = 0;
+ void Toolbar::keyPressEvent(XKeyEvent *ke) {
+ if (ke->window == frame.workspace_label && m_editing) {
+ openbox.grab();
- m_editing = False;
+ if (! new_workspace_name) {
+ new_workspace_name = new char[128];
+ new_name_pos = 0;
- openbox.setNoFocus(False);
- if (openbox.focusedWindow()) {
- openbox.focusedWindow()->setInputFocus();
- openbox.focusedWindow()->setFocusFlag(True);
- } else
- openbox.focusWindow((OpenboxWindow *) 0);
-
- // check to make sure that new_name[0] != 0... otherwise we have a null
- // workspace name which causes serious problems, especially for the
- // Openbox::LoadRC() method.
- if (*new_workspace_name) {
- screen.getCurrentWorkspace()->setName(new_workspace_name);
- screen.getCurrentWorkspace()->getMenu()->hide();
- screen.getWorkspacemenu()->
- remove(screen.getCurrentWorkspace()->getWorkspaceID() + 2);
- screen.getWorkspacemenu()->
- insert(screen.getCurrentWorkspace()->getName(),
- screen.getCurrentWorkspace()->getMenu(),
- screen.getCurrentWorkspace()->getWorkspaceID() + 2);
- screen.getWorkspacemenu()->update();
- }
-
- delete [] new_workspace_name;
- new_workspace_name = (char *) 0;
- new_name_pos = 0;
-
- // reset the background to that of the workspace label (its normal
- // setting)
- Pixmap tmp = frame.wlabel;
- BTexture *texture = &(screen.getToolbarStyle()->label);
- if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
- frame.wlabel = None;
- XSetWindowBackground(display, frame.workspace_label,
- texture->getColor()->getPixel());
- } else {
- frame.wlabel =
- image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
- XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
- }
- if (tmp) image_ctrl->removeImage(tmp);
-
- reconfigure();
- } else if (! (ks == XK_Shift_L || ks == XK_Shift_R ||
- ks == XK_Control_L || ks == XK_Control_R ||
- ks == XK_Caps_Lock || ks == XK_Shift_Lock ||
- ks == XK_Meta_L || ks == XK_Meta_R ||
- ks == XK_Alt_L || ks == XK_Alt_R ||
- ks == XK_Super_L || ks == XK_Super_R ||
- ks == XK_Hyper_L || ks == XK_Hyper_R)) {
- if (ks == XK_BackSpace) {
- if (new_name_pos > 0) {
- --new_name_pos;
- *(new_workspace_name + new_name_pos) = '\0';
- } else {
- *new_workspace_name = '\0';
- }
- } else {
- *(new_workspace_name + new_name_pos) = *keychar;
- ++new_name_pos;
- *(new_workspace_name + new_name_pos) = '\0';
+ if (! new_workspace_name) return;
}
- XClearWindow(display, frame.workspace_label);
- int l = strlen(new_workspace_name), tw, x;
+ KeySym ks;
+ char keychar[1];
+ XLookupString(ke, keychar, 1, &ks, 0);
+
+ // either we are told to end with a return or we hit the end of the buffer
+ if (ks == XK_Return || new_name_pos == 127) {
+ *(new_workspace_name + new_name_pos) = 0;
+
+ m_editing = False;
+
+ openbox.setNoFocus(False);
+ if (openbox.focusedWindow()) {
+ openbox.focusedWindow()->setInputFocus();
+ openbox.focusedWindow()->setFocusFlag(True);
+ } else
+ openbox.focusWindow((OpenboxWindow *) 0);
+
+ // check to make sure that new_name[0] != 0... otherwise we have a null
+ // workspace name which causes serious problems, especially for the
+ // Openbox::LoadRC() method.
+ if (*new_workspace_name) {
+ screen.getCurrentWorkspace()->setName(new_workspace_name);
+ screen.getCurrentWorkspace()->getMenu()->hide();
+ screen.getWorkspacemenu()->
+ remove(screen.getCurrentWorkspace()->getWorkspaceID() + 2);
+ screen.getWorkspacemenu()->
+ insert(screen.getCurrentWorkspace()->getName(),
+ screen.getCurrentWorkspace()->getMenu(),
+ screen.getCurrentWorkspace()->getWorkspaceID() + 2);
+ screen.getWorkspacemenu()->update();
+ }
+
+ delete [] new_workspace_name;
+ new_workspace_name = (char *) 0;
+ new_name_pos = 0;
+
+ // reset the background to that of the workspace label (its normal
+ // setting)
+ Pixmap tmp = frame.wlabel;
+ BTexture *texture = &(screen.getToolbarStyle()->label);
+ if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
+ frame.wlabel = None;
+ XSetWindowBackground(display, frame.workspace_label,
+ texture->getColor()->getPixel());
+ } else {
+ frame.wlabel =
+ image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
+ XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
+ }
+ if (tmp) image_ctrl->removeImage(tmp);
+
+ reconfigure();
+ } else if (! (ks == XK_Shift_L || ks == XK_Shift_R ||
+ ks == XK_Control_L || ks == XK_Control_R ||
+ ks == XK_Caps_Lock || ks == XK_Shift_Lock ||
+ ks == XK_Meta_L || ks == XK_Meta_R ||
+ ks == XK_Alt_L || ks == XK_Alt_R ||
+ ks == XK_Super_L || ks == XK_Super_R ||
+ ks == XK_Hyper_L || ks == XK_Hyper_R)) {
+ if (ks == XK_BackSpace) {
+ if (new_name_pos > 0) {
+ --new_name_pos;
+ *(new_workspace_name + new_name_pos) = '\0';
+ } else {
+ *new_workspace_name = '\0';
+ }
+ } else {
+ *(new_workspace_name + new_name_pos) = *keychar;
+ ++new_name_pos;
+ *(new_workspace_name + new_name_pos) = '\0';
+ }
+
+ XClearWindow(display, frame.workspace_label);
+ int l = strlen(new_workspace_name), tw, x;
+
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen.getToolbarStyle()->fontset,
+ new_workspace_name, l, &ink, &logical);
+ tw = logical.width;
+ } else {
+ tw = XTextWidth(screen.getToolbarStyle()->font,
+ new_workspace_name, l);
+ }
+ x = (frame.workspace_label_w - tw) / 2;
+
+ if (x < (signed) frame.bevel_w) x = frame.bevel_w;
+
+ WindowStyle *style = screen.getWindowStyle();
+ if (i18n.multibyte())
+ XmbDrawString(display, frame.workspace_label, style->fontset,
+ style->l_text_focus_gc, x,
+ (1 - style->fontset_extents->max_ink_extent.y),
+ new_workspace_name, l);
+ else
+ XDrawString(display, frame.workspace_label, style->l_text_focus_gc, x,
+ (style->font->ascent + 1),
+ new_workspace_name, l);
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen.getToolbarStyle()->fontset,
- new_workspace_name, l, &ink, &logical);
- tw = logical.width;
- } else {
- tw = XTextWidth(screen.getToolbarStyle()->font,
- new_workspace_name, l);
+ XDrawRectangle(display, frame.workspace_label,
+ screen.getWindowStyle()->l_text_focus_gc, x + tw, 0, 1,
+ frame.label_h - 1);
}
- x = (frame.workspace_label_w - tw) / 2;
- if (x < (signed) frame.bevel_w) x = frame.bevel_w;
-
- WindowStyle *style = screen.getWindowStyle();
- if (i18n->multibyte())
- XmbDrawString(display, frame.workspace_label, style->fontset,
- style->l_text_focus_gc, x,
- (1 - style->fontset_extents->max_ink_extent.y),
- new_workspace_name, l);
- else
- XDrawString(display, frame.workspace_label, style->l_text_focus_gc, x,
- (style->font->ascent + 1),
- new_workspace_name, l);
-
- XDrawRectangle(display, frame.workspace_label,
- screen.getWindowStyle()->l_text_focus_gc, x + tw, 0, 1,
- frame.label_h - 1);
+ openbox.ungrab();
}
-
- openbox.ungrab();
}
-}
-void Toolbar::timeout() {
- checkClock(True);
+ void Toolbar::timeout() {
+ checkClock(True);
- timeval now;
- gettimeofday(&now, 0);
- clock_timer->setTimeout((60 - (now.tv_sec % 60)) * 1000);
-}
+ timeval now;
+ gettimeofday(&now, 0);
+ clock_timer->setTimeout((60 - (now.tv_sec % 60)) * 1000);
+ }
-void Toolbar::HideHandler::timeout() {
- toolbar->m_hidden = !toolbar->m_hidden;
- if (toolbar->m_hidden)
- XMoveWindow(toolbar->display, toolbar->frame.window,
- toolbar->frame.x_hidden, toolbar->frame.y_hidden);
- else
- XMoveWindow(toolbar->display, toolbar->frame.window,
- toolbar->frame.x, toolbar->frame.y);
-}
+ void Toolbar::HideHandler::timeout() {
+ toolbar->m_hidden = !toolbar->m_hidden;
+ if (toolbar->m_hidden)
+ XMoveWindow(toolbar->display, toolbar->frame.window,
+ toolbar->frame.x_hidden, toolbar->frame.y_hidden);
+ else
+ XMoveWindow(toolbar->display, toolbar->frame.window,
+ toolbar->frame.x, toolbar->frame.y);
+ }
-Toolbarmenu::Toolbarmenu(Toolbar &tb) : Basemenu(tb.screen), toolbar(tb) {
- setLabel(i18n->getMessage(ToolbarSet, ToolbarToolbarTitle, "Toolbar"));
- setInternalMenu();
+ Toolbarmenu::Toolbarmenu(Toolbar &tb) : Basemenu(tb.screen), toolbar(tb) {
+ setLabel(i18n(ToolbarSet, ToolbarToolbarTitle, "Toolbar"));
+ setInternalMenu();
- placementmenu = new Placementmenu(*this);
+ placementmenu = new Placementmenu(*this);
- 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->getMessage(ToolbarSet, ToolbarEditWkspcName,
- "Edit current workspace name"), 3);
+ insert(i18n(CommonSet, CommonPlacementTitle, "Placement"),
+ placementmenu);
+ insert(i18n(CommonSet, CommonAlwaysOnTop, "Always on top"), 1);
+ insert(i18n(CommonSet, CommonAutoHide, "Auto hide"), 2);
+ insert(i18n(ToolbarSet, ToolbarEditWkspcName,
+ "Edit current workspace name"), 3);
- update();
-
- setValues();
-}
+ update();
-void Toolbarmenu::setValues() {
- setItemSelected(1, toolbar.onTop());
- setItemSelected(2, toolbar.autoHide());
-}
+ setValues();
+ }
+
+ void Toolbarmenu::setValues() {
+ setItemSelected(1, toolbar.onTop());
+ setItemSelected(2, toolbar.autoHide());
+ }
-Toolbarmenu::~Toolbarmenu() {
- delete placementmenu;
-}
+ Toolbarmenu::~Toolbarmenu() {
+ delete placementmenu;
+ }
-void Toolbarmenu::itemSelected(int button, int index) {
- if (button != 1)
- return;
+ void Toolbarmenu::itemSelected(int button, int index) {
+ if (button != 1)
+ return;
- BasemenuItem *item = find(index);
- if (! item) return;
+ BasemenuItem *item = find(index);
+ if (! item) return;
- switch (item->function()) {
- case 1: { // always on top
- Bool change = ((toolbar.onTop()) ? False : True);
- toolbar.setOnTop(change);
- setItemSelected(1, change);
+ switch (item->function()) {
+ case 1: { // always on top
+ Bool change = ((toolbar.onTop()) ? False : True);
+ toolbar.setOnTop(change);
+ setItemSelected(1, change);
- if (toolbar.onTop()) toolbar.screen.raiseWindows((Window *) 0, 0);
- break;
- }
+ if (toolbar.onTop()) toolbar.screen.raiseWindows((Window *) 0, 0);
+ break;
+ }
- case 2: { // auto hide
- Bool change = ((toolbar.autoHide()) ? False : True);
- toolbar.setAutoHide(change);
- setItemSelected(2, change);
+ case 2: { // auto hide
+ Bool change = ((toolbar.autoHide()) ? False : True);
+ toolbar.setAutoHide(change);
+ setItemSelected(2, change);
#ifdef SLIT
- toolbar.screen.getSlit()->reposition();
+ toolbar.screen.getSlit()->reposition();
#endif // SLIT
- break;
- }
+ break;
+ }
- case 3: { // edit current workspace name
- toolbar.edit();
- hide();
+ case 3: { // edit current workspace name
+ toolbar.edit();
+ hide();
- break;
+ break;
+ }
+ } // switch
}
- } // switch
-}
-void Toolbarmenu::internal_hide() {
- Basemenu::internal_hide();
- if (toolbar.autoHide() && ! toolbar.isEditing())
- toolbar.hide_handler.timeout();
-}
+ void Toolbarmenu::internal_hide() {
+ Basemenu::internal_hide();
+ if (toolbar.autoHide() && ! toolbar.isEditing())
+ toolbar.hide_handler.timeout();
+ }
-void Toolbarmenu::reconfigure() {
- setValues();
- placementmenu->reconfigure();
+ void Toolbarmenu::reconfigure() {
+ setValues();
+ placementmenu->reconfigure();
- Basemenu::reconfigure();
-}
+ Basemenu::reconfigure();
+ }
-Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
- : Basemenu(tm.toolbar.screen), toolbarmenu(tm) {
- setLabel(i18n->getMessage(ToolbarSet, ToolbarToolbarPlacement,
- "Toolbar Placement"));
- setInternalMenu();
- setMinimumSublevels(3);
-
- insert(i18n->getMessage(CommonSet, CommonPlacementTopLeft,
- "Top Left"), Toolbar::TopLeft);
- insert(i18n->getMessage(CommonSet, CommonPlacementBottomLeft,
- "Bottom Left"), Toolbar::BottomLeft);
- insert(i18n->getMessage(CommonSet, CommonPlacementTopCenter,
- "Top Center"), Toolbar::TopCenter);
- insert(i18n->getMessage(CommonSet, CommonPlacementBottomCenter,
- "Bottom Center"), Toolbar::BottomCenter);
- insert(i18n->getMessage(CommonSet, CommonPlacementTopRight,
- "Top Right"), Toolbar::TopRight);
- insert(i18n->getMessage(CommonSet, CommonPlacementBottomRight,
- "Bottom Right"), Toolbar::BottomRight);
- update();
-}
+ Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu &tm)
+ : Basemenu(tm.toolbar.screen), toolbarmenu(tm) {
+ setLabel(i18n(ToolbarSet, ToolbarToolbarPlacement,
+ "Toolbar Placement"));
+ setInternalMenu();
+ setMinimumSublevels(3);
+
+ insert(i18n(CommonSet, CommonPlacementTopLeft,
+ "Top Left"), Toolbar::TopLeft);
+ insert(i18n(CommonSet, CommonPlacementBottomLeft,
+ "Bottom Left"), Toolbar::BottomLeft);
+ insert(i18n(CommonSet, CommonPlacementTopCenter,
+ "Top Center"), Toolbar::TopCenter);
+ insert(i18n(CommonSet, CommonPlacementBottomCenter,
+ "Bottom Center"), Toolbar::BottomCenter);
+ insert(i18n(CommonSet, CommonPlacementTopRight,
+ "Top Right"), Toolbar::TopRight);
+ insert(i18n(CommonSet, CommonPlacementBottomRight,
+ "Bottom Right"), Toolbar::BottomRight);
+ update();
+ }
-void Toolbarmenu::Placementmenu::itemSelected(int button, int index) {
- if (button != 1)
- return;
+ void Toolbarmenu::Placementmenu::itemSelected(int button, int index) {
+ if (button != 1)
+ return;
- BasemenuItem *item = find(index);
- if (! item) return;
+ BasemenuItem *item = find(index);
+ if (! item) return;
- toolbarmenu.toolbar.setPlacement(item->function());
- hide();
- toolbarmenu.toolbar.reconfigure();
+ toolbarmenu.toolbar.setPlacement(item->function());
+ hide();
+ toolbarmenu.toolbar.reconfigure();
#ifdef SLIT
- // reposition the slit as well to make sure it doesn't intersect the
- // toolbar
- toolbarmenu.toolbar.screen.getSlit()->reposition();
+ // reposition the slit as well to make sure it doesn't intersect the
+ // toolbar
+ toolbarmenu.toolbar.screen.getSlit()->reposition();
#endif // SLIT
-}
+ }
*/
OpenboxWindow::OpenboxWindow(Openbox &o, Window w, BScreen *s) : openbox(o) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(WindowSet, WindowCreating,
- "OpenboxWindow::OpenboxWindow(): creating 0x%lx\n"),
- w);
+ fprintf(stderr, i18n(WindowSet, WindowCreating,
+ "OpenboxWindow::OpenboxWindow(): creating 0x%lx\n"),
+ w);
#endif // DEBUG
client.window = w;
(! wattrib.screen) || wattrib.override_redirect) {
#ifdef DEBUG
fprintf(stderr,
- i18n->getMessage(WindowSet, WindowXGetWindowAttributesFail,
- "OpenboxWindow::OpenboxWindow(): XGetWindowAttributes "
- "failed\n"));
+ i18n(WindowSet, WindowXGetWindowAttributesFail,
+ "OpenboxWindow::OpenboxWindow(): XGetWindowAttributes "
+ "failed\n"));
#endif // DEBUG
openbox.ungrab();
screen = openbox.searchScreen(RootWindowOfScreen(wattrib.screen));
if (! screen) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(WindowSet, WindowCannotFindScreen,
- "OpenboxWindow::OpenboxWindow(): can't find screen\n"
- "\tfor root window 0x%lx\n"),
- RootWindowOfScreen(wattrib.screen));
+ fprintf(stderr, i18n(WindowSet, WindowCannotFindScreen,
+ "OpenboxWindow::OpenboxWindow(): can't find screen\n"
+ "\tfor root window 0x%lx\n"),
+ RootWindowOfScreen(wattrib.screen));
#endif // DEBUG
openbox.ungrab();
if (win && (win != client.window)) {
OpenboxWindow *tr;
if ((tr = openbox.searchWindow(win))) {
- while (tr->client.transient) tr = tr->client.transient;
- client.transient_for = tr;
- tr->client.transient = this;
- flags.stuck = client.transient_for->flags.stuck;
- flags.transient = True;
+ while (tr->client.transient) tr = tr->client.transient;
+ client.transient_for = tr;
+ tr->client.transient = this;
+ flags.stuck = client.transient_for->flags.stuck;
+ flags.transient = True;
} else if (win == client.window_group) {
- if ((tr = openbox.searchGroup(win, this))) {
- while (tr->client.transient) tr = tr->client.transient;
- client.transient_for = tr;
- tr->client.transient = this;
- flags.stuck = client.transient_for->flags.stuck;
- flags.transient = True;
- }
+ if ((tr = openbox.searchGroup(win, this))) {
+ while (tr->client.transient) tr = tr->client.transient;
+ client.transient_for = tr;
+ tr->client.transient = this;
+ flags.stuck = client.transient_for->flags.stuck;
+ flags.transient = True;
+ }
}
}
if ((client.normal_hint_flags & PMinSize) &&
(client.normal_hint_flags & PMaxSize) &&
- client.max_width <= client.min_width &&
+ client.max_width <= client.min_width &&
client.max_height <= client.min_height) {
decorations.maximize = decorations.handle =
functions.resize = functions.maximize = False;
setGravityOffsets();
if ((openbox.isStartup()) ||
- (frame.x >= 0 &&
- (signed) (frame.y + frame.y_border) >= 0 &&
- frame.x <= (signed) screen->size().w() &&
- frame.y <= (signed) screen->size().h()))
+ (frame.x >= 0 &&
+ (signed) (frame.y + frame.y_border) >= 0 &&
+ frame.x <= (signed) screen->size().w() &&
+ frame.y <= (signed) screen->size().h()))
place_window = false;
}
frame.window = createToplevelWindow(frame.x, frame.y, frame.width,
- frame.height,
- frame.border_w);
+ frame.height,
+ frame.border_w);
openbox.saveWindowSearch(frame.window, this);
frame.plate = createChildWindow(frame.window);
if (! screen->sloppyFocus())
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
- GrabModeSync, GrabModeSync, frame.plate, None);
+ GrabModeSync, GrabModeSync, frame.plate, None);
openbox.grabButton(Button1, Mod1Mask, frame.window, True,
- ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
- GrabModeAsync, frame.window, openbox.getMoveCursor());
+ ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
+ GrabModeAsync, frame.window, openbox.getMoveCursor());
openbox.grabButton(Button2, Mod1Mask, frame.window, True,
- ButtonReleaseMask, GrabModeAsync, GrabModeAsync, frame.window, None);
+ ButtonReleaseMask, GrabModeAsync, GrabModeAsync, frame.window, None);
openbox.grabButton(Button3, Mod1Mask, frame.window, True,
- ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
- GrabModeAsync, frame.window, None);
+ ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
+ GrabModeAsync, frame.window, None);
positionWindows();
XRaiseWindow(display, frame.plate);
* Returns: the newly created window
*/
Window OpenboxWindow::createToplevelWindow(int x, int y, unsigned int width,
- unsigned int height,
- unsigned int borderwidth)
+ unsigned int height,
+ unsigned int borderwidth)
{
XSetWindowAttributes attrib_create;
unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWColormap |
- CWOverrideRedirect | CWEventMask;
+ CWOverrideRedirect | CWEventMask;
attrib_create.background_pixmap = None;
attrib_create.colormap = screen->getColormap();
attrib_create.override_redirect = True;
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | EnterWindowMask;
+ ButtonMotionMask | EnterWindowMask;
return XCreateWindow(display, screen->getRootWindow(), x, y, width, height,
- borderwidth, screen->getDepth(), InputOutput,
- screen->getVisual(), create_mask,
- &attrib_create);
+ borderwidth, screen->getDepth(), InputOutput,
+ screen->getVisual(), create_mask,
+ &attrib_create);
}
Window OpenboxWindow::createChildWindow(Window parent, Cursor cursor) {
XSetWindowAttributes attrib_create;
unsigned long create_mask = CWBackPixmap | CWBorderPixel |
- CWEventMask;
+ CWEventMask;
attrib_create.background_pixmap = None;
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | ExposureMask |
- EnterWindowMask | LeaveWindowMask;
+ ButtonMotionMask | ExposureMask |
+ EnterWindowMask | LeaveWindowMask;
if (cursor) {
create_mask |= CWCursor;
}
return XCreateWindow(display, parent, 0, 0, 1, 1, 0, screen->getDepth(),
- InputOutput, screen->getVisual(), create_mask,
- &attrib_create);
+ InputOutput, screen->getVisual(), create_mask,
+ &attrib_create);
}
XFlush(display);
attrib_set.event_mask = PropertyChangeMask | StructureNotifyMask |
- FocusChangeMask;
+ FocusChangeMask;
attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask;
+ ButtonMotionMask;
XChangeWindowAttributes(display, client.window, CWEventMask|CWDontPropagate,
&attrib_set);
unsigned int ufoo;
XShapeQueryExtents(display, client.window, &flags.shaped, &foo, &foo,
- &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo);
+ &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo);
if (flags.shaped) {
XShapeCombineShape(display, frame.window, ShapeBounding,
- frame.mwm_border_w, frame.y_border +
- frame.mwm_border_w, client.window,
- ShapeBounding, ShapeSet);
+ frame.mwm_border_w, frame.y_border +
+ frame.mwm_border_w, client.window,
+ ShapeBounding, ShapeSet);
int num = 1;
XRectangle xrect[2];
xrect[0].height = frame.y_border;
if (decorations.handle) {
- xrect[1].x = 0;
- xrect[1].y = frame.y_handle;
- xrect[1].width = frame.width;
- xrect[1].height = frame.handle_h + frame.border_w;
- num++;
+ xrect[1].x = 0;
+ xrect[1].y = frame.y_handle;
+ xrect[1].width = frame.width;
+ xrect[1].height = frame.handle_h + frame.border_w;
+ num++;
}
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
- xrect, num, ShapeUnion, Unsorted);
+ xrect, num, ShapeUnion, Unsorted);
}
}
#endif // SHAPE
if (!decorations.iconify)
bcount--;
frame.label_w = frame.width - bx * 2 - (frame.button_w + bw) * bcount;
-
+
bool hasclose, hasiconify, hasmaximize;
hasclose = hasiconify = hasmaximize = false;
-
+
for (int i = 0; format[i] != '\0' && i < 4; i++) {
switch(format[i]) {
case 'C':
client.x = frame.x + frame.mwm_border_w + frame.border_w;
client.y = frame.y + frame.y_border + frame.mwm_border_w +
- frame.border_w;
+ frame.border_w;
if (client.title) {
- if (i18n->multibyte()) {
+ if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen->getWindowStyle()->fontset,
- client.title, client.title_len, &ink, &logical);
+ client.title, client.title_len, &ink, &logical);
client.title_text_w = logical.width;
} else {
client.title_text_w = XTextWidth(screen->getWindowStyle()->font,
- client.title, client.title_len);
+ client.title, client.title_len);
}
client.title_text_w += (frame.bevel_w * 4);
}
if (! screen->sloppyFocus())
openbox.grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
- GrabModeSync, GrabModeSync, None, None);
+ GrabModeSync, GrabModeSync, None, None);
else
openbox.ungrabButton(Button1, 0, frame.plate);
windowmenu->move(windowmenu->getX(), frame.y + frame.title_h);
windowmenu->reconfigure();
}
-
+
// re-get the timeout delay
timer->setTimeout(openbox.getAutoRaiseDelay());
}
if (decorations.titlebar) {
XSetWindowBorderWidth(display, frame.title, frame.border_w);
XMoveResizeWindow(display, frame.title, -frame.border_w,
- -frame.border_w, frame.width, frame.title_h);
+ -frame.border_w, frame.width, frame.title_h);
positionButtons();
} else if (frame.title) {
XMoveResizeWindow(display, frame.handle, -frame.border_w,
frame.y_handle - frame.border_w,
- frame.width, frame.handle_h);
+ frame.width, frame.handle_h);
XMoveResizeWindow(display, frame.left_grip, -frame.border_w,
- -frame.border_w, frame.grip_w, frame.grip_h);
+ -frame.border_w, frame.grip_w, frame.grip_h);
XMoveResizeWindow(display, frame.right_grip,
- frame.width - frame.grip_w - frame.border_w,
+ frame.width - frame.grip_w - frame.border_w,
-frame.border_w, frame.grip_w, frame.grip_h);
XMapSubwindows(display, frame.handle);
} else if (frame.handle) {
if (XGetWMName(display, client.window, &text_prop)) {
if (text_prop.value && text_prop.nitems > 0) {
if (text_prop.encoding != XA_STRING) {
- text_prop.nitems = strlen((char *) text_prop.value);
-
- if ((XmbTextPropertyToTextList(display, &text_prop,
- &list, &num) == Success) &&
- (num > 0) && *list) {
- client.title = bstrdup(*list);
- XFreeStringList(list);
- } else {
- client.title = bstrdup((char *) text_prop.value);
- }
+ text_prop.nitems = strlen((char *) text_prop.value);
+
+ if ((XmbTextPropertyToTextList(display, &text_prop,
+ &list, &num) == Success) &&
+ (num > 0) && *list) {
+ client.title = bstrdup(*list);
+ XFreeStringList(list);
+ } else {
+ client.title = bstrdup((char *) text_prop.value);
+ }
} else {
- client.title = bstrdup((char *) text_prop.value);
+ client.title = bstrdup((char *) text_prop.value);
}
XFree((char *) text_prop.value);
} else {
- client.title = bstrdup(i18n->getMessage(WindowSet, WindowUnnamed,
- "Unnamed"));
+ client.title = bstrdup(i18n(WindowSet, WindowUnnamed,
+ "Unnamed"));
}
} else {
- client.title = bstrdup(i18n->getMessage(WindowSet, WindowUnnamed,
- "Unnamed"));
+ client.title = bstrdup(i18n(WindowSet, WindowUnnamed,
+ "Unnamed"));
}
client.title_len = strlen(client.title);
- if (i18n->multibyte()) {
+ if (i18n.multibyte()) {
XRectangle ink, logical;
XmbTextExtents(screen->getWindowStyle()->fontset,
- client.title, client.title_len, &ink, &logical);
+ client.title, client.title_len, &ink, &logical);
client.title_text_w = logical.width;
} else {
client.title_len = strlen(client.title);
client.title_text_w = XTextWidth(screen->getWindowStyle()->font,
- client.title, client.title_len);
+ client.title, client.title_len);
}
client.title_text_w += (frame.bevel_w * 4);
if (XGetWMIconName(display, client.window, &text_prop)) {
if (text_prop.value && text_prop.nitems > 0) {
if (text_prop.encoding != XA_STRING) {
- text_prop.nitems = strlen((char *) text_prop.value);
-
- if ((XmbTextPropertyToTextList(display, &text_prop,
- &list, &num) == Success) &&
- (num > 0) && *list) {
- client.icon_title = bstrdup(*list);
- XFreeStringList(list);
- } else {
- client.icon_title = bstrdup((char *) text_prop.value);
- }
+ text_prop.nitems = strlen((char *) text_prop.value);
+
+ if ((XmbTextPropertyToTextList(display, &text_prop,
+ &list, &num) == Success) &&
+ (num > 0) && *list) {
+ client.icon_title = bstrdup(*list);
+ XFreeStringList(list);
+ } else {
+ client.icon_title = bstrdup((char *) text_prop.value);
+ }
} else {
- client.icon_title = bstrdup((char *) text_prop.value);
+ client.icon_title = bstrdup((char *) text_prop.value);
}
XFree((char *) text_prop.value);
} else {
if (XGetWMProtocols(display, client.window, &proto, &num_return)) {
for (int i = 0; i < num_return; ++i) {
if (proto[i] == openbox.getWMDeleteAtom())
- functions.close = decorations.close = True;
+ functions.close = decorations.close = True;
else if (proto[i] == openbox.getWMTakeFocusAtom())
flags.send_focus_message = True;
else if (proto[i] == openbox.getOpenboxStructureMessagesAtom())
if (wmhint->flags & InputHint) {
if (wmhint->input == True) {
if (flags.send_focus_message)
- focus_mode = F_LocallyActive;
+ focus_mode = F_LocallyActive;
else
- focus_mode = F_Passive;
+ focus_mode = F_Passive;
} else {
if (flags.send_focus_message)
- focus_mode = F_GloballyActive;
+ focus_mode = F_GloballyActive;
else
- focus_mode = F_NoInput;
+ focus_mode = F_NoInput;
}
} else {
focus_mode = F_Passive;
unsigned long num, len;
int ret = XGetWindowProperty(display, client.window,
- openbox.getMotifWMHintsAtom(), 0,
- PropMwmHintsElements, False,
- openbox.getMotifWMHintsAtom(), &atom_return,
- &format, &num, &len,
- (unsigned char **) &client.mwm_hint);
+ openbox.getMotifWMHintsAtom(), 0,
+ PropMwmHintsElements, False,
+ openbox.getMotifWMHintsAtom(), &atom_return,
+ &format, &num, &len,
+ (unsigned char **) &client.mwm_hint);
if (ret != Success || !client.mwm_hint || num != PropMwmHintsElements)
return;
if (client.mwm_hint->flags & MwmHintsDecorations) {
if (client.mwm_hint->decorations & MwmDecorAll) {
decorations.titlebar = decorations.handle = decorations.border =
- decorations.iconify = decorations.maximize =
- decorations.close = decorations.menu = True;
+ decorations.iconify = decorations.maximize =
+ decorations.close = decorations.menu = True;
} else {
decorations.titlebar = decorations.handle = decorations.border =
- decorations.iconify = decorations.maximize =
- decorations.close = decorations.menu = False;
+ decorations.iconify = decorations.maximize =
+ decorations.close = decorations.menu = False;
if (client.mwm_hint->decorations & MwmDecorBorder)
- decorations.border = True;
+ decorations.border = True;
if (client.mwm_hint->decorations & MwmDecorHandle)
- decorations.handle = True;
+ decorations.handle = True;
if (client.mwm_hint->decorations & MwmDecorTitle)
- decorations.titlebar = True;
+ decorations.titlebar = True;
if (client.mwm_hint->decorations & MwmDecorMenu)
- decorations.menu = True;
+ decorations.menu = True;
if (client.mwm_hint->decorations & MwmDecorIconify)
- decorations.iconify = True;
+ decorations.iconify = True;
if (client.mwm_hint->decorations & MwmDecorMaximize)
- decorations.maximize = True;
+ decorations.maximize = True;
}
}
if (client.mwm_hint->flags & MwmHintsFunctions) {
if (client.mwm_hint->functions & MwmFuncAll) {
functions.resize = functions.move = functions.iconify =
- functions.maximize = functions.close = True;
+ functions.maximize = functions.close = True;
} else {
functions.resize = functions.move = functions.iconify =
- functions.maximize = functions.close = False;
+ functions.maximize = functions.close = False;
if (client.mwm_hint->functions & MwmFuncResize)
- functions.resize = True;
+ functions.resize = True;
if (client.mwm_hint->functions & MwmFuncMove)
- functions.move = True;
+ functions.move = True;
if (client.mwm_hint->functions & MwmFuncIconify)
- functions.iconify = True;
+ functions.iconify = True;
if (client.mwm_hint->functions & MwmFuncMaximize)
- functions.maximize = True;
+ functions.maximize = True;
if (client.mwm_hint->functions & MwmFuncClose)
- functions.close = True;
+ functions.close = True;
}
}
}
unsigned long num, len;
int ret = XGetWindowProperty(display, client.window,
- openbox.getOpenboxHintsAtom(), 0,
- PropOpenboxHintsElements, False,
- openbox.getOpenboxHintsAtom(), &atom_return,
- &format, &num, &len,
- (unsigned char **) &client.openbox_hint);
+ openbox.getOpenboxHintsAtom(), 0,
+ PropOpenboxHintsElements, False,
+ openbox.getOpenboxHintsAtom(), &atom_return,
+ &format, &num, &len,
+ (unsigned char **) &client.openbox_hint);
if (ret != Success || !client.openbox_hint ||
num != PropOpenboxHintsElements)
return;
if ((client.openbox_hint->flags & AttribMaxHoriz) &&
(client.openbox_hint->flags & AttribMaxVert))
flags.maximized = (client.openbox_hint->attrib &
- (AttribMaxHoriz | AttribMaxVert)) ? 1 : 0;
+ (AttribMaxHoriz | AttribMaxVert)) ? 1 : 0;
else if (client.openbox_hint->flags & AttribMaxVert)
flags.maximized = (client.openbox_hint->attrib & AttribMaxVert) ? 2 : 0;
else if (client.openbox_hint->flags & AttribMaxHoriz)
switch (client.openbox_hint->decoration) {
case DecorNone:
decorations.titlebar = decorations.border = decorations.handle =
- decorations.iconify = decorations.maximize =
- decorations.menu = False;
+ decorations.iconify = decorations.maximize =
+ decorations.menu = False;
functions.resize = functions.move = functions.iconify =
- functions.maximize = False;
+ functions.maximize = False;
break;
case DecorTiny:
decorations.titlebar = decorations.iconify = decorations.menu =
- functions.move = functions.iconify = True;
+ functions.move = functions.iconify = True;
decorations.border = decorations.handle = decorations.maximize =
- functions.resize = functions.maximize = False;
+ functions.resize = functions.maximize = False;
break;
case DecorTool:
decorations.titlebar = decorations.menu = functions.move = True;
decorations.iconify = decorations.border = decorations.handle =
- decorations.maximize = functions.resize = functions.maximize =
- functions.iconify = False;
+ decorations.maximize = functions.resize = functions.maximize =
+ functions.iconify = False;
break;
case DecorNormal:
default:
decorations.titlebar = decorations.border = decorations.handle =
- decorations.iconify = decorations.maximize =
- decorations.menu = True;
+ decorations.iconify = decorations.maximize =
+ decorations.menu = True;
functions.resize = functions.move = functions.iconify =
- functions.maximize = True;
+ functions.maximize = True;
break;
}
void OpenboxWindow::configure(int dx, int dy,
- unsigned int dw, unsigned int dh) {
+ unsigned int dw, unsigned int dh) {
Bool send_event = (frame.x != dx || frame.y != dy);
if ((dw != frame.width) || (dh != frame.height)) {
#ifdef SHAPE
if (openbox.hasShapeExtensions() && flags.shaped) {
XShapeCombineShape(display, frame.window, ShapeBounding,
- frame.mwm_border_w, frame.y_border +
- frame.mwm_border_w, client.window,
- ShapeBounding, ShapeSet);
+ frame.mwm_border_w, frame.y_border +
+ frame.mwm_border_w, client.window,
+ ShapeBounding, ShapeSet);
int num = 1;
XRectangle xrect[2];
xrect[0].height = frame.y_border;
if (decorations.handle) {
- xrect[1].x = 0;
- xrect[1].y = frame.y_handle;
- xrect[1].width = frame.width;
- xrect[1].height = frame.handle_h + frame.border_w;
- num++;
+ xrect[1].x = 0;
+ xrect[1].y = frame.y_handle;
+ xrect[1].width = frame.width;
+ xrect[1].height = frame.handle_h + frame.border_w;
+ num++;
}
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
- xrect, num, ShapeUnion, Unsorted);
+ xrect, num, ShapeUnion, Unsorted);
}
#endif // SHAPE
if (send_event && ! flags.moving) {
client.x = dx + frame.mwm_border_w + frame.border_w;
client.y = dy + frame.y_border + frame.mwm_border_w +
- frame.border_w;
+ frame.border_w;
XEvent event;
event.type = ConfigureNotify;
frame.width, frame.height);
else if (frame.y > (signed) screen->size().h())
configure(screen->size().w() - frame.width,
- screen->size().h() - frame.height, frame.width, frame.height);
+ screen->size().h() - frame.height, frame.width, frame.height);
else
configure(screen->size().w() - frame.width,
frame.y + frame.border_w, frame.width, frame.height);
} else if (! flags.focused) {
if (focus_mode == F_LocallyActive || focus_mode == F_Passive) {
XSetInputFocus(display, client.window,
- RevertToPointerRoot, CurrentTime);
+ RevertToPointerRoot, CurrentTime);
openbox.focusWindow(this);
if (flags.send_focus_message) {
&r, &c, &rx, &ry, &x, &y, &m);
startMove(rx, ry);
}
-
+
if (flags.iconic && screen->focusNew()) setInputFocus();
flags.visible = True;
void OpenboxWindow::maximize(unsigned int button) {
if (flags.moving)
endMove();
-
+
// handle case where menu is open then the max button is used instead
if (windowmenu && windowmenu->isVisible()) windowmenu->hide();
// so we do not need to call configure() because resizing will handle it
if (!flags.resizing)
configure(openbox_attrib.premax_x, openbox_attrib.premax_y,
- openbox_attrib.premax_w, openbox_attrib.premax_h);
+ openbox_attrib.premax_w, openbox_attrib.premax_h);
openbox_attrib.premax_x = openbox_attrib.premax_y = 0;
openbox_attrib.premax_w = openbox_attrib.premax_h = 0;
Rect space = screen->availableArea();
unsigned int dw = space.w(),
- dh = space.h();
+ dh = space.h();
dw -= frame.border_w * 2;
dw -= frame.mwm_border_w * 2;
dw -= client.base_width;
dh += frame.mwm_border_w * 2;
int dx = space.x() + ((space.w() - dw) / 2) - frame.border_w,
- dy = space.y() + ((space.h() - dh) / 2) - frame.border_w;
+ dy = space.y() + ((space.h() - dh) / 2) - frame.border_w;
switch(button) {
case 1:
if (cmaps) {
if (XGetWindowAttributes(display, client.window, &wattrib)) {
if (install) {
- // install the window's colormap
- for (i = 0; i < ncmap; i++) {
- if (*(cmaps + i) == wattrib.colormap)
- // this window is using an installed color map... do not install
- install = False;
- }
- // otherwise, install the window's colormap
- if (install)
- XInstallColormap(display, wattrib.colormap);
+ // install the window's colormap
+ for (i = 0; i < ncmap; i++) {
+ if (*(cmaps + i) == wattrib.colormap)
+ // this window is using an installed color map... do not install
+ install = False;
+ }
+ // otherwise, install the window's colormap
+ if (install)
+ XInstallColormap(display, wattrib.colormap);
} else {
- // uninstall the window's colormap
- for (i = 0; i < ncmap; i++) {
- if (*(cmaps + i) == wattrib.colormap)
- // we found the colormap to uninstall
- XUninstallColormap(display, wattrib.colormap);
- }
+ // uninstall the window's colormap
+ for (i = 0; i < ncmap; i++) {
+ if (*(cmaps + i) == wattrib.colormap)
+ // we found the colormap to uninstall
+ XUninstallColormap(display, wattrib.colormap);
+ }
}
}
state[0] = (unsigned long) current_state;
state[1] = (unsigned long) None;
XChangeProperty(display, client.window, openbox.getWMStateAtom(),
- openbox.getWMStateAtom(), 32, PropModeReplace,
- (unsigned char *) state, 2);
+ openbox.getWMStateAtom(), 32, PropModeReplace,
+ (unsigned char *) state, 2);
XChangeProperty(display, client.window,
- openbox.getOpenboxAttributesAtom(),
+ openbox.getOpenboxAttributesAtom(),
openbox.getOpenboxAttributesAtom(), 32, PropModeReplace,
(unsigned char *) &openbox_attrib,
- PropOpenboxAttributesElements);
+ PropOpenboxAttributesElements);
}
unsigned long *state, ulfoo, nitems;
if ((XGetWindowProperty(display, client.window, openbox.getWMStateAtom(),
- 0l, 2l, False, openbox.getWMStateAtom(),
- &atom_return, &foo, &nitems, &ulfoo,
- (unsigned char **) &state) != Success) ||
+ 0l, 2l, False, openbox.getWMStateAtom(),
+ &atom_return, &foo, &nitems, &ulfoo,
+ (unsigned char **) &state) != Success) ||
(! state)) {
openbox.ungrab();
return False;
OpenboxAttributes *net;
int ret = XGetWindowProperty(display, client.window,
- openbox.getOpenboxAttributesAtom(), 0l,
- PropOpenboxAttributesElements, False,
- openbox.getOpenboxAttributesAtom(),
- &atom_return, &foo, &nitems, &ulfoo,
- (unsigned char **) &net);
+ openbox.getOpenboxAttributesAtom(), 0l,
+ PropOpenboxAttributesElements, False,
+ openbox.getOpenboxAttributesAtom(),
+ &atom_return, &foo, &nitems, &ulfoo,
+ (unsigned char **) &net);
if (ret != Success || !net || nitems != PropOpenboxAttributesElements)
return;
if (client.title_text_w > frame.label_w) {
for (; dlen >= 0; dlen--) {
- if (i18n->multibyte()) {
- XRectangle ink, logical;
- XmbTextExtents(screen->getWindowStyle()->fontset, client.title, dlen,
- &ink, &logical);
- l = logical.width;
+ if (i18n.multibyte()) {
+ XRectangle ink, logical;
+ XmbTextExtents(screen->getWindowStyle()->fontset, client.title, dlen,
+ &ink, &logical);
+ l = logical.width;
} else {
- l = XTextWidth(screen->getWindowStyle()->font, client.title, dlen);
+ l = XTextWidth(screen->getWindowStyle()->font, client.title, dlen);
}
l += (frame.bevel_w * 4);
if (l < frame.label_w)
- break;
+ break;
}
}
WindowStyle *style = screen->getWindowStyle();
GC text_gc = (flags.focused) ? style->l_text_focus_gc :
style->l_text_unfocus_gc;
- if (i18n->multibyte())
+ if (i18n.multibyte())
XmbDrawString(display, frame.label, style->fontset, text_gc, dx,
- (1 - style->fontset_extents->max_ink_extent.y),
- client.title, dlen);
+ (1 - style->fontset_extents->max_ink_extent.y),
+ client.title, dlen);
else
XDrawString(display, frame.label, text_gc, dx,
- (style->font->ascent + 1), client.title, dlen);
+ (style->font->ascent + 1), client.title, dlen);
}
if (flags.focused) {
if (frame.fbutton)
XSetWindowBackgroundPixmap(display, frame.iconify_button,
- frame.fbutton);
+ frame.fbutton);
else
XSetWindowBackground(display, frame.iconify_button,
- frame.fbutton_pixel);
+ frame.fbutton_pixel);
} else {
if (frame.ubutton)
XSetWindowBackgroundPixmap(display, frame.iconify_button,
- frame.ubutton);
+ frame.ubutton);
else
XSetWindowBackground(display, frame.iconify_button,
- frame.ubutton_pixel);
+ frame.ubutton_pixel);
}
} else {
if (frame.pbutton)
XClearWindow(display, frame.iconify_button);
XDrawRectangle(display, frame.iconify_button,
- ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
- screen->getWindowStyle()->b_pic_unfocus_gc),
- 2, (frame.button_h - 5), (frame.button_w - 5), 2);
+ ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
+ screen->getWindowStyle()->b_pic_unfocus_gc),
+ 2, (frame.button_h - 5), (frame.button_w - 5), 2);
}
if (flags.focused) {
if (frame.fbutton)
XSetWindowBackgroundPixmap(display, frame.maximize_button,
- frame.fbutton);
+ frame.fbutton);
else
XSetWindowBackground(display, frame.maximize_button,
- frame.fbutton_pixel);
+ frame.fbutton_pixel);
} else {
if (frame.ubutton)
XSetWindowBackgroundPixmap(display, frame.maximize_button,
- frame.ubutton);
+ frame.ubutton);
else
XSetWindowBackground(display, frame.maximize_button,
- frame.ubutton_pixel);
+ frame.ubutton_pixel);
}
} else {
if (frame.pbutton)
XSetWindowBackgroundPixmap(display, frame.maximize_button,
- frame.pbutton);
+ frame.pbutton);
else
XSetWindowBackground(display, frame.maximize_button,
- frame.pbutton_pixel);
+ frame.pbutton_pixel);
}
XClearWindow(display, frame.maximize_button);
XDrawRectangle(display, frame.maximize_button,
- ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
- screen->getWindowStyle()->b_pic_unfocus_gc),
- 2, 2, (frame.button_w - 5), (frame.button_h - 5));
+ ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
+ screen->getWindowStyle()->b_pic_unfocus_gc),
+ 2, 2, (frame.button_w - 5), (frame.button_h - 5));
XDrawLine(display, frame.maximize_button,
- ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
- screen->getWindowStyle()->b_pic_unfocus_gc),
- 2, 3, (frame.button_w - 3), 3);
+ ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
+ screen->getWindowStyle()->b_pic_unfocus_gc),
+ 2, 3, (frame.button_w - 3), 3);
}
if (flags.focused) {
if (frame.fbutton)
XSetWindowBackgroundPixmap(display, frame.close_button,
- frame.fbutton);
+ frame.fbutton);
else
XSetWindowBackground(display, frame.close_button,
- frame.fbutton_pixel);
+ frame.fbutton_pixel);
} else {
if (frame.ubutton)
XSetWindowBackgroundPixmap(display, frame.close_button,
- frame.ubutton);
+ frame.ubutton);
else
XSetWindowBackground(display, frame.close_button,
- frame.ubutton_pixel);
+ frame.ubutton_pixel);
}
} else {
if (frame.pbutton)
XClearWindow(display, frame.close_button);
XDrawLine(display, frame.close_button,
- ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
- screen->getWindowStyle()->b_pic_unfocus_gc), 2, 2,
+ ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
+ screen->getWindowStyle()->b_pic_unfocus_gc), 2, 2,
(frame.button_w - 3), (frame.button_h - 3));
XDrawLine(display, frame.close_button,
- ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
- screen->getWindowStyle()->b_pic_unfocus_gc), 2,
- (frame.button_h - 3),
+ ((flags.focused) ? screen->getWindowStyle()->b_pic_focus_gc :
+ screen->getWindowStyle()->b_pic_unfocus_gc), 2,
+ (frame.button_h - 3),
(frame.button_w - 3), 2);
}
void OpenboxWindow::mapRequestEvent(XMapRequestEvent *re) {
if (re->window == client.window) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(WindowSet, WindowMapRequest,
- "OpenboxWindow::mapRequestEvent() for 0x%lx\n"),
+ fprintf(stderr, i18n(WindowSet, WindowMapRequest,
+ "OpenboxWindow::mapRequestEvent() for 0x%lx\n"),
client.window);
#endif // DEBUG
case ZoomState:
default:
deiconify(False, True, True); // specify that we're initializing the
- // window
+ // window
break;
}
void OpenboxWindow::unmapNotifyEvent(XUnmapEvent *ue) {
if (ue->window == client.window) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(WindowSet, WindowUnmapNotify,
- "OpenboxWindow::unmapNotifyEvent() for 0x%lx\n"),
+ fprintf(stderr, i18n(WindowSet, WindowUnmapNotify,
+ "OpenboxWindow::unmapNotifyEvent() for 0x%lx\n"),
client.window);
#endif // DEBUG
if (flags.moving)
endMove();
-
+
XChangeSaveSet(display, client.window, SetModeDelete);
XSelectInput(display, client.window, NoEventMask);
XDeleteProperty(display, client.window, openbox.getWMStateAtom());
XDeleteProperty(display, client.window,
- openbox.getOpenboxAttributesAtom());
+ openbox.getOpenboxAttributesAtom());
XUnmapWindow(display, frame.window);
XUnmapWindow(display, client.window);
XEvent dummy;
if (! XCheckTypedWindowEvent(display, client.window, ReparentNotify,
- &dummy)) {
+ &dummy)) {
#ifdef DEBUG
- fprintf(stderr, i18n->getMessage(WindowSet, WindowUnmapNotifyReparent,
- "OpenboxWindow::unmapNotifyEvent(): reparent 0x%lx to "
- "root.\n"), client.window);
+ fprintf(stderr, i18n(WindowSet, WindowUnmapNotifyReparent,
+ "OpenboxWindow::unmapNotifyEvent(): reparent 0x%lx to "
+ "root.\n"), client.window);
#endif // DEBUG
restoreGravity();
XReparentWindow(display, client.window, screen->getRootWindow(),
- client.x, client.y);
+ client.x, client.y);
}
XFlush(display);
flags.stuck = client.transient_for->flags.stuck;
flags.transient = True;
} else if (win == client.window_group) {
- //jr This doesn't look quite right...
+ //jr This doesn't look quite right...
if ((client.transient_for = openbox.searchGroup(win, this))) {
client.transient_for->client.transient = this;
flags.stuck = client.transient_for->flags.stuck;
if (client.max_width <= client.min_width &&
client.max_height <= client.min_height)
decorations.maximize = decorations.handle =
- functions.resize = functions.maximize = False;
+ functions.resize = functions.maximize = False;
else
decorations.maximize = decorations.handle =
- functions.resize = functions.maximize = True;
+ functions.resize = functions.maximize = True;
}
int x = frame.x, y = frame.y;
case Above:
case TopIf:
default:
- if (flags.iconic) deiconify();
- screen->getWorkspace(workspace_number)->raiseWindow(this);
- break;
+ if (flags.iconic) deiconify();
+ screen->getWorkspace(workspace_number)->raiseWindow(this);
+ break;
case Below:
case BottomIf:
- if (flags.iconic) deiconify();
- screen->getWorkspace(workspace_number)->lowerWindow(this);
- break;
+ if (flags.iconic) deiconify();
+ screen->getWorkspace(workspace_number)->lowerWindow(this);
+ break;
}
}
return;
int stack_change = 1; // < 0 means to lower the window
- // > 0 means to raise the window
- // 0 means to leave it where it is
-
+ // > 0 means to raise the window
+ // 0 means to leave it where it is
+
// alt + left/right click begins interactively moving/resizing the window
// when the mouse is moved
if (be->state == Mod1Mask && (be->button == 1 || be->button == 3)) {
resize_zone |= ZoneRight;
}
}
- // control + left click on the titlebar shades the window
+ // control + left click on the titlebar shades the window
} else if (be->state == ControlMask && be->button == 1) {
if (be->window == frame.title ||
be->window == frame.label)
shade();
- // left click
+ // left click
} else if (be->state == 0 && be->button == 1) {
if (windowmenu && windowmenu->isVisible())
- windowmenu->hide();
+ windowmenu->hide();
if (be->window == frame.maximize_button) {
redrawMaximizeButton(True);
be->window == frame.label) {
// shade the window when the titlebar is double clicked
if ( (be->time - lastButtonPressTime) <=
- openbox.getDoubleClickInterval()) {
+ openbox.getDoubleClickInterval()) {
lastButtonPressTime = 0;
shade();
} else {
else if (be->window == frame.right_grip)
resize_zone = ZoneBottom | ZoneRight;
}
- // middle click
+ // middle click
} else if (be->state == 0 && be->button == 2) {
if (be->window == frame.maximize_button) {
redrawMaximizeButton(True);
- // a middle click anywhere on the window's frame except for on the buttons
- // will lower the window
+ // a middle click anywhere on the window's frame except for on the buttons
+ // will lower the window
} else if (! (be->window == frame.iconify_button ||
be->window == frame.close_button) ) {
stack_change = -1;
}
- // right click
+ // right click
} else if (be->state == 0 && be->button == 3) {
if (be->window == frame.maximize_button) {
redrawMaximizeButton(True);
- // a right click on the window's frame will show or hide the window's
- // windowmenu
+ // a right click on the window's frame will show or hide the window's
+ // windowmenu
} else if (be->window == frame.title ||
be->window == frame.label ||
be->window == frame.handle ||
}
if (mx > (signed) (frame.x + frame.width -
- windowmenu->getWidth())) {
+ windowmenu->getWidth())) {
mx = frame.x + frame.width - windowmenu->getWidth();
} else if (mx < frame.x) {
mx = frame.x;
}
if (my > (signed) (frame.y + frame.y_handle -
- windowmenu->getHeight())) {
+ windowmenu->getHeight())) {
my = frame.y + frame.y_handle - windowmenu->getHeight();
} else if (my < (signed) (frame.y +
- ((decorations.titlebar) ? frame.title_h : frame.y_border))) {
+ ((decorations.titlebar) ? frame.title_h : frame.y_border))) {
my = frame.y +
((decorations.titlebar) ? frame.title_h : frame.y_border);
}
}
}
}
- // mouse wheel up
+ // mouse wheel up
} else if (be->state == 0 && be->button == 4) {
if ((be->window == frame.label ||
- be->window == frame.title) &&
+ be->window == frame.title) &&
!flags.shaded)
shade();
- // mouse wheel down
+ // mouse wheel down
} else if (be->state == 0 && be->button == 5) {
if ((be->window == frame.label ||
- be->window == frame.title) &&
+ be->window == frame.title) &&
flags.shaded)
shade();
}
} else if (stack_change > 0) {
screen->getWorkspace(workspace_number)->raiseWindow(this);
}
-
+
openbox.ungrab();
}
if (re->window == frame.window) {
XUngrabPointer(display, CurrentTime); // why? i dont know
}
- // left button released
+ // left button released
} else if (re->button == 1) {
if (re->window == frame.maximize_button) {
if (re->state == Button1Mask && // only the left button was depressed
if (re->state == Button1Mask && // only the left button was depressed
(re->x >= 0) && ((unsigned) re->x <= frame.button_w) &&
(re->y >= 0) && ((unsigned) re->y <= frame.button_h)) {
- close();
+ close();
}
//we should always redraw the close button. some applications
//eg. acroread don't honour the close.
redrawCloseButton(False);
}
- // middle button released
+ // middle button released
} else if (re->button == 2) {
if (re->window == frame.maximize_button) {
if (re->state == Button2Mask && // only the middle button was depressed
redrawMaximizeButton(False);
}
}
- // right button released
+ // right button released
} else if (re->button == 3) {
if (re->window == frame.maximize_button) {
if (re->state == Button3Mask && // only the right button was depressed
}
}
}
-
+
// when the window is being interactively moved, a button release stops the
// move where it is
if (flags.moving) {
endMove();
- // when the window is being interactively resized, a button release stops the
- // resizing
+ // when the window is being interactively resized, a button release stops the
+ // resizing
} else if (flags.resizing) {
flags.resizing = False;
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
if (resize_zone & ZoneLeft) {
left_fixsize();
} else { // when resizing with "Alt+Button3", the resize is the same as if
- // done with the right grip (the right side of the window is what
- // moves)
+ // done with the right grip (the right side of the window is what
+ // moves)
right_fixsize();
}
// unset maximized state when resized after fully maximized
if (flags.maximized == 1) {
- maximize(0);
+ maximize(0);
}
configure(frame.resize_x, frame.resize_y,
frame.resize_w - (frame.border_w * 2),
OpenboxWindow *w = openbox.getMaskedWindow();
if (w != (OpenboxWindow *) 0 && w->flags.moving)
w->endMove();
-
+
XGrabPointer(display, frame.window, False, PointerMotionMask |
ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
None, openbox.getMoveCursor(), CurrentTime);
void OpenboxWindow::motionNotifyEvent(XMotionEvent *me) {
if (flags.moving)
- doMove(me->x_root, me->y_root);
+ doMove(me->x_root, me->y_root);
else if (!flags.resizing && (me->state & Button1Mask) && functions.move &&
- (frame.title == me->window || frame.label == me->window ||
- frame.handle == me->window || frame.window == me->window))
+ (frame.title == me->window || frame.label == me->window ||
+ frame.handle == me->window || frame.window == me->window))
startMove(me->x_root, me->y_root);
else if (functions.resize &&
- (((me->state & Button1Mask) && (me->window == frame.right_grip ||
- me->window == frame.left_grip)) ||
- (me->state == (Mod1Mask | Button3Mask) &&
- me->window == frame.window))) {
+ (((me->state & Button1Mask) && (me->window == frame.right_grip ||
+ me->window == frame.left_grip)) ||
+ (me->state == (Mod1Mask | Button3Mask) &&
+ me->window == frame.window))) {
Bool left = resize_zone & ZoneLeft;
if (! flags.resizing) {
if (left)
left_fixsize(&gx, &gy);
else
- right_fixsize(&gx, &gy);
+ right_fixsize(&gx, &gy);
screen->showGeometry(gx, gy);
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
- frame.resize_x, frame.resize_y,
- frame.resize_w - 1, frame.resize_h - 1);
+ frame.resize_x, frame.resize_y,
+ frame.resize_w - 1, frame.resize_h - 1);
} else {
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
- frame.resize_x, frame.resize_y,
- frame.resize_w - 1, frame.resize_h - 1);
+ frame.resize_x, frame.resize_y,
+ frame.resize_w - 1, frame.resize_h - 1);
int gx, gy;
left_fixsize(&gx, &gy);
} else {
- frame.resize_w = frame.width + (me->x - frame.grab_x);
- if (frame.resize_w < 1) frame.resize_w = 1;
+ frame.resize_w = frame.width + (me->x - frame.grab_x);
+ if (frame.resize_w < 1) frame.resize_w = 1;
- right_fixsize(&gx, &gy);
+ right_fixsize(&gx, &gy);
}
XDrawRectangle(display, screen->getRootWindow(), screen->getOpGC(),
- frame.resize_x, frame.resize_y,
- frame.resize_w - 1, frame.resize_h - 1);
+ frame.resize_x, frame.resize_y,
+ frame.resize_w - 1, frame.resize_h - 1);
screen->showGeometry(gx, gy);
}
openbox.grab();
if (! validateClient()) return;
XShapeCombineShape(display, frame.window, ShapeBounding,
- frame.mwm_border_w, frame.y_border +
- frame.mwm_border_w, client.window,
- ShapeBounding, ShapeSet);
+ frame.mwm_border_w, frame.y_border +
+ frame.mwm_border_w, client.window,
+ ShapeBounding, ShapeSet);
int num = 1;
XRectangle xrect[2];
xrect[0].height = frame.y_border;
if (decorations.handle) {
- xrect[1].x = 0;
- xrect[1].y = frame.y_handle;
- xrect[1].width = frame.width;
- xrect[1].height = frame.handle_h + frame.border_w;
- num++;
+ xrect[1].x = 0;
+ xrect[1].y = frame.y_handle;
+ xrect[1].width = frame.width;
+ xrect[1].height = frame.handle_h + frame.border_w;
+ num++;
}
XShapeCombineRectangles(display, frame.window, ShapeBounding, 0, 0,
- xrect, num, ShapeUnion, Unsorted);
+ xrect, num, ShapeUnion, Unsorted);
openbox.ungrab();
}
}
switch (net->decoration) {
case DecorNone:
decorations.titlebar = decorations.border = decorations.handle =
- decorations.iconify = decorations.maximize = decorations.menu = False;
+ decorations.iconify = decorations.maximize = decorations.menu = False;
break;
// the height of the titlebar is based upon the height of the font being
// used to display the window's title
WindowStyle *style = screen->getWindowStyle();
- if (i18n->multibyte())
+ if (i18n.multibyte())
frame.title_h = (style->fontset_extents->max_ink_extent.height +
- (frame.bevel_w * 2) + 2);
+ (frame.bevel_w * 2) + 2);
else
frame.title_h = (style->font->ascent + style->font->descent +
- (frame.bevel_w * 2) + 2);
+ (frame.bevel_w * 2) + 2);
frame.label_h = frame.title_h - (frame.bevel_w * 2);
frame.button_w = frame.button_h = (frame.label_h - 2);
frame.handle_h = 0;
frame.grip_w = frame.grip_h = 0;
}
-
+
frame.width = client.width + (frame.mwm_border_w * 2);
frame.height = frame.y_handle + frame.handle_h;
}
frame.resize_w = dx + (frame.mwm_border_w * 2) + (frame.border_w * 2) - 1;
frame.resize_h = dy + frame.y_border + frame.handle_h +
- (frame.mwm_border_w * 2) + (frame.border_w * 3) - 1;
+ (frame.mwm_border_w * 2) + (frame.border_w * 3) - 1;
if (resize_zone & ZoneTop)
frame.resize_y = frame.y + frame.height - frame.resize_h +
screen->getBorderWidth() * 2;
frame.resize_w = dx + (frame.mwm_border_w * 2) + (frame.border_w * 2) - 1;
frame.resize_x = frame.x + frame.width - frame.resize_w +
- (frame.border_w * 2);
+ (frame.border_w * 2);
frame.resize_h = dy + frame.y_border + frame.handle_h +
- (frame.mwm_border_w * 2) + (frame.border_w * 3) - 1;
+ (frame.mwm_border_w * 2) + (frame.border_w * 3) - 1;
if (resize_zone & ZoneTop)
frame.resize_y = frame.y + frame.height - frame.resize_h +
screen->getBorderWidth() * 2;
-
+
}
Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
- window(win), screen(*win.getScreen())
+window(win), screen(*win.getScreen())
{
setTitleVisibility(False);
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();
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) {
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;
if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus()))
screen.getOpenbox().focusWindow(0);
}
-
+
_windows.erase(_windows.begin() + w->getWindowNumber());
clientmenu->remove(w->getWindowNumber());
clientmenu->update();
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();
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();
}
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) {
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())) {
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;
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);
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"));
}
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()))
#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;
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 &);
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;
+// -*- 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
// 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) {
} 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';
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);
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;
-// 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
// 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
# include "../config.h"
#endif // HAVE_CONFIG_H
-#include "i18n.h"
-#include "openbox.h"
-
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif // HAVE_STDIO_H
#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) {
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);
}
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);
}
// 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];
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);
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 (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);
-
-
- 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);
-
- delete [] configdir;
- }
- config.setFile(rc_file);
-
- no_focus = False;
+ if (! XSupportsLocale())
+ fprintf(stderr, "X server does not support locale\n");
- resource.style_file = NULL;
- resource.titlebar_layout = NULL;
- resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
+ if (XSetLocaleModifiers("") == NULL)
+ fprintf(stderr, "cannot set locale modifiers\n");
- current_screen = (BScreen *) 0;
- masked_window = (OpenboxWindow *) 0;
- masked = None;
+ ::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);
- load();
+
+ 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);
+
+ delete [] configdir;
+ }
+ config.setFile(rc_file);
+
+ no_focus = False;
+
+ 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() {
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);
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);
-
- 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 (my + screen->getWorkspacemenu()->getHeight() >
- screen->size().h())
- my = screen->size().h() -
- screen->getWorkspacemenu()->getHeight() -
- screen->getBorderWidth();
-
- 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 (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 (my + screen->getRootmenu()->getHeight() > screen->size().h())
- my = screen->size().h() -
- screen->getRootmenu()->getHeight() -
- screen->getBorderWidth();
-
- screen->getRootmenu()->move(mx, my);
-
- if (! screen->getRootmenu()->isVisible()) {
- checkMenu();
- screen->getRootmenu()->show();
- }
+ 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 + 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();
+
+ 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 (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 (my + screen->getRootmenu()->getHeight() > screen->size().h())
+ my = screen->size().h() -
+ screen->getRootmenu()->getHeight() -
+ screen->getBorderWidth();
+
+ screen->getRootmenu()->move(mx, my);
+
+ if (! screen->getRootmenu()->isVisible()) {
+ checkMenu();
+ screen->getRootmenu()->show();
+ }
} else if (e->xbutton.button == 4) {
if ((screen->getCurrentWorkspaceID() + 1) >
screen->getWorkspaceCount() - 1)
grab();
if (validateWindow(e->xconfigurerequest.window)) {
- XWindowChanges xwc;
-
- xwc.x = e->xconfigurerequest.x;
- xwc.y = e->xconfigurerequest.y;
- xwc.width = e->xconfigurerequest.width;
- xwc.height = e->xconfigurerequest.height;
- xwc.border_width = e->xconfigurerequest.border_width;
- xwc.sibling = e->xconfigurerequest.above;
- xwc.stack_mode = e->xconfigurerequest.detail;
-
- XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
- e->xconfigurerequest.value_mask, &xwc);
+ XWindowChanges xwc;
+
+ xwc.x = e->xconfigurerequest.x;
+ xwc.y = e->xconfigurerequest.y;
+ xwc.width = e->xconfigurerequest.width;
+ xwc.height = e->xconfigurerequest.height;
+ xwc.border_width = e->xconfigurerequest.border_width;
+ xwc.sibling = e->xconfigurerequest.above;
+ xwc.stack_mode = e->xconfigurerequest.detail;
+
+ XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
+ e->xconfigurerequest.value_mask, &xwc);
}
ungrab();
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);
if (win)
win->mapNotifyEvent(&e->xmap);
- break;
+ break;
}
case UnmapNotify: {
case MotionNotify: {
// strip the lock key modifiers
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
-
+
last_time = e->xmotion.time;
OpenboxWindow *win = (OpenboxWindow *) 0;
OpenboxWindow *win = searchWindow(e->xproperty.window);
if (win)
- win->propertyNotifyEvent(e->xproperty.atom);
+ win->propertyNotifyEvent(e->xproperty.atom);
}
break;
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();
}
if (screen)
screen->setRootColormapInstalled((e->xcolormap.state ==
- ColormapInstalled) ? True : False);
+ ColormapInstalled) ? True : False);
break;
}
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);
screen->prevFocus();
else
screen->nextFocus();
- }
+ }
} else if (e->xclient.message_type == getOpenboxChangeAttributesAtom()) {
- 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];
-
- win->changeOpenboxHints(&net);
- }
+ 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];
+
+ win->changeOpenboxHints(&net);
+ }
}
}
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
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);
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);
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
grab();
load();
-
+
for_each(menuTimestamps.begin(), menuTimestamps.end(),
PointerAssassin());
menuTimestamps.clear();
wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
win->setFocusFlag(true);
wkspc->focusWindow(win);
-
+
if (tbar)
tbar->redrawWindowLabel(true);
current_screen->updateNetizenWindowFocus();