- 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);
- 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);
- 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);
+ }
- 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);
- 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);
- 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];
+ }
- 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.
+ }
-/*
- * 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
+ {
-{
-
- 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;
+ }