new i18n class using overloaded operator() instead of getMessage()
This commit is contained in:
parent
30136ab3e9
commit
ae3dc273c4
18 changed files with 4153 additions and 4156 deletions
|
@ -104,8 +104,9 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
||||||
char errtxt[128];
|
char errtxt[128];
|
||||||
|
|
||||||
XGetErrorText(d, e->error_code, errtxt, 128);
|
XGetErrorText(d, e->error_code, errtxt, 128);
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayXError,
|
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXError,
|
||||||
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"),
|
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"
|
||||||
|
),
|
||||||
base_display->getApplicationName(), errtxt, e->error_code,
|
base_display->getApplicationName(), errtxt, e->error_code,
|
||||||
e->request_code, e->minor_code, e->resourceid);
|
e->request_code, e->minor_code, e->resourceid);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
@ -122,502 +123,502 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
||||||
#ifndef HAVE_SIGACTION
|
#ifndef HAVE_SIGACTION
|
||||||
static RETSIGTYPE signalhandler(int sig) {
|
static RETSIGTYPE signalhandler(int sig) {
|
||||||
#else // HAVE_SIGACTION
|
#else // HAVE_SIGACTION
|
||||||
static void signalhandler(int sig) {
|
static void signalhandler(int sig) {
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
|
|
||||||
static int re_enter = 0;
|
static int re_enter = 0;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGCHLD:
|
case SIGCHLD:
|
||||||
int status;
|
int status;
|
||||||
waitpid(-1, &status, WNOHANG | WUNTRACED);
|
waitpid(-1, &status, WNOHANG | WUNTRACED);
|
||||||
|
|
||||||
#ifndef HAVE_SIGACTION
|
|
||||||
// assume broken, braindead sysv signal semantics
|
|
||||||
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
#endif // HAVE_SIGACTION
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (base_display->handleSignal(sig)) {
|
|
||||||
|
|
||||||
#ifndef HAVE_SIGACTION
|
#ifndef HAVE_SIGACTION
|
||||||
// assume broken, braindead sysv signal semantics
|
// assume broken, braindead sysv signal semantics
|
||||||
signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
|
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
#endif // HAVE_SIGACTION
|
#endif // HAVE_SIGACTION
|
||||||
|
|
||||||
return;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (base_display->handleSignal(sig)) {
|
||||||
|
|
||||||
|
#ifndef HAVE_SIGACTION
|
||||||
|
// assume broken, braindead sysv signal semantics
|
||||||
|
signal(sig, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
#endif // HAVE_SIGACTION
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplaySignalCaught,
|
||||||
|
"%s: signal %d caught\n"),
|
||||||
|
base_display->getApplicationName(), sig);
|
||||||
|
|
||||||
|
if (! base_display->isStartup() && ! re_enter) {
|
||||||
|
internal_error = True;
|
||||||
|
|
||||||
|
re_enter = 1;
|
||||||
|
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayShuttingDown,
|
||||||
|
"shutting down\n"));
|
||||||
|
base_display->shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sig != SIGTERM && sig != SIGINT) {
|
||||||
|
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayAborting,
|
||||||
|
"aborting... dumping core\n"));
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplaySignalCaught,
|
|
||||||
"%s: signal %d caught\n"),
|
|
||||||
base_display->getApplicationName(), sig);
|
|
||||||
|
|
||||||
if (! base_display->isStartup() && ! re_enter) {
|
|
||||||
internal_error = True;
|
|
||||||
|
|
||||||
re_enter = 1;
|
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayShuttingDown,
|
|
||||||
"shutting down\n"));
|
|
||||||
base_display->shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sig != SIGTERM && sig != SIGINT) {
|
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayAborting,
|
|
||||||
"aborting... dumping core\n"));
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// convenience functions
|
// convenience functions
|
||||||
#ifndef __EMX__
|
#ifndef __EMX__
|
||||||
void bexec(const char *command, char* displaystring) {
|
void bexec(const char *command, char* displaystring) {
|
||||||
if (! fork()) {
|
if (! fork()) {
|
||||||
setsid();
|
setsid();
|
||||||
putenv(displaystring);
|
putenv(displaystring);
|
||||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif // !__EMX__
|
#endif // !__EMX__
|
||||||
|
|
||||||
char *bstrdup(const char *s) {
|
char *bstrdup(const char *s) {
|
||||||
const int l = strlen(s) + 1;
|
const int l = strlen(s) + 1;
|
||||||
char *n = new char[l];
|
char *n = new char[l];
|
||||||
strncpy(n, s, l);
|
strncpy(n, s, l);
|
||||||
return n;
|
return n;
|
||||||
}
|
|
||||||
|
|
||||||
BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|
||||||
application_name = bstrdup(app_name);
|
|
||||||
|
|
||||||
_startup = True;
|
|
||||||
_shutdown = False;
|
|
||||||
server_grabs = 0;
|
|
||||||
last_bad_window = None;
|
|
||||||
|
|
||||||
::base_display = this;
|
|
||||||
|
|
||||||
#ifdef HAVE_SIGACTION
|
|
||||||
struct sigaction action;
|
|
||||||
|
|
||||||
action.sa_handler = signalhandler;
|
|
||||||
action.sa_mask = sigset_t();
|
|
||||||
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
|
|
||||||
|
|
||||||
sigaction(SIGPIPE, &action, NULL);
|
|
||||||
sigaction(SIGSEGV, &action, NULL);
|
|
||||||
sigaction(SIGFPE, &action, NULL);
|
|
||||||
sigaction(SIGTERM, &action, NULL);
|
|
||||||
sigaction(SIGINT, &action, NULL);
|
|
||||||
sigaction(SIGCHLD, &action, NULL);
|
|
||||||
sigaction(SIGHUP, &action, NULL);
|
|
||||||
sigaction(SIGUSR1, &action, NULL);
|
|
||||||
sigaction(SIGUSR2, &action, NULL);
|
|
||||||
#else // !HAVE_SIGACTION
|
|
||||||
signal(SIGPIPE, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGSEGV, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGFPE, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGTERM, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGUSR1, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGUSR2, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
|
|
||||||
#endif // HAVE_SIGACTION
|
|
||||||
|
|
||||||
if (! (display = XOpenDisplay(dpy_name))) {
|
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet, BaseDisplayXConnectFail,
|
|
||||||
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
|
|
||||||
::exit(2);
|
|
||||||
} else if (fcntl(ConnectionNumber(display), F_SETFD, 1) == -1) {
|
|
||||||
fprintf(stderr,
|
|
||||||
i18n->getMessage(BaseDisplaySet, BaseDisplayCloseOnExecFail,
|
|
||||||
"BaseDisplay::BaseDisplay: couldn't mark display connection "
|
|
||||||
"as close-on-exec\n"));
|
|
||||||
::exit(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display_name = XDisplayName(dpy_name);
|
BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
||||||
|
application_name = bstrdup(app_name);
|
||||||
|
|
||||||
|
_startup = True;
|
||||||
|
_shutdown = False;
|
||||||
|
server_grabs = 0;
|
||||||
|
last_bad_window = None;
|
||||||
|
|
||||||
|
::base_display = this;
|
||||||
|
|
||||||
|
#ifdef HAVE_SIGACTION
|
||||||
|
struct sigaction action;
|
||||||
|
|
||||||
|
action.sa_handler = signalhandler;
|
||||||
|
action.sa_mask = sigset_t();
|
||||||
|
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
|
||||||
|
|
||||||
|
sigaction(SIGPIPE, &action, NULL);
|
||||||
|
sigaction(SIGSEGV, &action, NULL);
|
||||||
|
sigaction(SIGFPE, &action, NULL);
|
||||||
|
sigaction(SIGTERM, &action, NULL);
|
||||||
|
sigaction(SIGINT, &action, NULL);
|
||||||
|
sigaction(SIGCHLD, &action, NULL);
|
||||||
|
sigaction(SIGHUP, &action, NULL);
|
||||||
|
sigaction(SIGUSR1, &action, NULL);
|
||||||
|
sigaction(SIGUSR2, &action, NULL);
|
||||||
|
#else // !HAVE_SIGACTION
|
||||||
|
signal(SIGPIPE, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGSEGV, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGFPE, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGTERM, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGINT, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGUSR1, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGUSR2, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGHUP, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
signal(SIGCHLD, (RETSIGTYPE (*)(int)) signalhandler);
|
||||||
|
#endif // HAVE_SIGACTION
|
||||||
|
|
||||||
|
if (! (display = XOpenDisplay(dpy_name))) {
|
||||||
|
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXConnectFail,
|
||||||
|
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
|
||||||
|
::exit(2);
|
||||||
|
} else if (fcntl(ConnectionNumber(display), F_SETFD, 1) == -1) {
|
||||||
|
fprintf(stderr,
|
||||||
|
i18n(BaseDisplaySet, BaseDisplayCloseOnExecFail,
|
||||||
|
"BaseDisplay::BaseDisplay: couldn't mark display connection "
|
||||||
|
"as close-on-exec\n"));
|
||||||
|
::exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
display_name = XDisplayName(dpy_name);
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
shape.extensions = XShapeQueryExtension(display, &shape.event_basep,
|
shape.extensions = XShapeQueryExtension(display, &shape.event_basep,
|
||||||
&shape.error_basep);
|
&shape.error_basep);
|
||||||
#else // !SHAPE
|
#else // !SHAPE
|
||||||
shape.extensions = False;
|
shape.extensions = False;
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
xa_wm_colormap_windows =
|
xa_wm_colormap_windows =
|
||||||
XInternAtom(display, "WM_COLORMAP_WINDOWS", False);
|
XInternAtom(display, "WM_COLORMAP_WINDOWS", False);
|
||||||
xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
|
xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
|
||||||
xa_wm_state = XInternAtom(display, "WM_STATE", False);
|
xa_wm_state = XInternAtom(display, "WM_STATE", False);
|
||||||
xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
|
xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
|
||||||
xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
|
xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
|
||||||
xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
|
xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
|
||||||
motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
|
motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
|
||||||
|
|
||||||
openbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False);
|
openbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False);
|
||||||
openbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
|
openbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
|
||||||
openbox_change_attributes =
|
openbox_change_attributes =
|
||||||
XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False);
|
XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False);
|
||||||
|
|
||||||
openbox_structure_messages =
|
openbox_structure_messages =
|
||||||
XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False);
|
XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False);
|
||||||
openbox_notify_startup =
|
openbox_notify_startup =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False);
|
||||||
openbox_notify_window_add =
|
openbox_notify_window_add =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False);
|
||||||
openbox_notify_window_del =
|
openbox_notify_window_del =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False);
|
||||||
openbox_notify_current_workspace =
|
openbox_notify_current_workspace =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False);
|
||||||
openbox_notify_workspace_count =
|
openbox_notify_workspace_count =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False);
|
||||||
openbox_notify_window_focus =
|
openbox_notify_window_focus =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False);
|
||||||
openbox_notify_window_raise =
|
openbox_notify_window_raise =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False);
|
||||||
openbox_notify_window_lower =
|
openbox_notify_window_lower =
|
||||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False);
|
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False);
|
||||||
|
|
||||||
openbox_change_workspace =
|
openbox_change_workspace =
|
||||||
XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False);
|
XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False);
|
||||||
openbox_change_window_focus =
|
openbox_change_window_focus =
|
||||||
XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False);
|
XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False);
|
||||||
openbox_cycle_window_focus =
|
openbox_cycle_window_focus =
|
||||||
XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False);
|
XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False);
|
||||||
|
|
||||||
#ifdef NEWWMSPEC
|
#ifdef NEWWMSPEC
|
||||||
|
|
||||||
net_supported = XInternAtom(display, "_NET_SUPPORTED", False);
|
net_supported = XInternAtom(display, "_NET_SUPPORTED", False);
|
||||||
net_client_list = XInternAtom(display, "_NET_CLIENT_LIST", False);
|
net_client_list = XInternAtom(display, "_NET_CLIENT_LIST", False);
|
||||||
net_client_list_stacking = XInternAtom(display, "_NET_CLIENT_LIST_STACKING", False);
|
net_client_list_stacking = XInternAtom(display, "_NET_CLIENT_LIST_STACKING", False);
|
||||||
net_number_of_desktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False);
|
net_number_of_desktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False);
|
||||||
net_desktop_geometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
|
net_desktop_geometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
|
||||||
net_desktop_viewport = XInternAtom(display, "_NET_DESKTOP_VIEWPORT", False);
|
net_desktop_viewport = XInternAtom(display, "_NET_DESKTOP_VIEWPORT", False);
|
||||||
net_current_desktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", False);
|
net_current_desktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", False);
|
||||||
net_desktop_names = XInternAtom(display, "_NET_DESKTOP_NAMES", False);
|
net_desktop_names = XInternAtom(display, "_NET_DESKTOP_NAMES", False);
|
||||||
net_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
|
net_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
|
||||||
net_workarea = XInternAtom(display, "_NET_WORKAREA", False);
|
net_workarea = XInternAtom(display, "_NET_WORKAREA", False);
|
||||||
net_supporting_wm_check = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
|
net_supporting_wm_check = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
|
||||||
net_virtual_roots = XInternAtom(display, "_NET_VIRTUAL_ROOTS", False);
|
net_virtual_roots = XInternAtom(display, "_NET_VIRTUAL_ROOTS", False);
|
||||||
|
|
||||||
net_close_window = XInternAtom(display, "_NET_CLOSE_WINDOW", False);
|
net_close_window = XInternAtom(display, "_NET_CLOSE_WINDOW", False);
|
||||||
net_wm_moveresize = XInternAtom(display, "_NET_WM_MOVERESIZE", False);
|
net_wm_moveresize = XInternAtom(display, "_NET_WM_MOVERESIZE", False);
|
||||||
|
|
||||||
net_properties = XInternAtom(display, "_NET_PROPERTIES", False);
|
net_properties = XInternAtom(display, "_NET_PROPERTIES", False);
|
||||||
net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
|
net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
|
||||||
net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
||||||
net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||||
net_wm_state = XInternAtom(display, "_NET_WM_STATE", False);
|
net_wm_state = XInternAtom(display, "_NET_WM_STATE", False);
|
||||||
net_wm_strut = XInternAtom(display, "_NET_WM_STRUT", False);
|
net_wm_strut = XInternAtom(display, "_NET_WM_STRUT", False);
|
||||||
net_wm_icon_geometry = XInternAtom(display, "_NET_WM_ICON_GEOMETRY", False);
|
net_wm_icon_geometry = XInternAtom(display, "_NET_WM_ICON_GEOMETRY", False);
|
||||||
net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
|
net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
|
||||||
net_wm_pid = XInternAtom(display, "_NET_WM_PID", False);
|
net_wm_pid = XInternAtom(display, "_NET_WM_PID", False);
|
||||||
net_wm_handled_icons = XInternAtom(display, "_NET_WM_HANDLED_ICONS", False);
|
net_wm_handled_icons = XInternAtom(display, "_NET_WM_HANDLED_ICONS", False);
|
||||||
|
|
||||||
net_wm_ping = XInternAtom(display, "_NET_WM_PING", False);
|
net_wm_ping = XInternAtom(display, "_NET_WM_PING", False);
|
||||||
|
|
||||||
#endif // NEWWMSPEC
|
#endif // NEWWMSPEC
|
||||||
|
|
||||||
cursor.session = XCreateFontCursor(display, XC_left_ptr);
|
cursor.session = XCreateFontCursor(display, XC_left_ptr);
|
||||||
cursor.move = XCreateFontCursor(display, XC_fleur);
|
cursor.move = XCreateFontCursor(display, XC_fleur);
|
||||||
cursor.ll_angle = XCreateFontCursor(display, XC_ll_angle);
|
cursor.ll_angle = XCreateFontCursor(display, XC_ll_angle);
|
||||||
cursor.lr_angle = XCreateFontCursor(display, XC_lr_angle);
|
cursor.lr_angle = XCreateFontCursor(display, XC_lr_angle);
|
||||||
cursor.ul_angle = XCreateFontCursor(display, XC_ul_angle);
|
cursor.ul_angle = XCreateFontCursor(display, XC_ul_angle);
|
||||||
cursor.ur_angle = XCreateFontCursor(display, XC_ur_angle);
|
cursor.ur_angle = XCreateFontCursor(display, XC_ur_angle);
|
||||||
|
|
||||||
XSetErrorHandler((XErrorHandler) handleXErrors);
|
XSetErrorHandler((XErrorHandler) handleXErrors);
|
||||||
|
|
||||||
screenInfoList.reserve(numberOfScreens());
|
screenInfoList.reserve(numberOfScreens());
|
||||||
for (unsigned int s = 0; s < numberOfScreens(); s++)
|
for (unsigned int s = 0; s < numberOfScreens(); s++)
|
||||||
screenInfoList.push_back(new ScreenInfo(*this, s));
|
screenInfoList.push_back(new ScreenInfo(*this, s));
|
||||||
|
|
||||||
#ifndef NOCLOBBER
|
#ifndef NOCLOBBER
|
||||||
NumLockMask = ScrollLockMask = 0;
|
NumLockMask = ScrollLockMask = 0;
|
||||||
|
|
||||||
const XModifierKeymap* const modmap = XGetModifierMapping(display);
|
const XModifierKeymap* const modmap = XGetModifierMapping(display);
|
||||||
if (modmap && modmap->max_keypermod > 0) {
|
if (modmap && modmap->max_keypermod > 0) {
|
||||||
const int mask_table[] = {
|
const int mask_table[] = {
|
||||||
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
||||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||||
};
|
};
|
||||||
const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
|
const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
|
||||||
modmap->max_keypermod;
|
modmap->max_keypermod;
|
||||||
// get the values of the keyboard lock modifiers
|
// get the values of the keyboard lock modifiers
|
||||||
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
|
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
|
||||||
// since it doesn't need to be.
|
// since it doesn't need to be.
|
||||||
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
|
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
|
||||||
const KeyCode scroll_lock_code = XKeysymToKeycode(display, XK_Scroll_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])
|
for (size_t cnt = 0; cnt < size; ++cnt) {
|
||||||
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
if (! modmap->modifiermap[cnt]) continue;
|
||||||
if (scroll_lock_code == modmap->modifiermap[cnt])
|
|
||||||
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
if (num_lock_code == modmap->modifiermap[cnt])
|
||||||
|
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||||
|
if (scroll_lock_code == modmap->modifiermap[cnt])
|
||||||
|
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaskList[0] = 0;
|
||||||
|
MaskList[1] = LockMask;
|
||||||
|
MaskList[2] = NumLockMask;
|
||||||
|
MaskList[3] = ScrollLockMask;
|
||||||
|
MaskList[4] = LockMask | NumLockMask;
|
||||||
|
MaskList[5] = NumLockMask | ScrollLockMask;
|
||||||
|
MaskList[6] = LockMask | ScrollLockMask;
|
||||||
|
MaskList[7] = LockMask | NumLockMask | ScrollLockMask;
|
||||||
|
MaskListLength = sizeof(MaskList) / sizeof(MaskList[0]);
|
||||||
|
|
||||||
|
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
|
||||||
|
#else
|
||||||
|
NumLockMask = Mod2Mask;
|
||||||
|
ScrollLockMask = Mod5Mask;
|
||||||
|
#endif // NOCLOBBER
|
||||||
}
|
}
|
||||||
|
|
||||||
MaskList[0] = 0;
|
|
||||||
MaskList[1] = LockMask;
|
BaseDisplay::~BaseDisplay(void) {
|
||||||
MaskList[2] = NumLockMask;
|
std::for_each(screenInfoList.begin(), screenInfoList.end(),
|
||||||
MaskList[3] = ScrollLockMask;
|
PointerAssassin());
|
||||||
MaskList[4] = LockMask | NumLockMask;
|
// we don't create the BTimers, we don't delete them
|
||||||
MaskList[5] = NumLockMask | ScrollLockMask;
|
|
||||||
MaskList[6] = LockMask | ScrollLockMask;
|
if (application_name != NULL)
|
||||||
MaskList[7] = LockMask | NumLockMask | ScrollLockMask;
|
delete [] application_name;
|
||||||
MaskListLength = sizeof(MaskList) / sizeof(MaskList[0]);
|
|
||||||
|
XCloseDisplay(display);
|
||||||
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
|
}
|
||||||
#else
|
|
||||||
NumLockMask = Mod2Mask;
|
|
||||||
ScrollLockMask = Mod5Mask;
|
|
||||||
#endif // NOCLOBBER
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BaseDisplay::~BaseDisplay(void) {
|
void BaseDisplay::eventLoop(void) {
|
||||||
std::for_each(screenInfoList.begin(), screenInfoList.end(),
|
run();
|
||||||
PointerAssassin());
|
|
||||||
// we don't create the BTimers, we don't delete them
|
|
||||||
|
|
||||||
if (application_name != NULL)
|
|
||||||
delete [] application_name;
|
|
||||||
|
|
||||||
XCloseDisplay(display);
|
int xfd = ConnectionNumber(display);
|
||||||
}
|
|
||||||
|
|
||||||
|
while ((! _shutdown) && (! internal_error)) {
|
||||||
|
if (XPending(display)) {
|
||||||
|
XEvent e;
|
||||||
|
XNextEvent(display, &e);
|
||||||
|
|
||||||
void BaseDisplay::eventLoop(void) {
|
if (last_bad_window != None && e.xany.window == last_bad_window) {
|
||||||
run();
|
|
||||||
|
|
||||||
int xfd = ConnectionNumber(display);
|
|
||||||
|
|
||||||
while ((! _shutdown) && (! internal_error)) {
|
|
||||||
if (XPending(display)) {
|
|
||||||
XEvent e;
|
|
||||||
XNextEvent(display, &e);
|
|
||||||
|
|
||||||
if (last_bad_window != None && e.xany.window == last_bad_window) {
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, i18n->getMessage(BaseDisplaySet,
|
fprintf(stderr, i18n(BaseDisplaySet,
|
||||||
BaseDisplayBadWindowRemove,
|
BaseDisplayBadWindowRemove,
|
||||||
"BaseDisplay::eventLoop(): removing bad window "
|
"BaseDisplay::eventLoop(): removing bad window "
|
||||||
"from event queue\n"));
|
"from event queue\n"));
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
} else {
|
||||||
|
last_bad_window = None;
|
||||||
|
process_event(&e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
last_bad_window = None;
|
fd_set rfds;
|
||||||
process_event(&e);
|
timeval now, tm, *timeout = (timeval *) 0;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fd_set rfds;
|
|
||||||
timeval now, tm, *timeout = (timeval *) 0;
|
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(xfd, &rfds);
|
FD_SET(xfd, &rfds);
|
||||||
|
|
||||||
if (!timerList.empty()) {
|
if (!timerList.empty()) {
|
||||||
|
gettimeofday(&now, 0);
|
||||||
|
|
||||||
|
tm.tv_sec = tm.tv_usec = 0l;
|
||||||
|
|
||||||
|
BTimer *timer = timerList.front();
|
||||||
|
ASSERT(timer != NULL);
|
||||||
|
|
||||||
|
tm.tv_sec = timer->getStartTime().tv_sec +
|
||||||
|
timer->getTimeout().tv_sec - now.tv_sec;
|
||||||
|
tm.tv_usec = timer->getStartTime().tv_usec +
|
||||||
|
timer->getTimeout().tv_usec - now.tv_usec;
|
||||||
|
|
||||||
|
while (tm.tv_usec >= 1000000) {
|
||||||
|
tm.tv_sec++;
|
||||||
|
tm.tv_usec -= 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (tm.tv_usec < 0) {
|
||||||
|
if (tm.tv_sec > 0) {
|
||||||
|
tm.tv_sec--;
|
||||||
|
tm.tv_usec += 1000000;
|
||||||
|
} else {
|
||||||
|
tm.tv_usec = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout = &tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
select(xfd + 1, &rfds, 0, 0, timeout);
|
||||||
|
|
||||||
|
// check for timer timeout
|
||||||
gettimeofday(&now, 0);
|
gettimeofday(&now, 0);
|
||||||
|
|
||||||
tm.tv_sec = tm.tv_usec = 0l;
|
TimerList::iterator it;
|
||||||
|
for (it = timerList.begin(); it != timerList.end(); ++it) {
|
||||||
|
BTimer *timer = *it;
|
||||||
|
ASSERT(timer != NULL);
|
||||||
|
|
||||||
BTimer *timer = timerList.front();
|
tm.tv_sec = timer->getStartTime().tv_sec +
|
||||||
ASSERT(timer != NULL);
|
timer->getTimeout().tv_sec;
|
||||||
|
tm.tv_usec = timer->getStartTime().tv_usec +
|
||||||
|
timer->getTimeout().tv_usec;
|
||||||
|
|
||||||
tm.tv_sec = timer->getStartTime().tv_sec +
|
if ((now.tv_sec < tm.tv_sec) ||
|
||||||
timer->getTimeout().tv_sec - now.tv_sec;
|
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
|
||||||
tm.tv_usec = timer->getStartTime().tv_usec +
|
|
||||||
timer->getTimeout().tv_usec - now.tv_usec;
|
|
||||||
|
|
||||||
while (tm.tv_usec >= 1000000) {
|
|
||||||
tm.tv_sec++;
|
|
||||||
tm.tv_usec -= 1000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (tm.tv_usec < 0) {
|
|
||||||
if (tm.tv_sec > 0) {
|
|
||||||
tm.tv_sec--;
|
|
||||||
tm.tv_usec += 1000000;
|
|
||||||
} else {
|
|
||||||
tm.tv_usec = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
timer->fireTimeout();
|
||||||
|
|
||||||
|
// restart the current timer so that the start time is updated
|
||||||
|
if (! timer->doOnce()) {
|
||||||
|
// reorder
|
||||||
|
removeTimer(timer);
|
||||||
|
addTimer(timer);
|
||||||
|
timer->start();
|
||||||
|
} else
|
||||||
|
timer->stop();
|
||||||
|
it = timerList.begin(); // we no longer have any idea if the iterator is
|
||||||
|
// valid, but what was at the front() is no
|
||||||
|
// longer.
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout = &tm;
|
|
||||||
}
|
|
||||||
|
|
||||||
select(xfd + 1, &rfds, 0, 0, timeout);
|
|
||||||
|
|
||||||
// check for timer timeout
|
|
||||||
gettimeofday(&now, 0);
|
|
||||||
|
|
||||||
TimerList::iterator it;
|
|
||||||
for (it = timerList.begin(); it != timerList.end(); ++it) {
|
|
||||||
BTimer *timer = *it;
|
|
||||||
ASSERT(timer != NULL);
|
|
||||||
|
|
||||||
tm.tv_sec = timer->getStartTime().tv_sec +
|
|
||||||
timer->getTimeout().tv_sec;
|
|
||||||
tm.tv_usec = timer->getStartTime().tv_usec +
|
|
||||||
timer->getTimeout().tv_usec;
|
|
||||||
|
|
||||||
if ((now.tv_sec < tm.tv_sec) ||
|
|
||||||
(now.tv_sec == tm.tv_sec && now.tv_usec < tm.tv_usec))
|
|
||||||
break;
|
|
||||||
|
|
||||||
timer->fireTimeout();
|
|
||||||
|
|
||||||
// restart the current timer so that the start time is updated
|
|
||||||
if (! timer->doOnce()) {
|
|
||||||
// reorder
|
|
||||||
removeTimer(timer);
|
|
||||||
addTimer(timer);
|
|
||||||
timer->start();
|
|
||||||
} else
|
|
||||||
timer->stop();
|
|
||||||
it = timerList.begin(); // we no longer have any idea if the iterator is
|
|
||||||
// valid, but what was at the front() is no
|
|
||||||
// longer.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const Bool BaseDisplay::validateWindow(Window window) {
|
const Bool BaseDisplay::validateWindow(Window window) {
|
||||||
XEvent event;
|
XEvent event;
|
||||||
if (XCheckTypedWindowEvent(display, window, DestroyNotify, &event)) {
|
if (XCheckTypedWindowEvent(display, window, DestroyNotify, &event)) {
|
||||||
XPutBackEvent(display, &event);
|
XPutBackEvent(display, &event);
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void BaseDisplay::grab(void) {
|
||||||
void BaseDisplay::grab(void) {
|
if (! server_grabs++)
|
||||||
if (! server_grabs++)
|
XGrabServer(display);
|
||||||
XGrabServer(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseDisplay::ungrab(void) {
|
|
||||||
if (! --server_grabs)
|
|
||||||
XUngrabServer(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseDisplay::addTimer(BTimer *timer) {
|
|
||||||
ASSERT(timer != (BTimer *) 0);
|
|
||||||
|
|
||||||
TimerList::iterator it;
|
|
||||||
for (it = timerList.begin(); it != timerList.end(); ++it) {
|
|
||||||
BTimer *tmp = *it;
|
|
||||||
if ((tmp->getTimeout().tv_sec > timer->getTimeout().tv_sec) ||
|
|
||||||
((tmp->getTimeout().tv_sec == timer->getTimeout().tv_sec) &&
|
|
||||||
(tmp->getTimeout().tv_usec >= timer->getTimeout().tv_usec)))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timerList.insert(it, timer);
|
|
||||||
}
|
void BaseDisplay::ungrab(void) {
|
||||||
|
if (! --server_grabs)
|
||||||
|
XUngrabServer(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseDisplay::removeTimer(BTimer *timer) {
|
void BaseDisplay::addTimer(BTimer *timer) {
|
||||||
ASSERT(timer != (BTimer *) 0);
|
ASSERT(timer != (BTimer *) 0);
|
||||||
timerList.remove(timer);
|
|
||||||
}
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
void BaseDisplay::removeTimer(BTimer *timer) {
|
||||||
* Grabs a button, but also grabs the button in every possible combination with
|
ASSERT(timer != (BTimer *) 0);
|
||||||
* the keyboard lock keys, so that they do not cancel out the event.
|
timerList.remove(timer);
|
||||||
*/
|
}
|
||||||
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,
|
* Grabs a button, but also grabs the button in every possible combination with
|
||||||
Cursor cursor) const
|
* 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
|
#ifndef NOCLOBBER
|
||||||
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
|
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
|
||||||
XGrabButton(display, button, modifiers | MaskList[cnt], grab_window,
|
XGrabButton(display, button, modifiers | MaskList[cnt], grab_window,
|
||||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||||
confine_to, cursor);
|
confine_to, cursor);
|
||||||
#else // NOCLOBBER
|
#else // NOCLOBBER
|
||||||
XGrabButton(display, button, modifiers, grab_window,
|
XGrabButton(display, button, modifiers, grab_window,
|
||||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||||
confine_to, cursor);
|
confine_to, cursor);
|
||||||
#endif // NOCLOBBER
|
#endif // NOCLOBBER
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Releases the grab on a button, and ungrabs all possible combinations of the
|
* Releases the grab on a button, and ungrabs all possible combinations of the
|
||||||
* keyboard lock keys.
|
* keyboard lock keys.
|
||||||
*/
|
*/
|
||||||
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
|
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
|
||||||
Window grab_window) const {
|
Window grab_window) const {
|
||||||
#ifndef NOCLOBBER
|
#ifndef NOCLOBBER
|
||||||
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
|
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
|
||||||
XUngrabButton(display, button, modifiers | MaskList[cnt], grab_window);
|
XUngrabButton(display, button, modifiers | MaskList[cnt], grab_window);
|
||||||
#else // NOCLOBBER
|
#else // NOCLOBBER
|
||||||
XUngrabButton(display, button, modifiers, grab_window);
|
XUngrabButton(display, button, modifiers, grab_window);
|
||||||
#endif // NOCLOBBER
|
#endif // NOCLOBBER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
|
ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
|
||||||
screen_number(num)
|
screen_number(num)
|
||||||
{
|
{
|
||||||
|
|
||||||
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
|
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
|
||||||
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
|
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
|
||||||
|
|
||||||
m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
||||||
screen_number)),
|
screen_number)),
|
||||||
HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
||||||
screen_number)));
|
screen_number)));
|
||||||
|
|
||||||
// search for a TrueColor Visual... if we can't find one... we will use the
|
// search for a TrueColor Visual... if we can't find one... we will use the
|
||||||
// default visual for the screen
|
// default visual for the screen
|
||||||
XVisualInfo vinfo_template, *vinfo_return;
|
XVisualInfo vinfo_template, *vinfo_return;
|
||||||
int vinfo_nitems;
|
int vinfo_nitems;
|
||||||
|
|
||||||
vinfo_template.screen = screen_number;
|
vinfo_template.screen = screen_number;
|
||||||
vinfo_template.c_class = TrueColor;
|
vinfo_template.c_class = TrueColor;
|
||||||
|
|
||||||
visual = (Visual *) 0;
|
visual = (Visual *) 0;
|
||||||
|
|
||||||
if ((vinfo_return = XGetVisualInfo(basedisplay.getXDisplay(),
|
if ((vinfo_return = XGetVisualInfo(basedisplay.getXDisplay(),
|
||||||
VisualScreenMask | VisualClassMask,
|
VisualScreenMask | VisualClassMask,
|
||||||
&vinfo_template, &vinfo_nitems)) &&
|
&vinfo_template, &vinfo_nitems)) &&
|
||||||
vinfo_nitems > 0) {
|
vinfo_nitems > 0) {
|
||||||
for (int i = 0; i < vinfo_nitems; i++) {
|
for (int i = 0; i < vinfo_nitems; i++) {
|
||||||
if (depth < (vinfo_return + i)->depth) {
|
if (depth < (vinfo_return + i)->depth) {
|
||||||
depth = (vinfo_return + i)->depth;
|
depth = (vinfo_return + i)->depth;
|
||||||
visual = (vinfo_return + i)->visual;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
366
src/Basemenu.cc
366
src/Basemenu.cc
|
@ -87,46 +87,46 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
|
||||||
|
|
||||||
menu.bevel_w = screen.getBevelWidth();
|
menu.bevel_w = screen.getBevelWidth();
|
||||||
|
|
||||||
if (i18n->multibyte())
|
if (i18n.multibyte())
|
||||||
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
||||||
screen.getMenuStyle()->t_fontset_extents->max_ink_extent.height +
|
screen.getMenuStyle()->t_fontset_extents->max_ink_extent.height +
|
||||||
(menu.bevel_w * 2);
|
(menu.bevel_w * 2);
|
||||||
else
|
else
|
||||||
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
||||||
screen.getMenuStyle()->t_font->ascent +
|
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.label = 0;
|
||||||
|
|
||||||
menu.sublevels =
|
menu.sublevels =
|
||||||
menu.persub =
|
menu.persub =
|
||||||
menu.minsub = 0;
|
menu.minsub = 0;
|
||||||
|
|
||||||
MenuStyle *style = screen.getMenuStyle();
|
MenuStyle *style = screen.getMenuStyle();
|
||||||
if (i18n->multibyte()) {
|
if (i18n.multibyte()) {
|
||||||
menu.item_h = style->f_fontset_extents->max_ink_extent.height +
|
menu.item_h = style->f_fontset_extents->max_ink_extent.height +
|
||||||
(menu.bevel_w);
|
(menu.bevel_w);
|
||||||
} else {
|
} else {
|
||||||
menu.item_h = style->f_font->ascent + style->f_font->descent +
|
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;
|
menu.height = menu.title_h + screen.getBorderWidth() + menu.frame_h;
|
||||||
|
|
||||||
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
||||||
CWColormap | CWOverrideRedirect | CWEventMask;
|
CWColormap | CWOverrideRedirect | CWEventMask;
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
attrib.background_pixmap = None;
|
attrib.background_pixmap = None;
|
||||||
attrib.background_pixel = attrib.border_pixel =
|
attrib.background_pixel = attrib.border_pixel =
|
||||||
screen.getBorderColor()->getPixel();
|
screen.getBorderColor()->getPixel();
|
||||||
attrib.colormap = screen.getColormap();
|
attrib.colormap = screen.getColormap();
|
||||||
attrib.override_redirect = True;
|
attrib.override_redirect = True;
|
||||||
attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
|
attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
|
||||||
ButtonMotionMask | ExposureMask;
|
ButtonMotionMask | ExposureMask;
|
||||||
|
|
||||||
menu.window =
|
menu.window =
|
||||||
XCreateWindow(display, screen.getRootWindow(), menu.x, menu.y, menu.width,
|
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);
|
InputOutput, screen.getVisual(), attrib_mask, &attrib);
|
||||||
openbox.saveMenuSearch(menu.window, this);
|
openbox.saveMenuSearch(menu.window, this);
|
||||||
|
|
||||||
|
@ -136,16 +136,16 @@ Basemenu::Basemenu(BScreen &scrn) : openbox(scrn.getOpenbox()), screen(scrn) {
|
||||||
|
|
||||||
menu.title =
|
menu.title =
|
||||||
XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0,
|
XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0,
|
||||||
screen.getDepth(), InputOutput, screen.getVisual(),
|
screen.getDepth(), InputOutput, screen.getVisual(),
|
||||||
attrib_mask, &attrib);
|
attrib_mask, &attrib);
|
||||||
openbox.saveMenuSearch(menu.title, this);
|
openbox.saveMenuSearch(menu.title, this);
|
||||||
|
|
||||||
attrib.event_mask |= PointerMotionMask;
|
attrib.event_mask |= PointerMotionMask;
|
||||||
menu.frame = XCreateWindow(display, menu.window, 0,
|
menu.frame = XCreateWindow(display, menu.window, 0,
|
||||||
menu.title_h + screen.getBorderWidth(),
|
menu.title_h + screen.getBorderWidth(),
|
||||||
menu.width, menu.frame_h, 0,
|
menu.width, menu.frame_h, 0,
|
||||||
screen.getDepth(), InputOutput,
|
screen.getDepth(), InputOutput,
|
||||||
screen.getVisual(), attrib_mask, &attrib);
|
screen.getVisual(), attrib_mask, &attrib);
|
||||||
openbox.saveMenuSearch(menu.frame, this);
|
openbox.saveMenuSearch(menu.frame, this);
|
||||||
|
|
||||||
// even though this is the end of the constructor the menu is still not
|
// even though this is the end of the constructor the menu is still not
|
||||||
|
@ -243,15 +243,15 @@ int Basemenu::remove(int index) {
|
||||||
Basemenu *tmp = (Basemenu *) item->submenu();
|
Basemenu *tmp = (Basemenu *) item->submenu();
|
||||||
|
|
||||||
if (! tmp->internal_menu) {
|
if (! tmp->internal_menu) {
|
||||||
delete tmp;
|
delete tmp;
|
||||||
} else {
|
} else {
|
||||||
tmp->internal_hide();
|
tmp->internal_hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->label())
|
if (item->label())
|
||||||
delete [] item->label();
|
delete [] item->label();
|
||||||
|
|
||||||
if (item->exec())
|
if (item->exec())
|
||||||
delete [] item->exec();
|
delete [] item->exec();
|
||||||
|
|
||||||
|
@ -269,33 +269,33 @@ int Basemenu::remove(int index) {
|
||||||
|
|
||||||
void Basemenu::update(void) {
|
void Basemenu::update(void) {
|
||||||
MenuStyle *style = screen.getMenuStyle();
|
MenuStyle *style = screen.getMenuStyle();
|
||||||
if (i18n->multibyte()) {
|
if (i18n.multibyte()) {
|
||||||
menu.item_h = style->f_fontset_extents->max_ink_extent.height +
|
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.title_h = style->t_fontset_extents->max_ink_extent.height +
|
||||||
(menu.bevel_w * 2);
|
(menu.bevel_w * 2);
|
||||||
} else {
|
} else {
|
||||||
menu.item_h = style->f_font->ascent + style->f_font->descent +
|
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.title_h = style->t_font->ascent + style->t_font->descent +
|
||||||
(menu.bevel_w * 2);
|
(menu.bevel_w * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title_vis) {
|
if (title_vis) {
|
||||||
const char *s = (menu.label) ? menu.label :
|
const char *s = (menu.label) ? menu.label :
|
||||||
i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
|
i18n(BasemenuSet, BasemenuOpenboxMenu,
|
||||||
"Openbox Menu");
|
"Openbox Menu");
|
||||||
int l = strlen(s);
|
int l = strlen(s);
|
||||||
|
|
||||||
|
|
||||||
if (i18n->multibyte()) {
|
|
||||||
|
if (i18n.multibyte()) {
|
||||||
XRectangle ink, logical;
|
XRectangle ink, logical;
|
||||||
XmbTextExtents(screen.getMenuStyle()->t_fontset, s, l, &ink, &logical);
|
XmbTextExtents(screen.getMenuStyle()->t_fontset, s, l, &ink, &logical);
|
||||||
menu.item_w = logical.width;
|
menu.item_w = logical.width;
|
||||||
} else {
|
} else {
|
||||||
menu.item_w = XTextWidth(screen.getMenuStyle()->t_font, s, l);
|
menu.item_w = XTextWidth(screen.getMenuStyle()->t_font, s, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.item_w += (menu.bevel_w * 2);
|
menu.item_w += (menu.bevel_w * 2);
|
||||||
} else {
|
} else {
|
||||||
menu.item_w = 1;
|
menu.item_w = 1;
|
||||||
|
@ -305,10 +305,10 @@ void Basemenu::update(void) {
|
||||||
menuitemList::const_iterator it = menuitems.begin();
|
menuitemList::const_iterator it = menuitems.begin();
|
||||||
for (; it != menuitems.end(); it++) {
|
for (; it != menuitems.end(); it++) {
|
||||||
const char *s = (((*it)->u && *(*it)->u) ? *(*it)->u :
|
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);
|
int l = strlen(s);
|
||||||
|
|
||||||
if (i18n->multibyte()) {
|
if (i18n.multibyte()) {
|
||||||
XRectangle ink, logical;
|
XRectangle ink, logical;
|
||||||
XmbTextExtents(screen.getMenuStyle()->f_fontset, s, l, &ink, &logical);
|
XmbTextExtents(screen.getMenuStyle()->f_fontset, s, l, &ink, &logical);
|
||||||
ii = logical.width;
|
ii = logical.width;
|
||||||
|
@ -324,8 +324,8 @@ void Basemenu::update(void) {
|
||||||
menu.sublevels = 1;
|
menu.sublevels = 1;
|
||||||
|
|
||||||
while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels)
|
while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels)
|
||||||
+ menu.title_h + screen.getBorderWidth()) >
|
+ menu.title_h + screen.getBorderWidth()) >
|
||||||
screen.size().h())
|
screen.size().h())
|
||||||
menu.sublevels++;
|
menu.sublevels++;
|
||||||
|
|
||||||
if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
|
if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
|
||||||
|
@ -342,7 +342,7 @@ void Basemenu::update(void) {
|
||||||
|
|
||||||
menu.frame_h = (menu.item_h * menu.persub);
|
menu.frame_h = (menu.item_h * menu.persub);
|
||||||
menu.height = ((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) +
|
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.frame_h) menu.frame_h = 1;
|
||||||
if (menu.height < 1) menu.height = 1;
|
if (menu.height < 1) menu.height = 1;
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ void Basemenu::update(void) {
|
||||||
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
||||||
menu.title_pixmap = None;
|
menu.title_pixmap = None;
|
||||||
XSetWindowBackground(display, menu.title,
|
XSetWindowBackground(display, menu.title,
|
||||||
texture->getColor()->getPixel());
|
texture->getColor()->getPixel());
|
||||||
} else {
|
} else {
|
||||||
menu.title_pixmap =
|
menu.title_pixmap =
|
||||||
image_ctrl->renderImage(menu.width, menu.title_h, texture);
|
image_ctrl->renderImage(menu.width, menu.title_h, texture);
|
||||||
|
@ -369,7 +369,7 @@ void Basemenu::update(void) {
|
||||||
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
||||||
menu.frame_pixmap = None;
|
menu.frame_pixmap = None;
|
||||||
XSetWindowBackground(display, menu.frame,
|
XSetWindowBackground(display, menu.frame,
|
||||||
texture->getColor()->getPixel());
|
texture->getColor()->getPixel());
|
||||||
} else {
|
} else {
|
||||||
menu.frame_pixmap =
|
menu.frame_pixmap =
|
||||||
image_ctrl->renderImage(menu.width, menu.frame_h, texture);
|
image_ctrl->renderImage(menu.width, menu.frame_h, texture);
|
||||||
|
@ -403,9 +403,9 @@ void Basemenu::update(void) {
|
||||||
XResizeWindow(display, menu.title, menu.width, menu.title_h);
|
XResizeWindow(display, menu.title, menu.width, menu.title_h);
|
||||||
|
|
||||||
XMoveResizeWindow(display, menu.frame, 0,
|
XMoveResizeWindow(display, menu.frame, 0,
|
||||||
((title_vis) ? menu.title_h +
|
((title_vis) ? menu.title_h +
|
||||||
screen.getBorderWidth() : 0), menu.width,
|
screen.getBorderWidth() : 0), menu.width,
|
||||||
menu.frame_h);
|
menu.frame_h);
|
||||||
|
|
||||||
XClearWindow(display, menu.window);
|
XClearWindow(display, menu.window);
|
||||||
XClearWindow(display, menu.title);
|
XClearWindow(display, menu.title);
|
||||||
|
@ -436,7 +436,7 @@ void Basemenu::show(void) {
|
||||||
|
|
||||||
if (! parent) {
|
if (! parent) {
|
||||||
if (shown && (! shown->torn))
|
if (shown && (! shown->torn))
|
||||||
shown->hide();
|
shown->hide();
|
||||||
|
|
||||||
shown = this;
|
shown = this;
|
||||||
}
|
}
|
||||||
|
@ -487,12 +487,12 @@ void Basemenu::move(int x, int y) {
|
||||||
|
|
||||||
void Basemenu::redrawTitle(void) {
|
void Basemenu::redrawTitle(void) {
|
||||||
char *text = (char *) ((menu.label) ? menu.label :
|
char *text = (char *) ((menu.label) ? menu.label :
|
||||||
i18n->getMessage(BasemenuSet, BasemenuOpenboxMenu,
|
i18n(BasemenuSet, BasemenuOpenboxMenu,
|
||||||
"Openbox Menu"));
|
"Openbox Menu"));
|
||||||
int dx = menu.bevel_w, len = strlen(text);
|
int dx = menu.bevel_w, len = strlen(text);
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
|
|
||||||
if (i18n->multibyte()) {
|
if (i18n.multibyte()) {
|
||||||
XRectangle ink, logical;
|
XRectangle ink, logical;
|
||||||
XmbTextExtents(screen.getMenuStyle()->t_fontset, text, len, &ink, &logical);
|
XmbTextExtents(screen.getMenuStyle()->t_fontset, text, len, &ink, &logical);
|
||||||
l = logical.width;
|
l = logical.width;
|
||||||
|
@ -513,13 +513,13 @@ void Basemenu::redrawTitle(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuStyle *style = screen.getMenuStyle();
|
MenuStyle *style = screen.getMenuStyle();
|
||||||
if (i18n->multibyte())
|
if (i18n.multibyte())
|
||||||
XmbDrawString(display, menu.title, style->t_fontset, style->t_text_gc, dx,
|
XmbDrawString(display, menu.title, style->t_fontset, style->t_text_gc, dx,
|
||||||
(menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
|
(menu.bevel_w - style->t_fontset_extents->max_ink_extent.y),
|
||||||
text, len);
|
text, len);
|
||||||
else
|
else
|
||||||
XDrawString(display, menu.title, style->t_text_gc, dx,
|
XDrawString(display, menu.title, style->t_text_gc, dx,
|
||||||
(style->t_font->ascent + menu.bevel_w), text, len);
|
(style->t_font->ascent + menu.bevel_w), text, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,47 +534,47 @@ void Basemenu::drawSubmenu(int index) {
|
||||||
if (index >= 0 && index < (signed)menuitems.size()) {
|
if (index >= 0 && index < (signed)menuitems.size()) {
|
||||||
BasemenuItem *item = menuitems[index];
|
BasemenuItem *item = menuitems[index];
|
||||||
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
|
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
|
||||||
item->isEnabled()) {
|
item->isEnabled()) {
|
||||||
if (item->submenu()->parent != this) item->submenu()->parent = this;
|
if (item->submenu()->parent != this) item->submenu()->parent = this;
|
||||||
int sbl = index / menu.persub, i = index - (sbl * menu.persub),
|
int sbl = index / menu.persub, i = index - (sbl * menu.persub),
|
||||||
x = menu.x +
|
x = menu.x +
|
||||||
((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
|
((menu.item_w * (sbl + 1)) + screen.getBorderWidth()), y;
|
||||||
|
|
||||||
if (alignment == AlignTop)
|
if (alignment == AlignTop)
|
||||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||||
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
|
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
|
||||||
((item->submenu()->title_vis) ?
|
((item->submenu()->title_vis) ?
|
||||||
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
|
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
|
||||||
else
|
else
|
||||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||||
(menu.item_h * i) +
|
(menu.item_h * i) +
|
||||||
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
|
((title_vis) ? menu.title_h + screen.getBorderWidth() : 0) -
|
||||||
((item->submenu()->title_vis) ?
|
((item->submenu()->title_vis) ?
|
||||||
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
|
item->submenu()->menu.title_h + screen.getBorderWidth() : 0));
|
||||||
|
|
||||||
if (alignment == AlignBottom &&
|
if (alignment == AlignBottom &&
|
||||||
(y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
|
(y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
|
||||||
menu.y) + menu.height)
|
menu.y) + menu.height)
|
||||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||||
menu.height - item->submenu()->menu.height);
|
menu.height - item->submenu()->menu.height);
|
||||||
|
|
||||||
if ((x + item->submenu()->getWidth()) > screen.size().w()) {
|
if ((x + item->submenu()->getWidth()) > screen.size().w()) {
|
||||||
x = ((shifted) ? menu.x_shift : menu.x) -
|
x = ((shifted) ? menu.x_shift : menu.x) -
|
||||||
item->submenu()->getWidth() - screen.getBorderWidth();
|
item->submenu()->getWidth() - screen.getBorderWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x < 0) x = 0;
|
if (x < 0) x = 0;
|
||||||
|
|
||||||
if ((y + item->submenu()->getHeight()) > screen.size().h())
|
if ((y + item->submenu()->getHeight()) > screen.size().h())
|
||||||
y = screen.size().h() - item->submenu()->getHeight() -
|
y = screen.size().h() - item->submenu()->getHeight() -
|
||||||
(screen.getBorderWidth() * 2);
|
(screen.getBorderWidth() * 2);
|
||||||
if (y < 0) y = 0;
|
if (y < 0) y = 0;
|
||||||
|
|
||||||
item->submenu()->move(x, y);
|
item->submenu()->move(x, y);
|
||||||
if (! moving) drawItem(index, True);
|
if (! moving) drawItem(index, True);
|
||||||
|
|
||||||
if (! item->submenu()->isVisible())
|
if (! item->submenu()->isVisible())
|
||||||
item->submenu()->show();
|
item->submenu()->show();
|
||||||
item->submenu()->moving = moving;
|
item->submenu()->moving = moving;
|
||||||
which_sub = index;
|
which_sub = index;
|
||||||
} else {
|
} else {
|
||||||
|
@ -592,13 +592,13 @@ bool Basemenu::hasSubmenu(int index) {
|
||||||
|
|
||||||
|
|
||||||
void Basemenu::drawItem(int index, Bool highlight, Bool clear,
|
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;
|
if (index < 0 || index > (signed)menuitems.size()) return;
|
||||||
|
|
||||||
BasemenuItem *item = menuitems[index];
|
BasemenuItem *item = menuitems[index];
|
||||||
if (! item) return;
|
if (! item) return;
|
||||||
|
|
||||||
Bool dotext = True, dohilite = True, dosel = True;
|
Bool dotext = True, dohilite = True, dosel = True;
|
||||||
const char *text = (item->ulabel()) ? *item->ulabel() : item->label();
|
const char *text = (item->ulabel()) ? *item->ulabel() : item->label();
|
||||||
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
|
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
|
||||||
|
@ -606,62 +606,62 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
|
||||||
int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0;
|
int 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;
|
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,
|
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;
|
unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4;
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
if (i18n->multibyte()) {
|
if (i18n.multibyte()) {
|
||||||
XRectangle ink, logical;
|
XRectangle ink, logical;
|
||||||
XmbTextExtents(screen.getMenuStyle()->f_fontset,
|
XmbTextExtents(screen.getMenuStyle()->f_fontset,
|
||||||
text, len, &ink, &logical);
|
text, len, &ink, &logical);
|
||||||
text_w = logical.width;
|
text_w = logical.width;
|
||||||
text_y = item_y + (menu.bevel_w / 2) -
|
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 {
|
} else {
|
||||||
text_w = XTextWidth(screen.getMenuStyle()->f_font, text, len);
|
text_w = XTextWidth(screen.getMenuStyle()->f_font, text, len);
|
||||||
text_y = item_y +
|
text_y = item_y +
|
||||||
screen.getMenuStyle()->f_font->ascent +
|
screen.getMenuStyle()->f_font->ascent +
|
||||||
(menu.bevel_w / 2);
|
(menu.bevel_w / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(screen.getMenuStyle()->f_justify) {
|
switch(screen.getMenuStyle()->f_justify) {
|
||||||
case BScreen::LeftJustify:
|
case BScreen::LeftJustify:
|
||||||
text_x = item_x + menu.bevel_w + menu.item_h + 1;
|
text_x = item_x + menu.bevel_w + menu.item_h + 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BScreen::RightJustify:
|
case BScreen::RightJustify:
|
||||||
text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
|
text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BScreen::CenterJustify:
|
case BScreen::CenterJustify:
|
||||||
text_x = item_x + ((menu.item_w + 1 - text_w) / 2);
|
text_x = item_x + ((menu.item_w + 1 - text_w) / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_h = menu.item_h - menu.bevel_w;
|
text_h = menu.item_h - menu.bevel_w;
|
||||||
}
|
}
|
||||||
|
|
||||||
GC gc =
|
GC gc =
|
||||||
((highlight || item->isSelected()) ? screen.getMenuStyle()->h_text_gc :
|
((highlight || item->isSelected()) ? screen.getMenuStyle()->h_text_gc :
|
||||||
screen.getMenuStyle()->f_text_gc),
|
screen.getMenuStyle()->f_text_gc),
|
||||||
tgc =
|
tgc =
|
||||||
((highlight) ? screen.getMenuStyle()->h_text_gc :
|
((highlight) ? screen.getMenuStyle()->h_text_gc :
|
||||||
((item->isEnabled()) ? screen.getMenuStyle()->f_text_gc :
|
((item->isEnabled()) ? screen.getMenuStyle()->f_text_gc :
|
||||||
screen.getMenuStyle()->d_text_gc));
|
screen.getMenuStyle()->d_text_gc));
|
||||||
|
|
||||||
sel_x = item_x;
|
sel_x = item_x;
|
||||||
if (screen.getMenuStyle()->bullet_pos == Right)
|
if (screen.getMenuStyle()->bullet_pos == Right)
|
||||||
sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
|
sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
|
||||||
sel_x += quarter_w;
|
sel_x += quarter_w;
|
||||||
sel_y = item_y + quarter_w;
|
sel_y = item_y + quarter_w;
|
||||||
|
|
||||||
if (clear) {
|
if (clear) {
|
||||||
XClearArea(display, menu.frame, item_x, item_y, menu.item_w, menu.item_h,
|
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)) {
|
} else if (! (x == y && y == -1 && w == h && h == 0)) {
|
||||||
// calculate the which part of the hilite to redraw
|
// calculate the which part of the hilite to redraw
|
||||||
if (! (max(item_x, x) <= (signed) min(item_x + menu.item_w, x + w) &&
|
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;
|
dohilite = False;
|
||||||
} else {
|
} else {
|
||||||
hilite_x = max(item_x, x);
|
hilite_x = max(item_x, x);
|
||||||
|
@ -671,44 +671,44 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
|
||||||
hoff_x = hilite_x % menu.item_w;
|
hoff_x = hilite_x % menu.item_w;
|
||||||
hoff_y = hilite_y % menu.item_h;
|
hoff_y = hilite_y % menu.item_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we need to redraw the text
|
// check if we need to redraw the text
|
||||||
int text_ry = item_y + (menu.bevel_w / 2);
|
int text_ry = item_y + (menu.bevel_w / 2);
|
||||||
if (! (max(text_x, x) <= (signed) min(text_x + text_w, x + w) &&
|
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;
|
dotext = False;
|
||||||
|
|
||||||
// check if we need to redraw the select pixmap/menu bullet
|
// check if we need to redraw the select pixmap/menu bullet
|
||||||
if (! (max(sel_x, x) <= (signed) min(sel_x + half_w, x + w) &&
|
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;
|
dosel = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
|
if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
|
||||||
if (menu.hilite_pixmap)
|
if (menu.hilite_pixmap)
|
||||||
XCopyArea(display, menu.hilite_pixmap, menu.frame,
|
XCopyArea(display, menu.hilite_pixmap, menu.frame,
|
||||||
screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
|
screen.getMenuStyle()->hilite_gc, hoff_x, hoff_y,
|
||||||
hilite_w, hilite_h, hilite_x, hilite_y);
|
hilite_w, hilite_h, hilite_x, hilite_y);
|
||||||
else
|
else
|
||||||
XFillRectangle(display, menu.frame,
|
XFillRectangle(display, menu.frame,
|
||||||
screen.getMenuStyle()->hilite_gc,
|
screen.getMenuStyle()->hilite_gc,
|
||||||
hilite_x, hilite_y, hilite_w, hilite_h);
|
hilite_x, hilite_y, hilite_w, hilite_h);
|
||||||
} else if (dosel && item->isSelected() &&
|
} else if (dosel && item->isSelected() &&
|
||||||
(menu.sel_pixmap != ParentRelative)) {
|
(menu.sel_pixmap != ParentRelative)) {
|
||||||
if (menu.sel_pixmap)
|
if (menu.sel_pixmap)
|
||||||
XCopyArea(display, menu.sel_pixmap, menu.frame,
|
XCopyArea(display, menu.sel_pixmap, menu.frame,
|
||||||
screen.getMenuStyle()->hilite_gc, 0, 0,
|
screen.getMenuStyle()->hilite_gc, 0, 0,
|
||||||
half_w, half_w, sel_x, sel_y);
|
half_w, half_w, sel_x, sel_y);
|
||||||
else
|
else
|
||||||
XFillRectangle(display, menu.frame,
|
XFillRectangle(display, menu.frame,
|
||||||
screen.getMenuStyle()->hilite_gc,
|
screen.getMenuStyle()->hilite_gc,
|
||||||
sel_x, sel_y, half_w, half_w);
|
sel_x, sel_y, half_w, half_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dotext && text) {
|
if (dotext && text) {
|
||||||
if (i18n->multibyte())
|
if (i18n.multibyte())
|
||||||
XmbDrawString(display, menu.frame, screen.getMenuStyle()->f_fontset,
|
XmbDrawString(display, menu.frame, screen.getMenuStyle()->f_fontset,
|
||||||
tgc, text_x, text_y, text, len);
|
tgc, text_x, text_y, text, len);
|
||||||
else
|
else
|
||||||
XDrawString(display, menu.frame, tgc, text_x, text_y, text, len);
|
XDrawString(display, menu.frame, tgc, text_x, text_y, text, len);
|
||||||
}
|
}
|
||||||
|
@ -724,24 +724,24 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
|
||||||
|
|
||||||
if (screen.getMenuStyle()->bullet_pos == Right) {
|
if (screen.getMenuStyle()->bullet_pos == Right) {
|
||||||
tri[0].x = sel_x + quarter_w - 2;
|
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].x = 4;
|
||||||
tri[1].y = 2;
|
tri[1].y = 2;
|
||||||
tri[2].x = -4;
|
tri[2].x = -4;
|
||||||
tri[2].y = 2;
|
tri[2].y = 2;
|
||||||
} else {
|
} else {
|
||||||
tri[0].x = sel_x + quarter_w - 2;
|
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].x = 4;
|
||||||
tri[1].y = 2;
|
tri[1].y = 2;
|
||||||
tri[2].x = 0;
|
tri[2].x = 0;
|
||||||
tri[2].y = -4;
|
tri[2].y = -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFillPolygon(display, menu.frame, gc, tri, 3, Convex,
|
XFillPolygon(display, menu.frame, gc, tri, 3, Convex,
|
||||||
CoordModePrevious);
|
CoordModePrevious);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Diamond:
|
case Diamond:
|
||||||
XPoint dia[4];
|
XPoint dia[4];
|
||||||
|
|
||||||
|
@ -825,9 +825,9 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
|
||||||
BasemenuItem *item = menuitems[w];
|
BasemenuItem *item = menuitems[w];
|
||||||
|
|
||||||
if (item->submenu())
|
if (item->submenu())
|
||||||
drawSubmenu(w);
|
drawSubmenu(w);
|
||||||
else
|
else
|
||||||
drawItem(w, (item->isEnabled()), True);
|
drawItem(w, (item->isEnabled()), True);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
menu.x_move = be->x_root - menu.x;
|
menu.x_move = be->x_root - menu.x;
|
||||||
|
@ -840,34 +840,34 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
|
||||||
if (re->window == menu.title) {
|
if (re->window == menu.title) {
|
||||||
if (moving) {
|
if (moving) {
|
||||||
moving = False;
|
moving = False;
|
||||||
|
|
||||||
if (which_sub != -1)
|
if (which_sub != -1)
|
||||||
drawSubmenu(which_sub);
|
drawSubmenu(which_sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (re->x >= 0 && re->x <= (signed) menu.width &&
|
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)
|
if (re->button == 3)
|
||||||
hide();
|
hide();
|
||||||
} else if (re->window == menu.frame &&
|
} else if (re->window == menu.frame &&
|
||||||
re->x >= 0 && re->x < (signed) menu.width &&
|
re->x >= 0 && re->x < (signed) menu.width &&
|
||||||
re->y >= 0 && re->y < (signed) menu.frame_h) {
|
re->y >= 0 && re->y < (signed) menu.frame_h) {
|
||||||
if (re->button == 3) {
|
if (re->button == 3) {
|
||||||
hide();
|
hide();
|
||||||
} else {
|
} else {
|
||||||
int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h),
|
int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h),
|
||||||
ix = sbl * menu.item_w, iy = i * menu.item_h,
|
ix = sbl * menu.item_w, iy = i * menu.item_h,
|
||||||
w = (sbl * menu.persub) + i,
|
w = (sbl * menu.persub) + i,
|
||||||
p = (which_sbl * menu.persub) + which_press;
|
p = (which_sbl * menu.persub) + which_press;
|
||||||
|
|
||||||
if (w < (signed)menuitems.size() && w >= 0) {
|
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 (p == w && isItemEnabled(w)) {
|
||||||
if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
|
if (re->x > ix && re->x < (signed) (ix + menu.item_w) &&
|
||||||
re->y > iy && re->y < (signed) (iy + menu.item_h)) {
|
re->y > iy && re->y < (signed) (iy + menu.item_h)) {
|
||||||
itemSelected(re->button, w);
|
itemSelected(re->button, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
drawItem(p, False, True);
|
drawItem(p, False, True);
|
||||||
|
@ -880,44 +880,44 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
|
||||||
if (me->window == menu.title && (me->state & Button1Mask)) {
|
if (me->window == menu.title && (me->state & Button1Mask)) {
|
||||||
if (movable) {
|
if (movable) {
|
||||||
if (! moving) {
|
if (! moving) {
|
||||||
if (parent && (! torn)) {
|
if (parent && (! torn)) {
|
||||||
parent->drawItem(parent->which_sub, False, True);
|
parent->drawItem(parent->which_sub, False, True);
|
||||||
parent->which_sub = -1;
|
parent->which_sub = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
moving = torn = True;
|
moving = torn = True;
|
||||||
|
|
||||||
if (which_sub != -1)
|
if (which_sub != -1)
|
||||||
drawSubmenu(which_sub);
|
drawSubmenu(which_sub);
|
||||||
} else {
|
} else {
|
||||||
menu.x = me->x_root - menu.x_move,
|
menu.x = me->x_root - menu.x_move,
|
||||||
menu.y = me->y_root - menu.y_move;
|
menu.y = me->y_root - menu.y_move;
|
||||||
|
|
||||||
XMoveWindow(display, menu.window, menu.x, menu.y);
|
XMoveWindow(display, menu.window, menu.x, menu.y);
|
||||||
|
|
||||||
if (which_sub != -1)
|
if (which_sub != -1)
|
||||||
drawSubmenu(which_sub);
|
drawSubmenu(which_sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((! (me->state & Button1Mask)) && me->window == menu.frame &&
|
} else if ((! (me->state & Button1Mask)) && me->window == menu.frame &&
|
||||||
me->x >= 0 && me->x < (signed) menu.width &&
|
me->x >= 0 && me->x < (signed) menu.width &&
|
||||||
me->y >= 0 && me->y < (signed) menu.frame_h) {
|
me->y >= 0 && me->y < (signed) menu.frame_h) {
|
||||||
int sbl = (me->x / menu.item_w), i = (me->y / menu.item_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) &&
|
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) {
|
if (which_press != -1 && which_sbl != -1) {
|
||||||
int p = (which_sbl * menu.persub) + which_press;
|
int p = (which_sbl * menu.persub) + which_press;
|
||||||
BasemenuItem *item = menuitems[p];
|
BasemenuItem *item = menuitems[p];
|
||||||
|
|
||||||
drawItem(p, False, True);
|
drawItem(p, False, True);
|
||||||
if (item->submenu())
|
if (item->submenu())
|
||||||
if (item->submenu()->isVisible() &&
|
if (item->submenu()->isVisible() &&
|
||||||
(! item->submenu()->isTorn())) {
|
(! item->submenu()->isTorn())) {
|
||||||
item->submenu()->internal_hide();
|
item->submenu()->internal_hide();
|
||||||
which_sub = -1;
|
which_sub = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
which_press = i;
|
which_press = i;
|
||||||
|
@ -926,9 +926,9 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
|
||||||
BasemenuItem *itmp = menuitems[w];
|
BasemenuItem *itmp = menuitems[w];
|
||||||
|
|
||||||
if (itmp->submenu())
|
if (itmp->submenu())
|
||||||
drawSubmenu(w);
|
drawSubmenu(w);
|
||||||
else
|
else
|
||||||
drawItem(w, (itmp->isEnabled()), True);
|
drawItem(w, (itmp->isEnabled()), True);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -943,10 +943,10 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
|
||||||
// items down in that sublevel
|
// items down in that sublevel
|
||||||
|
|
||||||
int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h),
|
int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h),
|
||||||
// next... figure out how many sublevels over the redraw spans
|
// next... figure out how many sublevels over the redraw spans
|
||||||
sbl_d = ((ee->x + ee->width) / menu.item_w),
|
sbl_d = ((ee->x + ee->width) / menu.item_w),
|
||||||
// then we see how many items down to redraw
|
// then we see how many items down to redraw
|
||||||
id_d = ((ee->y + ee->height) / menu.item_h);
|
id_d = ((ee->y + ee->height) / menu.item_h);
|
||||||
|
|
||||||
if (id_d > menu.persub) id_d = menu.persub;
|
if (id_d > menu.persub) id_d = menu.persub;
|
||||||
|
|
||||||
|
@ -957,10 +957,10 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
|
||||||
// set the iterator to the first item in the sublevel needing redrawing
|
// set the iterator to the first item in the sublevel needing redrawing
|
||||||
it = menuitems.begin() + (id + (i * menu.persub));
|
it = menuitems.begin() + (id + (i * menu.persub));
|
||||||
for (ii = id; ii <= id_d && it != menuitems.end(); it++, ii++) {
|
for (ii = id; ii <= id_d && it != menuitems.end(); it++, ii++) {
|
||||||
int index = ii + (i * menu.persub);
|
int index = ii + (i * menu.persub);
|
||||||
// redraw the item
|
// redraw the item
|
||||||
drawItem(index, (which_sub == index), False,
|
drawItem(index, (which_sub == index), False,
|
||||||
ee->x, ee->y, ee->width, ee->height);
|
ee->x, ee->y, ee->width, ee->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -994,15 +994,15 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
|
||||||
if (which_sub != -1) {
|
if (which_sub != -1) {
|
||||||
BasemenuItem *tmp = menuitems[which_sub];
|
BasemenuItem *tmp = menuitems[which_sub];
|
||||||
if (tmp->submenu()->isVisible()) {
|
if (tmp->submenu()->isVisible()) {
|
||||||
int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
|
int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h),
|
||||||
w = (sbl * menu.persub) + i;
|
w = (sbl * menu.persub) + i;
|
||||||
|
|
||||||
if (w != which_sub && (! tmp->submenu()->isTorn())) {
|
if (w != which_sub && (! tmp->submenu()->isTorn())) {
|
||||||
tmp->submenu()->internal_hide();
|
tmp->submenu()->internal_hide();
|
||||||
|
|
||||||
drawItem(which_sub, False, True);
|
drawItem(which_sub, False, True);
|
||||||
which_sub = -1;
|
which_sub = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,9 +1031,9 @@ void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
|
||||||
|
|
||||||
void Basemenu::reconfigure(void) {
|
void Basemenu::reconfigure(void) {
|
||||||
XSetWindowBackground(display, menu.window,
|
XSetWindowBackground(display, menu.window,
|
||||||
screen.getBorderColor()->getPixel());
|
screen.getBorderColor()->getPixel());
|
||||||
XSetWindowBorder(display, menu.window,
|
XSetWindowBorder(display, menu.window,
|
||||||
screen.getBorderColor()->getPixel());
|
screen.getBorderColor()->getPixel());
|
||||||
XSetWindowBorderWidth(display, menu.window, screen.getBorderWidth());
|
XSetWindowBorderWidth(display, menu.window, screen.getBorderWidth());
|
||||||
|
|
||||||
menu.bevel_w = screen.getBevelWidth();
|
menu.bevel_w = screen.getBevelWidth();
|
||||||
|
|
|
@ -39,29 +39,29 @@
|
||||||
|
|
||||||
Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
||||||
{
|
{
|
||||||
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuConfigOptions,
|
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions,
|
||||||
"Config options"));
|
"Config options"));
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
focusmenu = new Focusmenu(this);
|
focusmenu = new Focusmenu(this);
|
||||||
placementmenu = new Placementmenu(this);
|
placementmenu = new Placementmenu(this);
|
||||||
|
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
|
||||||
"Focus Model"), focusmenu);
|
"Focus Model"), focusmenu);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
|
insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
|
||||||
"Window Placement"), placementmenu);
|
"Window Placement"), placementmenu);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuImageDithering,
|
insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
|
||||||
"Image Dithering"), 1);
|
"Image Dithering"), 1);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuOpaqueMove,
|
insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove,
|
||||||
"Opaque Window Moving"), 2);
|
"Opaque Window Moving"), 2);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFullMax,
|
insert(i18n(ConfigmenuSet, ConfigmenuFullMax,
|
||||||
"Full Maximization"), 3);
|
"Full Maximization"), 3);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusNew,
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusNew,
|
||||||
"Focus New Windows"), 4);
|
"Focus New Windows"), 4);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusLast,
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
|
||||||
"Focus Last Window on Workspace"), 5);
|
"Focus Last Window on Workspace"), 5);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuHideToolbar,
|
insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar,
|
||||||
"Hide toolbar"), 6);
|
"Hide toolbar"), 6);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
|
@ -145,16 +145,16 @@ void Configmenu::reconfigure() {
|
||||||
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) {
|
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) {
|
||||||
configmenu = cm;
|
configmenu = cm;
|
||||||
|
|
||||||
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuFocusModel,
|
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel,
|
||||||
"Focus Model"));
|
"Focus Model"));
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickToFocus,
|
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus,
|
||||||
"Click To Focus"), 1);
|
"Click To Focus"), 1);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSloppyFocus,
|
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus,
|
||||||
"Sloppy Focus"), 2);
|
"Sloppy Focus"), 2);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuAutoRaise,
|
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise,
|
||||||
"Auto Raise"), 3);
|
"Auto Raise"), 3);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
|
@ -207,37 +207,37 @@ void Configmenu::Focusmenu::itemSelected(int button, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
|
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
|
||||||
Basemenu(cm->screen) {
|
Basemenu(cm->screen) {
|
||||||
configmenu = cm;
|
configmenu = cm;
|
||||||
|
|
||||||
setLabel(i18n->getMessage(ConfigmenuSet, ConfigmenuWindowPlacement,
|
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
|
||||||
"Window Placement"));
|
"Window Placement"));
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartRows,
|
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows,
|
||||||
"Smart Placement (Rows)"),
|
"Smart Placement (Rows)"),
|
||||||
BScreen::RowSmartPlacement);
|
BScreen::RowSmartPlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuSmartCols,
|
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols,
|
||||||
"Smart Placement (Columns)"),
|
"Smart Placement (Columns)"),
|
||||||
BScreen::ColSmartPlacement);
|
BScreen::ColSmartPlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuCascade,
|
insert(i18n(ConfigmenuSet, ConfigmenuCascade,
|
||||||
"Cascade Placement"), BScreen::CascadePlacement);
|
"Cascade Placement"), BScreen::CascadePlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBestFit,
|
insert(i18n(ConfigmenuSet, ConfigmenuBestFit,
|
||||||
"Best Fit Placement"), BScreen::BestFitPlacement);
|
"Best Fit Placement"), BScreen::BestFitPlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse,
|
insert(i18n(ConfigmenuSet, ConfigmenuUnderMouse,
|
||||||
"Under Mouse Placement"),
|
"Under Mouse Placement"),
|
||||||
BScreen::UnderMousePlacement);
|
BScreen::UnderMousePlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuClickMouse,
|
insert(i18n(ConfigmenuSet, ConfigmenuClickMouse,
|
||||||
"Click Mouse Placement"),
|
"Click Mouse Placement"),
|
||||||
BScreen::ClickMousePlacement);
|
BScreen::ClickMousePlacement);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight,
|
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight,
|
||||||
"Left to Right"), BScreen::LeftRight);
|
"Left to Right"), BScreen::LeftRight);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft,
|
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft,
|
||||||
"Right to Left"), BScreen::RightLeft);
|
"Right to Left"), BScreen::RightLeft);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuTopBottom,
|
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom,
|
||||||
"Top to Bottom"), BScreen::TopBottom);
|
"Top to Bottom"), BScreen::TopBottom);
|
||||||
insert(i18n->getMessage(ConfigmenuSet, ConfigmenuBottomTop,
|
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop,
|
||||||
"Bottom to Top"), BScreen::BottomTop);
|
"Bottom to Top"), BScreen::BottomTop);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
|
@ -253,9 +253,9 @@ void Configmenu::Placementmenu::setValues() {
|
||||||
setItemSelected(5, p == BScreen::ClickMousePlacement);
|
setItemSelected(5, p == BScreen::ClickMousePlacement);
|
||||||
|
|
||||||
bool rl = (configmenu->screen.rowPlacementDirection() ==
|
bool rl = (configmenu->screen.rowPlacementDirection() ==
|
||||||
BScreen::LeftRight),
|
BScreen::LeftRight),
|
||||||
tb = (configmenu->screen.colPlacementDirection() ==
|
tb = (configmenu->screen.colPlacementDirection() ==
|
||||||
BScreen::TopBottom);
|
BScreen::TopBottom);
|
||||||
|
|
||||||
setItemSelected(6, rl);
|
setItemSelected(6, rl);
|
||||||
setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
|
setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
setLabel(i18n->getMessage(IconSet, IconIcons, "Icons"));
|
setLabel(i18n(IconSet, IconIcons, "Icons"));
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
846
src/Image.cc
846
src/Image.cc
File diff suppressed because it is too large
Load diff
2924
src/Screen.cc
2924
src/Screen.cc
File diff suppressed because it is too large
Load diff
138
src/Slit.cc
138
src/Slit.cc
|
@ -46,10 +46,10 @@
|
||||||
using std::ends;
|
using std::ends;
|
||||||
|
|
||||||
Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()),
|
Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()),
|
||||||
screen(scr), config(conf)
|
screen(scr), config(conf)
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
|
|
||||||
display = screen.getBaseDisplay().getXDisplay();
|
display = screen.getBaseDisplay().getXDisplay();
|
||||||
frame.window = frame.pixmap = None;
|
frame.window = frame.pixmap = None;
|
||||||
|
|
||||||
|
@ -61,21 +61,21 @@ Slit::Slit(BScreen &scr, Resource &conf) : openbox(scr.getOpenbox()),
|
||||||
|
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
||||||
CWColormap | CWOverrideRedirect | CWEventMask;
|
CWColormap | CWOverrideRedirect | CWEventMask;
|
||||||
attrib.background_pixmap = None;
|
attrib.background_pixmap = None;
|
||||||
attrib.background_pixel = attrib.border_pixel =
|
attrib.background_pixel = attrib.border_pixel =
|
||||||
screen.getBorderColor()->getPixel();
|
screen.getBorderColor()->getPixel();
|
||||||
attrib.colormap = screen.getColormap();
|
attrib.colormap = screen.getColormap();
|
||||||
attrib.override_redirect = True;
|
attrib.override_redirect = True;
|
||||||
attrib.event_mask = SubstructureRedirectMask | ButtonPressMask |
|
attrib.event_mask = SubstructureRedirectMask | ButtonPressMask |
|
||||||
EnterWindowMask | LeaveWindowMask;
|
EnterWindowMask | LeaveWindowMask;
|
||||||
|
|
||||||
frame.area = Rect(0, 0, 1, 1);
|
frame.area = Rect(0, 0, 1, 1);
|
||||||
|
|
||||||
frame.window =
|
frame.window =
|
||||||
XCreateWindow(display, screen.getRootWindow(),
|
XCreateWindow(display, screen.getRootWindow(),
|
||||||
frame.area.x(), frame.area.y(),
|
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(),
|
screen.getDepth(), InputOutput, screen.getVisual(),
|
||||||
create_mask, &attrib);
|
create_mask, &attrib);
|
||||||
openbox.saveSlitSearch(frame.window, this);
|
openbox.saveSlitSearch(frame.window, this);
|
||||||
|
@ -91,7 +91,7 @@ Slit::~Slit() {
|
||||||
delete timer;
|
delete timer;
|
||||||
|
|
||||||
clientList.clear();
|
clientList.clear();
|
||||||
|
|
||||||
delete slitmenu;
|
delete slitmenu;
|
||||||
|
|
||||||
screen.getImageControl()->removeImage(frame.pixmap);
|
screen.getImageControl()->removeImage(frame.pixmap);
|
||||||
|
@ -115,16 +115,16 @@ void Slit::addClient(Window w) {
|
||||||
|
|
||||||
if (wmhints) {
|
if (wmhints) {
|
||||||
if ((wmhints->flags & IconWindowHint) &&
|
if ((wmhints->flags & IconWindowHint) &&
|
||||||
(wmhints->icon_window != None)) {
|
(wmhints->icon_window != None)) {
|
||||||
XMoveWindow(display, client->client_window, screen.size().w() + 10,
|
XMoveWindow(display, client->client_window, screen.size().w() + 10,
|
||||||
screen.size().h() + 10);
|
screen.size().h() + 10);
|
||||||
XMapWindow(display, client->client_window);
|
XMapWindow(display, client->client_window);
|
||||||
|
|
||||||
client->icon_window = wmhints->icon_window;
|
client->icon_window = wmhints->icon_window;
|
||||||
client->window = client->icon_window;
|
client->window = client->icon_window;
|
||||||
} else {
|
} else {
|
||||||
client->icon_window = None;
|
client->icon_window = None;
|
||||||
client->window = client->client_window;
|
client->window = client->client_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(wmhints);
|
XFree(wmhints);
|
||||||
|
@ -151,7 +151,7 @@ void Slit::addClient(Window w) {
|
||||||
XChangeSaveSet(display, client->window, SetModeInsert);
|
XChangeSaveSet(display, client->window, SetModeInsert);
|
||||||
|
|
||||||
XSelectInput(display, frame.window, SubstructureRedirectMask |
|
XSelectInput(display, frame.window, SubstructureRedirectMask |
|
||||||
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
|
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
|
||||||
XSelectInput(display, client->window, StructureNotifyMask |
|
XSelectInput(display, client->window, StructureNotifyMask |
|
||||||
SubstructureNotifyMask | EnterWindowMask);
|
SubstructureNotifyMask | EnterWindowMask);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
|
@ -179,10 +179,10 @@ void Slit::removeClient(SlitClient *client, Bool remap) {
|
||||||
XSelectInput(display, frame.window, NoEventMask);
|
XSelectInput(display, frame.window, NoEventMask);
|
||||||
XSelectInput(display, client->window, NoEventMask);
|
XSelectInput(display, client->window, NoEventMask);
|
||||||
XReparentWindow(display, client->window, screen.getRootWindow(),
|
XReparentWindow(display, client->window, screen.getRootWindow(),
|
||||||
client->x, client->y);
|
client->x, client->y);
|
||||||
XChangeSaveSet(display, client->window, SetModeDelete);
|
XChangeSaveSet(display, client->window, SetModeDelete);
|
||||||
XSelectInput(display, frame.window, SubstructureRedirectMask |
|
XSelectInput(display, frame.window, SubstructureRedirectMask |
|
||||||
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
|
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ void Slit::load() {
|
||||||
m_direction = Vertical;
|
m_direction = Vertical;
|
||||||
} else
|
} else
|
||||||
m_direction = Vertical;
|
m_direction = Vertical;
|
||||||
|
|
||||||
rname.seekp(0); rclass.seekp(0);
|
rname.seekp(0); rclass.seekp(0);
|
||||||
rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
|
rname.rdbuf()->freeze(0); rclass.rdbuf()->freeze(0);
|
||||||
rname << rscreen.str() << "slit.onTop" << ends;
|
rname << rscreen.str() << "slit.onTop" << ends;
|
||||||
|
@ -390,10 +390,10 @@ void Slit::reconfigure(void) {
|
||||||
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
if (texture->getTexture() == (BImage_Flat | BImage_Solid)) {
|
||||||
frame.pixmap = None;
|
frame.pixmap = None;
|
||||||
XSetWindowBackground(display, frame.window,
|
XSetWindowBackground(display, frame.window,
|
||||||
texture->getColor()->getPixel());
|
texture->getColor()->getPixel());
|
||||||
} else {
|
} else {
|
||||||
frame.pixmap = image_ctrl->renderImage(frame.area.w(), frame.area.h(),
|
frame.pixmap = image_ctrl->renderImage(frame.area.w(), frame.area.h(),
|
||||||
texture);
|
texture);
|
||||||
XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap);
|
XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap);
|
||||||
}
|
}
|
||||||
if (tmp) image_ctrl->removeImage(tmp);
|
if (tmp) image_ctrl->removeImage(tmp);
|
||||||
|
@ -560,9 +560,9 @@ void Slit::reposition(void) {
|
||||||
|
|
||||||
Toolbar *tbar = screen.getToolbar();
|
Toolbar *tbar = screen.getToolbar();
|
||||||
int sw = frame.area.w() + (screen.getBorderWidth() * 2),
|
int sw = frame.area.w() + (screen.getBorderWidth() * 2),
|
||||||
sh = frame.area.h() + (screen.getBorderWidth() * 2),
|
sh = frame.area.h() + (screen.getBorderWidth() * 2),
|
||||||
tw = tbar->area().w() + screen.getBorderWidth(),
|
tw = tbar->area().w() + screen.getBorderWidth(),
|
||||||
th = tbar->area().h() + screen.getBorderWidth();
|
th = tbar->area().h() + screen.getBorderWidth();
|
||||||
|
|
||||||
if (tbar->area().x() < frame.area.x() + sw &&
|
if (tbar->area().x() < frame.area.x() + sw &&
|
||||||
tbar->area().x() + tw > frame.area.x() &&
|
tbar->area().x() + tw > frame.area.x() &&
|
||||||
|
@ -573,22 +573,22 @@ void Slit::reposition(void) {
|
||||||
if (m_direction == Vertical)
|
if (m_direction == Vertical)
|
||||||
frame.hidden.setY(frame.hidden.y() + tbar->getExposedHeight());
|
frame.hidden.setY(frame.hidden.y() + tbar->getExposedHeight());
|
||||||
else
|
else
|
||||||
frame.hidden.setY(frame.area.y());
|
frame.hidden.setY(frame.area.y());
|
||||||
} else {
|
} else {
|
||||||
frame.area.setY(frame.area.y() - tbar->getExposedHeight());
|
frame.area.setY(frame.area.y() - tbar->getExposedHeight());
|
||||||
if (m_direction == Vertical)
|
if (m_direction == Vertical)
|
||||||
frame.hidden.setY(frame.area.y() - tbar->getExposedHeight());
|
frame.hidden.setY(frame.area.y() - tbar->getExposedHeight());
|
||||||
else
|
else
|
||||||
frame.hidden.setY(frame.area.y());
|
frame.hidden.setY(frame.area.y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_hidden)
|
if (m_hidden)
|
||||||
XMoveResizeWindow(display, frame.window, frame.hidden.x(),
|
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
|
else
|
||||||
XMoveResizeWindow(display, frame.window, frame.area.x(),
|
XMoveResizeWindow(display, frame.window, frame.area.x(),
|
||||||
frame.area.y(), frame.area.w(), frame.area.h());
|
frame.area.y(), frame.area.w(), frame.area.h());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -703,18 +703,18 @@ void Slit::timeout(void) {
|
||||||
|
|
||||||
|
|
||||||
Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen), slit(sl) {
|
Slitmenu::Slitmenu(Slit &sl) : Basemenu(sl.screen), slit(sl) {
|
||||||
setLabel(i18n->getMessage(SlitSet, SlitSlitTitle, "Slit"));
|
setLabel(i18n(SlitSet, SlitSlitTitle, "Slit"));
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
directionmenu = new Directionmenu(*this);
|
directionmenu = new Directionmenu(*this);
|
||||||
placementmenu = new Placementmenu(*this);
|
placementmenu = new Placementmenu(*this);
|
||||||
|
|
||||||
insert(i18n->getMessage(CommonSet, CommonDirectionTitle, "Direction"),
|
insert(i18n(CommonSet, CommonDirectionTitle, "Direction"),
|
||||||
directionmenu);
|
directionmenu);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementTitle, "Placement"),
|
insert(i18n(CommonSet, CommonPlacementTitle, "Placement"),
|
||||||
placementmenu);
|
placementmenu);
|
||||||
insert(i18n->getMessage(CommonSet, CommonAlwaysOnTop, "Always on top"), 1);
|
insert(i18n(CommonSet, CommonAlwaysOnTop, "Always on top"), 1);
|
||||||
insert(i18n->getMessage(CommonSet, CommonAutoHide, "Auto hide"), 2);
|
insert(i18n(CommonSet, CommonAutoHide, "Auto hide"), 2);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
@ -779,18 +779,18 @@ void Slitmenu::reconfigure(void) {
|
||||||
|
|
||||||
Slitmenu::Directionmenu::Directionmenu(Slitmenu &sm)
|
Slitmenu::Directionmenu::Directionmenu(Slitmenu &sm)
|
||||||
: Basemenu(sm.slit.screen), slitmenu(sm) {
|
: Basemenu(sm.slit.screen), slitmenu(sm) {
|
||||||
setLabel(i18n->getMessage(SlitSet, SlitSlitDirection, "Slit Direction"));
|
setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction"));
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
insert(i18n->getMessage(CommonSet, CommonDirectionHoriz, "Horizontal"),
|
insert(i18n(CommonSet, CommonDirectionHoriz, "Horizontal"),
|
||||||
Slit::Horizontal);
|
Slit::Horizontal);
|
||||||
insert(i18n->getMessage(CommonSet, CommonDirectionVert, "Vertical"),
|
insert(i18n(CommonSet, CommonDirectionVert, "Vertical"),
|
||||||
Slit::Vertical);
|
Slit::Vertical);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Slitmenu::Directionmenu::setValues() {
|
void Slitmenu::Directionmenu::setValues() {
|
||||||
|
@ -831,33 +831,33 @@ void Slitmenu::Directionmenu::itemSelected(int button, int index) {
|
||||||
Slitmenu::Placementmenu::Placementmenu(Slitmenu &sm)
|
Slitmenu::Placementmenu::Placementmenu(Slitmenu &sm)
|
||||||
: Basemenu(sm.slit.screen), slitmenu(sm) {
|
: Basemenu(sm.slit.screen), slitmenu(sm) {
|
||||||
|
|
||||||
setLabel(i18n->getMessage(SlitSet, SlitSlitPlacement, "Slit Placement"));
|
setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement"));
|
||||||
setMinimumSublevels(3);
|
setMinimumSublevels(3);
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementTopLeft, "Top Left"),
|
insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"),
|
||||||
Slit::TopLeft);
|
Slit::TopLeft);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementCenterLeft, "Center Left"),
|
insert(i18n(CommonSet, CommonPlacementCenterLeft, "Center Left"),
|
||||||
Slit::CenterLeft);
|
Slit::CenterLeft);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
|
insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"),
|
||||||
Slit::BottomLeft);
|
Slit::BottomLeft);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementTopCenter, "Top Center"),
|
insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"),
|
||||||
Slit::TopCenter);
|
Slit::TopCenter);
|
||||||
insert("");
|
insert("");
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementBottomCenter,
|
insert(i18n(CommonSet, CommonPlacementBottomCenter,
|
||||||
"Bottom Center"),
|
"Bottom Center"),
|
||||||
Slit::BottomCenter);
|
Slit::BottomCenter);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementTopRight, "Top Right"),
|
insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"),
|
||||||
Slit::TopRight);
|
Slit::TopRight);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementCenterRight,
|
insert(i18n(CommonSet, CommonPlacementCenterRight,
|
||||||
"Center Right"),
|
"Center Right"),
|
||||||
Slit::CenterRight);
|
Slit::CenterRight);
|
||||||
insert(i18n->getMessage(CommonSet, CommonPlacementBottomRight,
|
insert(i18n(CommonSet, CommonPlacementBottomRight,
|
||||||
"Bottom Right"),
|
"Bottom Right"),
|
||||||
Slit::BottomRight);
|
Slit::BottomRight);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Slitmenu::Placementmenu::itemSelected(int button, int index) {
|
void Slitmenu::Placementmenu::itemSelected(int button, int index) {
|
||||||
|
|
1780
src/Toolbar.cc
1780
src/Toolbar.cc
File diff suppressed because it is too large
Load diff
626
src/Window.cc
626
src/Window.cc
File diff suppressed because it is too large
Load diff
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
|
|
||||||
Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
|
Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
|
||||||
window(win), screen(*win.getScreen())
|
window(win), screen(*win.getScreen())
|
||||||
{
|
{
|
||||||
|
|
||||||
setTitleVisibility(False);
|
setTitleVisibility(False);
|
||||||
|
@ -51,24 +51,24 @@ Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
sendToMenu = new SendtoWorkspacemenu(*this);
|
sendToMenu = new SendtoWorkspacemenu(*this);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuSendTo, "Send To ..."),
|
insert(i18n(WindowmenuSet, WindowmenuSendTo, "Send To ..."),
|
||||||
sendToMenu);
|
sendToMenu);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuShade, "Shade"),
|
insert(i18n(WindowmenuSet, WindowmenuShade, "Shade"),
|
||||||
BScreen::WindowShade);
|
BScreen::WindowShade);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuIconify, "Iconify"),
|
insert(i18n(WindowmenuSet, WindowmenuIconify, "Iconify"),
|
||||||
BScreen::WindowIconify);
|
BScreen::WindowIconify);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuMaximize, "Maximize"),
|
insert(i18n(WindowmenuSet, WindowmenuMaximize, "Maximize"),
|
||||||
BScreen::WindowMaximize);
|
BScreen::WindowMaximize);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuRaise,"Raise"),
|
insert(i18n(WindowmenuSet, WindowmenuRaise,"Raise"),
|
||||||
BScreen::WindowRaise);
|
BScreen::WindowRaise);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuLower, "Lower"),
|
insert(i18n(WindowmenuSet, WindowmenuLower, "Lower"),
|
||||||
BScreen::WindowLower);
|
BScreen::WindowLower);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuStick, "Stick"),
|
insert(i18n(WindowmenuSet, WindowmenuStick, "Stick"),
|
||||||
BScreen::WindowStick);
|
BScreen::WindowStick);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuKillClient, "Kill Client"),
|
insert(i18n(WindowmenuSet, WindowmenuKillClient, "Kill Client"),
|
||||||
BScreen::WindowKill);
|
BScreen::WindowKill);
|
||||||
insert(i18n->getMessage(WindowmenuSet, WindowmenuClose, "Close"),
|
insert(i18n(WindowmenuSet, WindowmenuClose, "Close"),
|
||||||
BScreen::WindowClose);
|
BScreen::WindowClose);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
@ -159,11 +159,11 @@ void Windowmenu::reconfigure(void) {
|
||||||
|
|
||||||
Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu &w)
|
Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu &w)
|
||||||
: Basemenu(w.screen), windowmenu(w) {
|
: Basemenu(w.screen), windowmenu(w) {
|
||||||
setTitleVisibility(False);
|
setTitleVisibility(False);
|
||||||
setMovable(False);
|
setMovable(False);
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, int index) {
|
void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, int index) {
|
||||||
|
|
|
@ -111,10 +111,10 @@ int Workspace::removeWindow(OpenboxWindow *w) {
|
||||||
if (w->isFocused()) {
|
if (w->isFocused()) {
|
||||||
if (w == _last)
|
if (w == _last)
|
||||||
_last = (OpenboxWindow *) 0;
|
_last = (OpenboxWindow *) 0;
|
||||||
|
|
||||||
OpenboxWindow *fw = (OpenboxWindow *) 0;
|
OpenboxWindow *fw = (OpenboxWindow *) 0;
|
||||||
if (w->isTransient() && w->getTransientFor() &&
|
if (w->isTransient() && w->getTransientFor() &&
|
||||||
w->getTransientFor()->isVisible())
|
w->getTransientFor()->isVisible())
|
||||||
fw = w->getTransientFor();
|
fw = w->getTransientFor();
|
||||||
else if (screen.sloppyFocus()) // sloppy focus
|
else if (screen.sloppyFocus()) // sloppy focus
|
||||||
fw = (OpenboxWindow *) 0;
|
fw = (OpenboxWindow *) 0;
|
||||||
|
@ -124,7 +124,7 @@ int Workspace::removeWindow(OpenboxWindow *w) {
|
||||||
if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus()))
|
if (!(fw != (OpenboxWindow *) 0 && fw->setInputFocus()))
|
||||||
screen.getOpenbox().focusWindow(0);
|
screen.getOpenbox().focusWindow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_windows.erase(_windows.begin() + w->getWindowNumber());
|
_windows.erase(_windows.begin() + w->getWindowNumber());
|
||||||
clientmenu->remove(w->getWindowNumber());
|
clientmenu->remove(w->getWindowNumber());
|
||||||
clientmenu->update();
|
clientmenu->update();
|
||||||
|
@ -303,10 +303,10 @@ void Workspace::setName(const char *new_name) {
|
||||||
name = bstrdup(new_name);
|
name = bstrdup(new_name);
|
||||||
} else {
|
} else {
|
||||||
name = new char[128];
|
name = new char[128];
|
||||||
sprintf(name, i18n->getMessage(WorkspaceSet, WorkspaceDefaultNameFormat,
|
sprintf(name, i18n(WorkspaceSet, WorkspaceDefaultNameFormat,
|
||||||
"Workspace %d"), id + 1);
|
"Workspace %d"), id + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
clientmenu->setLabel(name);
|
clientmenu->setLabel(name);
|
||||||
clientmenu->update();
|
clientmenu->update();
|
||||||
screen.saveWorkspaceNames();
|
screen.saveWorkspaceNames();
|
||||||
|
@ -359,49 +359,49 @@ static rectList calcSpace(const Rect &win, const rectList &spaces) {
|
||||||
|
|
||||||
bool rowRLBT(const Rect &first, const Rect &second){
|
bool rowRLBT(const Rect &first, const Rect &second){
|
||||||
if (first.y()+first.h()==second.y()+second.h())
|
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();
|
return first.y()+first.h()>second.y()+second.h();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rowRLTB(const Rect &first, const Rect &second){
|
bool rowRLTB(const Rect &first, const Rect &second){
|
||||||
if (first.y()==second.y())
|
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();
|
return first.y()<second.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rowLRBT(const Rect &first, const Rect &second){
|
bool rowLRBT(const Rect &first, const Rect &second){
|
||||||
if (first.y()+first.h()==second.y()+second.h())
|
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();
|
return first.y()+first.h()>second.y()+second.h();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rowLRTB(const Rect &first, const Rect &second){
|
bool rowLRTB(const Rect &first, const Rect &second){
|
||||||
if (first.y()==second.y())
|
if (first.y()==second.y())
|
||||||
return first.x()<second.x();
|
return first.x()<second.x();
|
||||||
return first.y()<second.y();
|
return first.y()<second.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool colLRTB(const Rect &first, const Rect &second){
|
bool colLRTB(const Rect &first, const Rect &second){
|
||||||
if (first.x()==second.x())
|
if (first.x()==second.x())
|
||||||
return first.y()<second.y();
|
return first.y()<second.y();
|
||||||
return first.x()<second.x();
|
return first.x()<second.x();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool colLRBT(const Rect &first, const Rect &second){
|
bool colLRBT(const Rect &first, const Rect &second){
|
||||||
if (first.x()==second.x())
|
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();
|
return first.x()<second.x();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool colRLTB(const Rect &first, const Rect &second){
|
bool colRLTB(const Rect &first, const Rect &second){
|
||||||
if (first.x()+first.w()==second.x()+second.w())
|
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();
|
return first.x()+first.w()>second.x()+second.w();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool colRLBT(const Rect &first, const Rect &second){
|
bool colRLBT(const Rect &first, const Rect &second){
|
||||||
if (first.x()+first.w()==second.x()+second.w())
|
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();
|
return first.x()+first.w()>second.x()+second.w();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,13 +414,13 @@ Point *Workspace::bestFitPlacement(const Size &win_size, const Rect &space) {
|
||||||
rectList spaces;
|
rectList spaces;
|
||||||
rectList::const_iterator siter;
|
rectList::const_iterator siter;
|
||||||
spaces.push_back(space); //initially the entire screen is free
|
spaces.push_back(space); //initially the entire screen is free
|
||||||
|
|
||||||
//Find Free Spaces
|
//Find Free Spaces
|
||||||
winVect::iterator it;
|
winVect::iterator it;
|
||||||
for (it = _windows.begin(); it != _windows.end(); ++it)
|
for (it = _windows.begin(); it != _windows.end(); ++it)
|
||||||
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
||||||
spaces);
|
spaces);
|
||||||
|
|
||||||
//Find first space that fits the window
|
//Find first space that fits the window
|
||||||
best = NULL;
|
best = NULL;
|
||||||
for (siter=spaces.begin(); siter!=spaces.end(); ++siter) {
|
for (siter=spaces.begin(); siter!=spaces.end(); ++siter) {
|
||||||
|
@ -469,23 +469,23 @@ Point *Workspace::rowSmartPlacement(const Size &win_size, const Rect &space) {
|
||||||
|
|
||||||
rectList::const_iterator siter;
|
rectList::const_iterator siter;
|
||||||
spaces.push_back(space); //initially the entire screen is free
|
spaces.push_back(space); //initially the entire screen is free
|
||||||
|
|
||||||
//Find Free Spaces
|
//Find Free Spaces
|
||||||
winVect::iterator it;
|
winVect::iterator it;
|
||||||
for (it = _windows.begin(); it != _windows.end(); ++it)
|
for (it = _windows.begin(); it != _windows.end(); ++it)
|
||||||
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
||||||
spaces);
|
spaces);
|
||||||
//Sort spaces by preference
|
//Sort spaces by preference
|
||||||
if(screen.rowPlacementDirection() == BScreen::RightLeft)
|
if(screen.rowPlacementDirection() == BScreen::RightLeft)
|
||||||
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
||||||
sort(spaces.begin(),spaces.end(),rowRLTB);
|
sort(spaces.begin(),spaces.end(),rowRLTB);
|
||||||
else
|
else
|
||||||
sort(spaces.begin(),spaces.end(),rowRLBT);
|
sort(spaces.begin(),spaces.end(),rowRLBT);
|
||||||
else
|
else
|
||||||
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
||||||
sort(spaces.begin(),spaces.end(),rowLRTB);
|
sort(spaces.begin(),spaces.end(),rowLRTB);
|
||||||
else
|
else
|
||||||
sort(spaces.begin(),spaces.end(),rowLRBT);
|
sort(spaces.begin(),spaces.end(),rowLRBT);
|
||||||
best = NULL;
|
best = NULL;
|
||||||
for (siter=spaces.begin(); siter!=spaces.end(); ++siter)
|
for (siter=spaces.begin(); siter!=spaces.end(); ++siter)
|
||||||
if ((siter->w() >= win_size.w()) && (siter->h() >= win_size.h())) {
|
if ((siter->w() >= win_size.w()) && (siter->h() >= win_size.h())) {
|
||||||
|
@ -510,23 +510,23 @@ Point *Workspace::colSmartPlacement(const Size &win_size, const Rect &space) {
|
||||||
|
|
||||||
rectList::const_iterator siter;
|
rectList::const_iterator siter;
|
||||||
spaces.push_back(space); //initially the entire screen is free
|
spaces.push_back(space); //initially the entire screen is free
|
||||||
|
|
||||||
//Find Free Spaces
|
//Find Free Spaces
|
||||||
winVect::iterator it;
|
winVect::iterator it;
|
||||||
for (it = _windows.begin(); it != _windows.end(); ++it)
|
for (it = _windows.begin(); it != _windows.end(); ++it)
|
||||||
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
spaces = calcSpace((*it)->area().Inflate(screen.getBorderWidth() * 4),
|
||||||
spaces);
|
spaces);
|
||||||
//Sort spaces by user preference
|
//Sort spaces by user preference
|
||||||
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
if(screen.colPlacementDirection() == BScreen::TopBottom)
|
||||||
if(screen.rowPlacementDirection() == BScreen::LeftRight)
|
if(screen.rowPlacementDirection() == BScreen::LeftRight)
|
||||||
sort(spaces.begin(),spaces.end(),colLRTB);
|
sort(spaces.begin(),spaces.end(),colLRTB);
|
||||||
else
|
else
|
||||||
sort(spaces.begin(),spaces.end(),colRLTB);
|
sort(spaces.begin(),spaces.end(),colRLTB);
|
||||||
else
|
else
|
||||||
if(screen.rowPlacementDirection() == BScreen::LeftRight)
|
if(screen.rowPlacementDirection() == BScreen::LeftRight)
|
||||||
sort(spaces.begin(),spaces.end(),colLRBT);
|
sort(spaces.begin(),spaces.end(),colLRBT);
|
||||||
else
|
else
|
||||||
sort(spaces.begin(),spaces.end(),colRLBT);
|
sort(spaces.begin(),spaces.end(),colRLBT);
|
||||||
|
|
||||||
//Find first space that fits the window
|
//Find first space that fits the window
|
||||||
best = NULL;
|
best = NULL;
|
||||||
|
@ -591,7 +591,7 @@ void Workspace::placeWindow(OpenboxWindow &win) {
|
||||||
|
|
||||||
if (place == NULL)
|
if (place == NULL)
|
||||||
place = cascadePlacement(win, space);
|
place = cascadePlacement(win, space);
|
||||||
|
|
||||||
ASSERT(place != NULL);
|
ASSERT(place != NULL);
|
||||||
if (place->x() + window_size.w() > (signed) space.x() + space.w())
|
if (place->x() + window_size.w() > (signed) space.x() + space.w())
|
||||||
place->setX(((signed) space.x() + space.w() - window_size.w()) / 2);
|
place->setX(((signed) space.x() + space.w() - window_size.w()) / 2);
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
Workspacemenu::Workspacemenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
Workspacemenu::Workspacemenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
||||||
setInternalMenu();
|
setInternalMenu();
|
||||||
|
|
||||||
setLabel(i18n->getMessage(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
|
setLabel(i18n(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
|
||||||
"Workspaces"));
|
"Workspaces"));
|
||||||
insert(i18n->getMessage(WorkspacemenuSet, WorkspacemenuNewWorkspace,
|
insert(i18n(WorkspacemenuSet, WorkspacemenuNewWorkspace,
|
||||||
"New Workspace"));
|
"New Workspace"));
|
||||||
insert(i18n->getMessage(WorkspacemenuSet, WorkspacemenuRemoveLast,
|
insert(i18n(WorkspacemenuSet, WorkspacemenuRemoveLast,
|
||||||
"Remove Last"));
|
"Remove Last"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void Workspacemenu::itemSelected(int button, int index) {
|
||||||
else if (index == 1)
|
else if (index == 1)
|
||||||
screen.removeLastWorkspace();
|
screen.removeLastWorkspace();
|
||||||
else if ((screen.getCurrentWorkspace()->getWorkspaceID() !=
|
else if ((screen.getCurrentWorkspace()->getWorkspaceID() !=
|
||||||
(index - 2)) && ((index - 2) < screen.getWorkspaceCount()))
|
(index - 2)) && ((index - 2) < screen.getWorkspaceCount()))
|
||||||
screen.changeWorkspaceID(index - 2);
|
screen.changeWorkspaceID(index - 2);
|
||||||
|
|
||||||
if (! (screen.getWorkspacemenu()->isTorn() || isTorn()))
|
if (! (screen.getWorkspacemenu()->isTorn() || isTorn()))
|
||||||
|
|
|
@ -42,14 +42,36 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using std::cerr;
|
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) {
|
int XDisplay::XErrorHandler(Display *d, XErrorEvent *e) {
|
||||||
d=d;e=e;
|
#ifdef DEBUG
|
||||||
return 0;
|
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;
|
_grabs = 0;
|
||||||
_hasshape = false;
|
_hasshape = false;
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,11 @@ private:
|
||||||
|
|
||||||
typedef std::vector<XScreen*> XScreenList;
|
typedef std::vector<XScreen*> XScreenList;
|
||||||
XScreenList _screens;
|
XScreenList _screens;
|
||||||
|
|
||||||
|
// X error handling
|
||||||
static int XErrorHandler(Display *d, XErrorEvent *e);
|
static int XErrorHandler(Display *d, XErrorEvent *e);
|
||||||
|
static std::string _app_name;
|
||||||
|
static Window _last_bad_window;
|
||||||
|
|
||||||
// no copying!!
|
// no copying!!
|
||||||
XDisplay(const XDisplay &);
|
XDisplay(const XDisplay &);
|
||||||
|
@ -52,7 +55,7 @@ protected:
|
||||||
virtual void process_event(XEvent *) = 0;
|
virtual void process_event(XEvent *) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XDisplay(const char *dpyname = 0);
|
XDisplay(const std::string &application_name, const char *dpyname = 0);
|
||||||
virtual ~XDisplay();
|
virtual ~XDisplay();
|
||||||
|
|
||||||
XScreen *screen(unsigned int s) const;
|
XScreen *screen(unsigned int s) const;
|
||||||
|
|
74
src/i18n.cc
74
src/i18n.cc
|
@ -1,5 +1,6 @@
|
||||||
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||||
// i18n.cc for Openbox
|
// 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)
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
@ -20,52 +21,37 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "../config.h"
|
# include "../config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include "i18n.h"
|
extern "C" {
|
||||||
|
|
||||||
#include <X11/Xlocale.h>
|
#include <X11/Xlocale.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif // HAVE_STDLIB_H
|
#endif // HAVE_STDLIB_H
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
#ifdef HAVE_STRING_H
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif // HAVE_STRING_H
|
#endif // HAVE_STRING_H
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif // HAVE_STDIO_H
|
#endif // HAVE_STDIO_H
|
||||||
|
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
# include <locale.h>
|
# include <locale.h>
|
||||||
#endif // HAVE_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) {
|
#include "i18n.h"
|
||||||
mb = False;
|
|
||||||
|
I18n::I18n(const char *catalog) {
|
||||||
|
mb = false;
|
||||||
#ifdef HAVE_SETLOCALE
|
#ifdef HAVE_SETLOCALE
|
||||||
locale = setlocale(LC_ALL, "");
|
locale = setlocale(LC_ALL, "");
|
||||||
if (! locale) {
|
if (! locale) {
|
||||||
|
@ -76,7 +62,7 @@ I18n::I18n(void) {
|
||||||
} else {
|
} else {
|
||||||
// MB_CUR_MAX returns the size of a char in the current locale
|
// MB_CUR_MAX returns the size of a char in the current locale
|
||||||
if (MB_CUR_MAX > 1)
|
if (MB_CUR_MAX > 1)
|
||||||
mb = True;
|
mb = true;
|
||||||
// truncate any encoding off the end of the locale
|
// truncate any encoding off the end of the locale
|
||||||
char *l = strchr(locale, '@');
|
char *l = strchr(locale, '@');
|
||||||
if (l) *l = '\0';
|
if (l) *l = '\0';
|
||||||
|
@ -88,14 +74,12 @@ I18n::I18n(void) {
|
||||||
catalog_fd = (nl_catd) -1;
|
catalog_fd = (nl_catd) -1;
|
||||||
#endif
|
#endif
|
||||||
#endif // HAVE_SETLOCALE
|
#endif // HAVE_SETLOCALE
|
||||||
|
if (catalog)
|
||||||
catalog_filename = (char *) 0;
|
openCatalog(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
I18n::~I18n(void) {
|
I18n::~I18n() {
|
||||||
delete [] catalog_filename;
|
|
||||||
|
|
||||||
#if defined(NLS) && defined(HAVE_CATCLOSE)
|
#if defined(NLS) && defined(HAVE_CATCLOSE)
|
||||||
if (catalog_fd != (nl_catd) -1)
|
if (catalog_fd != (nl_catd) -1)
|
||||||
catclose(catalog_fd);
|
catclose(catalog_fd);
|
||||||
|
@ -105,35 +89,27 @@ I18n::~I18n(void) {
|
||||||
|
|
||||||
void I18n::openCatalog(const char *catalog) {
|
void I18n::openCatalog(const char *catalog) {
|
||||||
#if defined(NLS) && defined(HAVE_CATOPEN)
|
#if defined(NLS) && defined(HAVE_CATOPEN)
|
||||||
int lp = strlen(LOCALEPATH), lc = strlen(locale),
|
string catalog_filename = LOCALEPATH;
|
||||||
ct = strlen(catalog), len = lp + lc + ct + 3;
|
catalog_filename += '/';
|
||||||
catalog_filename = new char[len];
|
catalog_filename += locale;
|
||||||
|
catalog_filename += '/';
|
||||||
strncpy(catalog_filename, LOCALEPATH, lp);
|
catalog_filename += catalog;
|
||||||
*(catalog_filename + lp) = '/';
|
|
||||||
strncpy(catalog_filename + lp + 1, locale, lc);
|
|
||||||
*(catalog_filename + lp + lc + 1) = '/';
|
|
||||||
strncpy(catalog_filename + lp + lc + 2, catalog, ct + 1);
|
|
||||||
|
|
||||||
# ifdef MCLoadBySet
|
# ifdef MCLoadBySet
|
||||||
catalog_fd = catopen(catalog_filename, MCLoadBySet);
|
catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet);
|
||||||
# else // !MCLoadBySet
|
# else // !MCLoadBySet
|
||||||
catalog_fd = catopen(catalog_filename, NL_CAT_LOCALE);
|
catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE);
|
||||||
# endif // MCLoadBySet
|
# endif // MCLoadBySet
|
||||||
|
|
||||||
if (catalog_fd == (nl_catd) -1)
|
if (catalog_fd == (nl_catd) -1)
|
||||||
fprintf(stderr, "failed to open catalog, using default messages\n");
|
fprintf(stderr, "failed to open catalog, using default messages\n");
|
||||||
#else // !HAVE_CATOPEN
|
|
||||||
|
|
||||||
catalog_filename = (char *) 0;
|
|
||||||
#endif // HAVE_CATOPEN
|
#endif // HAVE_CATOPEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* I18n::operator()(int set, int msg, const char *msgString) const {
|
||||||
const char *I18n::getMessage(int set, int msg, const char *msgString) const {
|
|
||||||
#if defined(NLS) && defined(HAVE_CATGETS)
|
#if defined(NLS) && defined(HAVE_CATGETS)
|
||||||
if (catalog_fd != (nl_catd) -1)
|
if (catalog_fd != (nl_catd) -1)
|
||||||
return (const char *) catgets(catalog_fd, set, msg, msgString);
|
return catgets(catalog_fd, set, msg, msgString);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
return msgString;
|
return msgString;
|
||||||
|
|
23
src/i18n.h
23
src/i18n.h
|
@ -1,5 +1,6 @@
|
||||||
// i18n.h for Openbox
|
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
// i18n.hh for Openbox
|
||||||
|
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
@ -28,39 +29,35 @@
|
||||||
// add ifdefs to every call to getMessage
|
// add ifdefs to every call to getMessage
|
||||||
#include "../nls/openbox-nls.h"
|
#include "../nls/openbox-nls.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
# include <locale.h>
|
# include <locale.h>
|
||||||
#endif // HAVE_LOCALE_H
|
#endif // HAVE_LOCALE_H
|
||||||
|
|
||||||
#ifdef HAVE_NL_TYPES_H
|
#ifdef HAVE_NL_TYPES_H
|
||||||
extern "C" {
|
|
||||||
# include <nl_types.h>
|
# include <nl_types.h>
|
||||||
}
|
|
||||||
#endif // HAVE_NL_TYPES_H
|
#endif // HAVE_NL_TYPES_H
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class I18n {
|
class I18n {
|
||||||
private:
|
private:
|
||||||
char *locale, *catalog_filename;
|
char *locale;
|
||||||
bool mb;
|
bool mb;
|
||||||
#ifdef HAVE_NL_TYPES_H
|
#ifdef HAVE_NL_TYPES_H
|
||||||
nl_catd catalog_fd;
|
nl_catd catalog_fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
I18n(void);
|
I18n(const char *catalog = 0);
|
||||||
~I18n(void);
|
~I18n();
|
||||||
|
|
||||||
inline bool multibyte(void) const { return mb; }
|
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);
|
void openCatalog(const char *catalog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern I18n i18n; // located in main.cc
|
||||||
extern I18n *i18n;
|
|
||||||
extern void NLSInit(const char *);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __i18n_h
|
#endif // __i18n_h
|
||||||
|
|
100
src/main.cc
100
src/main.cc
|
@ -32,9 +32,6 @@
|
||||||
# include "../config.h"
|
# include "../config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include "i18n.h"
|
|
||||||
#include "openbox.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif // HAVE_STDIO_H
|
#endif // HAVE_STDIO_H
|
||||||
|
@ -59,68 +56,72 @@
|
||||||
#define MAXPATHLEN 255
|
#define MAXPATHLEN 255
|
||||||
#endif // MAXPATHLEN
|
#endif // MAXPATHLEN
|
||||||
|
|
||||||
|
#include "openbox.h"
|
||||||
|
#include "i18n.h"
|
||||||
|
|
||||||
|
I18n i18n("openbox.cat");
|
||||||
|
|
||||||
static void showHelp(int exitval) {
|
static void showHelp(int exitval) {
|
||||||
// print program usage and command line options
|
// print program usage and command line options
|
||||||
printf(i18n->getMessage(mainSet, mainUsage,
|
printf(i18n(mainSet, mainUsage,
|
||||||
"Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
|
"Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
|
||||||
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n\n"
|
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n\n"
|
||||||
"\t\t\t 1997 - 2000 Brad Hughes\n\n"
|
"\t\t\t 1997 - 2000 Brad Hughes\n\n"
|
||||||
" -display <string>\t\tuse display connection.\n"
|
" -display <string>\t\tuse display connection.\n"
|
||||||
" -rc <string>\t\t\tuse alternate resource file.\n"
|
" -rc <string>\t\t\tuse alternate resource file.\n"
|
||||||
" -menu <string>\t\t\tuse alternate menu file.\n"
|
" -menu <string>\t\t\tuse alternate menu file.\n"
|
||||||
" -version\t\t\tdisplay version and exit.\n"
|
" -version\t\t\tdisplay version and exit.\n"
|
||||||
" -help\t\t\t\tdisplay this help text and exit.\n\n"),
|
" -help\t\t\t\tdisplay this help text and exit.\n\n"),
|
||||||
__openbox_version);
|
__openbox_version);
|
||||||
|
|
||||||
// some people have requested that we print out compile options
|
// some people have requested that we print out compile options
|
||||||
// as well
|
// as well
|
||||||
fprintf(stdout,i18n->getMessage(mainSet, mainCompileOptions,
|
fprintf(stdout,i18n(mainSet, mainCompileOptions,
|
||||||
"Compile time options:\n"
|
"Compile time options:\n"
|
||||||
" Debugging:\t\t\t%s\n"
|
" Debugging:\t\t\t%s\n"
|
||||||
" Interlacing:\t\t\t%s\n"
|
" Interlacing:\t\t\t%s\n"
|
||||||
" Shape:\t\t\t%s\n"
|
" Shape:\t\t\t%s\n"
|
||||||
" Slit:\t\t\t\t%s\n"
|
" Slit:\t\t\t\t%s\n"
|
||||||
" 8bpp Ordered Dithering:\t%s\n"
|
" 8bpp Ordered Dithering:\t%s\n"
|
||||||
" Event Clobbering:\t\t%s\n\n"),
|
" Event Clobbering:\t\t%s\n\n"),
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes"),
|
i18n(CommonSet, CommonYes, "yes"),
|
||||||
#else // !DEBUG
|
#else // !DEBUG
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no"),
|
i18n(CommonSet, CommonNo, "no"),
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
#ifdef INTERLACE
|
#ifdef INTERLACE
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes"),
|
i18n(CommonSet, CommonYes, "yes"),
|
||||||
#else // !INTERLACE
|
#else // !INTERLACE
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no"),
|
i18n(CommonSet, CommonNo, "no"),
|
||||||
#endif // INTERLACE
|
#endif // INTERLACE
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes"),
|
i18n(CommonSet, CommonYes, "yes"),
|
||||||
#else // !SHAPE
|
#else // !SHAPE
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no"),
|
i18n(CommonSet, CommonNo, "no"),
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
#ifdef SLIT
|
#ifdef SLIT
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes"),
|
i18n(CommonSet, CommonYes, "yes"),
|
||||||
#else // !SLIT
|
#else // !SLIT
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no"),
|
i18n(CommonSet, CommonNo, "no"),
|
||||||
#endif // SLIT
|
#endif // SLIT
|
||||||
|
|
||||||
#ifdef ORDEREDPSEUDO
|
#ifdef ORDEREDPSEUDO
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes"),
|
i18n(CommonSet, CommonYes, "yes"),
|
||||||
#else // !ORDEREDPSEUDO
|
#else // !ORDEREDPSEUDO
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no"),
|
i18n(CommonSet, CommonNo, "no"),
|
||||||
#endif // ORDEREDPSEUDO
|
#endif // ORDEREDPSEUDO
|
||||||
|
|
||||||
#ifndef NOCLOBBER
|
#ifndef NOCLOBBER
|
||||||
i18n->getMessage(CommonSet, CommonYes, "yes")
|
i18n(CommonSet, CommonYes, "yes")
|
||||||
#else // !NOCLOBBER
|
#else // !NOCLOBBER
|
||||||
i18n->getMessage(CommonSet, CommonNo, "no")
|
i18n(CommonSet, CommonNo, "no")
|
||||||
#endif // NOCLOBBER
|
#endif // NOCLOBBER
|
||||||
);
|
);
|
||||||
|
|
||||||
::exit(exitval);
|
::exit(exitval);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -128,16 +129,14 @@ int main(int argc, char **argv) {
|
||||||
char *rc_file = (char *) 0;
|
char *rc_file = (char *) 0;
|
||||||
char *menu_file = (char *) 0;
|
char *menu_file = (char *) 0;
|
||||||
|
|
||||||
NLSInit("openbox.cat");
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (! strcmp(argv[i], "-rc")) {
|
if (! strcmp(argv[i], "-rc")) {
|
||||||
// look for alternative rc file to use
|
// look for alternative rc file to use
|
||||||
|
|
||||||
if ((++i) >= argc) {
|
if ((++i) >= argc) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->getMessage(mainSet, mainRCRequiresArg,
|
i18n(mainSet, mainRCRequiresArg,
|
||||||
"error: '-rc' requires and argument\n"));
|
"error: '-rc' requires and argument\n"));
|
||||||
|
|
||||||
::exit(1);
|
::exit(1);
|
||||||
}
|
}
|
||||||
|
@ -148,8 +147,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if ((++i) >= argc) {
|
if ((++i) >= argc) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->getMessage(mainSet, mainMENURequiresArg,
|
i18n(mainSet, mainMENURequiresArg,
|
||||||
"error: '-menu' requires and argument\n"));
|
"error: '-menu' requires and argument\n"));
|
||||||
|
|
||||||
::exit(1);
|
::exit(1);
|
||||||
}
|
}
|
||||||
|
@ -160,11 +159,11 @@ int main(int argc, char **argv) {
|
||||||
// set by the environment variable DISPLAY
|
// set by the environment variable DISPLAY
|
||||||
|
|
||||||
if ((++i) >= argc) {
|
if ((++i) >= argc) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->getMessage(mainSet, mainDISPLAYRequiresArg,
|
i18n(mainSet, mainDISPLAYRequiresArg,
|
||||||
"error: '-display' requires an argument\n"));
|
"error: '-display' requires an argument\n"));
|
||||||
|
|
||||||
::exit(1);
|
::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_display = argv[i];
|
session_display = argv[i];
|
||||||
|
@ -172,16 +171,15 @@ int main(int argc, char **argv) {
|
||||||
sprintf(dtmp, "DISPLAY=%s", session_display);
|
sprintf(dtmp, "DISPLAY=%s", session_display);
|
||||||
|
|
||||||
if (putenv(dtmp)) {
|
if (putenv(dtmp)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->
|
i18n(mainSet, mainWarnDisplaySet,
|
||||||
getMessage(mainSet, mainWarnDisplaySet,
|
"warning: couldn't set environment variable 'DISPLAY'\n"));
|
||||||
"warning: couldn't set environment variable 'DISPLAY'\n"));
|
perror("putenv()");
|
||||||
perror("putenv()");
|
|
||||||
}
|
}
|
||||||
} else if (! strcmp(argv[i], "-version")) {
|
} else if (! strcmp(argv[i], "-version")) {
|
||||||
// print current version string
|
// print current version string
|
||||||
printf("Openbox %s : (c) 1997 - 2000 Brad Hughes\n"
|
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);
|
__openbox_version);
|
||||||
|
|
||||||
::exit(0);
|
::exit(0);
|
||||||
|
|
326
src/openbox.cc
326
src/openbox.cc
|
@ -153,94 +153,94 @@ Openbox *openbox;
|
||||||
|
|
||||||
Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
|
Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
|
||||||
char *menu) : BaseDisplay(m_argv[0], dpy_name) {
|
char *menu) : BaseDisplay(m_argv[0], dpy_name) {
|
||||||
grab();
|
grab();
|
||||||
|
|
||||||
if (! XSupportsLocale())
|
if (! XSupportsLocale())
|
||||||
fprintf(stderr, "X server does not support locale\n");
|
fprintf(stderr, "X server does not support locale\n");
|
||||||
|
|
||||||
if (XSetLocaleModifiers("") == NULL)
|
if (XSetLocaleModifiers("") == NULL)
|
||||||
fprintf(stderr, "cannot set locale modifiers\n");
|
fprintf(stderr, "cannot set locale modifiers\n");
|
||||||
|
|
||||||
::openbox = this;
|
::openbox = this;
|
||||||
argc = m_argc;
|
argc = m_argc;
|
||||||
argv = m_argv;
|
argv = m_argv;
|
||||||
if (rc == NULL || menu == NULL) {
|
if (rc == NULL || menu == NULL) {
|
||||||
char *homedir = getenv("HOME");
|
char *homedir = getenv("HOME");
|
||||||
char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
|
char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
|
||||||
sprintf(configdir, "%s/.openbox", homedir);
|
sprintf(configdir, "%s/.openbox", homedir);
|
||||||
// try to make sure the ~/.openbox directory exists
|
// try to make sure the ~/.openbox directory exists
|
||||||
mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
|
mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
|
||||||
S_IRGRP | S_IWGRP | S_IXGRP |
|
S_IRGRP | S_IWGRP | S_IXGRP |
|
||||||
S_IROTH | S_IWOTH | S_IXOTH);
|
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) {
|
if (rc == NULL) {
|
||||||
menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
|
rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
|
||||||
sprintf(menu_file, "%s/menu", configdir);
|
sprintf(rc_file, "%s/rc", configdir);
|
||||||
} else
|
} else
|
||||||
menu_file = bstrdup(menu);
|
rc_file = bstrdup(rc);
|
||||||
|
|
||||||
delete [] configdir;
|
if (menu == NULL) {
|
||||||
}
|
menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
|
||||||
config.setFile(rc_file);
|
sprintf(menu_file, "%s/menu", configdir);
|
||||||
|
} else
|
||||||
no_focus = False;
|
menu_file = bstrdup(menu);
|
||||||
|
|
||||||
resource.style_file = NULL;
|
delete [] configdir;
|
||||||
resource.titlebar_layout = NULL;
|
}
|
||||||
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
|
config.setFile(rc_file);
|
||||||
|
|
||||||
current_screen = (BScreen *) 0;
|
no_focus = False;
|
||||||
masked_window = (OpenboxWindow *) 0;
|
|
||||||
masked = None;
|
|
||||||
|
|
||||||
load();
|
resource.style_file = NULL;
|
||||||
|
resource.titlebar_layout = NULL;
|
||||||
|
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
|
||||||
|
|
||||||
|
current_screen = (BScreen *) 0;
|
||||||
|
masked_window = (OpenboxWindow *) 0;
|
||||||
|
masked = None;
|
||||||
|
|
||||||
|
load();
|
||||||
|
|
||||||
#ifdef HAVE_GETPID
|
#ifdef HAVE_GETPID
|
||||||
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
|
openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
|
||||||
#endif // HAVE_GETPID
|
#endif // HAVE_GETPID
|
||||||
|
|
||||||
for (unsigned int s = 0; s < numberOfScreens(); s++) {
|
for (unsigned int s = 0; s < numberOfScreens(); s++) {
|
||||||
BScreen *screen = new BScreen(*this, s, config);
|
BScreen *screen = new BScreen(*this, s, config);
|
||||||
|
|
||||||
if (! screen->isScreenManaged()) {
|
if (! screen->isScreenManaged()) {
|
||||||
delete screen;
|
delete screen;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
screenList.push_back(screen);
|
screenList.push_back(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screenList.empty()) {
|
if (screenList.empty()) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->getMessage(openboxSet, openboxNoManagableScreens,
|
i18n(openboxSet, openboxNoManagableScreens,
|
||||||
"Openbox::Openbox: no managable screens found, aborting.\n"));
|
"Openbox::Openbox: no managable screens found, aborting.\n"));
|
||||||
::exit(3);
|
::exit(3);
|
||||||
}
|
}
|
||||||
current_screen = screenList.front();
|
current_screen = screenList.front();
|
||||||
|
|
||||||
// save current settings and default values
|
// save current settings and default values
|
||||||
save();
|
save();
|
||||||
|
|
||||||
XSynchronize(getXDisplay(), False);
|
|
||||||
XSync(getXDisplay(), False);
|
|
||||||
|
|
||||||
reconfigure_wait = reread_menu_wait = False;
|
XSynchronize(getXDisplay(), False);
|
||||||
|
XSync(getXDisplay(), False);
|
||||||
|
|
||||||
timer = new BTimer(*this, *this);
|
reconfigure_wait = reread_menu_wait = False;
|
||||||
timer->setTimeout(0);
|
|
||||||
timer->fireOnce(True);
|
|
||||||
|
|
||||||
ungrab();
|
timer = new BTimer(*this, *this);
|
||||||
|
timer->setTimeout(0);
|
||||||
|
timer->fireOnce(True);
|
||||||
|
|
||||||
focusWindow(0);
|
ungrab();
|
||||||
}
|
|
||||||
|
focusWindow(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Openbox::~Openbox() {
|
Openbox::~Openbox() {
|
||||||
|
@ -291,7 +291,7 @@ void Openbox::process_event(XEvent *e) {
|
||||||
win->buttonPressEvent(&e->xbutton);
|
win->buttonPressEvent(&e->xbutton);
|
||||||
|
|
||||||
if (e->xbutton.button == 1)
|
if (e->xbutton.button == 1)
|
||||||
win->installColormap(True);
|
win->installColormap(True);
|
||||||
} else if ((menu = searchMenu(e->xbutton.window))) {
|
} else if ((menu = searchMenu(e->xbutton.window))) {
|
||||||
menu->buttonPressEvent(&e->xbutton);
|
menu->buttonPressEvent(&e->xbutton);
|
||||||
|
|
||||||
|
@ -306,68 +306,68 @@ void Openbox::process_event(XEvent *e) {
|
||||||
ScreenList::iterator it;
|
ScreenList::iterator it;
|
||||||
for (it = screenList.begin(); it != screenList.end(); ++it) {
|
for (it = screenList.begin(); it != screenList.end(); ++it) {
|
||||||
BScreen *screen = *it;
|
BScreen *screen = *it;
|
||||||
if (e->xbutton.window == screen->getRootWindow()) {
|
if (e->xbutton.window == screen->getRootWindow()) {
|
||||||
if (e->xbutton.button == 1) {
|
if (e->xbutton.button == 1) {
|
||||||
if (! screen->isRootColormapInstalled())
|
if (! screen->isRootColormapInstalled())
|
||||||
screen->getImageControl()->installRootColormap();
|
screen->getImageControl()->installRootColormap();
|
||||||
|
|
||||||
if (screen->getWorkspacemenu()->isVisible())
|
if (screen->getWorkspacemenu()->isVisible())
|
||||||
screen->getWorkspacemenu()->hide();
|
screen->getWorkspacemenu()->hide();
|
||||||
|
|
||||||
if (screen->getRootmenu()->isVisible())
|
if (screen->getRootmenu()->isVisible())
|
||||||
screen->getRootmenu()->hide();
|
screen->getRootmenu()->hide();
|
||||||
} else if (e->xbutton.button == 2) {
|
} else if (e->xbutton.button == 2) {
|
||||||
int mx = e->xbutton.x_root -
|
int mx = e->xbutton.x_root -
|
||||||
(screen->getWorkspacemenu()->getWidth() / 2);
|
(screen->getWorkspacemenu()->getWidth() / 2);
|
||||||
int my = e->xbutton.y_root -
|
int my = e->xbutton.y_root -
|
||||||
(screen->getWorkspacemenu()->getTitleHeight() / 2);
|
(screen->getWorkspacemenu()->getTitleHeight() / 2);
|
||||||
|
|
||||||
if (mx < 0) mx = 0;
|
if (mx < 0) mx = 0;
|
||||||
if (my < 0) my = 0;
|
if (my < 0) my = 0;
|
||||||
|
|
||||||
if (mx + screen->getWorkspacemenu()->getWidth() >
|
if (mx + screen->getWorkspacemenu()->getWidth() >
|
||||||
screen->size().w())
|
screen->size().w())
|
||||||
mx = screen->size().w() -
|
mx = screen->size().w() -
|
||||||
screen->getWorkspacemenu()->getWidth() -
|
screen->getWorkspacemenu()->getWidth() -
|
||||||
screen->getBorderWidth();
|
screen->getBorderWidth();
|
||||||
|
|
||||||
if (my + screen->getWorkspacemenu()->getHeight() >
|
if (my + screen->getWorkspacemenu()->getHeight() >
|
||||||
screen->size().h())
|
screen->size().h())
|
||||||
my = screen->size().h() -
|
my = screen->size().h() -
|
||||||
screen->getWorkspacemenu()->getHeight() -
|
screen->getWorkspacemenu()->getHeight() -
|
||||||
screen->getBorderWidth();
|
screen->getBorderWidth();
|
||||||
|
|
||||||
screen->getWorkspacemenu()->move(mx, my);
|
screen->getWorkspacemenu()->move(mx, my);
|
||||||
|
|
||||||
if (! screen->getWorkspacemenu()->isVisible()) {
|
if (! screen->getWorkspacemenu()->isVisible()) {
|
||||||
screen->getWorkspacemenu()->removeParent();
|
screen->getWorkspacemenu()->removeParent();
|
||||||
screen->getWorkspacemenu()->show();
|
screen->getWorkspacemenu()->show();
|
||||||
}
|
}
|
||||||
} else if (e->xbutton.button == 3) {
|
} else if (e->xbutton.button == 3) {
|
||||||
int mx = e->xbutton.x_root -
|
int mx = e->xbutton.x_root -
|
||||||
(screen->getRootmenu()->getWidth() / 2);
|
(screen->getRootmenu()->getWidth() / 2);
|
||||||
int my = e->xbutton.y_root -
|
int my = e->xbutton.y_root -
|
||||||
(screen->getRootmenu()->getTitleHeight() / 2);
|
(screen->getRootmenu()->getTitleHeight() / 2);
|
||||||
|
|
||||||
if (mx < 0) mx = 0;
|
if (mx < 0) mx = 0;
|
||||||
if (my < 0) my = 0;
|
if (my < 0) my = 0;
|
||||||
|
|
||||||
if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
|
if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
|
||||||
mx = screen->size().w() -
|
mx = screen->size().w() -
|
||||||
screen->getRootmenu()->getWidth() -
|
screen->getRootmenu()->getWidth() -
|
||||||
screen->getBorderWidth();
|
screen->getBorderWidth();
|
||||||
|
|
||||||
if (my + screen->getRootmenu()->getHeight() > screen->size().h())
|
if (my + screen->getRootmenu()->getHeight() > screen->size().h())
|
||||||
my = screen->size().h() -
|
my = screen->size().h() -
|
||||||
screen->getRootmenu()->getHeight() -
|
screen->getRootmenu()->getHeight() -
|
||||||
screen->getBorderWidth();
|
screen->getBorderWidth();
|
||||||
|
|
||||||
screen->getRootmenu()->move(mx, my);
|
screen->getRootmenu()->move(mx, my);
|
||||||
|
|
||||||
if (! screen->getRootmenu()->isVisible()) {
|
if (! screen->getRootmenu()->isVisible()) {
|
||||||
checkMenu();
|
checkMenu();
|
||||||
screen->getRootmenu()->show();
|
screen->getRootmenu()->show();
|
||||||
}
|
}
|
||||||
} else if (e->xbutton.button == 4) {
|
} else if (e->xbutton.button == 4) {
|
||||||
if ((screen->getCurrentWorkspaceID() + 1) >
|
if ((screen->getCurrentWorkspaceID() + 1) >
|
||||||
screen->getWorkspaceCount() - 1)
|
screen->getWorkspaceCount() - 1)
|
||||||
|
@ -426,18 +426,18 @@ void Openbox::process_event(XEvent *e) {
|
||||||
grab();
|
grab();
|
||||||
|
|
||||||
if (validateWindow(e->xconfigurerequest.window)) {
|
if (validateWindow(e->xconfigurerequest.window)) {
|
||||||
XWindowChanges xwc;
|
XWindowChanges xwc;
|
||||||
|
|
||||||
xwc.x = e->xconfigurerequest.x;
|
xwc.x = e->xconfigurerequest.x;
|
||||||
xwc.y = e->xconfigurerequest.y;
|
xwc.y = e->xconfigurerequest.y;
|
||||||
xwc.width = e->xconfigurerequest.width;
|
xwc.width = e->xconfigurerequest.width;
|
||||||
xwc.height = e->xconfigurerequest.height;
|
xwc.height = e->xconfigurerequest.height;
|
||||||
xwc.border_width = e->xconfigurerequest.border_width;
|
xwc.border_width = e->xconfigurerequest.border_width;
|
||||||
xwc.sibling = e->xconfigurerequest.above;
|
xwc.sibling = e->xconfigurerequest.above;
|
||||||
xwc.stack_mode = e->xconfigurerequest.detail;
|
xwc.stack_mode = e->xconfigurerequest.detail;
|
||||||
|
|
||||||
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
|
XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
|
||||||
e->xconfigurerequest.value_mask, &xwc);
|
e->xconfigurerequest.value_mask, &xwc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ungrab();
|
ungrab();
|
||||||
|
@ -449,9 +449,9 @@ void Openbox::process_event(XEvent *e) {
|
||||||
case MapRequest: {
|
case MapRequest: {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
i18n->getMessage(openboxSet, openboxMapRequest,
|
i18n(openboxSet, openboxMapRequest,
|
||||||
"Openbox::process_event(): MapRequest for 0x%lx\n"),
|
"Openbox::process_event(): MapRequest for 0x%lx\n"),
|
||||||
e->xmaprequest.window);
|
e->xmaprequest.window);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
OpenboxWindow *win = searchWindow(e->xmaprequest.window);
|
OpenboxWindow *win = searchWindow(e->xmaprequest.window);
|
||||||
|
@ -471,7 +471,7 @@ void Openbox::process_event(XEvent *e) {
|
||||||
if (win)
|
if (win)
|
||||||
win->mapNotifyEvent(&e->xmap);
|
win->mapNotifyEvent(&e->xmap);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case UnmapNotify: {
|
case UnmapNotify: {
|
||||||
|
@ -514,7 +514,7 @@ void Openbox::process_event(XEvent *e) {
|
||||||
case MotionNotify: {
|
case MotionNotify: {
|
||||||
// strip the lock key modifiers
|
// strip the lock key modifiers
|
||||||
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
|
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
|
||||||
|
|
||||||
last_time = e->xmotion.time;
|
last_time = e->xmotion.time;
|
||||||
|
|
||||||
OpenboxWindow *win = (OpenboxWindow *) 0;
|
OpenboxWindow *win = (OpenboxWindow *) 0;
|
||||||
|
@ -535,7 +535,7 @@ void Openbox::process_event(XEvent *e) {
|
||||||
OpenboxWindow *win = searchWindow(e->xproperty.window);
|
OpenboxWindow *win = searchWindow(e->xproperty.window);
|
||||||
|
|
||||||
if (win)
|
if (win)
|
||||||
win->propertyNotifyEvent(e->xproperty.atom);
|
win->propertyNotifyEvent(e->xproperty.atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -562,16 +562,16 @@ void Openbox::process_event(XEvent *e) {
|
||||||
XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
|
XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
|
||||||
|
|
||||||
if ((e->xcrossing.window == e->xcrossing.root) &&
|
if ((e->xcrossing.window == e->xcrossing.root) &&
|
||||||
(screen = searchScreen(e->xcrossing.window))) {
|
(screen = searchScreen(e->xcrossing.window))) {
|
||||||
screen->getImageControl()->installRootColormap();
|
screen->getImageControl()->installRootColormap();
|
||||||
} else if ((win = searchWindow(e->xcrossing.window))) {
|
} else if ((win = searchWindow(e->xcrossing.window))) {
|
||||||
if (win->getScreen()->sloppyFocus() &&
|
if (win->getScreen()->sloppyFocus() &&
|
||||||
(! win->isFocused()) && (! no_focus)) {
|
(! win->isFocused()) && (! no_focus)) {
|
||||||
grab();
|
grab();
|
||||||
|
|
||||||
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
|
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
|
||||||
win->setInputFocus())
|
win->setInputFocus())
|
||||||
win->installColormap(True);
|
win->installColormap(True);
|
||||||
|
|
||||||
ungrab();
|
ungrab();
|
||||||
}
|
}
|
||||||
|
@ -641,7 +641,7 @@ void Openbox::process_event(XEvent *e) {
|
||||||
|
|
||||||
if (screen)
|
if (screen)
|
||||||
screen->setRootColormapInstalled((e->xcolormap.state ==
|
screen->setRootColormapInstalled((e->xcolormap.state ==
|
||||||
ColormapInstalled) ? True : False);
|
ColormapInstalled) ? True : False);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -667,19 +667,19 @@ void Openbox::process_event(XEvent *e) {
|
||||||
if (! win || ! win->validateClient()) return;
|
if (! win || ! win->validateClient()) return;
|
||||||
|
|
||||||
if (e->xclient.data.l[0] == IconicState)
|
if (e->xclient.data.l[0] == IconicState)
|
||||||
win->iconify();
|
win->iconify();
|
||||||
if (e->xclient.data.l[0] == NormalState)
|
if (e->xclient.data.l[0] == NormalState)
|
||||||
win->deiconify();
|
win->deiconify();
|
||||||
} else if (e->xclient.message_type == getOpenboxChangeWorkspaceAtom()) {
|
} 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 &&
|
if (screen && e->xclient.data.l[0] >= 0 &&
|
||||||
e->xclient.data.l[0] < screen->getWorkspaceCount())
|
e->xclient.data.l[0] < screen->getWorkspaceCount())
|
||||||
screen->changeWorkspaceID(e->xclient.data.l[0]);
|
screen->changeWorkspaceID(e->xclient.data.l[0]);
|
||||||
} else if (e->xclient.message_type == getOpenboxChangeWindowFocusAtom()) {
|
} 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);
|
win->installColormap(True);
|
||||||
} else if (e->xclient.message_type == getOpenboxCycleWindowFocusAtom()) {
|
} else if (e->xclient.message_type == getOpenboxCycleWindowFocusAtom()) {
|
||||||
BScreen *screen = searchScreen(e->xclient.window);
|
BScreen *screen = searchScreen(e->xclient.window);
|
||||||
|
@ -689,20 +689,20 @@ void Openbox::process_event(XEvent *e) {
|
||||||
screen->prevFocus();
|
screen->prevFocus();
|
||||||
else
|
else
|
||||||
screen->nextFocus();
|
screen->nextFocus();
|
||||||
}
|
}
|
||||||
} else if (e->xclient.message_type == getOpenboxChangeAttributesAtom()) {
|
} else if (e->xclient.message_type == getOpenboxChangeAttributesAtom()) {
|
||||||
OpenboxWindow *win = searchWindow(e->xclient.window);
|
OpenboxWindow *win = searchWindow(e->xclient.window);
|
||||||
|
|
||||||
if (win && win->validateClient()) {
|
if (win && win->validateClient()) {
|
||||||
OpenboxHints net;
|
OpenboxHints net;
|
||||||
net.flags = e->xclient.data.l[0];
|
net.flags = e->xclient.data.l[0];
|
||||||
net.attrib = e->xclient.data.l[1];
|
net.attrib = e->xclient.data.l[1];
|
||||||
net.workspace = e->xclient.data.l[2];
|
net.workspace = e->xclient.data.l[2];
|
||||||
net.stack = e->xclient.data.l[3];
|
net.stack = e->xclient.data.l[3];
|
||||||
net.decoration = e->xclient.data.l[4];
|
net.decoration = e->xclient.data.l[4];
|
||||||
|
|
||||||
win->changeOpenboxHints(&net);
|
win->changeOpenboxHints(&net);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +717,8 @@ void Openbox::process_event(XEvent *e) {
|
||||||
OpenboxWindow *win = (OpenboxWindow *) 0;
|
OpenboxWindow *win = (OpenboxWindow *) 0;
|
||||||
|
|
||||||
if ((win = searchWindow(e->xany.window)) ||
|
if ((win = searchWindow(e->xany.window)) ||
|
||||||
(shape_event->kind != ShapeBounding))
|
(shape_event->kind != ShapeBounding))
|
||||||
win->shapeEvent(shape_event);
|
win->shapeEvent(shape_event);
|
||||||
}
|
}
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
|
@ -880,17 +880,17 @@ void Openbox::shutdown() {
|
||||||
std::mem_fun(&BScreen::shutdown));
|
std::mem_fun(&BScreen::shutdown));
|
||||||
|
|
||||||
focusWindow(0);
|
focusWindow(0);
|
||||||
|
|
||||||
XSync(getXDisplay(), False);
|
XSync(getXDisplay(), False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Openbox::save() {
|
void Openbox::save() {
|
||||||
config.setAutoSave(false);
|
config.setAutoSave(false);
|
||||||
|
|
||||||
// save all values as they are so that the defaults will be written to the rc
|
// save all values as they are so that the defaults will be written to the rc
|
||||||
// file
|
// file
|
||||||
|
|
||||||
config.setValue("session.colorsPerChannel",
|
config.setValue("session.colorsPerChannel",
|
||||||
resource.colors_per_channel);
|
resource.colors_per_channel);
|
||||||
config.setValue("session.styleFile", resource.style_file);
|
config.setValue("session.styleFile", resource.style_file);
|
||||||
|
@ -898,8 +898,8 @@ void Openbox::save() {
|
||||||
config.setValue("session.doubleClickInterval",
|
config.setValue("session.doubleClickInterval",
|
||||||
(long)resource.double_click_interval);
|
(long)resource.double_click_interval);
|
||||||
config.setValue("session.autoRaiseDelay",
|
config.setValue("session.autoRaiseDelay",
|
||||||
((resource.auto_raise_delay.tv_sec * 1000) +
|
((resource.auto_raise_delay.tv_sec * 1000) +
|
||||||
(resource.auto_raise_delay.tv_usec / 1000)));
|
(resource.auto_raise_delay.tv_usec / 1000)));
|
||||||
config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
|
config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
|
||||||
config.setValue("session.cacheMax", (long)resource.cache_max);
|
config.setValue("session.cacheMax", (long)resource.cache_max);
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ void Openbox::load() {
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
long l;
|
long l;
|
||||||
|
|
||||||
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
|
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
|
||||||
l))
|
l))
|
||||||
resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
|
resource.colors_per_channel = (l < 2 ? 2 : (l > 6 ? 6 : l)); // >= 2, <= 6
|
||||||
|
@ -976,7 +976,7 @@ void Openbox::real_reconfigure() {
|
||||||
grab();
|
grab();
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
|
||||||
for_each(menuTimestamps.begin(), menuTimestamps.end(),
|
for_each(menuTimestamps.begin(), menuTimestamps.end(),
|
||||||
PointerAssassin());
|
PointerAssassin());
|
||||||
menuTimestamps.clear();
|
menuTimestamps.clear();
|
||||||
|
@ -1091,7 +1091,7 @@ void Openbox::focusWindow(OpenboxWindow *win) {
|
||||||
wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
|
wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
|
||||||
win->setFocusFlag(true);
|
win->setFocusFlag(true);
|
||||||
wkspc->focusWindow(win);
|
wkspc->focusWindow(win);
|
||||||
|
|
||||||
if (tbar)
|
if (tbar)
|
||||||
tbar->redrawWindowLabel(true);
|
tbar->redrawWindowLabel(true);
|
||||||
current_screen->updateNetizenWindowFocus();
|
current_screen->updateNetizenWindowFocus();
|
||||||
|
|
Loading…
Reference in a new issue