import from bb-cvs
added slit and enable-clobber defines back in Makefile.am
This commit is contained in:
parent
e640ee15ad
commit
8794d357e6
69 changed files with 12336 additions and 15362 deletions
|
@ -1,5 +1,6 @@
|
|||
// BaseDisplay.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// BaseDisplay.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,20 +21,14 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#ifdef SHAPE
|
||||
|
@ -48,11 +43,11 @@
|
|||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif // HAVE_STDLIB_H
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif // HAVE_STRING_H
|
||||
|
||||
|
@ -81,34 +76,37 @@
|
|||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
#endif // HAVE_SYS_WAIT_H
|
||||
}
|
||||
|
||||
#if defined(HAVE_PROCESS_H) && defined(__EMX__)
|
||||
# include <process.h>
|
||||
#endif // HAVE_PROCESS_H __EMX__
|
||||
#include <sstream>
|
||||
using std::string;
|
||||
|
||||
#include "i18n.h"
|
||||
#include "BaseDisplay.h"
|
||||
#include "Timer.h"
|
||||
#include "i18n.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "GCCache.hh"
|
||||
#include "Timer.hh"
|
||||
#include "Util.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// X error handler to handle any and all X errors while the application is
|
||||
// running
|
||||
static Bool internal_error = False;
|
||||
static bool internal_error = False;
|
||||
static Window last_bad_window = None;
|
||||
|
||||
BaseDisplay *base_display;
|
||||
|
||||
static int handleXErrors(Display *d, XErrorEvent *e) {
|
||||
#ifdef DEBUG
|
||||
static int handleXErrors(Display *d, XErrorEvent *e) {
|
||||
char errtxt[128];
|
||||
|
||||
XGetErrorText(d, e->error_code, errtxt, 128);
|
||||
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXError,
|
||||
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"
|
||||
),
|
||||
fprintf(stderr,
|
||||
i18n(BaseDisplaySet, BaseDisplayXError,
|
||||
"%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"),
|
||||
base_display->getApplicationName(), errtxt, e->error_code,
|
||||
e->request_code, e->minor_code, e->resourceid);
|
||||
#else
|
||||
static int handleXErrors(Display *, XErrorEvent *e) {
|
||||
#endif // DEBUG
|
||||
|
||||
if (e->error_code == BadWindow) last_bad_window = e->resourceid;
|
||||
|
@ -121,11 +119,11 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
|
|||
// signal handler to allow for proper and gentle shutdown
|
||||
|
||||
#ifndef HAVE_SIGACTION
|
||||
static RETSIGTYPE signalhandler(int sig)
|
||||
static RETSIGTYPE signalhandler(int sig) {
|
||||
#else // HAVE_SIGACTION
|
||||
static void signalhandler(int sig)
|
||||
static void signalhandler(int sig) {
|
||||
#endif // HAVE_SIGACTION
|
||||
{
|
||||
|
||||
static int re_enter = 0;
|
||||
|
||||
switch (sig) {
|
||||
|
@ -177,31 +175,10 @@ static void signalhandler(int sig)
|
|||
}
|
||||
|
||||
|
||||
// convenience functions
|
||||
#ifndef __EMX__
|
||||
void bexec(const char *command, char* displaystring) {
|
||||
if (! fork()) {
|
||||
setsid();
|
||||
putenv(displaystring);
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
#endif // !__EMX__
|
||||
BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name) {
|
||||
application_name = app_name;
|
||||
|
||||
char *bstrdup(const char *s) {
|
||||
const int l = strlen(s) + 1;
|
||||
char *n = new char[l];
|
||||
strncpy(n, s, l);
|
||||
return n;
|
||||
}
|
||||
|
||||
BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
||||
application_name = bstrdup(app_name);
|
||||
|
||||
_startup = True;
|
||||
_shutdown = False;
|
||||
server_grabs = 0;
|
||||
run_state = STARTUP;
|
||||
last_bad_window = None;
|
||||
|
||||
::base_display = this;
|
||||
|
@ -235,8 +212,9 @@ BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|||
#endif // HAVE_SIGACTION
|
||||
|
||||
if (! (display = XOpenDisplay(dpy_name))) {
|
||||
fprintf(stderr, i18n(BaseDisplaySet, BaseDisplayXConnectFail,
|
||||
"BaseDisplay::BaseDisplay: connection to X server failed.\n"));
|
||||
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,
|
||||
|
@ -255,93 +233,12 @@ BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|||
shape.extensions = False;
|
||||
#endif // SHAPE
|
||||
|
||||
xa_wm_colormap_windows =
|
||||
XInternAtom(display, "WM_COLORMAP_WINDOWS", False);
|
||||
xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
|
||||
xa_wm_state = XInternAtom(display, "WM_STATE", False);
|
||||
xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
|
||||
xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
|
||||
xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
|
||||
motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
|
||||
|
||||
openbox_hints = XInternAtom(display, "_BLACKBOX_HINTS", False);
|
||||
openbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
|
||||
openbox_change_attributes =
|
||||
XInternAtom(display, "_BLACKBOX_CHANGE_ATTRIBUTES", False);
|
||||
|
||||
openbox_structure_messages =
|
||||
XInternAtom(display, "_BLACKBOX_STRUCTURE_MESSAGES", False);
|
||||
openbox_notify_startup =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_STARTUP", False);
|
||||
openbox_notify_window_add =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_ADD", False);
|
||||
openbox_notify_window_del =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_DEL", False);
|
||||
openbox_notify_current_workspace =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_CURRENT_WORKSPACE", False);
|
||||
openbox_notify_workspace_count =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WORKSPACE_COUNT", False);
|
||||
openbox_notify_window_focus =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_FOCUS", False);
|
||||
openbox_notify_window_raise =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_RAISE", False);
|
||||
openbox_notify_window_lower =
|
||||
XInternAtom(display, "_BLACKBOX_NOTIFY_WINDOW_LOWER", False);
|
||||
|
||||
openbox_change_workspace =
|
||||
XInternAtom(display, "_BLACKBOX_CHANGE_WORKSPACE", False);
|
||||
openbox_change_window_focus =
|
||||
XInternAtom(display, "_BLACKBOX_CHANGE_WINDOW_FOCUS", False);
|
||||
openbox_cycle_window_focus =
|
||||
XInternAtom(display, "_BLACKBOX_CYCLE_WINDOW_FOCUS", False);
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
|
||||
net_supported = XInternAtom(display, "_NET_SUPPORTED", False);
|
||||
net_client_list = XInternAtom(display, "_NET_CLIENT_LIST", False);
|
||||
net_client_list_stacking = XInternAtom(display, "_NET_CLIENT_LIST_STACKING", False);
|
||||
net_number_of_desktops = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", False);
|
||||
net_desktop_geometry = XInternAtom(display, "_NET_DESKTOP_GEOMETRY", False);
|
||||
net_desktop_viewport = XInternAtom(display, "_NET_DESKTOP_VIEWPORT", False);
|
||||
net_current_desktop = XInternAtom(display, "_NET_CURRENT_DESKTOP", False);
|
||||
net_desktop_names = XInternAtom(display, "_NET_DESKTOP_NAMES", False);
|
||||
net_active_window = XInternAtom(display, "_NET_ACTIVE_WINDOW", False);
|
||||
net_workarea = XInternAtom(display, "_NET_WORKAREA", False);
|
||||
net_supporting_wm_check = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
net_virtual_roots = XInternAtom(display, "_NET_VIRTUAL_ROOTS", False);
|
||||
|
||||
net_close_window = XInternAtom(display, "_NET_CLOSE_WINDOW", False);
|
||||
net_wm_moveresize = XInternAtom(display, "_NET_WM_MOVERESIZE", False);
|
||||
|
||||
net_properties = XInternAtom(display, "_NET_PROPERTIES", False);
|
||||
net_wm_name = XInternAtom(display, "_NET_WM_NAME", False);
|
||||
net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
||||
net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||
net_wm_state = XInternAtom(display, "_NET_WM_STATE", False);
|
||||
net_wm_strut = XInternAtom(display, "_NET_WM_STRUT", False);
|
||||
net_wm_icon_geometry = XInternAtom(display, "_NET_WM_ICON_GEOMETRY", False);
|
||||
net_wm_icon = XInternAtom(display, "_NET_WM_ICON", False);
|
||||
net_wm_pid = XInternAtom(display, "_NET_WM_PID", False);
|
||||
net_wm_handled_icons = XInternAtom(display, "_NET_WM_HANDLED_ICONS", False);
|
||||
|
||||
net_wm_ping = XInternAtom(display, "_NET_WM_PING", False);
|
||||
|
||||
#endif // NEWWMSPEC
|
||||
|
||||
cursor.session = XCreateFontCursor(display, XC_left_ptr);
|
||||
cursor.move = XCreateFontCursor(display, XC_fleur);
|
||||
cursor.ll_angle = XCreateFontCursor(display, XC_ll_angle);
|
||||
cursor.lr_angle = XCreateFontCursor(display, XC_lr_angle);
|
||||
cursor.ul_angle = XCreateFontCursor(display, XC_ul_angle);
|
||||
cursor.ur_angle = XCreateFontCursor(display, XC_ur_angle);
|
||||
|
||||
XSetErrorHandler((XErrorHandler) handleXErrors);
|
||||
|
||||
screenInfoList.reserve(numberOfScreens());
|
||||
for (unsigned int s = 0; s < numberOfScreens(); s++)
|
||||
screenInfoList.push_back(new ScreenInfo(*this, s));
|
||||
screenInfoList.reserve(ScreenCount(display));
|
||||
for (int i = 0; i < ScreenCount(display); ++i)
|
||||
screenInfoList.push_back(ScreenInfo(this, i));
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
NumLockMask = ScrollLockMask = 0;
|
||||
|
||||
const XModifierKeymap* const modmap = XGetModifierMapping(display);
|
||||
|
@ -355,15 +252,15 @@ BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|||
// get the values of the keyboard lock modifiers
|
||||
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
|
||||
// since it doesn't need to be.
|
||||
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
|
||||
const KeyCode scroll_lock_code = XKeysymToKeycode(display, XK_Scroll_Lock);
|
||||
const KeyCode num_lock = XKeysymToKeycode(display, XK_Num_Lock);
|
||||
const KeyCode scroll_lock = 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])
|
||||
if (num_lock == modmap->modifiermap[cnt])
|
||||
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
if (scroll_lock_code == modmap->modifiermap[cnt])
|
||||
if (scroll_lock == modmap->modifiermap[cnt])
|
||||
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
|
@ -379,20 +276,13 @@ BaseDisplay::BaseDisplay(const char *app_name, char *dpy_name) {
|
|||
MaskListLength = sizeof(MaskList) / sizeof(MaskList[0]);
|
||||
|
||||
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
|
||||
#else
|
||||
NumLockMask = Mod2Mask;
|
||||
ScrollLockMask = Mod5Mask;
|
||||
#endif // NOCLOBBER
|
||||
|
||||
gccache = 0;
|
||||
}
|
||||
|
||||
|
||||
BaseDisplay::~BaseDisplay(void) {
|
||||
std::for_each(screenInfoList.begin(), screenInfoList.end(),
|
||||
PointerAssassin());
|
||||
// we don't create the BTimers, we don't delete them
|
||||
|
||||
if (application_name != NULL)
|
||||
delete [] application_name;
|
||||
delete gccache;
|
||||
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
|
@ -401,24 +291,18 @@ BaseDisplay::~BaseDisplay(void) {
|
|||
void BaseDisplay::eventLoop(void) {
|
||||
run();
|
||||
|
||||
int xfd = ConnectionNumber(display);
|
||||
const int xfd = ConnectionNumber(display);
|
||||
|
||||
while ((! _shutdown) && (! internal_error)) {
|
||||
while (run_state == RUNNING && ! internal_error) {
|
||||
if (XPending(display)) {
|
||||
XEvent e;
|
||||
XNextEvent(display, &e);
|
||||
|
||||
if (last_bad_window != None && e.xany.window == last_bad_window) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, i18n(BaseDisplaySet,
|
||||
BaseDisplayBadWindowRemove,
|
||||
"BaseDisplay::eventLoop(): removing bad window "
|
||||
"from event queue\n"));
|
||||
#endif // DEBUG
|
||||
} else {
|
||||
last_bad_window = None;
|
||||
process_event(&e);
|
||||
}
|
||||
if (last_bad_window != None && e.xany.window == last_bad_window)
|
||||
continue;
|
||||
|
||||
last_bad_window = None;
|
||||
process_event(&e);
|
||||
} else {
|
||||
fd_set rfds;
|
||||
timeval now, tm, *timeout = (timeval *) 0;
|
||||
|
@ -426,33 +310,11 @@ void BaseDisplay::eventLoop(void) {
|
|||
FD_ZERO(&rfds);
|
||||
FD_SET(xfd, &rfds);
|
||||
|
||||
if (!timerList.empty()) {
|
||||
if (! timerList.empty()) {
|
||||
const BTimer* const timer = timerList.top();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
tm = timer->timeRemaining(now);
|
||||
|
||||
timeout = &tm;
|
||||
}
|
||||
|
@ -462,105 +324,53 @@ void BaseDisplay::eventLoop(void) {
|
|||
// 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))
|
||||
// there is a small chance for deadlock here:
|
||||
// *IF* the timer list keeps getting refreshed *AND* the time between
|
||||
// timer->start() and timer->shouldFire() is within the timer's period
|
||||
// then the timer will keep firing. This should be VERY near impossible.
|
||||
while (! timerList.empty()) {
|
||||
BTimer *timer = timerList.top();
|
||||
if (! timer->shouldFire(now))
|
||||
break;
|
||||
|
||||
timer->fireTimeout();
|
||||
timerList.pop();
|
||||
|
||||
// restart the current timer so that the start time is updated
|
||||
if (! timer->doOnce()) {
|
||||
// reorder
|
||||
removeTimer(timer);
|
||||
addTimer(timer);
|
||||
timer->fireTimeout();
|
||||
timer->halt();
|
||||
if (timer->isRecurring())
|
||||
timer->start();
|
||||
} else
|
||||
timer->stop();
|
||||
it = timerList.begin(); // we no longer have any idea if the iterator is
|
||||
// valid, but what was at the front() is no
|
||||
// longer.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Bool BaseDisplay::validateWindow(Window window) {
|
||||
XEvent event;
|
||||
if (XCheckTypedWindowEvent(display, window, DestroyNotify, &event)) {
|
||||
XPutBackEvent(display, &event);
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::grab(void) {
|
||||
if (! server_grabs++)
|
||||
XGrabServer(display);
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::ungrab(void) {
|
||||
if (! --server_grabs)
|
||||
XUngrabServer(display);
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::addTimer(BTimer *timer) {
|
||||
ASSERT(timer != (BTimer *) 0);
|
||||
if (! timer) return;
|
||||
|
||||
TimerList::iterator it;
|
||||
for (it = timerList.begin(); it != timerList.end(); ++it) {
|
||||
BTimer *tmp = *it;
|
||||
if ((tmp->getTimeout().tv_sec > timer->getTimeout().tv_sec) ||
|
||||
((tmp->getTimeout().tv_sec == timer->getTimeout().tv_sec) &&
|
||||
(tmp->getTimeout().tv_usec >= timer->getTimeout().tv_usec)))
|
||||
break;
|
||||
}
|
||||
|
||||
timerList.insert(it, timer);
|
||||
timerList.push(timer);
|
||||
}
|
||||
|
||||
|
||||
void BaseDisplay::removeTimer(BTimer *timer) {
|
||||
ASSERT(timer != (BTimer *) 0);
|
||||
timerList.remove(timer);
|
||||
timerList.release(timer);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Grabs a button, but also grabs the button in every possible combination with
|
||||
* the keyboard lock keys, so that they do not cancel out the event.
|
||||
* Grabs a button, but also grabs the button in every possible combination
|
||||
* with the keyboard lock keys, so that they do not cancel out the event.
|
||||
*/
|
||||
void BaseDisplay::grabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window, Bool owner_events,
|
||||
Window grab_window, bool owner_events,
|
||||
unsigned int event_mask, int pointer_mode,
|
||||
int keybaord_mode, Window confine_to,
|
||||
Cursor cursor) const
|
||||
{
|
||||
#ifndef NOCLOBBER
|
||||
for (size_t cnt = 0; cnt < MaskListLength; ++cnt)
|
||||
int keyboard_mode, Window confine_to,
|
||||
Cursor cursor) const {
|
||||
for (size_t cnt = 0; cnt < MaskListLength; ++cnt) {
|
||||
XGrabButton(display, button, modifiers | MaskList[cnt], grab_window,
|
||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||
owner_events, event_mask, pointer_mode, keyboard_mode,
|
||||
confine_to, cursor);
|
||||
#else // NOCLOBBER
|
||||
XGrabButton(display, button, modifiers, grab_window,
|
||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||
confine_to, cursor);
|
||||
#endif // NOCLOBBER
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -569,26 +379,37 @@ void BaseDisplay::grabButton(unsigned int button, unsigned int modifiers,
|
|||
*/
|
||||
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const {
|
||||
#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);
|
||||
#else // NOCLOBBER
|
||||
XUngrabButton(display, button, modifiers, grab_window);
|
||||
#endif // NOCLOBBER
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ScreenInfo::ScreenInfo(BaseDisplay &d, int num) : basedisplay(d),
|
||||
screen_number(num)
|
||||
const ScreenInfo* BaseDisplay::getScreenInfo(unsigned int s) const {
|
||||
if (s < screenInfoList.size())
|
||||
return &screenInfoList[s];
|
||||
return (const ScreenInfo*) 0;
|
||||
}
|
||||
|
||||
|
||||
BGCCache *BaseDisplay::gcCache(void) const
|
||||
{
|
||||
if (! gccache) gccache = new BGCCache(this);
|
||||
return gccache;
|
||||
}
|
||||
|
||||
root_window = RootWindow(basedisplay.getXDisplay(), screen_number);
|
||||
depth = DefaultDepth(basedisplay.getXDisplay(), screen_number);
|
||||
|
||||
m_size = Size(WidthOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
||||
screen_number)),
|
||||
HeightOfScreen(ScreenOfDisplay(basedisplay.getXDisplay(),
|
||||
screen_number)));
|
||||
ScreenInfo::ScreenInfo(BaseDisplay *d, unsigned int num) {
|
||||
basedisplay = d;
|
||||
screen_number = num;
|
||||
|
||||
root_window = RootWindow(basedisplay->getXDisplay(), screen_number);
|
||||
depth = DefaultDepth(basedisplay->getXDisplay(), screen_number);
|
||||
|
||||
rect.setSize(WidthOfScreen(ScreenOfDisplay(basedisplay->getXDisplay(),
|
||||
screen_number)),
|
||||
HeightOfScreen(ScreenOfDisplay(basedisplay->getXDisplay(),
|
||||
screen_number)));
|
||||
|
||||
// search for a TrueColor Visual... if we can't find one... we will use the
|
||||
// default visual for the screen
|
||||
|
@ -600,10 +421,10 @@ screen_number(num)
|
|||
|
||||
visual = (Visual *) 0;
|
||||
|
||||
if ((vinfo_return = XGetVisualInfo(basedisplay.getXDisplay(),
|
||||
VisualScreenMask | VisualClassMask,
|
||||
&vinfo_template, &vinfo_nitems)) &&
|
||||
vinfo_nitems > 0) {
|
||||
vinfo_return = XGetVisualInfo(basedisplay->getXDisplay(),
|
||||
VisualScreenMask | VisualClassMask,
|
||||
&vinfo_template, &vinfo_nitems);
|
||||
if (vinfo_return && vinfo_nitems > 0) {
|
||||
for (int i = 0; i < vinfo_nitems; i++) {
|
||||
if (depth < (vinfo_return + i)->depth) {
|
||||
depth = (vinfo_return + i)->depth;
|
||||
|
@ -615,10 +436,20 @@ screen_number(num)
|
|||
}
|
||||
|
||||
if (visual) {
|
||||
colormap = XCreateColormap(basedisplay.getXDisplay(), root_window,
|
||||
colormap = XCreateColormap(basedisplay->getXDisplay(), root_window,
|
||||
visual, AllocNone);
|
||||
} else {
|
||||
visual = DefaultVisual(basedisplay.getXDisplay(), screen_number);
|
||||
colormap = DefaultColormap(basedisplay.getXDisplay(), screen_number);
|
||||
visual = DefaultVisual(basedisplay->getXDisplay(), screen_number);
|
||||
colormap = DefaultColormap(basedisplay->getXDisplay(), screen_number);
|
||||
}
|
||||
|
||||
// get the default display string and strip the screen number
|
||||
string default_string = DisplayString(basedisplay->getXDisplay());
|
||||
const string::size_type pos = default_string.rfind(".");
|
||||
if (pos != string::npos)
|
||||
default_string.resize(pos);
|
||||
|
||||
std::ostringstream formatter;
|
||||
formatter << "DISPLAY=" << default_string << '.' << screen_number;
|
||||
display_string = formatter.str();
|
||||
}
|
||||
|
|
|
@ -1,367 +0,0 @@
|
|||
// BaseDisplay.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __BaseDisplay_hh
|
||||
#define __BaseDisplay_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
// forward declaration
|
||||
class BaseDisplay;
|
||||
class ScreenInfo;
|
||||
|
||||
#include "Timer.h"
|
||||
#include "Geometry.h"
|
||||
#include "Util.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#define AttribShaded (1l << 0)
|
||||
#define AttribMaxHoriz (1l << 1)
|
||||
#define AttribMaxVert (1l << 2)
|
||||
#define AttribOmnipresent (1l << 3)
|
||||
#define AttribWorkspace (1l << 4)
|
||||
#define AttribStack (1l << 5)
|
||||
#define AttribDecoration (1l << 6)
|
||||
|
||||
#define StackTop (0)
|
||||
#define StackNormal (1)
|
||||
#define StackBottom (2)
|
||||
|
||||
#define DecorNone (0)
|
||||
#define DecorNormal (1)
|
||||
#define DecorTiny (2)
|
||||
#define DecorTool (3)
|
||||
|
||||
typedef struct _openbox_hints {
|
||||
unsigned long flags, attrib, workspace, stack, decoration;
|
||||
} OpenboxHints;
|
||||
|
||||
typedef struct _openbox_attributes {
|
||||
unsigned long flags, attrib, workspace, stack, decoration;
|
||||
int premax_x, premax_y;
|
||||
unsigned int premax_w, premax_h;
|
||||
} OpenboxAttributes;
|
||||
|
||||
#define PropOpenboxHintsElements (5)
|
||||
#define PropOpenboxAttributesElements (9)
|
||||
|
||||
#ifndef __EMX__
|
||||
void bexec(const char *, char *);
|
||||
#endif // !__EMX__
|
||||
|
||||
char *bstrdup(const char *);
|
||||
|
||||
class BaseDisplay {
|
||||
private:
|
||||
struct cursor {
|
||||
Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
|
||||
} cursor;
|
||||
|
||||
struct shape {
|
||||
Bool extensions;
|
||||
int event_basep, error_basep;
|
||||
} shape;
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
unsigned int MaskList[8];
|
||||
size_t MaskListLength;
|
||||
#endif // NOCLOBBER
|
||||
|
||||
Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state,
|
||||
xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state,
|
||||
motif_wm_hints;
|
||||
|
||||
// NETAttributes
|
||||
Atom openbox_attributes, openbox_change_attributes, openbox_hints;
|
||||
|
||||
// NETStructureMessages
|
||||
Atom openbox_structure_messages, openbox_notify_startup,
|
||||
openbox_notify_window_add, openbox_notify_window_del,
|
||||
openbox_notify_window_focus, openbox_notify_current_workspace,
|
||||
openbox_notify_workspace_count, openbox_notify_window_raise,
|
||||
openbox_notify_window_lower;
|
||||
|
||||
// message_types for client -> wm messages
|
||||
Atom openbox_change_workspace, openbox_change_window_focus,
|
||||
openbox_cycle_window_focus;
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
|
||||
// root window properties
|
||||
Atom net_supported, net_client_list, net_client_list_stacking,
|
||||
net_number_of_desktops, net_desktop_geometry, net_desktop_viewport,
|
||||
net_current_desktop, net_desktop_names, net_active_window, net_workarea,
|
||||
net_supporting_wm_check, net_virtual_roots;
|
||||
|
||||
// root window messages
|
||||
Atom net_close_window, net_wm_moveresize;
|
||||
|
||||
// application window properties
|
||||
Atom net_properties, net_wm_name, net_wm_desktop, net_wm_window_type,
|
||||
net_wm_state, net_wm_strut, net_wm_icon_geometry, net_wm_icon, net_wm_pid,
|
||||
net_wm_handled_icons;
|
||||
|
||||
// application protocols
|
||||
Atom net_wm_ping;
|
||||
|
||||
#endif // NEWWMSPEC
|
||||
|
||||
Bool _startup, _shutdown;
|
||||
Display *display;
|
||||
|
||||
typedef std::vector<ScreenInfo*> ScreenInfoList;
|
||||
ScreenInfoList screenInfoList;
|
||||
|
||||
typedef std::list<BTimer*> TimerList;
|
||||
TimerList timerList;
|
||||
|
||||
char *display_name, *application_name;
|
||||
unsigned int server_grabs, colors_per_channel;
|
||||
|
||||
|
||||
protected:
|
||||
// pure virtual function... you must override this
|
||||
virtual void process_event(XEvent *) = 0;
|
||||
|
||||
// the masks of the modifiers which are ignored in button events.
|
||||
int NumLockMask, ScrollLockMask;
|
||||
|
||||
|
||||
public:
|
||||
BaseDisplay(const char *, char * = 0);
|
||||
virtual ~BaseDisplay();
|
||||
|
||||
inline const Atom &getWMChangeStateAtom() const
|
||||
{ return xa_wm_change_state; }
|
||||
inline const Atom &getWMStateAtom() const
|
||||
{ return xa_wm_state; }
|
||||
inline const Atom &getWMDeleteAtom() const
|
||||
{ return xa_wm_delete_window; }
|
||||
inline const Atom &getWMProtocolsAtom() const
|
||||
{ return xa_wm_protocols; }
|
||||
inline const Atom &getWMTakeFocusAtom() const
|
||||
{ return xa_wm_take_focus; }
|
||||
inline const Atom &getWMColormapAtom() const
|
||||
{ return xa_wm_colormap_windows; }
|
||||
inline const Atom &getMotifWMHintsAtom() const
|
||||
{ return motif_wm_hints; }
|
||||
|
||||
// this atom is for normal app->WM hints about decorations, stacking,
|
||||
// starting workspace etc...
|
||||
inline const Atom &getOpenboxHintsAtom() const
|
||||
{ return openbox_hints;}
|
||||
|
||||
// these atoms are for normal app->WM interaction beyond the scope of the
|
||||
// ICCCM...
|
||||
inline const Atom &getOpenboxAttributesAtom() const
|
||||
{ return openbox_attributes; }
|
||||
inline const Atom &getOpenboxChangeAttributesAtom() const
|
||||
{ return openbox_change_attributes; }
|
||||
|
||||
// these atoms are for window->WM interaction, with more control and
|
||||
// information on window "structure"... common examples are
|
||||
// notifying apps when windows are raised/lowered... when the user changes
|
||||
// workspaces... i.e. "pager talk"
|
||||
inline const Atom &getOpenboxStructureMessagesAtom() const
|
||||
{ return openbox_structure_messages; }
|
||||
|
||||
// *Notify* portions of the NETStructureMessages protocol
|
||||
inline const Atom &getOpenboxNotifyStartupAtom() const
|
||||
{ return openbox_notify_startup; }
|
||||
inline const Atom &getOpenboxNotifyWindowAddAtom() const
|
||||
{ return openbox_notify_window_add; }
|
||||
inline const Atom &getOpenboxNotifyWindowDelAtom() const
|
||||
{ return openbox_notify_window_del; }
|
||||
inline const Atom &getOpenboxNotifyWindowFocusAtom() const
|
||||
{ return openbox_notify_window_focus; }
|
||||
inline const Atom &getOpenboxNotifyCurrentWorkspaceAtom() const
|
||||
{ return openbox_notify_current_workspace; }
|
||||
inline const Atom &getOpenboxNotifyWorkspaceCountAtom() const
|
||||
{ return openbox_notify_workspace_count; }
|
||||
inline const Atom &getOpenboxNotifyWindowRaiseAtom() const
|
||||
{ return openbox_notify_window_raise; }
|
||||
inline const Atom &getOpenboxNotifyWindowLowerAtom() const
|
||||
{ return openbox_notify_window_lower; }
|
||||
|
||||
// atoms to change that request changes to the desktop environment during
|
||||
// runtime... these messages can be sent by any client... as the sending
|
||||
// client window id is not included in the ClientMessage event...
|
||||
inline const Atom &getOpenboxChangeWorkspaceAtom() const
|
||||
{ return openbox_change_workspace; }
|
||||
inline const Atom &getOpenboxChangeWindowFocusAtom() const
|
||||
{ return openbox_change_window_focus; }
|
||||
inline const Atom &getOpenboxCycleWindowFocusAtom() const
|
||||
{ return openbox_cycle_window_focus; }
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
|
||||
// root window properties
|
||||
inline const Atom &getNETSupportedAtom() const
|
||||
{ return net_supported; }
|
||||
inline const Atom &getNETClientListAtom() const
|
||||
{ return net_client_list; }
|
||||
inline const Atom &getNETClientListStackingAtom() const
|
||||
{ return net_client_list_stacking; }
|
||||
inline const Atom &getNETNumberOfDesktopsAtom() const
|
||||
{ return net_number_of_desktops; }
|
||||
inline const Atom &getNETDesktopGeometryAtom() const
|
||||
{ return net_desktop_geometry; }
|
||||
inline const Atom &getNETDesktopViewportAtom() const
|
||||
{ return net_desktop_viewport; }
|
||||
inline const Atom &getNETCurrentDesktopAtom() const
|
||||
{ return net_current_desktop; }
|
||||
inline const Atom &getNETDesktopNamesAtom() const
|
||||
{ return net_desktop_names; }
|
||||
inline const Atom &getNETActiveWindowAtom() const
|
||||
{ return net_active_window; }
|
||||
inline const Atom &getNETWorkareaAtom() const
|
||||
{ return net_workarea; }
|
||||
inline const Atom &getNETSupportingWMCheckAtom() const
|
||||
{ return net_supporting_wm_check; }
|
||||
inline const Atom &getNETVirtualRootsAtom() const
|
||||
{ return net_virtual_roots; }
|
||||
|
||||
// root window messages
|
||||
inline const Atom &getNETCloseWindowAtom() const
|
||||
{ return net_close_window; }
|
||||
inline const Atom &getNETWMMoveResizeAtom() const
|
||||
{ return net_wm_moveresize; }
|
||||
|
||||
// application window properties
|
||||
inline const Atom &getNETPropertiesAtom() const
|
||||
{ return net_properties; }
|
||||
inline const Atom &getNETWMNameAtom() const
|
||||
{ return net_wm_name; }
|
||||
inline const Atom &getNETWMDesktopAtom() const
|
||||
{ return net_wm_desktop; }
|
||||
inline const Atom &getNETWMWindowTypeAtom() const
|
||||
{ return net_wm_window_type; }
|
||||
inline const Atom &getNETWMStateAtom() const
|
||||
{ return net_wm_state; }
|
||||
inline const Atom &getNETWMStrutAtom() const
|
||||
{ return net_wm_strut; }
|
||||
inline const Atom &getNETWMIconGeometryAtom() const
|
||||
{ return net_wm_icon_geometry; }
|
||||
inline const Atom &getNETWMIconAtom() const
|
||||
{ return net_wm_icon; }
|
||||
inline const Atom &getNETWMPidAtom() const
|
||||
{ return net_wm_pid; }
|
||||
inline const Atom &getNETWMHandledIconsAtom() const
|
||||
{ return net_wm_handled_icons; }
|
||||
|
||||
// application protocols
|
||||
inline const Atom &getNETWMPingAtom() const
|
||||
{ return net_wm_ping; }
|
||||
|
||||
#endif // NEWWMSPEC
|
||||
|
||||
inline ScreenInfo *getScreenInfo(unsigned int s) {
|
||||
ASSERT(s < screenInfoList.size());
|
||||
return screenInfoList[s];
|
||||
}
|
||||
|
||||
inline const Bool &hasShapeExtensions() const
|
||||
{ return shape.extensions; }
|
||||
inline const Bool &doShutdown() const
|
||||
{ return _shutdown; }
|
||||
inline const Bool &isStartup() const
|
||||
{ return _startup; }
|
||||
|
||||
inline const Cursor &getSessionCursor() const
|
||||
{ return cursor.session; }
|
||||
inline const Cursor &getMoveCursor() const
|
||||
{ return cursor.move; }
|
||||
inline const Cursor &getLowerLeftAngleCursor() const
|
||||
{ return cursor.ll_angle; }
|
||||
inline const Cursor &getLowerRightAngleCursor() const
|
||||
{ return cursor.lr_angle; }
|
||||
inline const Cursor &getUpperLeftAngleCursor() const
|
||||
{ return cursor.ul_angle; }
|
||||
inline const Cursor &getUpperRightAngleCursor() const
|
||||
{ return cursor.ur_angle; }
|
||||
|
||||
inline Display *getXDisplay() { return display; }
|
||||
|
||||
inline const char *getXDisplayName() const
|
||||
{ return (const char *) display_name; }
|
||||
inline const char *getApplicationName() const
|
||||
{ return (const char *) application_name; }
|
||||
|
||||
inline const unsigned int numberOfScreens() const
|
||||
{ return ScreenCount(display); }
|
||||
inline const int &getShapeEventBase() const
|
||||
{ return shape.event_basep; }
|
||||
|
||||
inline void shutdown() { _shutdown = True; }
|
||||
inline void run() { _startup = _shutdown = False; }
|
||||
|
||||
const Bool validateWindow(Window);
|
||||
|
||||
void grabButton(unsigned int, unsigned int, Window, Bool, unsigned int, int,
|
||||
int, Window, Cursor) const;
|
||||
void ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const;
|
||||
|
||||
void grab();
|
||||
void ungrab();
|
||||
void eventLoop();
|
||||
void addTimer(BTimer *);
|
||||
void removeTimer(BTimer *);
|
||||
|
||||
// another pure virtual... this is used to handle signals that BaseDisplay
|
||||
// doesn't understand itself
|
||||
virtual Bool handleSignal(int) = 0;
|
||||
};
|
||||
|
||||
|
||||
class ScreenInfo {
|
||||
private:
|
||||
BaseDisplay &basedisplay;
|
||||
Visual *visual;
|
||||
Window root_window;
|
||||
Colormap colormap;
|
||||
|
||||
int depth, screen_number;
|
||||
Size m_size;
|
||||
|
||||
|
||||
public:
|
||||
ScreenInfo(BaseDisplay &, int);
|
||||
|
||||
inline BaseDisplay &getBaseDisplay() { return basedisplay; }
|
||||
|
||||
inline Visual *getVisual() const { return visual; }
|
||||
inline const Window &getRootWindow() const { return root_window; }
|
||||
inline const Colormap &getColormap() const { return colormap; }
|
||||
|
||||
inline const int &getDepth() const { return depth; }
|
||||
inline const int &getScreenNumber() const { return screen_number; }
|
||||
|
||||
// inline const unsigned int &getWidth() const { return width; }
|
||||
// inline const unsigned int &getHeight() const { return height; }
|
||||
inline const Size &size() const { return m_size; }
|
||||
};
|
||||
|
||||
|
||||
#endif // __BaseDisplay_hh
|
156
src/BaseDisplay.hh
Normal file
156
src/BaseDisplay.hh
Normal file
|
@ -0,0 +1,156 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// BaseDisplay.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __BaseDisplay_hh
|
||||
#define __BaseDisplay_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// forward declaration
|
||||
class BaseDisplay;
|
||||
class BGCCache;
|
||||
|
||||
#include "Timer.hh"
|
||||
#include "Util.hh"
|
||||
|
||||
class ScreenInfo {
|
||||
private:
|
||||
BaseDisplay *basedisplay;
|
||||
Visual *visual;
|
||||
Window root_window;
|
||||
Colormap colormap;
|
||||
|
||||
int depth;
|
||||
unsigned int screen_number;
|
||||
std::string display_string;
|
||||
Rect rect;
|
||||
|
||||
public:
|
||||
ScreenInfo(BaseDisplay *d, unsigned int num);
|
||||
|
||||
inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; }
|
||||
inline Visual *getVisual(void) const { return visual; }
|
||||
inline Window getRootWindow(void) const { return root_window; }
|
||||
inline Colormap getColormap(void) const { return colormap; }
|
||||
inline int getDepth(void) const { return depth; }
|
||||
inline unsigned int getScreenNumber(void) const
|
||||
{ return screen_number; }
|
||||
inline const Rect& getRect(void) const { return rect; }
|
||||
inline unsigned int getWidth(void) const { return rect.width(); }
|
||||
inline unsigned int getHeight(void) const { return rect.height(); }
|
||||
inline const std::string& displayString(void) const
|
||||
{ return display_string; }
|
||||
};
|
||||
|
||||
|
||||
class BaseDisplay: public TimerQueueManager {
|
||||
private:
|
||||
struct BShape {
|
||||
bool extensions;
|
||||
int event_basep, error_basep;
|
||||
};
|
||||
BShape shape;
|
||||
|
||||
unsigned int MaskList[8];
|
||||
size_t MaskListLength;
|
||||
|
||||
enum RunState { STARTUP, RUNNING, SHUTDOWN };
|
||||
RunState run_state;
|
||||
|
||||
Display *display;
|
||||
mutable BGCCache *gccache;
|
||||
|
||||
typedef std::vector<ScreenInfo> ScreenInfoList;
|
||||
ScreenInfoList screenInfoList;
|
||||
TimerQueue timerList;
|
||||
|
||||
const char *display_name, *application_name;
|
||||
|
||||
// no copying!
|
||||
BaseDisplay(const BaseDisplay &);
|
||||
BaseDisplay& operator=(const BaseDisplay&);
|
||||
|
||||
protected:
|
||||
// pure virtual function... you must override this
|
||||
virtual void process_event(XEvent *e) = 0;
|
||||
|
||||
// the masks of the modifiers which are ignored in button events.
|
||||
int NumLockMask, ScrollLockMask;
|
||||
|
||||
|
||||
public:
|
||||
BaseDisplay(const char *app_name, const char *dpy_name = 0);
|
||||
virtual ~BaseDisplay(void);
|
||||
|
||||
const ScreenInfo* getScreenInfo(const unsigned int s) const;
|
||||
|
||||
BGCCache *gcCache(void) const;
|
||||
|
||||
inline bool hasShapeExtensions(void) const
|
||||
{ return shape.extensions; }
|
||||
inline bool doShutdown(void) const
|
||||
{ return run_state == SHUTDOWN; }
|
||||
inline bool isStartup(void) const
|
||||
{ return run_state == STARTUP; }
|
||||
|
||||
inline Display *getXDisplay(void) const { return display; }
|
||||
|
||||
inline const char *getXDisplayName(void) const
|
||||
{ return display_name; }
|
||||
inline const char *getApplicationName(void) const
|
||||
{ return application_name; }
|
||||
|
||||
inline unsigned int getNumberOfScreens(void) const
|
||||
{ return screenInfoList.size(); }
|
||||
inline int getShapeEventBase(void) const
|
||||
{ return shape.event_basep; }
|
||||
|
||||
inline void shutdown(void) { run_state = SHUTDOWN; }
|
||||
inline void run(void) { run_state = RUNNING; }
|
||||
|
||||
void grabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window, bool owner_events,
|
||||
unsigned int event_mask, int pointer_mode,
|
||||
int keyboard_mode, Window confine_to, Cursor cursor) const;
|
||||
void ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const;
|
||||
|
||||
void eventLoop(void);
|
||||
|
||||
// from TimerQueueManager interface
|
||||
virtual void addTimer(BTimer *timer);
|
||||
virtual void removeTimer(BTimer *timer);
|
||||
|
||||
// another pure virtual... this is used to handle signals that BaseDisplay
|
||||
// doesn't understand itself
|
||||
virtual bool handleSignal(int sig) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // __BaseDisplay_hh
|
594
src/Basemenu.cc
594
src/Basemenu.cc
File diff suppressed because it is too large
Load diff
169
src/Basemenu.h
169
src/Basemenu.h
|
@ -1,169 +0,0 @@
|
|||
// Basemenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Basemenu_hh
|
||||
#define __Basemenu_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
class Openbox;
|
||||
class BImageControl;
|
||||
class BScreen;
|
||||
class Basemenu;
|
||||
class BasemenuItem;
|
||||
#include <vector>
|
||||
typedef std::vector<BasemenuItem *> menuitemList;
|
||||
|
||||
class Basemenu {
|
||||
private:
|
||||
menuitemList menuitems;
|
||||
Openbox &openbox;
|
||||
Basemenu *parent;
|
||||
BImageControl *image_ctrl;
|
||||
BScreen &screen;
|
||||
|
||||
Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
|
||||
hide_tree;
|
||||
Display *display;
|
||||
int which_sub, which_press, which_sbl, alignment;
|
||||
|
||||
struct _menu {
|
||||
Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
|
||||
Window window, frame, title;
|
||||
|
||||
char *label;
|
||||
int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
|
||||
grab_x, grab_y;
|
||||
unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
|
||||
bevel_h;
|
||||
} menu;
|
||||
|
||||
|
||||
protected:
|
||||
inline BasemenuItem *find(int index) { return menuitems[index]; }
|
||||
inline void setTitleVisibility(Bool b) { title_vis = b; }
|
||||
inline void setMovable(Bool b) { movable = b; }
|
||||
inline void setHideTree(Bool h) { hide_tree = h; }
|
||||
inline void setMinimumSublevels(int m) { menu.minsub = m; }
|
||||
|
||||
virtual void itemSelected(int, int) = 0;
|
||||
virtual void drawItem(int, Bool = False, Bool = False,
|
||||
int = -1, int = -1, unsigned int = 0,
|
||||
unsigned int = 0);
|
||||
virtual void redrawTitle();
|
||||
virtual void internal_hide(void);
|
||||
|
||||
|
||||
public:
|
||||
Basemenu(BScreen &);
|
||||
virtual ~Basemenu(void);
|
||||
|
||||
inline const Bool &isTorn(void) const { return torn; }
|
||||
inline const Bool &isVisible(void) const { return visible; }
|
||||
|
||||
inline BScreen &getScreen(void) { return screen; }
|
||||
|
||||
inline const Window &getWindowID(void) const { return menu.window; }
|
||||
|
||||
inline const char *getLabel(void) const { return menu.label; }
|
||||
|
||||
int insert(const char *, int = 0, const char * = (const char *) 0, int = -1);
|
||||
int insert(const char **, int = -1, int = 0);
|
||||
int insert(const char *, Basemenu *, int = -1);
|
||||
int remove(int);
|
||||
|
||||
inline int getX(void) const { return menu.x; }
|
||||
inline int getY(void) const { return menu.y; }
|
||||
inline unsigned int getCount(void) { return menuitems.size(); }
|
||||
inline int getCurrentSubmenu(void) const { return which_sub; }
|
||||
|
||||
inline unsigned int getWidth(void) const { return menu.width; }
|
||||
inline unsigned int getHeight(void) const { return menu.height; }
|
||||
inline unsigned int getTitleHeight(void) const { return menu.title_h; }
|
||||
|
||||
inline void setInternalMenu(void) { internal_menu = True; }
|
||||
inline void setAlignment(int a) { alignment = a; }
|
||||
inline void setTorn(void) { torn = True; }
|
||||
inline void removeParent(void)
|
||||
{ if (internal_menu) parent = (Basemenu *) 0; }
|
||||
|
||||
bool hasSubmenu(int);
|
||||
bool isItemSelected(int);
|
||||
bool isItemEnabled(int);
|
||||
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void buttonReleaseEvent(XButtonEvent *);
|
||||
void motionNotifyEvent(XMotionEvent *);
|
||||
void enterNotifyEvent(XCrossingEvent *);
|
||||
void leaveNotifyEvent(XCrossingEvent *);
|
||||
void exposeEvent(XExposeEvent *);
|
||||
void reconfigure(void);
|
||||
void setLabel(const char *n);
|
||||
void move(int, int);
|
||||
void update(void);
|
||||
void setItemSelected(int, bool);
|
||||
void setItemEnabled(int, bool);
|
||||
|
||||
virtual void drawSubmenu(int);
|
||||
virtual void show(void);
|
||||
virtual void hide(void);
|
||||
|
||||
enum { AlignDontCare = 1, AlignTop, AlignBottom };
|
||||
enum { Right = 1, Left };
|
||||
enum { Empty = 0, Square, Triangle, Diamond };
|
||||
};
|
||||
|
||||
|
||||
class BasemenuItem {
|
||||
private:
|
||||
Basemenu *s;
|
||||
const char **u, *l, *e;
|
||||
int f, enabled, selected;
|
||||
|
||||
friend class Basemenu;
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
BasemenuItem(const char *lp, int fp, const char *ep = (const char *) 0):
|
||||
s(0), u(0), l(lp), e(ep), f(fp), enabled(1), selected(0) {}
|
||||
|
||||
BasemenuItem(const char *lp, Basemenu *mp): s(mp), u(0), l(lp), e(0), f(0),
|
||||
enabled(1), selected(0) {}
|
||||
|
||||
BasemenuItem(const char **up, int fp): s(0), u(up), l(0), e(0), f(fp),
|
||||
enabled(1), selected(0) {}
|
||||
|
||||
inline const char *exec(void) const { return e; }
|
||||
inline const char *label(void) const { return l; }
|
||||
inline const char **ulabel(void) const { return u; }
|
||||
inline const int &function(void) const { return f; }
|
||||
inline Basemenu *submenu(void) { return s; }
|
||||
|
||||
inline const int &isEnabled(void) const { return enabled; }
|
||||
inline void setEnabled(int e) { enabled = e; }
|
||||
inline const int &isSelected(void) const { return selected; }
|
||||
inline void setSelected(int s) { selected = s; }
|
||||
};
|
||||
|
||||
|
||||
#endif // __Basemenu_hh
|
|
@ -1,5 +1,6 @@
|
|||
// Clientmenu.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Clientmenu.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,44 +21,39 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "openbox.h"
|
||||
#include "Clientmenu.h"
|
||||
#include "Screen.h"
|
||||
#include "Window.h"
|
||||
#include "Workspace.h"
|
||||
#include "Workspacemenu.h"
|
||||
#include "blackbox.hh"
|
||||
#include "Clientmenu.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Window.hh"
|
||||
#include "Workspace.hh"
|
||||
#include "Workspacemenu.hh"
|
||||
|
||||
|
||||
Clientmenu::Clientmenu(Workspace &ws) : Basemenu(ws.getScreen()),
|
||||
screen(ws.getScreen()), wkspc(ws)
|
||||
{
|
||||
Clientmenu::Clientmenu(Workspace *ws) : Basemenu(ws->getScreen()) {
|
||||
wkspc = ws;
|
||||
|
||||
setInternalMenu();
|
||||
}
|
||||
|
||||
|
||||
void Clientmenu::itemSelected(int button, int index) {
|
||||
void Clientmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button > 2) return;
|
||||
|
||||
OpenboxWindow *win = wkspc.getWindow(index);
|
||||
BlackboxWindow *win = wkspc->getWindow(index);
|
||||
if (win) {
|
||||
if (button == 1) {
|
||||
if (! wkspc.isCurrent()) wkspc.setCurrent();
|
||||
if (! wkspc->isCurrent()) wkspc->setCurrent();
|
||||
} else if (button == 2) {
|
||||
if (! wkspc.isCurrent()) win->deiconify(True, False);
|
||||
if (! wkspc->isCurrent()) win->deiconify(True, False);
|
||||
}
|
||||
wkspc.raiseWindow(win);
|
||||
wkspc->raiseWindow(win);
|
||||
win->setInputFocus();
|
||||
}
|
||||
|
||||
if (! (screen.getWorkspacemenu()->isTorn() || isTorn())) hide();
|
||||
Workspacemenu* wkspcmenu = wkspc->getScreen()->getWorkspacemenu();
|
||||
if (! (wkspcmenu->isTorn() || isTorn())) hide();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Clientmenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Clientmenu.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -23,20 +24,22 @@
|
|||
#ifndef __Clientmenu_hh
|
||||
#define __Clientmenu_hh
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Basemenu.hh"
|
||||
class Workspace;
|
||||
class BScreen;
|
||||
|
||||
class Clientmenu : public Basemenu {
|
||||
private:
|
||||
BScreen &screen;
|
||||
Workspace &wkspc;
|
||||
Workspace *wkspc;
|
||||
|
||||
Clientmenu(const Clientmenu&);
|
||||
Clientmenu& operator=(const Clientmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Clientmenu(Workspace &);
|
||||
Clientmenu(Workspace *ws);
|
||||
};
|
||||
|
||||
|
242
src/Color.cc
Normal file
242
src/Color.cc
Normal file
|
@ -0,0 +1,242 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Color.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "Color.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
}
|
||||
|
||||
|
||||
BColor::ColorCache BColor::colorcache;
|
||||
bool BColor::cleancache = false;
|
||||
|
||||
BColor::BColor(const BaseDisplay * const _display, unsigned int _screen)
|
||||
: allocated(false), r(-1), g(-1), b(-1), p(0), dpy(_display), scrn(_screen)
|
||||
{}
|
||||
|
||||
BColor::BColor(int _r, int _g, int _b,
|
||||
const BaseDisplay * const _display, unsigned int _screen)
|
||||
: allocated(false), r(_r), g(_g), b(_b), p(0), dpy(_display), scrn(_screen)
|
||||
{}
|
||||
|
||||
|
||||
BColor::BColor(const std::string &_name,
|
||||
const BaseDisplay * const _display, unsigned int _screen)
|
||||
: allocated(false), r(-1), g(-1), b(-1), p(0), dpy(_display), scrn(_screen),
|
||||
colorname(_name) {
|
||||
parseColorName();
|
||||
}
|
||||
|
||||
|
||||
BColor::~BColor(void) {
|
||||
deallocate();
|
||||
}
|
||||
|
||||
|
||||
void BColor::setDisplay(const BaseDisplay * const _display,
|
||||
unsigned int _screen) {
|
||||
if (_display == display() && _screen == screen()) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
deallocate();
|
||||
|
||||
dpy = _display;
|
||||
scrn = _screen;
|
||||
|
||||
if (! colorname.empty()) {
|
||||
parseColorName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long BColor::pixel(void) const {
|
||||
if (! allocated) {
|
||||
// mutable
|
||||
BColor *that = (BColor *) this;
|
||||
that->allocate();
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void BColor::parseColorName(void) {
|
||||
assert(dpy != 0);
|
||||
|
||||
if (colorname.empty()) {
|
||||
fprintf(stderr, "BColor: empty colorname, cannot parse (using black)\n");
|
||||
setRGB(0, 0, 0);
|
||||
}
|
||||
|
||||
if (scrn == ~(0u))
|
||||
scrn = DefaultScreen(display()->getXDisplay());
|
||||
Colormap colormap = display()->getScreenInfo(scrn)->getColormap();
|
||||
|
||||
// get rgb values from colorname
|
||||
XColor xcol;
|
||||
xcol.red = 0;
|
||||
xcol.green = 0;
|
||||
xcol.blue = 0;
|
||||
xcol.pixel = 0;
|
||||
|
||||
if (! XParseColor(display()->getXDisplay(), colormap,
|
||||
colorname.c_str(), &xcol)) {
|
||||
fprintf(stderr, "BColor::allocate: color parse error: \"%s\"\n",
|
||||
colorname.c_str());
|
||||
setRGB(0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
setRGB(xcol.red >> 8, xcol.green >> 8, xcol.blue >> 8);
|
||||
}
|
||||
|
||||
|
||||
void BColor::allocate(void) {
|
||||
assert(dpy != 0);
|
||||
|
||||
if (scrn == ~(0u)) scrn = DefaultScreen(display()->getXDisplay());
|
||||
Colormap colormap = display()->getScreenInfo(scrn)->getColormap();
|
||||
|
||||
if (! isValid()) {
|
||||
if (colorname.empty()) {
|
||||
fprintf(stderr, "BColor: cannot allocate invalid color (using black)\n");
|
||||
setRGB(0, 0, 0);
|
||||
} else {
|
||||
parseColorName();
|
||||
}
|
||||
}
|
||||
|
||||
// see if we have allocated this color before
|
||||
RGB rgb(display(), scrn, r, g, b);
|
||||
ColorCache::iterator it = colorcache.find(rgb);
|
||||
if (it != colorcache.end()) {
|
||||
// found
|
||||
allocated = true;
|
||||
p = (*it).second.p;
|
||||
(*it).second.count++;
|
||||
return;
|
||||
}
|
||||
|
||||
// allocate color from rgb values
|
||||
XColor xcol;
|
||||
xcol.red = r | r << 8;
|
||||
xcol.green = g | g << 8;
|
||||
xcol.blue = b | b << 8;
|
||||
xcol.pixel = 0;
|
||||
|
||||
if (! XAllocColor(display()->getXDisplay(), colormap, &xcol)) {
|
||||
fprintf(stderr, "BColor::allocate: color alloc error: rgb:%x/%x/%x\n",
|
||||
r, g, b);
|
||||
xcol.pixel = 0;
|
||||
}
|
||||
|
||||
p = xcol.pixel;
|
||||
allocated = true;
|
||||
|
||||
colorcache.insert(ColorCacheItem(rgb, PixelRef(p)));
|
||||
|
||||
if (cleancache)
|
||||
doCacheCleanup();
|
||||
}
|
||||
|
||||
|
||||
void BColor::deallocate(void) {
|
||||
if (! allocated)
|
||||
return;
|
||||
|
||||
assert(dpy != 0);
|
||||
|
||||
ColorCache::iterator it = colorcache.find(RGB(display(), scrn, r, g, b));
|
||||
if (it != colorcache.end()) {
|
||||
if ((*it).second.count >= 1)
|
||||
(*it).second.count--;
|
||||
}
|
||||
|
||||
if (cleancache)
|
||||
doCacheCleanup();
|
||||
|
||||
allocated = false;
|
||||
}
|
||||
|
||||
|
||||
BColor &BColor::operator=(const BColor &c) {
|
||||
deallocate();
|
||||
|
||||
setRGB(c.r, c.g, c.b);
|
||||
colorname = c.colorname;
|
||||
dpy = c.dpy;
|
||||
scrn = c.scrn;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void BColor::cleanupColorCache(void) {
|
||||
cleancache = true;
|
||||
}
|
||||
|
||||
|
||||
void BColor::doCacheCleanup(void) {
|
||||
// ### TODO - support multiple displays!
|
||||
ColorCache::iterator it = colorcache.begin();
|
||||
if (it == colorcache.end()) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
const BaseDisplay* const display = (*it).first.display;
|
||||
unsigned long *pixels = new unsigned long[ colorcache.size() ];
|
||||
unsigned int i, count;
|
||||
|
||||
for (i = 0; i < display->getNumberOfScreens(); i++) {
|
||||
count = 0;
|
||||
it = colorcache.begin();
|
||||
|
||||
while (it != colorcache.end()) {
|
||||
if ((*it).second.count != 0 || (*it).first.screen != i) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
|
||||
pixels[ count++ ] = (*it).second.p;
|
||||
ColorCache::iterator it2 = it;
|
||||
++it;
|
||||
colorcache.erase(it2);
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
XFreeColors(display->getXDisplay(),
|
||||
display->getScreenInfo(i)->getColormap(),
|
||||
pixels, count, 0);
|
||||
}
|
||||
|
||||
delete [] pixels;
|
||||
cleancache = false;
|
||||
}
|
128
src/Color.hh
Normal file
128
src/Color.hh
Normal file
|
@ -0,0 +1,128 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Color.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef COLOR_HH
|
||||
#define COLOR_HH
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class BaseDisplay;
|
||||
|
||||
class BColor {
|
||||
public:
|
||||
BColor(const BaseDisplay * const _display = 0, unsigned int _screen = ~(0u));
|
||||
BColor(int _r, int _g, int _b,
|
||||
const BaseDisplay * const _display, unsigned int _screen = ~(0u));
|
||||
BColor(const std::string &_name,
|
||||
const BaseDisplay * const _display, unsigned int _screen = ~(0u));
|
||||
~BColor(void);
|
||||
|
||||
inline const std::string &name(void) const { return colorname; }
|
||||
|
||||
inline int red(void) const { return r; }
|
||||
inline int green(void) const { return g; }
|
||||
inline int blue(void) const { return b; }
|
||||
void setRGB(int _r, int _g, int _b) {
|
||||
deallocate();
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
}
|
||||
|
||||
inline const BaseDisplay *display(void) const { return dpy; }
|
||||
inline unsigned int screen(void) const { return scrn; }
|
||||
void setDisplay(const BaseDisplay * const _display,
|
||||
unsigned int _screen = ~(0u));
|
||||
|
||||
inline bool isAllocated(void) const { return allocated; }
|
||||
|
||||
inline bool isValid(void) const { return r != -1 && g != -1 && b != -1; }
|
||||
|
||||
unsigned long pixel(void) const;
|
||||
|
||||
// operators
|
||||
BColor &operator=(const BColor &c);
|
||||
inline bool operator==(const BColor &c) const
|
||||
{ return (r == c.r && b == c.b && b == c.b); }
|
||||
inline bool operator!=(const BColor &c) const
|
||||
{ return (! operator==(c)); }
|
||||
|
||||
static void cleanupColorCache(void);
|
||||
|
||||
private:
|
||||
void parseColorName(void);
|
||||
void allocate(void);
|
||||
void deallocate(void);
|
||||
|
||||
bool allocated;
|
||||
int r, g, b;
|
||||
unsigned long p;
|
||||
const BaseDisplay *dpy;
|
||||
unsigned int scrn;
|
||||
std::string colorname;
|
||||
|
||||
// global color allocator/deallocator
|
||||
struct RGB {
|
||||
const BaseDisplay* const display;
|
||||
const unsigned int screen;
|
||||
const int r, g, b;
|
||||
|
||||
RGB(void) : display(0), screen(~(0u)), r(-1), g(-1), b(-1) { }
|
||||
RGB(const BaseDisplay * const a, const unsigned int b,
|
||||
const int x, const int y, const int z)
|
||||
: display(a), screen(b), r(x), g(y), b(z) {}
|
||||
RGB(const RGB &x)
|
||||
: display(x.display), screen(x.screen), r(x.r), g(x.g), b(x.b) {}
|
||||
|
||||
inline bool operator==(const RGB &x) const {
|
||||
return display == x.display &&
|
||||
screen == x.screen &&
|
||||
r == x.r && g == x.g && b == x.b;
|
||||
}
|
||||
|
||||
inline bool operator<(const RGB &x) const {
|
||||
unsigned long p1, p2;
|
||||
p1 = (screen << 24 | r << 16 | g << 8 | b) & 0x00ffffff;
|
||||
p2 = (x.screen << 24 | x.r << 16 | x.g << 8 | x.b) & 0x00ffffff;
|
||||
return p1 < p2;
|
||||
}
|
||||
};
|
||||
struct PixelRef {
|
||||
const unsigned long p;
|
||||
unsigned int count;
|
||||
inline PixelRef(void) : p(0), count(0) { }
|
||||
inline PixelRef(const unsigned long x) : p(x), count(1) { }
|
||||
};
|
||||
typedef std::map<RGB,PixelRef> ColorCache;
|
||||
typedef ColorCache::value_type ColorCacheItem;
|
||||
static ColorCache colorcache;
|
||||
static bool cleancache;
|
||||
static void doCacheCleanup(void);
|
||||
};
|
||||
|
||||
#endif // COLOR_HH
|
|
@ -1,6 +1,6 @@
|
|||
// Configmenu.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens <ben@orodu.net>
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Configmenu.cc for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -21,26 +21,19 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "i18n.h"
|
||||
#include "Configmenu.h"
|
||||
#include "Toolbar.h"
|
||||
#include "Window.h"
|
||||
#include "Screen.h"
|
||||
#include "i18n.hh"
|
||||
#include "Configmenu.hh"
|
||||
#include "Image.hh"
|
||||
#include "Toolbar.hh"
|
||||
#include "Window.hh"
|
||||
#include "Screen.hh"
|
||||
|
||||
Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
||||
{
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions,
|
||||
"Config options"));
|
||||
Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config options"));
|
||||
setInternalMenu();
|
||||
|
||||
focusmenu = new Focusmenu(this);
|
||||
|
@ -60,28 +53,21 @@ Configmenu::Configmenu(BScreen &scr) : Basemenu(scr), screen(scr)
|
|||
"Focus New Windows"), 4);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
|
||||
"Focus Last Window on Workspace"), 5);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar,
|
||||
"Hide toolbar"), 6);
|
||||
update();
|
||||
|
||||
setValues();
|
||||
setItemSelected(2, getScreen()->getImageControl()->doDither());
|
||||
setItemSelected(3, getScreen()->doOpaqueMove());
|
||||
setItemSelected(4, getScreen()->doFullMax());
|
||||
setItemSelected(5, getScreen()->doFocusNew());
|
||||
setItemSelected(6, getScreen()->doFocusLast());
|
||||
}
|
||||
|
||||
void Configmenu::setValues() {
|
||||
setItemSelected(2, screen.imageDither());
|
||||
setItemSelected(3, screen.opaqueMove());
|
||||
setItemSelected(4, screen.fullMax());
|
||||
setItemSelected(5, screen.focusNew());
|
||||
setItemSelected(6, screen.focusLast());
|
||||
setItemSelected(7, screen.hideToolbar());
|
||||
}
|
||||
|
||||
Configmenu::~Configmenu() {
|
||||
Configmenu::~Configmenu(void) {
|
||||
delete focusmenu;
|
||||
delete placementmenu;
|
||||
}
|
||||
|
||||
void Configmenu::itemSelected(int button, int index) {
|
||||
void Configmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
|
@ -92,87 +78,73 @@ void Configmenu::itemSelected(int button, int index) {
|
|||
|
||||
switch(item->function()) {
|
||||
case 1: { // dither
|
||||
screen.setImageDither(!screen.imageDither());
|
||||
getScreen()->getImageControl()->
|
||||
setDither((! getScreen()->getImageControl()->doDither()));
|
||||
|
||||
setItemSelected(index, screen.imageDither());
|
||||
setItemSelected(index, getScreen()->getImageControl()->doDither());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: { // opaque move
|
||||
screen.setOpaqueMove(!screen.opaqueMove());
|
||||
getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove()));
|
||||
|
||||
setItemSelected(index, screen.opaqueMove());
|
||||
setItemSelected(index, getScreen()->doOpaqueMove());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: { // full maximization
|
||||
screen.setFullMax(!screen.fullMax());
|
||||
getScreen()->saveFullMax((! getScreen()->doFullMax()));
|
||||
|
||||
setItemSelected(index, screen.fullMax());
|
||||
setItemSelected(index, getScreen()->doFullMax());
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: { // focus new windows
|
||||
screen.setFocusNew(!screen.focusNew());
|
||||
getScreen()->saveFocusNew((! getScreen()->doFocusNew()));
|
||||
|
||||
setItemSelected(index, screen.focusNew());
|
||||
setItemSelected(index, getScreen()->doFocusNew());
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: { // focus last window on workspace
|
||||
screen.setFocusLast(!screen.focusLast());
|
||||
setItemSelected(index, screen.focusLast());
|
||||
break;
|
||||
}
|
||||
case 6:{ //toggle toolbar hide
|
||||
screen.setHideToolbar(!screen.hideToolbar());
|
||||
setItemSelected(index, screen.hideToolbar());
|
||||
getScreen()->saveFocusLast((! getScreen()->doFocusLast()));
|
||||
setItemSelected(index, getScreen()->doFocusLast());
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
}
|
||||
|
||||
void Configmenu::reconfigure() {
|
||||
setValues();
|
||||
|
||||
void Configmenu::reconfigure(void) {
|
||||
focusmenu->reconfigure();
|
||||
placementmenu->reconfigure();
|
||||
|
||||
Basemenu::reconfigure();
|
||||
}
|
||||
|
||||
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->screen) {
|
||||
configmenu = cm;
|
||||
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel,
|
||||
"Focus Model"));
|
||||
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel, "Focus Model"));
|
||||
setInternalMenu();
|
||||
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus,
|
||||
"Click To Focus"), 1);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus,
|
||||
"Sloppy Focus"), 2);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise,
|
||||
"Auto Raise"), 3);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus, "Click To Focus"), 1);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus, "Sloppy Focus"), 2);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4);
|
||||
update();
|
||||
|
||||
setValues();
|
||||
setItemSelected(0, (! getScreen()->isSloppyFocus()));
|
||||
setItemSelected(1, getScreen()->isSloppyFocus());
|
||||
setItemEnabled(2, getScreen()->isSloppyFocus());
|
||||
setItemSelected(2, getScreen()->doAutoRaise());
|
||||
setItemEnabled(3, getScreen()->isSloppyFocus());
|
||||
setItemSelected(3, getScreen()->doClickRaise());
|
||||
}
|
||||
|
||||
void Configmenu::Focusmenu::setValues() {
|
||||
setItemSelected(0, !configmenu->screen.sloppyFocus());
|
||||
setItemSelected(1, configmenu->screen.sloppyFocus());
|
||||
setItemEnabled(2, configmenu->screen.sloppyFocus());
|
||||
setItemSelected(2, configmenu->screen.autoRaise());
|
||||
}
|
||||
|
||||
void Configmenu::Focusmenu::reconfigure() {
|
||||
setValues();
|
||||
Basemenu::reconfigure();
|
||||
}
|
||||
|
||||
void Configmenu::Focusmenu::itemSelected(int button, int index) {
|
||||
void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
|
@ -183,101 +155,81 @@ void Configmenu::Focusmenu::itemSelected(int button, int index) {
|
|||
|
||||
switch (item->function()) {
|
||||
case 1: // click to focus
|
||||
configmenu->screen.setSloppyFocus(false);
|
||||
configmenu->screen.setAutoRaise(false);
|
||||
// make windows all grab button1 clicks
|
||||
configmenu->screen.reconfigure();
|
||||
getScreen()->toggleFocusModel(BScreen::ClickToFocus);
|
||||
break;
|
||||
|
||||
case 2: // sloppy focus
|
||||
configmenu->screen.setSloppyFocus(true);
|
||||
// make windows stop grabbing button1 clicks
|
||||
configmenu->screen.reconfigure();
|
||||
getScreen()->toggleFocusModel(BScreen::SloppyFocus);
|
||||
break;
|
||||
|
||||
case 3: // auto raise with sloppy focus
|
||||
configmenu->screen.setAutoRaise(!configmenu->screen.autoRaise());
|
||||
getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
|
||||
break;
|
||||
|
||||
case 4: // click raise with sloppy focus
|
||||
getScreen()->saveClickRaise(! getScreen()->doClickRaise());
|
||||
getScreen()->updateFocusModel();
|
||||
break;
|
||||
}
|
||||
|
||||
setItemSelected(0, !configmenu->screen.sloppyFocus());
|
||||
setItemSelected(1, configmenu->screen.sloppyFocus());
|
||||
setItemEnabled(2, configmenu->screen.sloppyFocus());
|
||||
setItemSelected(2, configmenu->screen.autoRaise());
|
||||
setItemSelected(0, (! getScreen()->isSloppyFocus()));
|
||||
setItemSelected(1, getScreen()->isSloppyFocus());
|
||||
setItemEnabled(2, getScreen()->isSloppyFocus());
|
||||
setItemSelected(2, getScreen()->doAutoRaise());
|
||||
setItemEnabled(3, getScreen()->isSloppyFocus());
|
||||
setItemSelected(3, getScreen()->doClickRaise());
|
||||
}
|
||||
|
||||
Configmenu::Placementmenu::Placementmenu(Configmenu *cm) :
|
||||
Basemenu(cm->screen) {
|
||||
configmenu = cm;
|
||||
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
|
||||
"Window Placement"));
|
||||
Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
|
||||
Basemenu(cm->getScreen()) {
|
||||
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement"));
|
||||
setInternalMenu();
|
||||
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows,
|
||||
"Smart Placement (Rows)"),
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows, "Smart Placement (Rows)"),
|
||||
BScreen::RowSmartPlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols,
|
||||
"Smart Placement (Columns)"),
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols, "Smart Placement (Columns)"),
|
||||
BScreen::ColSmartPlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuCascade,
|
||||
"Cascade Placement"), BScreen::CascadePlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuBestFit,
|
||||
"Best Fit Placement"), BScreen::BestFitPlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuUnderMouse,
|
||||
"Under Mouse Placement"),
|
||||
BScreen::UnderMousePlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuClickMouse,
|
||||
"Click Mouse Placement"),
|
||||
BScreen::ClickMousePlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight,
|
||||
"Left to Right"), BScreen::LeftRight);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft,
|
||||
"Right to Left"), BScreen::RightLeft);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom,
|
||||
"Top to Bottom"), BScreen::TopBottom);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop,
|
||||
"Bottom to Top"), BScreen::BottomTop);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuCascade, "Cascade Placement"),
|
||||
BScreen::CascadePlacement);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight, "Left to Right"),
|
||||
BScreen::LeftRight);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft, "Right to Left"),
|
||||
BScreen::RightLeft);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom, "Top to Bottom"),
|
||||
BScreen::TopBottom);
|
||||
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"),
|
||||
BScreen::BottomTop);
|
||||
update();
|
||||
|
||||
setValues();
|
||||
}
|
||||
switch (getScreen()->getPlacementPolicy()) {
|
||||
case BScreen::RowSmartPlacement:
|
||||
setItemSelected(0, True);
|
||||
break;
|
||||
|
||||
void Configmenu::Placementmenu::setValues() {
|
||||
const int p = configmenu->screen.placementPolicy();
|
||||
setItemSelected(0, p == BScreen::RowSmartPlacement);
|
||||
setItemSelected(1, p == BScreen::ColSmartPlacement);
|
||||
setItemSelected(2, p == BScreen::CascadePlacement);
|
||||
setItemSelected(3, p == BScreen::BestFitPlacement);
|
||||
setItemSelected(4, p == BScreen::UnderMousePlacement);
|
||||
setItemSelected(5, p == BScreen::ClickMousePlacement);
|
||||
case BScreen::ColSmartPlacement:
|
||||
setItemSelected(1, True);
|
||||
break;
|
||||
|
||||
bool rl = (configmenu->screen.rowPlacementDirection() ==
|
||||
case BScreen::CascadePlacement:
|
||||
setItemSelected(2, True);
|
||||
break;
|
||||
}
|
||||
|
||||
bool rl = (getScreen()->getRowPlacementDirection() ==
|
||||
BScreen::LeftRight),
|
||||
tb = (configmenu->screen.colPlacementDirection() ==
|
||||
BScreen::TopBottom);
|
||||
tb = (getScreen()->getColPlacementDirection() ==
|
||||
BScreen::TopBottom);
|
||||
|
||||
setItemSelected(6, rl);
|
||||
setItemEnabled(6, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
setItemSelected(7, !rl);
|
||||
setItemEnabled(7, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
setItemSelected(3, rl);
|
||||
setItemSelected(4, ! rl);
|
||||
|
||||
setItemSelected(8, tb);
|
||||
setItemEnabled(8, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
setItemSelected(9, !tb);
|
||||
setItemEnabled(9, (p != BScreen::UnderMousePlacement &&
|
||||
p != BScreen::ClickMousePlacement));
|
||||
setItemSelected(5, tb);
|
||||
setItemSelected(6, ! tb);
|
||||
}
|
||||
|
||||
void Configmenu::Placementmenu::reconfigure() {
|
||||
setValues();
|
||||
Basemenu::reconfigure();
|
||||
}
|
||||
|
||||
void Configmenu::Placementmenu::itemSelected(int button, int index) {
|
||||
void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
|
@ -288,44 +240,62 @@ void Configmenu::Placementmenu::itemSelected(int button, int index) {
|
|||
|
||||
switch (item->function()) {
|
||||
case BScreen::RowSmartPlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
getScreen()->savePlacementPolicy(item->function());
|
||||
|
||||
setItemSelected(0, True);
|
||||
setItemSelected(1, False);
|
||||
setItemSelected(2, False);
|
||||
|
||||
break;
|
||||
|
||||
case BScreen::ColSmartPlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
getScreen()->savePlacementPolicy(item->function());
|
||||
|
||||
setItemSelected(0, False);
|
||||
setItemSelected(1, True);
|
||||
setItemSelected(2, False);
|
||||
|
||||
break;
|
||||
|
||||
case BScreen::CascadePlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
break;
|
||||
getScreen()->savePlacementPolicy(item->function());
|
||||
|
||||
case BScreen::BestFitPlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
break;
|
||||
setItemSelected(0, False);
|
||||
setItemSelected(1, False);
|
||||
setItemSelected(2, True);
|
||||
|
||||
case BScreen::UnderMousePlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
break;
|
||||
|
||||
case BScreen::ClickMousePlacement:
|
||||
configmenu->screen.setPlacementPolicy(item->function());
|
||||
break;
|
||||
|
||||
case BScreen::LeftRight:
|
||||
configmenu->screen.setRowPlacementDirection(BScreen::LeftRight);
|
||||
getScreen()->saveRowPlacementDirection(BScreen::LeftRight);
|
||||
|
||||
setItemSelected(3, True);
|
||||
setItemSelected(4, False);
|
||||
|
||||
break;
|
||||
|
||||
case BScreen::RightLeft:
|
||||
configmenu->screen.setRowPlacementDirection(BScreen::RightLeft);
|
||||
getScreen()->saveRowPlacementDirection(BScreen::RightLeft);
|
||||
|
||||
setItemSelected(3, False);
|
||||
setItemSelected(4, True);
|
||||
|
||||
break;
|
||||
|
||||
case BScreen::TopBottom:
|
||||
configmenu->screen.setColPlacementDirection(BScreen::TopBottom);
|
||||
getScreen()->saveColPlacementDirection(BScreen::TopBottom);
|
||||
|
||||
setItemSelected(5, True);
|
||||
setItemSelected(6, False);
|
||||
|
||||
break;
|
||||
|
||||
case BScreen::BottomTop:
|
||||
configmenu->screen.setColPlacementDirection(BScreen::BottomTop);
|
||||
getScreen()->saveColPlacementDirection(BScreen::BottomTop);
|
||||
|
||||
setItemSelected(5, False);
|
||||
setItemSelected(6, True);
|
||||
|
||||
break;
|
||||
}
|
||||
setValues();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Configmenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Configmenu.hh for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -23,10 +24,10 @@
|
|||
#ifndef __Configmenu_hh
|
||||
#define __Configmenu_hh
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Basemenu.hh"
|
||||
|
||||
// forward declaration
|
||||
class Openbox;
|
||||
class Blackbox;
|
||||
class BScreen;
|
||||
class Configmenu;
|
||||
|
||||
|
@ -34,51 +35,48 @@ class Configmenu : public Basemenu {
|
|||
private:
|
||||
class Focusmenu : public Basemenu {
|
||||
private:
|
||||
Configmenu *configmenu;
|
||||
Focusmenu(const Focusmenu&);
|
||||
Focusmenu& operator=(const Focusmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void setValues();
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Focusmenu(Configmenu *);
|
||||
void reconfigure();
|
||||
Focusmenu(Configmenu *cm);
|
||||
};
|
||||
|
||||
class Placementmenu : public Basemenu {
|
||||
private:
|
||||
Configmenu *configmenu;
|
||||
Placementmenu(const Placementmenu&);
|
||||
Placementmenu& operator=(const Placementmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void setValues();
|
||||
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Placementmenu(Configmenu *);
|
||||
void reconfigure();
|
||||
Placementmenu(Configmenu *cm);
|
||||
};
|
||||
|
||||
BScreen &screen;
|
||||
Focusmenu *focusmenu;
|
||||
Placementmenu *placementmenu;
|
||||
|
||||
friend class Focusmenu;
|
||||
friend class Placementmenu;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void setValues();
|
||||
Configmenu(const Configmenu&);
|
||||
Configmenu& operator=(const Configmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Configmenu(BScreen &);
|
||||
virtual ~Configmenu();
|
||||
Configmenu(BScreen *scr);
|
||||
virtual ~Configmenu(void);
|
||||
|
||||
inline Basemenu *getFocusmenu() { return focusmenu; }
|
||||
inline Basemenu *getPlacementmenu() { return placementmenu; }
|
||||
inline Basemenu *getFocusmenu(void) { return focusmenu; }
|
||||
inline Basemenu *getPlacementmenu(void) { return placementmenu; }
|
||||
|
||||
void reconfigure();
|
||||
void reconfigure(void);
|
||||
};
|
||||
|
||||
#endif // __Configmenu_hh
|
197
src/GCCache.cc
Normal file
197
src/GCCache.cc
Normal file
|
@ -0,0 +1,197 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// GCCache.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
}
|
||||
|
||||
#include "GCCache.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Color.hh"
|
||||
#include "Util.hh"
|
||||
|
||||
|
||||
void BGCCacheContext::set(const BColor &_color,
|
||||
const XFontStruct * const _font,
|
||||
const int _function, const int _subwindow) {
|
||||
XGCValues gcv;
|
||||
pixel = gcv.foreground = _color.pixel();
|
||||
function = gcv.function = _function;
|
||||
subwindow = gcv.subwindow_mode = _subwindow;
|
||||
unsigned long mask = GCForeground | GCFunction | GCSubwindowMode;
|
||||
|
||||
if (_font) {
|
||||
fontid = gcv.font = _font->fid;
|
||||
mask |= GCFont;
|
||||
} else {
|
||||
fontid = 0;
|
||||
}
|
||||
|
||||
XChangeGC(display->getXDisplay(), gc, mask, &gcv);
|
||||
}
|
||||
|
||||
|
||||
void BGCCacheContext::set(const XFontStruct * const _font) {
|
||||
if (! _font) {
|
||||
fontid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
XGCValues gcv;
|
||||
fontid = gcv.font = _font->fid;
|
||||
XChangeGC(display->getXDisplay(), gc, GCFont, &gcv);
|
||||
}
|
||||
|
||||
|
||||
BGCCache::BGCCache(const BaseDisplay * const _display)
|
||||
: display(_display), context_count(128u),
|
||||
cache_size(16u), cache_buckets(8u),
|
||||
cache_total_size(cache_size * cache_buckets) {
|
||||
|
||||
contexts = new BGCCacheContext*[context_count];
|
||||
unsigned int i;
|
||||
for (i = 0; i < context_count; i++) {
|
||||
contexts[i] = new BGCCacheContext(display);
|
||||
}
|
||||
|
||||
cache = new BGCCacheItem*[cache_total_size];
|
||||
for (i = 0; i < cache_total_size; ++i) {
|
||||
cache[i] = new BGCCacheItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BGCCache::~BGCCache(void) {
|
||||
std::for_each(contexts, contexts + context_count, PointerAssassin());
|
||||
std::for_each(cache, cache + cache_total_size, PointerAssassin());
|
||||
delete [] cache;
|
||||
delete [] contexts;
|
||||
cache = 0;
|
||||
contexts = 0;
|
||||
}
|
||||
|
||||
|
||||
BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
|
||||
Window hd = display->getScreenInfo(scr)->getRootWindow();
|
||||
|
||||
BGCCacheContext *c;
|
||||
|
||||
for (unsigned int i = 0; i < context_count; ++i) {
|
||||
c = contexts[i];
|
||||
|
||||
if (! c->gc) {
|
||||
c->gc = XCreateGC(display->getXDisplay(), hd, 0, 0);
|
||||
c->used = false;
|
||||
c->screen = scr;
|
||||
}
|
||||
if (! c->used && c->screen == scr) {
|
||||
c->used = true;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "BGCCache: context fault!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
void BGCCache::release(BGCCacheContext *ctx) {
|
||||
ctx->used = false;
|
||||
}
|
||||
|
||||
|
||||
BGCCacheItem *BGCCache::find(const BColor &_color,
|
||||
const XFontStruct * const _font,
|
||||
int _function, int _subwindow) {
|
||||
const unsigned long pixel = _color.pixel();
|
||||
const unsigned int screen = _color.screen();
|
||||
const int key = _color.red() ^ _color.green() ^ _color.blue();
|
||||
int k = (key % cache_size) * cache_buckets;
|
||||
int i = 0; // loop variable
|
||||
BGCCacheItem *c = cache[ k ], *prev = 0;
|
||||
|
||||
// this will either loop 8 times then return/abort or it will stop matching
|
||||
while (c->ctx &&
|
||||
(c->ctx->pixel != pixel || c->ctx->function != _function ||
|
||||
c->ctx->subwindow != _subwindow || c->ctx->screen != screen)) {
|
||||
if (i < 7) {
|
||||
prev = c;
|
||||
c = cache[ ++k ];
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if (c->count == 0 && c->ctx->screen == screen) {
|
||||
// use this cache item
|
||||
c->ctx->set(_color, _font, _function, _subwindow);
|
||||
c->ctx->used = true;
|
||||
c->count = 1;
|
||||
c->hits = 1;
|
||||
return c;
|
||||
}
|
||||
// cache fault!
|
||||
fprintf(stderr, "BGCCache: cache fault\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
const unsigned long fontid = _font ? _font->fid : 0;
|
||||
if (c->ctx) {
|
||||
// reuse existing context
|
||||
if (fontid && fontid != c->ctx->fontid)
|
||||
c->ctx->set(_font);
|
||||
c->count++;
|
||||
c->hits++;
|
||||
if (prev && c->hits > prev->hits) {
|
||||
cache[ k ] = prev;
|
||||
cache[ k - 1 ] = c;
|
||||
}
|
||||
} else {
|
||||
c->ctx = nextContext(screen);
|
||||
c->ctx->set(_color, _font, _function, _subwindow);
|
||||
c->ctx->used = true;
|
||||
c->count = 1;
|
||||
c->hits = 1;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void BGCCache::release(BGCCacheItem *_item) {
|
||||
_item->count--;
|
||||
}
|
||||
|
||||
|
||||
void BGCCache::purge(void) {
|
||||
for (unsigned int i = 0; i < cache_total_size; ++i) {
|
||||
BGCCacheItem *d = cache[ i ];
|
||||
|
||||
if (d->ctx && d->count == 0) {
|
||||
release(d->ctx);
|
||||
d->ctx = 0;
|
||||
}
|
||||
}
|
||||
}
|
133
src/GCCache.hh
Normal file
133
src/GCCache.hh
Normal file
|
@ -0,0 +1,133 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// GCCache.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef GCCACHE_HH
|
||||
#define GCCACHE_HH
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Color.hh"
|
||||
|
||||
class BGCCacheItem;
|
||||
|
||||
class BGCCacheContext {
|
||||
public:
|
||||
void set(const BColor &_color, const XFontStruct * const _font,
|
||||
const int _function, const int _subwindow);
|
||||
void set(const XFontStruct * const _font);
|
||||
|
||||
private:
|
||||
BGCCacheContext(const BaseDisplay * const _display)
|
||||
: display(_display), gc(0), pixel(0ul), fontid(0ul),
|
||||
function(0), subwindow(0), used(false), screen(~(0u)) {}
|
||||
|
||||
const BaseDisplay *display;
|
||||
GC gc;
|
||||
unsigned long pixel;
|
||||
unsigned long fontid;
|
||||
int function;
|
||||
int subwindow;
|
||||
bool used;
|
||||
unsigned int screen;
|
||||
|
||||
BGCCacheContext(const BGCCacheContext &_nocopy);
|
||||
BGCCacheContext &operator=(const BGCCacheContext &_nocopy);
|
||||
|
||||
friend class BGCCache;
|
||||
friend class BGCCacheItem;
|
||||
};
|
||||
|
||||
class BGCCacheItem {
|
||||
public:
|
||||
inline const GC &gc(void) const { return ctx->gc; }
|
||||
|
||||
private:
|
||||
BGCCacheItem(void) : ctx(0), count(0), hits(0), fault(false) { }
|
||||
|
||||
BGCCacheContext *ctx;
|
||||
unsigned int count;
|
||||
unsigned int hits;
|
||||
bool fault;
|
||||
|
||||
BGCCacheItem(const BGCCacheItem &_nocopy);
|
||||
BGCCacheItem &operator=(const BGCCacheItem &_nocopy);
|
||||
|
||||
friend class BGCCache;
|
||||
};
|
||||
|
||||
class BGCCache {
|
||||
public:
|
||||
explicit BGCCache(const BaseDisplay * const _display);
|
||||
~BGCCache(void);
|
||||
|
||||
// cleans up the cache
|
||||
void purge(void);
|
||||
|
||||
BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0,
|
||||
int _function = GXcopy, int _subwindow = ClipByChildren);
|
||||
void release(BGCCacheItem *_item);
|
||||
|
||||
private:
|
||||
BGCCacheContext *nextContext(unsigned int _screen);
|
||||
void release(BGCCacheContext *ctx);
|
||||
|
||||
// this is closely modelled after the Qt GC cache, but with some of the
|
||||
// complexity stripped out
|
||||
const BaseDisplay *display;
|
||||
|
||||
const unsigned int context_count;
|
||||
const unsigned int cache_size;
|
||||
const unsigned int cache_buckets;
|
||||
const unsigned int cache_total_size;
|
||||
BGCCacheContext **contexts;
|
||||
BGCCacheItem **cache;
|
||||
};
|
||||
|
||||
class BPen {
|
||||
public:
|
||||
inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
|
||||
int _function = GXcopy, int _subwindow = ClipByChildren)
|
||||
: color(_color), font(_font), function(_function), subwindow(_subwindow),
|
||||
cache(_color.display()->gcCache()), item(0) { }
|
||||
inline ~BPen(void) { if (item) cache->release(item); }
|
||||
|
||||
inline const GC &gc(void) const {
|
||||
if (! item) item = cache->find(color, font, function, subwindow);
|
||||
return item->gc();
|
||||
}
|
||||
|
||||
private:
|
||||
const BColor &color;
|
||||
const XFontStruct *font;
|
||||
int function;
|
||||
int subwindow;
|
||||
|
||||
mutable BGCCache *cache;
|
||||
mutable BGCCacheItem *item;
|
||||
};
|
||||
|
||||
|
||||
#endif // GCCACHE_HH
|
145
src/Geometry.cc
145
src/Geometry.cc
|
@ -1,145 +0,0 @@
|
|||
// Geometry.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "Geometry.h"
|
||||
|
||||
Point::Point() : m_x(0), m_y(0) {
|
||||
}
|
||||
|
||||
Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) {
|
||||
}
|
||||
|
||||
Point::Point(const int x, const int y) : m_x(x), m_y(y) {
|
||||
}
|
||||
|
||||
void Point::setX(const int x) {
|
||||
m_x = x;
|
||||
}
|
||||
|
||||
void Point::setY(const int y) {
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
Size::Size() : m_w(0), m_h(0) {
|
||||
}
|
||||
|
||||
Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) {
|
||||
}
|
||||
|
||||
Size::Size(const unsigned int w, const unsigned int h) : m_w(w), m_h(h) {
|
||||
}
|
||||
|
||||
void Size::setW(const unsigned int w) {
|
||||
m_w = w;
|
||||
}
|
||||
|
||||
void Size::setH(const unsigned int h) {
|
||||
m_h = h;
|
||||
}
|
||||
|
||||
Rect::Rect() : m_origin(0, 0), m_size(0, 0) {
|
||||
}
|
||||
|
||||
Rect::Rect(const Point &origin, const Size &size) : m_origin(origin),
|
||||
m_size(size) {
|
||||
}
|
||||
|
||||
Rect::Rect(const int x, const int y, const unsigned int w, const unsigned int h)
|
||||
: m_origin(x, y), m_size(w, h) {
|
||||
}
|
||||
|
||||
void Rect::setSize(const Size &size) {
|
||||
m_size = size;
|
||||
}
|
||||
|
||||
void Rect::setSize(const unsigned int w, const unsigned int h) {
|
||||
m_size.setW(w);
|
||||
m_size.setH(h);
|
||||
}
|
||||
|
||||
void Rect::setOrigin(const Point &origin) {
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
void Rect::setOrigin(const int x, const int y) {
|
||||
m_origin.setX(x);
|
||||
m_origin.setY(y);
|
||||
}
|
||||
|
||||
void Rect::setX(const int x) {
|
||||
m_origin.setX(x);
|
||||
}
|
||||
|
||||
void Rect::setY(const int y) {
|
||||
m_origin.setY(y);
|
||||
}
|
||||
|
||||
void Rect::setW(unsigned int w) {
|
||||
m_size.setW(w);
|
||||
}
|
||||
|
||||
void Rect::setH(unsigned int h) {
|
||||
m_size.setH(h);
|
||||
}
|
||||
|
||||
bool Rect::Intersect(const Rect &r) const {
|
||||
return
|
||||
(x() < (r.x()+(signed)r.w()) ) &&
|
||||
( (x()+(signed)w()) > r.x()) &&
|
||||
(y() < (r.y()+(signed)r.h()) ) &&
|
||||
( (y()+(signed)h()) > r.y());
|
||||
}
|
||||
|
||||
Rect Rect::Inflate(const unsigned int i) const {
|
||||
return Rect(x(), y(), w()+i, h()+i);
|
||||
}
|
||||
|
||||
Rect Rect::Inflate(const unsigned int iw, const unsigned int ih) const {
|
||||
return Rect(x(), y(), w()+iw, h()+ih);
|
||||
}
|
||||
|
||||
Rect Rect::Inflate(const Size &i) const {
|
||||
return Rect(x(), y(), w()+i.w(), h()+i.h());
|
||||
}
|
||||
|
||||
Rect Rect::Deflate(const unsigned int d) const {
|
||||
return Rect(x(), y(), w()-d, h()-d);
|
||||
}
|
||||
|
||||
Rect Rect::Deflate(const unsigned int dw, const unsigned int dh) const {
|
||||
return Rect(x(), y(), w()-dw, h()-dh);
|
||||
}
|
||||
|
||||
Rect Rect::Deflate(const Size &d) const {
|
||||
return Rect(x(), y(), w()-d.w(), h()-d.h());
|
||||
}
|
||||
|
||||
Rect Rect::Translate(const int t) const {
|
||||
return Rect(x()+t, y()+t, w(), h());
|
||||
}
|
||||
|
||||
Rect Rect::Translate(const int tx, const int ty) const {
|
||||
return Rect(x()+tx, y()+ty, w(), h());
|
||||
}
|
||||
|
||||
Rect Rect::Translate(const Point &t) const {
|
||||
return Rect(x()+t.x(), y()+t.y(), w(), h());
|
||||
}
|
116
src/Geometry.h
116
src/Geometry.h
|
@ -1,116 +0,0 @@
|
|||
// Geometry.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __geometry_h
|
||||
#define __geometry_h
|
||||
|
||||
class Point{
|
||||
int m_x, m_y;
|
||||
public:
|
||||
Point();
|
||||
Point(const Point &point);
|
||||
Point(const int x, const int y);
|
||||
|
||||
void setX(const int x);
|
||||
inline int x() const {
|
||||
return m_x;
|
||||
}
|
||||
|
||||
void setY(const int y);
|
||||
inline int y() const {
|
||||
return m_y;
|
||||
}
|
||||
};
|
||||
|
||||
class Size{
|
||||
unsigned int m_w, m_h;
|
||||
public:
|
||||
Size();
|
||||
Size(const Size &size);
|
||||
Size(const unsigned int w, const unsigned int h);
|
||||
|
||||
void setW(const unsigned int w);
|
||||
inline unsigned int w() const {
|
||||
return m_w;
|
||||
}
|
||||
|
||||
void setH(const unsigned int h);
|
||||
inline unsigned int h() const {
|
||||
return m_h;
|
||||
}
|
||||
};
|
||||
|
||||
class Rect{
|
||||
Point m_origin;
|
||||
Size m_size;
|
||||
public:
|
||||
Rect();
|
||||
Rect(const Point &origin, const Size &size);
|
||||
Rect(const int x, const int y, const unsigned int w, const unsigned int h);
|
||||
|
||||
void setSize(const Size &size);
|
||||
void setSize(const unsigned int w, const unsigned int h);
|
||||
inline const Size &size() const {
|
||||
return const_cast<const Size &>(m_size);
|
||||
}
|
||||
|
||||
void setOrigin(const Point &origin);
|
||||
void setOrigin(const int x, const int y);
|
||||
inline const Point &origin() const {
|
||||
return const_cast<const Point &>(m_origin);
|
||||
}
|
||||
|
||||
void setX(const int x);
|
||||
inline int x() const {
|
||||
return m_origin.x();
|
||||
}
|
||||
|
||||
void setY(const int y);
|
||||
inline int y() const {
|
||||
return m_origin.y();
|
||||
}
|
||||
|
||||
void setW(const unsigned int w);
|
||||
inline unsigned int w() const {
|
||||
return m_size.w();
|
||||
}
|
||||
|
||||
void setH(const unsigned int h);
|
||||
inline unsigned int h() const {
|
||||
return m_size.h();
|
||||
}
|
||||
|
||||
bool Intersect(const Rect &r) const;
|
||||
// returns a rect that is this rect increased in size by the passed in amount
|
||||
Rect Inflate(const unsigned int i) const;
|
||||
Rect Inflate(const unsigned int iw, const unsigned int ih) const;
|
||||
Rect Inflate(const Size &i) const;
|
||||
// returns a rect that is this rect decreased in size by the passed in amount
|
||||
Rect Deflate(const unsigned int d) const;
|
||||
Rect Deflate(const unsigned int dw, const unsigned int dh) const;
|
||||
Rect Deflate(const Size &d) const;
|
||||
// returns a rect that is moved the amount specified
|
||||
Rect Translate(const int t) const;
|
||||
Rect Translate(const int tx, const int ty) const;
|
||||
Rect Translate(const Point &t) const;
|
||||
};
|
||||
|
||||
#endif // __geometry_h
|
|
@ -1,5 +1,6 @@
|
|||
// Iconmenu.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Icon.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,23 +21,17 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "i18n.h"
|
||||
#include "Iconmenu.h"
|
||||
#include "Screen.h"
|
||||
#include "Window.h"
|
||||
#include "i18n.hh"
|
||||
#include "Iconmenu.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Window.hh"
|
||||
|
||||
|
||||
Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
||||
Iconmenu::Iconmenu(BScreen *scrn) : Basemenu(scrn) {
|
||||
setInternalMenu();
|
||||
|
||||
setLabel(i18n(IconSet, IconIcons, "Icons"));
|
||||
|
@ -44,12 +39,12 @@ Iconmenu::Iconmenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
|||
}
|
||||
|
||||
|
||||
void Iconmenu::itemSelected(int button, int index) {
|
||||
void Iconmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
if (index >= 0 && index < screen.getIconCount()) {
|
||||
OpenboxWindow *win = screen.getIcon(index);
|
||||
if (index < getScreen()->getIconCount()) {
|
||||
BlackboxWindow *win = getScreen()->getIcon(index);
|
||||
|
||||
if (win) {
|
||||
win->deiconify();
|
||||
|
@ -57,6 +52,6 @@ void Iconmenu::itemSelected(int button, int index) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! (screen.getWorkspacemenu()->isTorn() || isTorn()))
|
||||
if (! (getScreen()->getWorkspacemenu()->isTorn() || isTorn()))
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// Iconmenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Icon_hh
|
||||
#define __Icon_hh
|
||||
|
||||
#include "Basemenu.h"
|
||||
|
||||
// forward declaration
|
||||
class Iconmenu;
|
||||
class BScreen;
|
||||
|
||||
class Iconmenu : public Basemenu {
|
||||
private:
|
||||
BScreen &screen;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
public:
|
||||
Iconmenu(BScreen &);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Icon_hh
|
1723
src/Image.cc
1723
src/Image.cc
File diff suppressed because it is too large
Load diff
242
src/Image.h
242
src/Image.h
|
@ -1,242 +0,0 @@
|
|||
// Image.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Image_hh
|
||||
#define __Image_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "Timer.h"
|
||||
#include <list>
|
||||
|
||||
class ScreenInfo;
|
||||
class BImage;
|
||||
class BImageControl;
|
||||
|
||||
|
||||
// bevel options
|
||||
#define BImage_Flat (1l<<1)
|
||||
#define BImage_Sunken (1l<<2)
|
||||
#define BImage_Raised (1l<<3)
|
||||
|
||||
// textures
|
||||
#define BImage_Solid (1l<<4)
|
||||
#define BImage_Gradient (1l<<5)
|
||||
|
||||
// gradients
|
||||
#define BImage_Horizontal (1l<<6)
|
||||
#define BImage_Vertical (1l<<7)
|
||||
#define BImage_Diagonal (1l<<8)
|
||||
#define BImage_CrossDiagonal (1l<<9)
|
||||
#define BImage_Rectangle (1l<<10)
|
||||
#define BImage_Pyramid (1l<<11)
|
||||
#define BImage_PipeCross (1l<<12)
|
||||
#define BImage_Elliptic (1l<<13)
|
||||
|
||||
// bevel types
|
||||
#define BImage_Bevel1 (1l<<14)
|
||||
#define BImage_Bevel2 (1l<<15)
|
||||
|
||||
// inverted image
|
||||
#define BImage_Invert (1l<<16)
|
||||
|
||||
// parent relative image
|
||||
#define BImage_ParentRelative (1l<<17)
|
||||
|
||||
#ifdef INTERLACE
|
||||
// fake interlaced image
|
||||
# define BImage_Interlaced (1l<<18)
|
||||
#endif // INTERLACE
|
||||
|
||||
class BColor {
|
||||
private:
|
||||
int allocated;
|
||||
unsigned char red, green, blue;
|
||||
unsigned long pixel;
|
||||
|
||||
public:
|
||||
BColor(char r = 0, char g = 0, char b = 0)
|
||||
{ red = r; green = g; blue = b; pixel = 0; allocated = 0; }
|
||||
|
||||
inline const int &isAllocated(void) const { return allocated; }
|
||||
|
||||
inline const unsigned char &getRed(void) const { return red; }
|
||||
inline const unsigned char &getGreen(void) const { return green; }
|
||||
inline const unsigned char &getBlue(void) const { return blue; }
|
||||
|
||||
inline const unsigned long &getPixel(void) const { return pixel; }
|
||||
|
||||
inline void setAllocated(int a) { allocated = a; }
|
||||
inline void setRGB(char r, char g, char b) { red = r; green = g; blue = b; }
|
||||
inline void setPixel(unsigned long p) { pixel = p; }
|
||||
};
|
||||
|
||||
|
||||
class BTexture {
|
||||
private:
|
||||
BColor color, colorTo, hiColor, loColor;
|
||||
unsigned long texture;
|
||||
|
||||
public:
|
||||
BTexture(void) { texture = 0; }
|
||||
|
||||
inline BColor *getColor(void) { return &color; }
|
||||
inline BColor *getColorTo(void) { return &colorTo; }
|
||||
inline BColor *getHiColor(void) { return &hiColor; }
|
||||
inline BColor *getLoColor(void) { return &loColor; }
|
||||
|
||||
inline const unsigned long &getTexture(void) const { return texture; }
|
||||
|
||||
inline void setTexture(unsigned long t) { texture = t; }
|
||||
inline void addTexture(unsigned long t) { texture |= t; }
|
||||
};
|
||||
|
||||
|
||||
class BImage {
|
||||
private:
|
||||
BImageControl &control;
|
||||
|
||||
#ifdef INTERLACE
|
||||
Bool interlaced;
|
||||
#endif // INTERLACE
|
||||
|
||||
XColor *colors;
|
||||
|
||||
BColor *from, *to;
|
||||
int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
|
||||
ncolors, cpc, cpccpc;
|
||||
unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
|
||||
unsigned int width, height, *xtable, *ytable;
|
||||
|
||||
|
||||
protected:
|
||||
Pixmap renderPixmap(void);
|
||||
|
||||
XImage *renderXImage(void);
|
||||
|
||||
void invert(void);
|
||||
void bevel1(void);
|
||||
void bevel2(void);
|
||||
void dgradient(void);
|
||||
void egradient(void);
|
||||
void hgradient(void);
|
||||
void pgradient(void);
|
||||
void rgradient(void);
|
||||
void vgradient(void);
|
||||
void cdgradient(void);
|
||||
void pcgradient(void);
|
||||
|
||||
|
||||
public:
|
||||
BImage(BImageControl &, unsigned int, unsigned int);
|
||||
~BImage(void);
|
||||
|
||||
Pixmap render(BTexture *);
|
||||
Pixmap render_solid(BTexture *);
|
||||
Pixmap render_gradient(BTexture *);
|
||||
};
|
||||
|
||||
|
||||
class BImageControl : public TimeoutHandler {
|
||||
private:
|
||||
Bool dither;
|
||||
BaseDisplay &basedisplay;
|
||||
ScreenInfo &screeninfo;
|
||||
#ifdef TIMEDCACHE
|
||||
BTimer *timer;
|
||||
#endif // TIMEDCACHE
|
||||
|
||||
Colormap colormap;
|
||||
|
||||
Window window;
|
||||
XColor *colors;
|
||||
int colors_per_channel, ncolors, screen_number, screen_depth,
|
||||
bits_per_pixel, red_offset, green_offset, blue_offset,
|
||||
red_bits, green_bits, blue_bits;
|
||||
unsigned char red_color_table[256], green_color_table[256],
|
||||
blue_color_table[256];
|
||||
unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
|
||||
grad_buffer_height;
|
||||
unsigned long *sqrt_table, cache_max;
|
||||
|
||||
typedef struct Cache {
|
||||
Pixmap pixmap;
|
||||
|
||||
unsigned int count, width, height;
|
||||
unsigned long pixel1, pixel2, texture;
|
||||
} Cache;
|
||||
|
||||
typedef std::list<Cache*> CacheList;
|
||||
CacheList cache;
|
||||
|
||||
|
||||
protected:
|
||||
Pixmap searchCache(unsigned int, unsigned int, unsigned long, BColor *,
|
||||
BColor *);
|
||||
|
||||
|
||||
public:
|
||||
BImageControl(BaseDisplay &, ScreenInfo &, Bool = False, int = 4,
|
||||
unsigned long = 300000l, unsigned long = 200l);
|
||||
virtual ~BImageControl(void);
|
||||
|
||||
inline BaseDisplay &getBaseDisplay(void) { return basedisplay; }
|
||||
|
||||
inline const Bool &doDither(void) { return dither; }
|
||||
|
||||
inline ScreenInfo &getScreenInfo(void) { return screeninfo; }
|
||||
|
||||
inline const Window &getDrawable(void) const { return window; }
|
||||
|
||||
inline Visual *getVisual(void) const { return screeninfo.getVisual(); }
|
||||
|
||||
inline const int &getBitsPerPixel(void) const { return bits_per_pixel; }
|
||||
inline const int &getDepth(void) const { return screen_depth; }
|
||||
inline const int &getColorsPerChannel(void) const
|
||||
{ return colors_per_channel; }
|
||||
|
||||
unsigned long getColor(const char *);
|
||||
unsigned long getColor(const char *, unsigned char *, unsigned char *,
|
||||
unsigned char *);
|
||||
unsigned long getSqrt(unsigned int);
|
||||
|
||||
Pixmap renderImage(unsigned int, unsigned int, BTexture *);
|
||||
|
||||
void installRootColormap(void);
|
||||
void removeImage(Pixmap);
|
||||
void getColorTables(unsigned char **, unsigned char **, unsigned char **,
|
||||
int *, int *, int *, int *, int *, int *);
|
||||
void getXColorTable(XColor **, int *);
|
||||
void getGradientBuffers(unsigned int, unsigned int,
|
||||
unsigned int **, unsigned int **);
|
||||
void setDither(Bool d) { dither = d; }
|
||||
void setColorsPerChannel(int);
|
||||
void parseTexture(BTexture *, const char *);
|
||||
void parseColor(BColor *, const char * = 0);
|
||||
|
||||
virtual void timeout(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Image_hh
|
||||
|
179
src/Image.hh
Normal file
179
src/Image.hh
Normal file
|
@ -0,0 +1,179 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Image.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Image_hh
|
||||
#define __Image_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
}
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "Timer.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Color.hh"
|
||||
|
||||
class BImageControl;
|
||||
class BTexture;
|
||||
class BImageCache;
|
||||
|
||||
class BImage {
|
||||
private:
|
||||
BImageControl *control;
|
||||
bool interlaced;
|
||||
XColor *colors;
|
||||
|
||||
BColor from, to;
|
||||
int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
|
||||
ncolors, cpc, cpccpc;
|
||||
unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
|
||||
unsigned int width, height, *xtable, *ytable;
|
||||
|
||||
void TrueColorDither(unsigned int bit_depth, int bytes_per_line,
|
||||
unsigned char *pixel_data);
|
||||
void PseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
|
||||
#ifdef ORDEREDPSEUDO
|
||||
void OrderedPseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
|
||||
#endif
|
||||
|
||||
Pixmap renderPixmap(void);
|
||||
|
||||
XImage *renderXImage(void);
|
||||
|
||||
void invert(void);
|
||||
void bevel1(void);
|
||||
void bevel2(void);
|
||||
void dgradient(void);
|
||||
void egradient(void);
|
||||
void hgradient(void);
|
||||
void pgradient(void);
|
||||
void rgradient(void);
|
||||
void vgradient(void);
|
||||
void cdgradient(void);
|
||||
void pcgradient(void);
|
||||
|
||||
|
||||
public:
|
||||
BImage(BImageControl *c, unsigned int w, unsigned int h);
|
||||
~BImage(void);
|
||||
|
||||
Pixmap render(const BTexture &texture);
|
||||
Pixmap render_solid(const BTexture &texture);
|
||||
Pixmap render_gradient(const BTexture &texture);
|
||||
|
||||
// static methods for the builtin cache
|
||||
static unsigned long maximumCacheSize(void);
|
||||
static void setMaximumCacheSize(const unsigned long cache_max);
|
||||
|
||||
static unsigned long cacheTimeout(void);
|
||||
static void setCacheTimeout(const unsigned long cache_timeout);
|
||||
|
||||
private:
|
||||
// global image cache
|
||||
static BImageCache *imagecache;
|
||||
};
|
||||
|
||||
|
||||
class BImageControl : public TimeoutHandler {
|
||||
public:
|
||||
struct CachedImage {
|
||||
Pixmap pixmap;
|
||||
|
||||
unsigned int count, width, height;
|
||||
unsigned long pixel1, pixel2, texture;
|
||||
};
|
||||
|
||||
BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
|
||||
bool _dither= False, int _cpc = 4,
|
||||
unsigned long cache_timeout = 300000l,
|
||||
unsigned long cmax = 200l);
|
||||
virtual ~BImageControl(void);
|
||||
|
||||
inline BaseDisplay *getBaseDisplay(void) const { return basedisplay; }
|
||||
|
||||
inline bool doDither(void) { return dither; }
|
||||
|
||||
inline const ScreenInfo *getScreenInfo(void) { return screeninfo; }
|
||||
|
||||
inline Window getDrawable(void) const { return window; }
|
||||
|
||||
inline Visual *getVisual(void) { return screeninfo->getVisual(); }
|
||||
|
||||
inline int getBitsPerPixel(void) const { return bits_per_pixel; }
|
||||
inline int getDepth(void) const { return screen_depth; }
|
||||
inline int getColorsPerChannel(void) const
|
||||
{ return colors_per_channel; }
|
||||
|
||||
unsigned long getSqrt(unsigned int x);
|
||||
|
||||
Pixmap renderImage(unsigned int width, unsigned int height,
|
||||
const BTexture &texture);
|
||||
|
||||
void installRootColormap(void);
|
||||
void removeImage(Pixmap pixmap);
|
||||
void getColorTables(unsigned char **rmt, unsigned char **gmt,
|
||||
unsigned char **bmt,
|
||||
int *roff, int *goff, int *boff,
|
||||
int *rbit, int *gbit, int *bbit);
|
||||
void getXColorTable(XColor **c, int *n);
|
||||
void getGradientBuffers(unsigned int w, unsigned int h,
|
||||
unsigned int **xbuf, unsigned int **ybuf);
|
||||
void setDither(bool d) { dither = d; }
|
||||
void setColorsPerChannel(int cpc);
|
||||
|
||||
virtual void timeout(void);
|
||||
|
||||
private:
|
||||
bool dither;
|
||||
BaseDisplay *basedisplay;
|
||||
const ScreenInfo *screeninfo;
|
||||
#ifdef TIMEDCACHE
|
||||
BTimer *timer;
|
||||
#endif // TIMEDCACHE
|
||||
|
||||
Colormap colormap;
|
||||
|
||||
Window window;
|
||||
XColor *colors;
|
||||
int colors_per_channel, ncolors, screen_number, screen_depth,
|
||||
bits_per_pixel, red_offset, green_offset, blue_offset,
|
||||
red_bits, green_bits, blue_bits;
|
||||
unsigned char red_color_table[256], green_color_table[256],
|
||||
blue_color_table[256];
|
||||
unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
|
||||
grad_buffer_height;
|
||||
unsigned long *sqrt_table, cache_max;
|
||||
|
||||
typedef std::list<CachedImage> CacheContainer;
|
||||
CacheContainer cache;
|
||||
|
||||
Pixmap searchCache(const unsigned int width, const unsigned int height,
|
||||
const unsigned long texture,
|
||||
const BColor &c1, const BColor &c2);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Image_hh
|
||||
|
604
src/ImageControl.cc
Normal file
604
src/ImageControl.cc
Normal file
|
@ -0,0 +1,604 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// ImageControl.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
extern "C" {
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
# include <ctype.h>
|
||||
#endif // HAVE_CTYPE_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "blackbox.hh"
|
||||
#include "i18n.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Color.hh"
|
||||
#include "Image.hh"
|
||||
#include "Texture.hh"
|
||||
|
||||
static unsigned long bsqrt(unsigned long x) {
|
||||
if (x <= 0) return 0;
|
||||
if (x == 1) return 1;
|
||||
|
||||
unsigned long r = x >> 1;
|
||||
unsigned long q;
|
||||
|
||||
while (1) {
|
||||
q = x / r;
|
||||
if (q >= r) return r;
|
||||
r = (r + q) >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
BImageControl *ctrl = 0;
|
||||
|
||||
BImageControl::BImageControl(BaseDisplay *dpy, const ScreenInfo *scrn,
|
||||
bool _dither, int _cpc,
|
||||
unsigned long cache_timeout,
|
||||
unsigned long cmax)
|
||||
{
|
||||
if (! ctrl) ctrl = this;
|
||||
|
||||
basedisplay = dpy;
|
||||
screeninfo = scrn;
|
||||
setDither(_dither);
|
||||
setColorsPerChannel(_cpc);
|
||||
|
||||
cache_max = cmax;
|
||||
#ifdef TIMEDCACHE
|
||||
if (cache_timeout) {
|
||||
timer = new BTimer(basedisplay, this);
|
||||
timer->setTimeout(cache_timeout);
|
||||
timer->start();
|
||||
} else {
|
||||
timer = (BTimer *) 0;
|
||||
}
|
||||
#endif // TIMEDCACHE
|
||||
|
||||
colors = (XColor *) 0;
|
||||
ncolors = 0;
|
||||
|
||||
grad_xbuffer = grad_ybuffer = (unsigned int *) 0;
|
||||
grad_buffer_width = grad_buffer_height = 0;
|
||||
|
||||
sqrt_table = (unsigned long *) 0;
|
||||
|
||||
screen_depth = screeninfo->getDepth();
|
||||
window = screeninfo->getRootWindow();
|
||||
screen_number = screeninfo->getScreenNumber();
|
||||
colormap = screeninfo->getColormap();
|
||||
|
||||
int count;
|
||||
XPixmapFormatValues *pmv = XListPixmapFormats(basedisplay->getXDisplay(),
|
||||
&count);
|
||||
if (pmv) {
|
||||
bits_per_pixel = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (pmv[i].depth == screen_depth) {
|
||||
bits_per_pixel = pmv[i].bits_per_pixel;
|
||||
break;
|
||||
}
|
||||
|
||||
XFree(pmv);
|
||||
}
|
||||
|
||||
if (bits_per_pixel == 0) bits_per_pixel = screen_depth;
|
||||
if (bits_per_pixel >= 24) setDither(False);
|
||||
|
||||
red_offset = green_offset = blue_offset = 0;
|
||||
|
||||
switch (getVisual()->c_class) {
|
||||
case TrueColor: {
|
||||
int i;
|
||||
|
||||
// compute color tables
|
||||
unsigned long red_mask = getVisual()->red_mask,
|
||||
green_mask = getVisual()->green_mask,
|
||||
blue_mask = getVisual()->blue_mask;
|
||||
|
||||
while (! (red_mask & 1)) { red_offset++; red_mask >>= 1; }
|
||||
while (! (green_mask & 1)) { green_offset++; green_mask >>= 1; }
|
||||
while (! (blue_mask & 1)) { blue_offset++; blue_mask >>= 1; }
|
||||
|
||||
red_bits = 255 / red_mask;
|
||||
green_bits = 255 / green_mask;
|
||||
blue_bits = 255 / blue_mask;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
red_color_table[i] = i / red_bits;
|
||||
green_color_table[i] = i / green_bits;
|
||||
blue_color_table[i] = i / blue_bits;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PseudoColor:
|
||||
case StaticColor: {
|
||||
ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
|
||||
|
||||
if (ncolors > (1 << screen_depth)) {
|
||||
colors_per_channel = (1 << screen_depth) / 3;
|
||||
ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
|
||||
}
|
||||
|
||||
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
|
||||
fprintf(stderr,
|
||||
i18n(ImageSet, ImageInvalidColormapSize,
|
||||
"BImageControl::BImageControl: invalid colormap size %d "
|
||||
"(%d/%d/%d) - reducing"),
|
||||
ncolors, colors_per_channel, colors_per_channel,
|
||||
colors_per_channel);
|
||||
|
||||
colors_per_channel = (1 << screen_depth) / 3;
|
||||
}
|
||||
|
||||
colors = new XColor[ncolors];
|
||||
if (! colors) {
|
||||
fprintf(stderr, i18n(ImageSet, ImageErrorAllocatingColormap,
|
||||
"BImageControl::BImageControl: error allocating "
|
||||
"colormap\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int i = 0, ii, p, r, g, b,
|
||||
|
||||
#ifdef ORDEREDPSEUDO
|
||||
bits = 256 / colors_per_channel;
|
||||
#else // !ORDEREDPSEUDO
|
||||
bits = 255 / (colors_per_channel - 1);
|
||||
#endif // ORDEREDPSEUDO
|
||||
|
||||
red_bits = green_bits = blue_bits = bits;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
red_color_table[i] = green_color_table[i] = blue_color_table[i] =
|
||||
i / bits;
|
||||
|
||||
for (r = 0, i = 0; r < colors_per_channel; r++)
|
||||
for (g = 0; g < colors_per_channel; g++)
|
||||
for (b = 0; b < colors_per_channel; b++, i++) {
|
||||
colors[i].red = (r * 0xffff) / (colors_per_channel - 1);
|
||||
colors[i].green = (g * 0xffff) / (colors_per_channel - 1);
|
||||
colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);;
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
}
|
||||
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
if (! XAllocColor(basedisplay->getXDisplay(), colormap, &colors[i])) {
|
||||
fprintf(stderr, i18n(ImageSet, ImageColorAllocFail,
|
||||
"couldn't alloc color %i %i %i\n"),
|
||||
colors[i].red, colors[i].green, colors[i].blue);
|
||||
colors[i].flags = 0;
|
||||
} else {
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
}
|
||||
}
|
||||
|
||||
XColor icolors[256];
|
||||
int incolors = (((1 << screen_depth) > 256) ? 256 : (1 << screen_depth));
|
||||
|
||||
for (i = 0; i < incolors; i++)
|
||||
icolors[i].pixel = i;
|
||||
|
||||
XQueryColors(basedisplay->getXDisplay(), colormap, icolors, incolors);
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
if (! colors[i].flags) {
|
||||
unsigned long chk = 0xffffffff, pixel, close = 0;
|
||||
|
||||
p = 2;
|
||||
while (p--) {
|
||||
for (ii = 0; ii < incolors; ii++) {
|
||||
r = (colors[i].red - icolors[i].red) >> 8;
|
||||
g = (colors[i].green - icolors[i].green) >> 8;
|
||||
b = (colors[i].blue - icolors[i].blue) >> 8;
|
||||
pixel = (r * r) + (g * g) + (b * b);
|
||||
|
||||
if (pixel < chk) {
|
||||
chk = pixel;
|
||||
close = ii;
|
||||
}
|
||||
|
||||
colors[i].red = icolors[close].red;
|
||||
colors[i].green = icolors[close].green;
|
||||
colors[i].blue = icolors[close].blue;
|
||||
|
||||
if (XAllocColor(basedisplay->getXDisplay(), colormap,
|
||||
&colors[i])) {
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GrayScale:
|
||||
case StaticGray: {
|
||||
if (getVisual()->c_class == StaticGray) {
|
||||
ncolors = 1 << screen_depth;
|
||||
} else {
|
||||
ncolors = colors_per_channel * colors_per_channel * colors_per_channel;
|
||||
|
||||
if (ncolors > (1 << screen_depth)) {
|
||||
colors_per_channel = (1 << screen_depth) / 3;
|
||||
ncolors =
|
||||
colors_per_channel * colors_per_channel * colors_per_channel;
|
||||
}
|
||||
}
|
||||
|
||||
if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) {
|
||||
fprintf(stderr,
|
||||
i18n(ImageSet, ImageInvalidColormapSize,
|
||||
"BImageControl::BImageControl: invalid colormap size %d "
|
||||
"(%d/%d/%d) - reducing"),
|
||||
ncolors, colors_per_channel, colors_per_channel,
|
||||
colors_per_channel);
|
||||
|
||||
colors_per_channel = (1 << screen_depth) / 3;
|
||||
}
|
||||
|
||||
colors = new XColor[ncolors];
|
||||
if (! colors) {
|
||||
fprintf(stderr,
|
||||
i18n(ImageSet, ImageErrorAllocatingColormap,
|
||||
"BImageControl::BImageControl: error allocating colormap\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int i = 0, ii, p, bits = 255 / (colors_per_channel - 1);
|
||||
red_bits = green_bits = blue_bits = bits;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
red_color_table[i] = green_color_table[i] = blue_color_table[i] =
|
||||
i / bits;
|
||||
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
colors[i].red = (i * 0xffff) / (colors_per_channel - 1);
|
||||
colors[i].green = (i * 0xffff) / (colors_per_channel - 1);
|
||||
colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
|
||||
if (! XAllocColor(basedisplay->getXDisplay(), colormap,
|
||||
&colors[i])) {
|
||||
fprintf(stderr, i18n(ImageSet, ImageColorAllocFail,
|
||||
"couldn't alloc color %i %i %i\n"),
|
||||
colors[i].red, colors[i].green, colors[i].blue);
|
||||
colors[i].flags = 0;
|
||||
} else {
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
}
|
||||
}
|
||||
|
||||
XColor icolors[256];
|
||||
int incolors = (((1 << screen_depth) > 256) ? 256 :
|
||||
(1 << screen_depth));
|
||||
|
||||
for (i = 0; i < incolors; i++)
|
||||
icolors[i].pixel = i;
|
||||
|
||||
XQueryColors(basedisplay->getXDisplay(), colormap, icolors, incolors);
|
||||
for (i = 0; i < ncolors; i++) {
|
||||
if (! colors[i].flags) {
|
||||
unsigned long chk = 0xffffffff, pixel, close = 0;
|
||||
|
||||
p = 2;
|
||||
while (p--) {
|
||||
for (ii = 0; ii < incolors; ii++) {
|
||||
int r = (colors[i].red - icolors[i].red) >> 8;
|
||||
int g = (colors[i].green - icolors[i].green) >> 8;
|
||||
int b = (colors[i].blue - icolors[i].blue) >> 8;
|
||||
pixel = (r * r) + (g * g) + (b * b);
|
||||
|
||||
if (pixel < chk) {
|
||||
chk = pixel;
|
||||
close = ii;
|
||||
}
|
||||
|
||||
colors[i].red = icolors[close].red;
|
||||
colors[i].green = icolors[close].green;
|
||||
colors[i].blue = icolors[close].blue;
|
||||
|
||||
if (XAllocColor(basedisplay->getXDisplay(), colormap,
|
||||
&colors[i])) {
|
||||
colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
fprintf(stderr,
|
||||
i18n(ImageSet, ImageUnsupVisual,
|
||||
"BImageControl::BImageControl: unsupported visual %d\n"),
|
||||
getVisual()->c_class);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BImageControl::~BImageControl(void) {
|
||||
delete [] sqrt_table;
|
||||
|
||||
delete [] grad_xbuffer;
|
||||
|
||||
delete [] grad_ybuffer;
|
||||
|
||||
if (colors) {
|
||||
unsigned long *pixels = new unsigned long [ncolors];
|
||||
|
||||
int i;
|
||||
for (i = 0; i < ncolors; i++)
|
||||
*(pixels + i) = (*(colors + i)).pixel;
|
||||
|
||||
XFreeColors(basedisplay->getXDisplay(), colormap, pixels, ncolors, 0);
|
||||
|
||||
delete [] colors;
|
||||
}
|
||||
|
||||
if (!cache.empty()) {
|
||||
//#ifdef DEBUG
|
||||
fprintf(stderr, i18n(ImageSet, ImagePixmapRelease,
|
||||
"BImageContol::~BImageControl: pixmap cache - "
|
||||
"releasing %d pixmaps\n"), cache.size());
|
||||
//#endif
|
||||
CacheContainer::iterator it = cache.begin();
|
||||
const CacheContainer::iterator end = cache.end();
|
||||
for (; it != end; ++it) {
|
||||
XFreePixmap(basedisplay->getXDisplay(), (*it).pixmap);
|
||||
}
|
||||
}
|
||||
#ifdef TIMEDCACHE
|
||||
if (timer) {
|
||||
timer->stop();
|
||||
delete timer;
|
||||
}
|
||||
#endif // TIMEDCACHE
|
||||
}
|
||||
|
||||
|
||||
Pixmap BImageControl::searchCache(const unsigned int width,
|
||||
const unsigned int height,
|
||||
const unsigned long texture,
|
||||
const BColor &c1, const BColor &c2) {
|
||||
if (cache.empty())
|
||||
return None;
|
||||
|
||||
CacheContainer::iterator it = cache.begin();
|
||||
const CacheContainer::iterator end = cache.end();
|
||||
for (; it != end; ++it) {
|
||||
CachedImage& tmp = *it;
|
||||
if ((tmp.width == width) && (tmp.height == height) &&
|
||||
(tmp.texture == texture) && (tmp.pixel1 == c1.pixel()))
|
||||
if (texture & BTexture::Gradient) {
|
||||
if (tmp.pixel2 == c2.pixel()) {
|
||||
tmp.count++;
|
||||
return tmp.pixmap;
|
||||
}
|
||||
} else {
|
||||
tmp.count++;
|
||||
return tmp.pixmap;
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
|
||||
const BTexture &texture) {
|
||||
if (texture.texture() & BTexture::Parent_Relative) return ParentRelative;
|
||||
|
||||
Pixmap pixmap = searchCache(width, height, texture.texture(),
|
||||
texture.color(), texture.colorTo());
|
||||
if (pixmap) return pixmap;
|
||||
|
||||
BImage image(this, width, height);
|
||||
pixmap = image.render(texture);
|
||||
|
||||
if (!pixmap)
|
||||
return None;
|
||||
|
||||
CachedImage tmp;
|
||||
|
||||
tmp.pixmap = pixmap;
|
||||
tmp.width = width;
|
||||
tmp.height = height;
|
||||
tmp.count = 1;
|
||||
tmp.texture = texture.texture();
|
||||
tmp.pixel1 = texture.color().pixel();
|
||||
|
||||
if (texture.texture() & BTexture::Gradient)
|
||||
tmp.pixel2 = texture.colorTo().pixel();
|
||||
else
|
||||
tmp.pixel2 = 0l;
|
||||
|
||||
cache.push_back(tmp);
|
||||
|
||||
if (cache.size() > cache_max) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, i18n(ImageSet, ImagePixmapCacheLarge,
|
||||
"BImageControl::renderImage: cache is large, "
|
||||
"forcing cleanout\n"));
|
||||
#endif // DEBUG
|
||||
|
||||
timeout();
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::removeImage(Pixmap pixmap) {
|
||||
if (!pixmap)
|
||||
return;
|
||||
|
||||
CacheContainer::iterator it = cache.begin();
|
||||
const CacheContainer::iterator end = cache.end();
|
||||
for (; it != end; ++it) {
|
||||
CachedImage &tmp = *it;
|
||||
if (tmp.pixmap == pixmap && tmp.count > 0)
|
||||
tmp.count--;
|
||||
}
|
||||
|
||||
#ifdef TIMEDCACHE
|
||||
if (! timer)
|
||||
#endif // TIMEDCACHE
|
||||
timeout();
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::getColorTables(unsigned char **rmt, unsigned char **gmt,
|
||||
unsigned char **bmt,
|
||||
int *roff, int *goff, int *boff,
|
||||
int *rbit, int *gbit, int *bbit) {
|
||||
if (rmt) *rmt = red_color_table;
|
||||
if (gmt) *gmt = green_color_table;
|
||||
if (bmt) *bmt = blue_color_table;
|
||||
|
||||
if (roff) *roff = red_offset;
|
||||
if (goff) *goff = green_offset;
|
||||
if (boff) *boff = blue_offset;
|
||||
|
||||
if (rbit) *rbit = red_bits;
|
||||
if (gbit) *gbit = green_bits;
|
||||
if (bbit) *bbit = blue_bits;
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::getXColorTable(XColor **c, int *n) {
|
||||
if (c) *c = colors;
|
||||
if (n) *n = ncolors;
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::getGradientBuffers(unsigned int w,
|
||||
unsigned int h,
|
||||
unsigned int **xbuf,
|
||||
unsigned int **ybuf)
|
||||
{
|
||||
if (w > grad_buffer_width) {
|
||||
if (grad_xbuffer) {
|
||||
delete [] grad_xbuffer;
|
||||
}
|
||||
|
||||
grad_buffer_width = w;
|
||||
|
||||
grad_xbuffer = new unsigned int[grad_buffer_width * 3];
|
||||
}
|
||||
|
||||
if (h > grad_buffer_height) {
|
||||
if (grad_ybuffer) {
|
||||
delete [] grad_ybuffer;
|
||||
}
|
||||
|
||||
grad_buffer_height = h;
|
||||
|
||||
grad_ybuffer = new unsigned int[grad_buffer_height * 3];
|
||||
}
|
||||
|
||||
*xbuf = grad_xbuffer;
|
||||
*ybuf = grad_ybuffer;
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::installRootColormap(void) {
|
||||
int ncmap = 0;
|
||||
Colormap *cmaps =
|
||||
XListInstalledColormaps(basedisplay->getXDisplay(), window, &ncmap);
|
||||
|
||||
if (cmaps) {
|
||||
bool install = True;
|
||||
for (int i = 0; i < ncmap; i++)
|
||||
if (*(cmaps + i) == colormap)
|
||||
install = False;
|
||||
|
||||
if (install)
|
||||
XInstallColormap(basedisplay->getXDisplay(), colormap);
|
||||
|
||||
XFree(cmaps);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BImageControl::setColorsPerChannel(int cpc) {
|
||||
if (cpc < 2) cpc = 2;
|
||||
if (cpc > 6) cpc = 6;
|
||||
|
||||
colors_per_channel = cpc;
|
||||
}
|
||||
|
||||
|
||||
unsigned long BImageControl::getSqrt(unsigned int x) {
|
||||
if (! sqrt_table) {
|
||||
// build sqrt table for use with elliptic gradient
|
||||
|
||||
sqrt_table = new unsigned long[(256 * 256 * 2) + 1];
|
||||
|
||||
for (int i = 0; i < (256 * 256 * 2); i++)
|
||||
*(sqrt_table + i) = bsqrt(i);
|
||||
}
|
||||
|
||||
return (*(sqrt_table + x));
|
||||
}
|
||||
|
||||
|
||||
struct ZeroRefCheck {
|
||||
inline bool operator()(const BImageControl::CachedImage &image) const {
|
||||
return (image.count == 0);
|
||||
}
|
||||
};
|
||||
|
||||
struct CacheCleaner {
|
||||
Display *display;
|
||||
ZeroRefCheck ref_check;
|
||||
CacheCleaner(Display *d): display(d) {}
|
||||
inline void operator()(const BImageControl::CachedImage& image) const {
|
||||
if (ref_check(image))
|
||||
XFreePixmap(display, image.pixmap);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void BImageControl::timeout(void) {
|
||||
CacheCleaner cleaner(basedisplay->getXDisplay());
|
||||
std::for_each(cache.begin(), cache.end(), cleaner);
|
||||
cache.remove_if(cleaner.ref_check);
|
||||
}
|
||||
|
167
src/Makefile.am
167
src/Makefile.am
|
@ -1,4 +1,4 @@
|
|||
# src/Makefile.am for Openbox
|
||||
# src/Makefile.am for Blackbox - an X11 Window manager
|
||||
# Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,17 +20,17 @@
|
|||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
DEFAULT_MENU=$(pkgdatadir)/menu
|
||||
DEFAULT_STYLE=$(pkgdatadir)/styles/steelblue
|
||||
DEFAULT_STYLE=$(pkgdatadir)/styles/Results
|
||||
|
||||
CPPFLAGS= @CPPFLAGS@ @SHAPE@ @SLIT@ @INTERLACE@ @ORDEREDPSEUDO@ \
|
||||
@DEBUG@ @NEWWMSPEC@ @NLS@ @TIMEDCACHE@ @CLOBBER@ \
|
||||
CPPFLAGS= @CPPFLAGS@ @SHAPE@ @ORDEREDPSEUDO@ \
|
||||
@DEBUG@ @NLS@ @TIMEDCACHE@ @SLIT@ @CLOBBER@ \
|
||||
-DLOCALEPATH=\"$(pkgdatadir)/nls\" \
|
||||
-DDEFAULTMENU=\"$(DEFAULT_MENU)\" \
|
||||
-DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\"
|
||||
|
||||
bin_PROGRAMS= openbox
|
||||
bin_PROGRAMS= blackbox
|
||||
|
||||
openbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Configmenu.cc Geometry.cc Iconmenu.cc Image.cc Netizen.cc Resource.cc Rootmenu.cc Screen.cc Slit.cc Timer.cc Toolbar.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc XAtom.cc openbox.cc bsd-snprintf.c i18n.cc main.cc
|
||||
blackbox_SOURCES= BaseDisplay.cc Basemenu.cc Clientmenu.cc Color.cc Configmenu.cc GCCache.cc Iconmenu.cc Image.cc ImageControl.cc Netizen.cc Rootmenu.cc Screen.cc Slit.cc Texture.cc Timer.cc Toolbar.cc Util.cc Window.cc Windowmenu.cc Workspace.cc Workspacemenu.cc blackbox.cc i18n.cc main.cc
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
|
@ -39,74 +39,87 @@ distclean-local:
|
|||
|
||||
# local dependencies
|
||||
|
||||
BaseDisplay.o: BaseDisplay.cc i18n.h BaseDisplay.h \
|
||||
Timer.h
|
||||
Basemenu.o: Basemenu.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
|
||||
Workspace.h Workspacemenu.h Resource.h
|
||||
Clientmenu.o: Clientmenu.cc openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Clientmenu.h Workspace.h Screen.h Configmenu.h Netizen.h \
|
||||
Rootmenu.h Workspacemenu.h Resource.h Geometry.h
|
||||
Configmenu.o: Configmenu.cc i18n.h Configmenu.h Basemenu.h \
|
||||
Screen.h BaseDisplay.h Timer.h Iconmenu.h Netizen.h \
|
||||
Rootmenu.h Workspace.h Workspacemenu.h openbox.h Image.h \
|
||||
Window.h Windowmenu.h Slit.h Toolbar.h Resource.h Geometry.h
|
||||
Geometry.o: Geometry.cc Geometry.h
|
||||
Icon.o: Iconmenu.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
|
||||
Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
Image.o: Image.cc i18n.h BaseDisplay.h Timer.h \
|
||||
Image.h
|
||||
Netizen.o: Netizen.cc Netizen.h BaseDisplay.h Timer.h \
|
||||
Screen.h Configmenu.h Basemenu.h openbox.h Image.h Window.h \
|
||||
Iconmenu.h Windowmenu.h Slit.h Rootmenu.h Workspace.h \
|
||||
Workspacemenu.h Resource.h Geometry.h
|
||||
Resource.o: Resource.cc Resource.h Util.h
|
||||
Rootmenu.o: Rootmenu.cc openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Rootmenu.h Screen.h Configmenu.h Netizen.h Workspace.h \
|
||||
Workspacemenu.h Resource.h Geometry.h
|
||||
Screen.o: Screen.cc i18n.h bsd-snprintf.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h Configmenu.h \
|
||||
Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
Slit.o: Slit.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
|
||||
Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
Timer.o: Timer.cc BaseDisplay.h Timer.h
|
||||
Toolbar.o: Toolbar.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Clientmenu.h Workspace.h Rootmenu.h Screen.h Configmenu.h \
|
||||
Netizen.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
XAtom.o: XAtom.cc XAtom.h Geometry.h Util.h
|
||||
Window.o: Window.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h Windowmenu.h Slit.h \
|
||||
Screen.h Configmenu.h Netizen.h Rootmenu.h Workspace.h \
|
||||
Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
Windowmenu.o: Windowmenu.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
|
||||
Workspace.h Workspacemenu.h Resource.h Geometry.h
|
||||
Workspace.o: Workspace.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Clientmenu.h Workspace.h Screen.h \
|
||||
Configmenu.h Netizen.h Rootmenu.h Workspacemenu.h Toolbar.h Resource.h \
|
||||
Geometry.h Geometry.h Util.h
|
||||
Workspacemenu.o: Workspacemenu.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Screen.h Configmenu.h Netizen.h Rootmenu.h \
|
||||
Workspace.h Workspacemenu.h Toolbar.h Resource.h Geometry.h
|
||||
openbox.o: openbox.cc i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Clientmenu.h Workspace.h Rootmenu.h \
|
||||
Screen.h Configmenu.h Netizen.h Workspacemenu.h Toolbar.h Resource.h \
|
||||
Geometry.h Util.h
|
||||
bsd-snprintf.o: bsd-snprintf.c bsd-snprintf.h
|
||||
i18n.o: i18n.cc i18n.h
|
||||
main.o: main.cc ../version.h i18n.h openbox.h BaseDisplay.h \
|
||||
Timer.h Image.h Window.h Iconmenu.h Basemenu.h \
|
||||
Windowmenu.h Slit.h Resource.h Geometry.h
|
||||
BaseDisplay.o: BaseDisplay.cc ../config.h i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh \
|
||||
Util.hh
|
||||
Basemenu.o: Basemenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh GCCache.hh Color.hh \
|
||||
Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh Iconmenu.hh \
|
||||
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh
|
||||
Clientmenu.o: Clientmenu.cc ../config.h blackbox.hh i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Clientmenu.hh \
|
||||
Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \
|
||||
Iconmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \
|
||||
Window.hh Windowmenu.hh
|
||||
Color.o: Color.cc ../config.h Color.hh BaseDisplay.hh Timer.hh
|
||||
Configmenu.o: Configmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
Configmenu.hh Basemenu.hh Image.hh Timer.hh BaseDisplay.hh Color.hh \
|
||||
Toolbar.hh Screen.hh Texture.hh Util.hh Iconmenu.hh Netizen.hh \
|
||||
Rootmenu.hh Workspace.hh Workspacemenu.hh blackbox.hh Window.hh \
|
||||
Windowmenu.hh
|
||||
GCCache.o: GCCache.cc ../config.h GCCache.hh BaseDisplay.hh Timer.hh \
|
||||
Color.hh Util.hh
|
||||
Iconmenu.o: Iconmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
Iconmenu.hh Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh \
|
||||
Configmenu.hh Netizen.hh Rootmenu.hh Timer.hh Workspace.hh \
|
||||
Workspacemenu.hh blackbox.hh BaseDisplay.hh Window.hh Windowmenu.hh
|
||||
Image.o: Image.cc ../config.h blackbox.hh i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh \
|
||||
Image.hh Texture.hh Util.hh
|
||||
ImageControl.o: ImageControl.cc ../config.h blackbox.hh i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Color.hh Image.hh \
|
||||
Texture.hh Util.hh
|
||||
Netizen.o: Netizen.cc ../config.h Netizen.hh Screen.hh Color.hh \
|
||||
Texture.hh Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Rootmenu.hh \
|
||||
Timer.hh Workspace.hh Workspacemenu.hh blackbox.hh i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh
|
||||
Rootmenu.o: Rootmenu.cc ../config.h blackbox.hh i18n.hh \
|
||||
../nls/blackbox-nls.hh BaseDisplay.hh Timer.hh Rootmenu.hh \
|
||||
Basemenu.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \
|
||||
Iconmenu.hh Netizen.hh Workspace.hh Workspacemenu.hh
|
||||
Screen.o: Screen.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \
|
||||
GCCache.hh Color.hh Iconmenu.hh Image.hh Screen.hh Texture.hh Util.hh \
|
||||
Configmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \
|
||||
Slit.hh Toolbar.hh Window.hh Windowmenu.hh
|
||||
Slit.o: Slit.cc ../config.h i18n.hh ../nls/blackbox-nls.hh blackbox.hh \
|
||||
BaseDisplay.hh Timer.hh Image.hh Color.hh Screen.hh Texture.hh \
|
||||
Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \
|
||||
Workspace.hh Workspacemenu.hh Slit.hh Toolbar.hh
|
||||
Texture.o: Texture.cc ../config.h Texture.hh Color.hh Util.hh \
|
||||
BaseDisplay.hh Timer.hh Image.hh Screen.hh Configmenu.hh Basemenu.hh \
|
||||
Iconmenu.hh Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh \
|
||||
blackbox.hh i18n.hh ../nls/blackbox-nls.hh
|
||||
Timer.o: Timer.cc ../config.h BaseDisplay.hh Timer.hh Util.hh
|
||||
Toolbar.o: Toolbar.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \
|
||||
GCCache.hh Color.hh Iconmenu.hh Image.hh Rootmenu.hh Screen.hh \
|
||||
Texture.hh Util.hh Configmenu.hh Netizen.hh Workspace.hh \
|
||||
Workspacemenu.hh Toolbar.hh Window.hh Windowmenu.hh Slit.hh
|
||||
Util.o: Util.cc ../config.h Util.hh
|
||||
Window.o: Window.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh GCCache.hh Color.hh Iconmenu.hh \
|
||||
Basemenu.hh Image.hh Screen.hh Texture.hh Util.hh Configmenu.hh \
|
||||
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \
|
||||
Window.hh Windowmenu.hh Slit.hh
|
||||
Windowmenu.o: Windowmenu.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Screen.hh Color.hh Texture.hh \
|
||||
Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh Netizen.hh Rootmenu.hh \
|
||||
Workspace.hh Workspacemenu.hh Window.hh Windowmenu.hh
|
||||
Workspace.o: Workspace.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Clientmenu.hh Basemenu.hh \
|
||||
Netizen.hh Screen.hh Color.hh Texture.hh Util.hh Configmenu.hh \
|
||||
Iconmenu.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh \
|
||||
Window.hh Windowmenu.hh
|
||||
Workspacemenu.o: Workspacemenu.cc ../config.h i18n.hh \
|
||||
../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh Timer.hh Screen.hh \
|
||||
Color.hh Texture.hh Util.hh Configmenu.hh Basemenu.hh Iconmenu.hh \
|
||||
Netizen.hh Rootmenu.hh Workspace.hh Workspacemenu.hh Toolbar.hh
|
||||
blackbox.o: blackbox.cc ../config.h i18n.hh ../nls/blackbox-nls.hh \
|
||||
blackbox.hh BaseDisplay.hh Timer.hh Basemenu.hh Clientmenu.hh \
|
||||
GCCache.hh Color.hh Image.hh Rootmenu.hh Screen.hh Texture.hh Util.hh \
|
||||
Configmenu.hh Iconmenu.hh Netizen.hh Workspace.hh Workspacemenu.hh \
|
||||
Slit.hh Toolbar.hh Window.hh Windowmenu.hh
|
||||
i18n.o: i18n.cc ../config.h i18n.hh ../nls/blackbox-nls.hh
|
||||
main.o: main.cc ../version.h ../config.h i18n.hh \
|
||||
../nls/blackbox-nls.hh blackbox.hh BaseDisplay.hh Timer.hh
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Netizen.cc for Openbox
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Netizen.cc for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
|
@ -20,95 +21,94 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "Netizen.h"
|
||||
#include "Screen.h"
|
||||
#include "Netizen.hh"
|
||||
#include "Screen.hh"
|
||||
|
||||
Netizen::Netizen(BScreen *scr, Window win) {
|
||||
screen = scr;
|
||||
blackbox = scr->getBlackbox();
|
||||
window = win;
|
||||
|
||||
Netizen::Netizen(BScreen &scr, Window win) :basedisplay(scr.getBaseDisplay()),
|
||||
screen(scr), window(win)
|
||||
{
|
||||
event.type = ClientMessage;
|
||||
event.xclient.message_type = basedisplay.getOpenboxStructureMessagesAtom();
|
||||
event.xclient.display = basedisplay.getXDisplay();
|
||||
event.xclient.message_type =
|
||||
blackbox->getBlackboxStructureMessagesAtom();
|
||||
event.xclient.display = blackbox->getXDisplay();
|
||||
event.xclient.window = window;
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyStartupAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyStartupAtom();
|
||||
event.xclient.data.l[1] = event.xclient.data.l[2] =
|
||||
event.xclient.data.l[3] = event.xclient.data.l[4] = 0l;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWorkspaceCount(void) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWorkspaceCountAtom();
|
||||
event.xclient.data.l[1] = screen.getWorkspaceCount();
|
||||
event.xclient.data.l[0] =
|
||||
blackbox->getBlackboxNotifyWorkspaceCountAtom();
|
||||
event.xclient.data.l[1] = screen->getWorkspaceCount();
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendCurrentWorkspace(void) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyCurrentWorkspaceAtom();
|
||||
event.xclient.data.l[1] = screen.getCurrentWorkspaceID();
|
||||
event.xclient.data.l[0] =
|
||||
blackbox->getBlackboxNotifyCurrentWorkspaceAtom();
|
||||
event.xclient.data.l[1] = screen->getCurrentWorkspaceID();
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWindowFocus(Window w) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowFocusAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyWindowFocusAtom();
|
||||
event.xclient.data.l[1] = w;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWindowAdd(Window w, unsigned long p) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowAddAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyWindowAddAtom();
|
||||
event.xclient.data.l[1] = w;
|
||||
event.xclient.data.l[2] = p;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
|
||||
event.xclient.data.l[2] = 0l;
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWindowDel(Window w) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowDelAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyWindowDelAtom();
|
||||
event.xclient.data.l[1] = w;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWindowRaise(Window w) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowRaiseAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyWindowRaiseAtom();
|
||||
event.xclient.data.l[1] = w;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendWindowLower(Window w) {
|
||||
event.xclient.data.l[0] = basedisplay.getOpenboxNotifyWindowLowerAtom();
|
||||
event.xclient.data.l[0] = blackbox->getBlackboxNotifyWindowLowerAtom();
|
||||
event.xclient.data.l[1] = w;
|
||||
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False, NoEventMask, &event);
|
||||
XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event);
|
||||
}
|
||||
|
||||
|
||||
void Netizen::sendConfigNotify(XEvent *e) {
|
||||
XSendEvent(basedisplay.getXDisplay(), window, False,
|
||||
XSendEvent(blackbox->getXDisplay(), window, False,
|
||||
StructureNotifyMask, e);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// Netizen.h for Openbox
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Netizen.hh for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
|
@ -23,26 +24,26 @@
|
|||
#ifndef __Netizen_hh
|
||||
#define __Netizen_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
class BaseDisplay;
|
||||
class Blackbox;
|
||||
class BScreen;
|
||||
class Netizen;
|
||||
|
||||
class Netizen {
|
||||
private:
|
||||
BaseDisplay &basedisplay;
|
||||
BScreen &screen;
|
||||
Blackbox *blackbox;
|
||||
BScreen *screen;
|
||||
Window window;
|
||||
XEvent event;
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
Netizen(BScreen &, Window);
|
||||
Netizen(BScreen *, Window);
|
||||
|
||||
inline const Window &getWindowID(void) const { return window; }
|
||||
inline Window getWindowID(void) const { return window; }
|
||||
|
||||
void sendWorkspaceCount(void);
|
||||
void sendCurrentWorkspace(void);
|
192
src/Resource.cc
192
src/Resource.cc
|
@ -1,192 +0,0 @@
|
|||
// Resource.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "Resource.h"
|
||||
#include "Util.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif // HAVE_STDLIB_H
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
bool Resource::m_initialized = false;
|
||||
|
||||
Resource::Resource(const std::string &file) {
|
||||
setFile(file);
|
||||
m_modified = false;
|
||||
m_database = NULL;
|
||||
m_autosave = true;
|
||||
if (!m_initialized) {
|
||||
XrmInitialize();
|
||||
m_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Resource::Resource() {
|
||||
m_modified = false;
|
||||
m_database = NULL;
|
||||
m_autosave = true;
|
||||
if (!m_initialized) {
|
||||
XrmInitialize();
|
||||
m_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Resource::~Resource() {
|
||||
if (m_database != NULL)
|
||||
XrmDestroyDatabase(m_database);
|
||||
}
|
||||
|
||||
void Resource::setFile(const std::string &file) {
|
||||
m_file = file;
|
||||
}
|
||||
|
||||
void Resource::setAutoSave(bool autosave) {
|
||||
m_autosave = autosave;
|
||||
}
|
||||
|
||||
void Resource::save() {
|
||||
ASSERT(m_database != NULL);
|
||||
XrmPutFileDatabase(m_database, m_file.c_str());
|
||||
m_modified = false;
|
||||
}
|
||||
|
||||
bool Resource::load() {
|
||||
if (m_database != NULL)
|
||||
XrmDestroyDatabase(m_database);
|
||||
m_modified = false;
|
||||
if (NULL == (m_database = XrmGetFileDatabase(m_file.c_str())))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Resource::create() {
|
||||
if (m_database != NULL)
|
||||
XrmDestroyDatabase(m_database);
|
||||
m_modified = false;
|
||||
ASSERT(NULL != (m_database = XrmGetStringDatabase("")));
|
||||
}
|
||||
|
||||
void Resource::setValue(const std::string &rname, bool value) {
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
const char *val = (value ? "True" : "False");
|
||||
std::string rc_string = rname + ": " + val;
|
||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||
|
||||
m_modified = true;
|
||||
if (m_autosave)
|
||||
save();
|
||||
}
|
||||
|
||||
void Resource::setValue(const std::string &rname, int value) {
|
||||
setValue(rname, (long)value);
|
||||
}
|
||||
|
||||
void Resource::setValue(const std::string &rname, long value) {
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
char val[11];
|
||||
sprintf(val, "%ld", value);
|
||||
std::string rc_string = rname + ": " + val;
|
||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||
|
||||
m_modified = true;
|
||||
if (m_autosave)
|
||||
save();
|
||||
}
|
||||
|
||||
void Resource::setValue(const std::string &rname, const char *value) {
|
||||
ASSERT(m_database != NULL);
|
||||
ASSERT(value != NULL);
|
||||
|
||||
std::string rc_string = rname + ": " + value;
|
||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||
|
||||
m_modified = true;
|
||||
if (m_autosave)
|
||||
save();
|
||||
}
|
||||
|
||||
void Resource::setValue(const std::string &rname, const std::string &value) {
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
std::string rc_string = rname + ": " + value;
|
||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||
|
||||
m_modified = true;
|
||||
if (m_autosave)
|
||||
save();
|
||||
}
|
||||
|
||||
bool Resource::getValue(const std::string &rname, const std::string &rclass,
|
||||
bool &value) const {
|
||||
ASSERT(rclass.c_str() != NULL);
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||
return false;
|
||||
std::string val = retvalue.addr;
|
||||
if (0 == strncasecmp(val.c_str(), "true", val.length()))
|
||||
value = true;
|
||||
else
|
||||
value = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Resource::getValue(const std::string &rname, const std::string &rclass,
|
||||
long &value) const {
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||
return false;
|
||||
char *end;
|
||||
value = strtol(retvalue.addr, &end, 10);
|
||||
if (end == retvalue.addr)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Resource::getValue(const std::string &rname, const std::string &rclass,
|
||||
std::string &value) const {
|
||||
ASSERT(m_database != NULL);
|
||||
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||
return false;
|
||||
value = retvalue.addr;
|
||||
return true;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
// Resource.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Resource_hh
|
||||
#define __Resource_hh
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
class Resource {
|
||||
public:
|
||||
explicit Resource(const std::string &file);
|
||||
Resource();
|
||||
virtual ~Resource();
|
||||
|
||||
inline const std::string &file() const {
|
||||
return static_cast<const std::string &>(m_file);
|
||||
}
|
||||
void setFile(const std::string &file);
|
||||
|
||||
// defaults to true!
|
||||
inline bool autoSave() const {
|
||||
return m_autosave;
|
||||
}
|
||||
void setAutoSave(bool);
|
||||
|
||||
inline bool isModified() const {
|
||||
return m_modified;
|
||||
}
|
||||
|
||||
void save();
|
||||
bool load();
|
||||
void create();
|
||||
|
||||
void setValue(const std::string &rname, bool value);
|
||||
void setValue(const std::string &rname, int value);
|
||||
void setValue(const std::string &rname, long value);
|
||||
void setValue(const std::string &rname, const std::string &value);
|
||||
void setValue(const std::string &rname, const char *value);
|
||||
|
||||
bool getValue(const std::string &rname, const std::string &rclass,
|
||||
bool &value) const;
|
||||
bool getValue(const std::string &rname, const std::string &rclass,
|
||||
long &value) const;
|
||||
bool getValue(const std::string &rname, const std::string &rclass,
|
||||
std::string &value) const;
|
||||
|
||||
private:
|
||||
static bool m_initialized;
|
||||
std::string m_file;
|
||||
bool m_modified;
|
||||
bool m_autosave;
|
||||
XrmDatabase m_database;
|
||||
};
|
||||
|
||||
#endif // __Resource_hh
|
|
@ -1,5 +1,6 @@
|
|||
// Rootmenu.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Rootmenu.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,48 +21,38 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "openbox.h"
|
||||
#include "Rootmenu.h"
|
||||
#include "Screen.h"
|
||||
|
||||
extern "C" {
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif // HAVE_STDLIB_H
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif // HAVE_STRING_H
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif // HAVE_SYS_PARAM_H
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 255
|
||||
#endif // MAXPATHLEN
|
||||
|
||||
|
||||
Rootmenu::Rootmenu(BScreen &scrn) : Basemenu(scrn), openbox(scrn.getOpenbox()),
|
||||
screen(scrn)
|
||||
{
|
||||
}
|
||||
|
||||
#include "blackbox.hh"
|
||||
#include "Rootmenu.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Util.hh"
|
||||
|
||||
void Rootmenu::itemSelected(int button, int index) {
|
||||
|
||||
Rootmenu::Rootmenu(BScreen *scrn) : Basemenu(scrn) { }
|
||||
|
||||
|
||||
void Rootmenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
|
@ -72,44 +63,33 @@ void Rootmenu::itemSelected(int button, int index) {
|
|||
|
||||
switch (item->function()) {
|
||||
case BScreen::Execute:
|
||||
if (item->exec()) {
|
||||
#ifndef __EMX__
|
||||
char displaystring[MAXPATHLEN];
|
||||
sprintf(displaystring, "DISPLAY=%s",
|
||||
DisplayString(screen.getBaseDisplay().getXDisplay()));
|
||||
sprintf(displaystring + strlen(displaystring) - 1, "%d",
|
||||
screen.getScreenNumber());
|
||||
|
||||
bexec(item->exec(), displaystring);
|
||||
#else // __EMX__
|
||||
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", item->exec(), NULL);
|
||||
#endif // !__EMX__
|
||||
}
|
||||
if (item->exec())
|
||||
bexec(item->exec(), getScreen()->displayString());
|
||||
break;
|
||||
|
||||
case BScreen::Restart:
|
||||
openbox.restart();
|
||||
getScreen()->getBlackbox()->restart();
|
||||
break;
|
||||
|
||||
case BScreen::RestartOther:
|
||||
if (item->exec())
|
||||
openbox.restart(item->exec());
|
||||
getScreen()->getBlackbox()->restart(item->exec());
|
||||
break;
|
||||
|
||||
case BScreen::Exit:
|
||||
openbox.shutdown();
|
||||
getScreen()->getBlackbox()->shutdown();
|
||||
break;
|
||||
|
||||
case BScreen::SetStyle:
|
||||
if (item->exec())
|
||||
openbox.setStyleFilename(item->exec());
|
||||
getScreen()->getBlackbox()->saveStyleFilename(item->exec());
|
||||
|
||||
case BScreen::Reconfigure:
|
||||
openbox.reconfigure();
|
||||
getScreen()->getBlackbox()->reconfigure();
|
||||
return;
|
||||
}
|
||||
|
||||
if (! (screen.getRootmenu()->isTorn() || isTorn()) &&
|
||||
if (! (getScreen()->getRootmenu()->isTorn() || isTorn()) &&
|
||||
item->function() != BScreen::Reconfigure &&
|
||||
item->function() != BScreen::SetStyle)
|
||||
hide();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Rootmenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Rootmenu.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -24,26 +25,21 @@
|
|||
#define __Rootmenu_hh
|
||||
|
||||
// forward declarations
|
||||
class Rootmenu;
|
||||
|
||||
class Openbox;
|
||||
class BScreen;
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Basemenu.hh"
|
||||
|
||||
|
||||
class Rootmenu : public Basemenu {
|
||||
private:
|
||||
Openbox &openbox;
|
||||
BScreen &screen;
|
||||
|
||||
Rootmenu(const Rootmenu&);
|
||||
Rootmenu& operator=(const Rootmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Rootmenu(BScreen &);
|
||||
Rootmenu(BScreen *scrn);
|
||||
};
|
||||
|
||||
|
4473
src/Screen.cc
4473
src/Screen.cc
File diff suppressed because it is too large
Load diff
336
src/Screen.h
336
src/Screen.h
|
@ -1,336 +0,0 @@
|
|||
// Screen.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Screen_hh
|
||||
#define __Screen_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
|
||||
#include "BaseDisplay.h"
|
||||
#include "Configmenu.h"
|
||||
#include "Iconmenu.h"
|
||||
#include "Netizen.h"
|
||||
#include "Rootmenu.h"
|
||||
#include "Timer.h"
|
||||
#include "Workspace.h"
|
||||
#include "Workspacemenu.h"
|
||||
#include "openbox.h"
|
||||
#ifdef SLIT
|
||||
# include "Slit.h"
|
||||
#endif // SLIT
|
||||
#include "Image.h"
|
||||
#include "Resource.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
// forward declaration
|
||||
class BScreen;
|
||||
|
||||
struct WindowStyle {
|
||||
BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
|
||||
b_pic_unfocus;
|
||||
BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
|
||||
b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
|
||||
GC l_text_focus_gc, l_text_unfocus_gc, b_pic_focus_gc, b_pic_unfocus_gc;
|
||||
|
||||
XFontSet fontset;
|
||||
XFontSetExtents *fontset_extents;
|
||||
XFontStruct *font;
|
||||
|
||||
int justify;
|
||||
};
|
||||
|
||||
struct ToolbarStyle {
|
||||
BColor l_text, w_text, c_text, b_pic;
|
||||
BTexture toolbar, label, window, button, pressed, clock;
|
||||
GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
|
||||
|
||||
XFontSet fontset;
|
||||
XFontSetExtents *fontset_extents;
|
||||
XFontStruct *font;
|
||||
|
||||
int justify;
|
||||
};
|
||||
|
||||
struct MenuStyle {
|
||||
BColor t_text, f_text, h_text, d_text;
|
||||
BTexture title, frame, hilite;
|
||||
GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
|
||||
|
||||
XFontSet t_fontset, f_fontset;
|
||||
XFontSetExtents *t_fontset_extents, *f_fontset_extents;
|
||||
XFontStruct *t_font, *f_font;
|
||||
|
||||
int t_justify, f_justify, bullet, bullet_pos;
|
||||
};
|
||||
|
||||
|
||||
class BScreen : public ScreenInfo {
|
||||
private:
|
||||
Bool root_colormap_installed, managed, geom_visible;
|
||||
GC opGC;
|
||||
Pixmap geom_pixmap;
|
||||
Window geom_window;
|
||||
|
||||
Openbox &openbox;
|
||||
Resource &config;
|
||||
BImageControl *image_control;
|
||||
Configmenu *configmenu;
|
||||
Iconmenu *iconmenu;
|
||||
Rootmenu *rootmenu;
|
||||
|
||||
typedef std::list<Rootmenu *> menuList;
|
||||
menuList rootmenuList;
|
||||
typedef std::list<Netizen *> netList;
|
||||
netList netizenList;
|
||||
typedef std::list<OpenboxWindow *> winList;
|
||||
winList iconList; // winList is declared in Workspace.h
|
||||
|
||||
#ifdef SLIT
|
||||
Slit *slit;
|
||||
#endif // SLIT
|
||||
|
||||
Toolbar *toolbar;
|
||||
Workspace *current_workspace;
|
||||
Workspacemenu *workspacemenu;
|
||||
|
||||
unsigned int geom_w, geom_h;
|
||||
unsigned long event_mask;
|
||||
|
||||
typedef std::vector<std::string> wkspNameList;
|
||||
wkspNameList workspaceNames;
|
||||
typedef std::vector<Workspace *> wkspList;
|
||||
wkspList workspacesList;
|
||||
|
||||
struct resource {
|
||||
WindowStyle wstyle;
|
||||
ToolbarStyle tstyle;
|
||||
MenuStyle mstyle;
|
||||
|
||||
bool sloppy_focus, auto_raise, auto_edge_balance, focus_last,
|
||||
ordered_dither, opaque_move, hide_toolbar, full_max, focus_new;
|
||||
BColor border_color;
|
||||
Resource styleconfig;
|
||||
|
||||
int workspaces, placement_policy, edge_snap_threshold, row_direction,
|
||||
col_direction;
|
||||
|
||||
unsigned int handle_width, bevel_width, frame_width, border_width;
|
||||
int zones; // number of zones to be used when alt-resizing a window
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
char *strftime_format;
|
||||
#else // !HAVE_STRFTIME
|
||||
bool clock24hour;
|
||||
int date_format;
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
char *root_command;
|
||||
} resource;
|
||||
|
||||
|
||||
protected:
|
||||
Bool parseMenuFile(FILE *, Rootmenu *);
|
||||
|
||||
void readDatabaseTexture(const char *, const char *, BTexture *,
|
||||
unsigned long);
|
||||
void readDatabaseColor(const char *, const char *, BColor *, unsigned long);
|
||||
|
||||
void readDatabaseFontSet(const char *, const char *, XFontSet *);
|
||||
XFontSet createFontSet(const char *);
|
||||
void readDatabaseFont(const char *, const char *, XFontStruct **);
|
||||
|
||||
void InitMenu();
|
||||
void LoadStyle();
|
||||
|
||||
|
||||
public:
|
||||
BScreen(Openbox &, int, Resource &);
|
||||
~BScreen();
|
||||
|
||||
inline const Bool &isScreenManaged() const { return managed; }
|
||||
inline const GC &getOpGC() const { return opGC; }
|
||||
|
||||
inline Openbox &getOpenbox() { return openbox; }
|
||||
inline BColor *getBorderColor() { return &resource.border_color; }
|
||||
inline BImageControl *getImageControl() { return image_control; }
|
||||
inline Rootmenu *getRootmenu() { return rootmenu; }
|
||||
|
||||
#ifdef SLIT
|
||||
inline Slit *getSlit() { return slit; }
|
||||
#endif // SLIT
|
||||
|
||||
inline Toolbar *getToolbar() { return toolbar; }
|
||||
|
||||
Rect availableArea() const;
|
||||
|
||||
inline Workspace *getWorkspace(unsigned int w) {
|
||||
ASSERT(w < workspacesList.size());
|
||||
return workspacesList[w];
|
||||
}
|
||||
inline Workspace *getCurrentWorkspace() { return current_workspace; }
|
||||
|
||||
inline Workspacemenu *getWorkspacemenu() { return workspacemenu; }
|
||||
|
||||
inline void iconUpdate() { iconmenu->update(); }
|
||||
|
||||
inline const unsigned int &getHandleWidth() const
|
||||
{ return resource.handle_width; }
|
||||
inline const unsigned int &getBevelWidth() const
|
||||
{ return resource.bevel_width; }
|
||||
inline const unsigned int &getFrameWidth() const
|
||||
{ return resource.frame_width; }
|
||||
inline const unsigned int &getBorderWidth() const
|
||||
{ return resource.border_width; }
|
||||
|
||||
inline const int getCurrentWorkspaceID()
|
||||
{ return current_workspace->getWorkspaceID(); }
|
||||
inline const int getWorkspaceCount() { return workspacesList.size(); }
|
||||
inline const int getIconCount() { return iconList.size(); }
|
||||
|
||||
inline const Bool &isRootColormapInstalled() const
|
||||
{ return root_colormap_installed; }
|
||||
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
|
||||
|
||||
inline bool sloppyFocus() const { return resource.sloppy_focus; }
|
||||
void setSloppyFocus(bool s);
|
||||
|
||||
inline bool autoRaise() const { return resource.auto_raise; }
|
||||
void setAutoRaise(bool a);
|
||||
|
||||
inline bool imageDither() const { return image_control->doDither(); }
|
||||
void setImageDither(bool d, bool reconfig = true);
|
||||
|
||||
inline bool orderedDither() const { return resource.ordered_dither; }
|
||||
|
||||
inline bool opaqueMove() const { return resource.opaque_move; }
|
||||
void setOpaqueMove(bool o);
|
||||
|
||||
inline bool fullMax() const { return resource.full_max; }
|
||||
void setFullMax(bool f);
|
||||
|
||||
inline bool focusNew() const { return resource.focus_new; }
|
||||
void setFocusNew(bool f);
|
||||
|
||||
inline bool focusLast() const { return resource.focus_last; }
|
||||
void setFocusLast(bool f);
|
||||
|
||||
inline int getWindowZones() const { return resource.zones; }
|
||||
void setWindowZones(int z);
|
||||
|
||||
inline int workspaceCount() const { return resource.workspaces; }
|
||||
void setWorkspaceCount(int w);
|
||||
|
||||
inline int placementPolicy() const { return resource.placement_policy; }
|
||||
void setPlacementPolicy(int p);
|
||||
|
||||
inline int edgeSnapThreshold() const { return resource.edge_snap_threshold; }
|
||||
void setEdgeSnapThreshold(int t);
|
||||
|
||||
inline int rowPlacementDirection() const { return resource.row_direction; }
|
||||
void setRowPlacementDirection(int d);
|
||||
|
||||
inline int colPlacementDirection() const { return resource.col_direction; }
|
||||
void setColPlacementDirection(int d);
|
||||
|
||||
inline char *rootCommand() const { return resource.root_command; }
|
||||
inline void setRootCommand(const char *cmd);
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
inline char *strftimeFormat() { return resource.strftime_format; }
|
||||
void setStrftimeFormat(const char *);
|
||||
#else // !HAVE_STRFTIME
|
||||
inline int dateFormat() { return resource.date_format; }
|
||||
void setDateFormat(int f);
|
||||
inline bool clock24Hour() { return resource.clock24hour; }
|
||||
void setClock24Hour(Bool c);
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
inline bool hideToolbar() const { return resource.hide_toolbar; }
|
||||
void setHideToolbar(bool);
|
||||
|
||||
inline WindowStyle *getWindowStyle() { return &resource.wstyle; }
|
||||
inline MenuStyle *getMenuStyle() { return &resource.mstyle; }
|
||||
inline ToolbarStyle *getToolbarStyle() { return &resource.tstyle; }
|
||||
|
||||
OpenboxWindow *getIcon(int);
|
||||
|
||||
int addWorkspace();
|
||||
int removeLastWorkspace();
|
||||
|
||||
void removeWorkspaceNames();
|
||||
void addWorkspaceName(const char *);
|
||||
void saveWorkspaceNames();
|
||||
void addNetizen(Netizen *);
|
||||
void removeNetizen(Window);
|
||||
void addIcon(OpenboxWindow *);
|
||||
void removeIcon(OpenboxWindow *);
|
||||
const char *getNameOfWorkspace(int);
|
||||
void changeWorkspaceID(int);
|
||||
void raiseWindows(Window *, int);
|
||||
void reassociateWindow(OpenboxWindow *, int, Bool);
|
||||
void prevFocus();
|
||||
void nextFocus();
|
||||
void raiseFocus();
|
||||
void reconfigure();
|
||||
void load();
|
||||
void save();
|
||||
void rereadMenu();
|
||||
void shutdown();
|
||||
void showPosition(int, int);
|
||||
void showGeometry(unsigned int, unsigned int);
|
||||
void hideGeometry();
|
||||
void updateNetizenCurrentWorkspace();
|
||||
void updateNetizenWorkspaceCount();
|
||||
void updateNetizenWindowFocus();
|
||||
void updateNetizenWindowAdd(Window, unsigned long);
|
||||
void updateNetizenWindowDel(Window);
|
||||
void updateNetizenConfigNotify(XEvent *);
|
||||
void updateNetizenWindowRaise(Window);
|
||||
void updateNetizenWindowLower(Window);
|
||||
|
||||
enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
|
||||
BestFitPlacement, UnderMousePlacement, ClickMousePlacement,
|
||||
LeftRight, RightLeft, TopBottom, BottomTop };
|
||||
enum { LeftJustify = 1, RightJustify, CenterJustify };
|
||||
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
|
||||
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
|
||||
WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
|
||||
WindowLower, WindowStick, WindowKill, SetStyle };
|
||||
};
|
||||
|
||||
|
||||
#endif // __Screen_hh
|
372
src/Screen.hh
Normal file
372
src/Screen.hh
Normal file
|
@ -0,0 +1,372 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Screen.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Screen_hh
|
||||
#define __Screen_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "Color.hh"
|
||||
#include "Texture.hh"
|
||||
#include "Configmenu.hh"
|
||||
#include "Iconmenu.hh"
|
||||
#include "Netizen.hh"
|
||||
#include "Rootmenu.hh"
|
||||
#include "Timer.hh"
|
||||
#include "Workspace.hh"
|
||||
#include "Workspacemenu.hh"
|
||||
#include "blackbox.hh"
|
||||
class Slit; // forward reference
|
||||
|
||||
enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
|
||||
|
||||
struct WindowStyle {
|
||||
BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
|
||||
b_pic_unfocus;
|
||||
BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
|
||||
b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
|
||||
|
||||
XFontSet fontset;
|
||||
XFontSetExtents *fontset_extents;
|
||||
XFontStruct *font;
|
||||
|
||||
TextJustify justify;
|
||||
|
||||
int doJustify(const char *text, int &start_pos, unsigned int max_length,
|
||||
unsigned int modifier, bool multibyte) const;
|
||||
};
|
||||
|
||||
struct ToolbarStyle {
|
||||
BColor l_text, w_text, c_text, b_pic;
|
||||
BTexture toolbar, label, window, button, pressed, clock;
|
||||
|
||||
XFontSet fontset;
|
||||
XFontSetExtents *fontset_extents;
|
||||
XFontStruct *font;
|
||||
|
||||
TextJustify justify;
|
||||
|
||||
int doJustify(const char *text, int &start_pos, unsigned int max_length,
|
||||
unsigned int modifier, bool multibyte) const;
|
||||
};
|
||||
|
||||
struct MenuStyle {
|
||||
BColor t_text, f_text, h_text, d_text;
|
||||
BTexture title, frame, hilite;
|
||||
|
||||
XFontSet t_fontset, f_fontset;
|
||||
XFontSetExtents *t_fontset_extents, *f_fontset_extents;
|
||||
XFontStruct *t_font, *f_font;
|
||||
|
||||
TextJustify t_justify, f_justify;
|
||||
int bullet, bullet_pos;
|
||||
};
|
||||
|
||||
struct Strut {
|
||||
unsigned int top, bottom, left, right;
|
||||
|
||||
Strut(void): top(0), bottom(0), left(0), right(0) {}
|
||||
};
|
||||
|
||||
class BScreen : public ScreenInfo {
|
||||
private:
|
||||
bool root_colormap_installed, managed, geom_visible;
|
||||
GC opGC;
|
||||
Pixmap geom_pixmap;
|
||||
Window geom_window;
|
||||
|
||||
Blackbox *blackbox;
|
||||
BImageControl *image_control;
|
||||
Configmenu *configmenu;
|
||||
Iconmenu *iconmenu;
|
||||
Rootmenu *rootmenu;
|
||||
|
||||
typedef std::list<Rootmenu*> RootmenuList;
|
||||
RootmenuList rootmenuList;
|
||||
|
||||
typedef std::list<Netizen*> NetizenList;
|
||||
NetizenList netizenList;
|
||||
BlackboxWindowList iconList, windowList;
|
||||
|
||||
Slit *slit;
|
||||
Toolbar *toolbar;
|
||||
Workspace *current_workspace;
|
||||
Workspacemenu *workspacemenu;
|
||||
|
||||
unsigned int geom_w, geom_h;
|
||||
unsigned long event_mask;
|
||||
|
||||
Rect usableArea;
|
||||
|
||||
typedef std::list<Strut*> StrutList;
|
||||
StrutList strutList;
|
||||
typedef std::vector<std::string> WorkspaceNamesList;
|
||||
WorkspaceNamesList workspaceNames;
|
||||
typedef std::vector<Workspace*> WorkspaceList;
|
||||
WorkspaceList workspacesList;
|
||||
|
||||
struct screen_resource {
|
||||
WindowStyle wstyle;
|
||||
ToolbarStyle tstyle;
|
||||
MenuStyle mstyle;
|
||||
|
||||
bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
|
||||
auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
|
||||
focus_new, focus_last, click_raise;
|
||||
BColor border_color;
|
||||
XrmDatabase stylerc;
|
||||
|
||||
unsigned int workspaces;
|
||||
int toolbar_placement, toolbar_width_percent, placement_policy,
|
||||
edge_snap_threshold, row_direction, col_direction;
|
||||
|
||||
bool slit_on_top, slit_auto_hide;
|
||||
int slit_placement, slit_direction;
|
||||
|
||||
unsigned int handle_width, bevel_width, frame_width, border_width;
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
std::string strftime_format;
|
||||
#else // !HAVE_STRFTIME
|
||||
bool clock24hour;
|
||||
int date_format;
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
} resource;
|
||||
|
||||
BScreen(const BScreen&);
|
||||
BScreen& operator=(const BScreen&);
|
||||
|
||||
bool parseMenuFile(FILE *file, Rootmenu *menu);
|
||||
|
||||
BTexture readDatabaseTexture(const std::string &rname,
|
||||
const std::string &rclass,
|
||||
const std::string &default_color);
|
||||
BColor readDatabaseColor(const std::string &rname,
|
||||
const std::string &rclass,
|
||||
const std::string &default_color);
|
||||
XFontSet readDatabaseFontSet(const std::string &rname,
|
||||
const std::string &rclass);
|
||||
XFontStruct *readDatabaseFont(const std::string &rname,
|
||||
const std::string &rclass);
|
||||
XFontSet createFontSet(const std::string &fontname);
|
||||
|
||||
void InitMenu(void);
|
||||
void LoadStyle(void);
|
||||
|
||||
|
||||
public:
|
||||
enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, LeftRight,
|
||||
RightLeft, TopBottom, BottomTop };
|
||||
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
|
||||
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
|
||||
WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
|
||||
WindowLower, WindowStick, WindowKill, SetStyle };
|
||||
enum FocusModel { SloppyFocus, ClickToFocus };
|
||||
|
||||
BScreen(Blackbox *bb, unsigned int scrn);
|
||||
~BScreen(void);
|
||||
|
||||
inline bool isToolbarOnTop(void) const
|
||||
{ return resource.toolbar_on_top; }
|
||||
inline bool doToolbarAutoHide(void) const
|
||||
{ return resource.toolbar_auto_hide; }
|
||||
inline bool isSloppyFocus(void) const
|
||||
{ return resource.sloppy_focus; }
|
||||
inline bool isRootColormapInstalled(void) const
|
||||
{ return root_colormap_installed; }
|
||||
inline bool doAutoRaise(void) const { return resource.auto_raise; }
|
||||
inline bool doClickRaise(void) const { return resource.click_raise; }
|
||||
inline bool isScreenManaged(void) const { return managed; }
|
||||
inline bool doImageDither(void) const
|
||||
{ return resource.image_dither; }
|
||||
inline bool doOrderedDither(void) const
|
||||
{ return resource.ordered_dither; }
|
||||
inline bool doOpaqueMove(void) const { return resource.opaque_move; }
|
||||
inline bool doFullMax(void) const { return resource.full_max; }
|
||||
inline bool doFocusNew(void) const { return resource.focus_new; }
|
||||
inline bool doFocusLast(void) const { return resource.focus_last; }
|
||||
|
||||
inline const GC &getOpGC(void) const { return opGC; }
|
||||
|
||||
inline Blackbox *getBlackbox(void) { return blackbox; }
|
||||
inline BColor *getBorderColor(void) { return &resource.border_color; }
|
||||
inline BImageControl *getImageControl(void) { return image_control; }
|
||||
inline Rootmenu *getRootmenu(void) { return rootmenu; }
|
||||
|
||||
inline bool isSlitOnTop(void) const { return resource.slit_on_top; }
|
||||
inline bool doSlitAutoHide(void) const
|
||||
{ return resource.slit_auto_hide; }
|
||||
inline Slit *getSlit(void) { return slit; }
|
||||
inline int getSlitPlacement(void) const
|
||||
{ return resource.slit_placement; }
|
||||
inline int getSlitDirection(void) const
|
||||
{ return resource.slit_direction; }
|
||||
inline void saveSlitPlacement(int p) { resource.slit_placement = p; }
|
||||
inline void saveSlitDirection(int d) { resource.slit_direction = d; }
|
||||
inline void saveSlitOnTop(bool t) { resource.slit_on_top = t; }
|
||||
inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; }
|
||||
|
||||
inline Toolbar *getToolbar(void) { return toolbar; }
|
||||
|
||||
Workspace *getWorkspace(unsigned int index);
|
||||
|
||||
inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
|
||||
|
||||
inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
|
||||
|
||||
inline unsigned int getHandleWidth(void) const
|
||||
{ return resource.handle_width; }
|
||||
inline unsigned int getBevelWidth(void) const
|
||||
{ return resource.bevel_width; }
|
||||
inline unsigned int getFrameWidth(void) const
|
||||
{ return resource.frame_width; }
|
||||
inline unsigned int getBorderWidth(void) const
|
||||
{ return resource.border_width; }
|
||||
|
||||
inline unsigned int getCurrentWorkspaceID(void)
|
||||
{ return current_workspace->getID(); }
|
||||
inline unsigned int getWorkspaceCount(void)
|
||||
{ return workspacesList.size(); }
|
||||
inline unsigned int getIconCount(void) { return iconList.size(); }
|
||||
inline unsigned int getNumberOfWorkspaces(void) const
|
||||
{ return resource.workspaces; }
|
||||
inline int getToolbarPlacement(void) const
|
||||
{ return resource.toolbar_placement; }
|
||||
inline int getToolbarWidthPercent(void) const
|
||||
{ return resource.toolbar_width_percent; }
|
||||
inline int getPlacementPolicy(void) const
|
||||
{ return resource.placement_policy; }
|
||||
inline int getEdgeSnapThreshold(void) const
|
||||
{ return resource.edge_snap_threshold; }
|
||||
inline int getRowPlacementDirection(void) const
|
||||
{ return resource.row_direction; }
|
||||
inline int getColPlacementDirection(void) const
|
||||
{ return resource.col_direction; }
|
||||
|
||||
inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
|
||||
inline void saveSloppyFocus(bool s) { resource.sloppy_focus = s; }
|
||||
inline void saveAutoRaise(bool a) { resource.auto_raise = a; }
|
||||
inline void saveClickRaise(bool c) { resource.click_raise = c; }
|
||||
inline void saveWorkspaces(unsigned int w) { resource.workspaces = w; }
|
||||
inline void saveToolbarOnTop(bool r) { resource.toolbar_on_top = r; }
|
||||
inline void saveToolbarAutoHide(bool r) { resource.toolbar_auto_hide = r; }
|
||||
inline void saveToolbarWidthPercent(int w)
|
||||
{ resource.toolbar_width_percent = w; }
|
||||
inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
|
||||
inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
|
||||
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
|
||||
inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
|
||||
inline void saveEdgeSnapThreshold(int t)
|
||||
{ resource.edge_snap_threshold = t; }
|
||||
inline void saveImageDither(bool d) { resource.image_dither = d; }
|
||||
inline void saveOpaqueMove(bool o) { resource.opaque_move = o; }
|
||||
inline void saveFullMax(bool f) { resource.full_max = f; }
|
||||
inline void saveFocusNew(bool f) { resource.focus_new = f; }
|
||||
inline void saveFocusLast(bool f) { resource.focus_last = f; }
|
||||
inline void iconUpdate(void) { iconmenu->update(); }
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
inline const char *getStrftimeFormat(void)
|
||||
{ return resource.strftime_format.c_str(); }
|
||||
void saveStrftimeFormat(const std::string& format);
|
||||
#else // !HAVE_STRFTIME
|
||||
inline int getDateFormat(void) { return resource.date_format; }
|
||||
inline void saveDateFormat(int f) { resource.date_format = f; }
|
||||
inline bool isClock24Hour(void) { return resource.clock24hour; }
|
||||
inline void saveClock24Hour(bool c) { resource.clock24hour = c; }
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
|
||||
inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
|
||||
inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
|
||||
|
||||
BlackboxWindow *getIcon(unsigned int index);
|
||||
|
||||
const Rect& availableArea(void) const;
|
||||
void updateAvailableArea(void);
|
||||
void addStrut(Strut *strut);
|
||||
void removeStrut(Strut *strut);
|
||||
|
||||
unsigned int addWorkspace(void);
|
||||
unsigned int removeLastWorkspace(void);
|
||||
void removeWorkspaceNames(void);
|
||||
void addWorkspaceName(const std::string& name);
|
||||
const std::string getNameOfWorkspace(unsigned int id);
|
||||
void changeWorkspaceID(unsigned int id);
|
||||
|
||||
void addNetizen(Netizen *n);
|
||||
void removeNetizen(Window w);
|
||||
|
||||
void addIcon(BlackboxWindow *w);
|
||||
void removeIcon(BlackboxWindow *w);
|
||||
|
||||
void manageWindow(Window w);
|
||||
void unmanageWindow(BlackboxWindow *w, bool remap);
|
||||
void raiseWindows(Window *workspace_stack, unsigned int num);
|
||||
void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
|
||||
bool ignore_sticky);
|
||||
void propagateWindowName(const BlackboxWindow *bw);
|
||||
void prevFocus(void);
|
||||
void nextFocus(void);
|
||||
void raiseFocus(void);
|
||||
void reconfigure(void);
|
||||
void toggleFocusModel(FocusModel model);
|
||||
void updateFocusModel(void);
|
||||
void rereadMenu(void);
|
||||
void shutdown(void);
|
||||
void showPosition(int x, int y);
|
||||
void showGeometry(unsigned int gx, unsigned int gy);
|
||||
void hideGeometry(void);
|
||||
|
||||
void buttonPressEvent(XButtonEvent *xbutton);
|
||||
|
||||
void updateNetizenCurrentWorkspace(void);
|
||||
void updateNetizenWorkspaceCount(void);
|
||||
void updateNetizenWindowFocus(void);
|
||||
void updateNetizenWindowAdd(Window w, unsigned long p);
|
||||
void updateNetizenWindowDel(Window w);
|
||||
void updateNetizenConfigNotify(XEvent *e);
|
||||
void updateNetizenWindowRaise(Window w);
|
||||
void updateNetizenWindowLower(Window w);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Screen_hh
|
933
src/Slit.cc
933
src/Slit.cc
File diff suppressed because it is too large
Load diff
175
src/Slit.h
175
src/Slit.h
|
@ -1,175 +0,0 @@
|
|||
// Slit.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Slit_hh
|
||||
#define __Slit_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Geometry.h"
|
||||
#include <list>
|
||||
|
||||
// forward declaration
|
||||
class Slit;
|
||||
class Slitmenu;
|
||||
|
||||
class Slitmenu : public Basemenu {
|
||||
private:
|
||||
class Directionmenu : public Basemenu {
|
||||
private:
|
||||
Slitmenu &slitmenu;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void setValues();
|
||||
|
||||
public:
|
||||
Directionmenu(Slitmenu &);
|
||||
void reconfigure();
|
||||
};
|
||||
|
||||
class Placementmenu : public Basemenu {
|
||||
private:
|
||||
Slitmenu &slitmenu;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
public:
|
||||
Placementmenu(Slitmenu &);
|
||||
};
|
||||
|
||||
Directionmenu *directionmenu;
|
||||
Placementmenu *placementmenu;
|
||||
|
||||
Slit &slit;
|
||||
|
||||
friend class Directionmenu;
|
||||
friend class Placementmenu;
|
||||
friend class Slit;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void internal_hide();
|
||||
virtual void setValues();
|
||||
|
||||
public:
|
||||
Slitmenu(Slit &);
|
||||
virtual ~Slitmenu();
|
||||
|
||||
inline Basemenu *getDirectionmenu() { return directionmenu; }
|
||||
inline Basemenu *getPlacementmenu() { return placementmenu; }
|
||||
|
||||
void reconfigure();
|
||||
};
|
||||
|
||||
|
||||
class Slit : public TimeoutHandler {
|
||||
private:
|
||||
class SlitClient {
|
||||
public:
|
||||
Window window, client_window, icon_window;
|
||||
|
||||
int x, y;
|
||||
unsigned int width, height;
|
||||
};
|
||||
|
||||
bool m_ontop, m_autohide, m_hidden;
|
||||
int m_direction, m_placement;
|
||||
Display *display;
|
||||
|
||||
Openbox &openbox;
|
||||
BScreen &screen;
|
||||
Resource &config;
|
||||
BTimer *timer;
|
||||
|
||||
typedef std::list<SlitClient *> slitClientList;
|
||||
slitClientList clientList;
|
||||
Slitmenu *slitmenu;
|
||||
|
||||
struct frame {
|
||||
Pixmap pixmap;
|
||||
Window window;
|
||||
|
||||
Rect area;
|
||||
Point hidden;
|
||||
} frame;
|
||||
|
||||
|
||||
friend class Slitmenu;
|
||||
friend class Slitmenu::Directionmenu;
|
||||
friend class Slitmenu::Placementmenu;
|
||||
|
||||
|
||||
public:
|
||||
Slit(BScreen &, Resource &);
|
||||
virtual ~Slit();
|
||||
|
||||
inline Slitmenu *getMenu() { return slitmenu; }
|
||||
|
||||
inline const Window &getWindowID() const { return frame.window; }
|
||||
|
||||
inline const Point &origin() const { return frame.area.origin(); }
|
||||
inline const Size &size() const { return frame.area.size(); }
|
||||
inline const Rect &area() const { return frame.area; }
|
||||
inline const Point &hiddenOrigin() const { return frame.hidden; }
|
||||
|
||||
void addClient(Window);
|
||||
void removeClient(SlitClient *, Bool = True);
|
||||
void removeClient(Window, Bool = True);
|
||||
void reconfigure();
|
||||
void load();
|
||||
void save();
|
||||
void reposition();
|
||||
void shutdown();
|
||||
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void enterNotifyEvent(XCrossingEvent *);
|
||||
void leaveNotifyEvent(XCrossingEvent *);
|
||||
void configureRequestEvent(XConfigureRequestEvent *);
|
||||
|
||||
virtual void timeout();
|
||||
|
||||
inline bool isHidden() const { return m_hidden; }
|
||||
|
||||
inline bool onTop() const { return m_ontop; }
|
||||
void setOnTop(bool);
|
||||
|
||||
inline bool autoHide() const { return m_autohide; }
|
||||
void setAutoHide(bool);
|
||||
|
||||
inline int placement() const { return m_placement; }
|
||||
void setPlacement(int);
|
||||
|
||||
inline int direction() const { return m_direction; }
|
||||
void setDirection(int);
|
||||
|
||||
enum { Vertical = 1, Horizontal };
|
||||
enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter,
|
||||
TopRight, CenterRight, BottomRight };
|
||||
};
|
||||
|
||||
|
||||
#endif // __Slit_hh
|
200
src/Texture.cc
Normal file
200
src/Texture.cc
Normal file
|
@ -0,0 +1,200 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Texture.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
#include "Texture.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Image.hh"
|
||||
#include "Screen.hh"
|
||||
#include "blackbox.hh"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
BTexture::BTexture(const BaseDisplay * const _display,
|
||||
unsigned int _screen, BImageControl* _ctrl)
|
||||
: c(_display, _screen), ct(_display, _screen),
|
||||
lc(_display, _screen), sc(_display, _screen), t(0),
|
||||
dpy(_display), ctrl(_ctrl), scrn(_screen) { }
|
||||
|
||||
|
||||
BTexture::BTexture(const string &d, const BaseDisplay * const _display,
|
||||
unsigned int _screen, BImageControl* _ctrl)
|
||||
: c(_display, _screen), ct(_display, _screen),
|
||||
lc(_display, _screen), sc(_display, _screen), t(0),
|
||||
dpy(_display), ctrl(_ctrl), scrn(_screen) {
|
||||
setDescription(d);
|
||||
}
|
||||
|
||||
|
||||
void BTexture::setColor(const BColor &cc) {
|
||||
c = cc;
|
||||
c.setDisplay(display(), screen());
|
||||
|
||||
unsigned char r, g, b, rr, gg, bb;
|
||||
|
||||
// calculate the light color
|
||||
r = c.red();
|
||||
g = c.green();
|
||||
b = c.blue();
|
||||
rr = r + (r >> 1);
|
||||
gg = g + (g >> 1);
|
||||
bb = b + (b >> 1);
|
||||
if (rr < r) rr = ~0;
|
||||
if (gg < g) gg = ~0;
|
||||
if (bb < b) bb = ~0;
|
||||
lc = BColor(rr, gg, bb, display(), screen());
|
||||
|
||||
// calculate the shadow color
|
||||
r = c.red();
|
||||
g = c.green();
|
||||
b = c.blue();
|
||||
rr = (r >> 2) + (r >> 1);
|
||||
gg = (g >> 2) + (g >> 1);
|
||||
bb = (b >> 2) + (b >> 1);
|
||||
if (rr > r) rr = 0;
|
||||
if (gg > g) gg = 0;
|
||||
if (bb > b) bb = 0;
|
||||
sc = BColor(rr, gg, bb, display(), screen());
|
||||
}
|
||||
|
||||
|
||||
void BTexture::setDescription(const string &d) {
|
||||
descr.erase();
|
||||
descr.reserve(d.length());
|
||||
|
||||
string::const_iterator it = d.begin(), end = d.end();
|
||||
for (; it != end; ++it)
|
||||
descr += tolower(*it);
|
||||
|
||||
if (descr.find("parentrelative") != string::npos) {
|
||||
setTexture(BTexture::Parent_Relative);
|
||||
} else {
|
||||
setTexture(0);
|
||||
|
||||
if (descr.find("gradient") != string::npos) {
|
||||
addTexture(BTexture::Gradient);
|
||||
if (descr.find("crossdiagonal") != string::npos)
|
||||
addTexture(BTexture::CrossDiagonal);
|
||||
else if (descr.find("rectangle") != string::npos)
|
||||
addTexture(BTexture::Rectangle);
|
||||
else if (descr.find("pyramid") != string::npos)
|
||||
addTexture(BTexture::Pyramid);
|
||||
else if (descr.find("pipecross") != string::npos)
|
||||
addTexture(BTexture::PipeCross);
|
||||
else if (descr.find("elliptic") != string::npos)
|
||||
addTexture(BTexture::Elliptic);
|
||||
else if (descr.find("diagonal") != string::npos)
|
||||
addTexture(BTexture::Diagonal);
|
||||
else if (descr.find("horizontal") != string::npos)
|
||||
addTexture(BTexture::Horizontal);
|
||||
else if (descr.find("vertical") != string::npos)
|
||||
addTexture(BTexture::Vertical);
|
||||
else
|
||||
addTexture(BTexture::Diagonal);
|
||||
} else {
|
||||
addTexture(BTexture::Solid);
|
||||
}
|
||||
|
||||
if (descr.find("raised") != string::npos)
|
||||
addTexture(BTexture::Raised);
|
||||
else if (descr.find("sunken") != string::npos)
|
||||
addTexture(BTexture::Sunken);
|
||||
else if (descr.find("flat") != string::npos)
|
||||
addTexture(BTexture::Flat);
|
||||
else
|
||||
addTexture(BTexture::Raised);
|
||||
|
||||
if (! (texture() & BTexture::Flat)) {
|
||||
if (descr.find("bevel2") != string::npos)
|
||||
addTexture(BTexture::Bevel2);
|
||||
else
|
||||
addTexture(BTexture::Bevel1);
|
||||
}
|
||||
|
||||
if (descr.find("interlaced") != string::npos)
|
||||
addTexture(BTexture::Interlaced);
|
||||
}
|
||||
}
|
||||
|
||||
void BTexture::setDisplay(const BaseDisplay * const _display,
|
||||
const unsigned int _screen) {
|
||||
if (_display == display() && _screen == screen()) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
dpy = _display;
|
||||
scrn = _screen;
|
||||
c.setDisplay(_display, _screen);
|
||||
ct.setDisplay(_display, _screen);
|
||||
lc.setDisplay(_display, _screen);
|
||||
sc.setDisplay(_display, _screen);
|
||||
}
|
||||
|
||||
|
||||
BTexture& BTexture::operator=(const BTexture &tt) {
|
||||
c = tt.c;
|
||||
ct = tt.ct;
|
||||
lc = tt.lc;
|
||||
sc = tt.sc;
|
||||
descr = tt.descr;
|
||||
t = tt.t;
|
||||
dpy = tt.dpy;
|
||||
scrn = tt.scrn;
|
||||
ctrl = tt.ctrl;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Pixmap BTexture::render(const unsigned int width, const unsigned int height,
|
||||
const Pixmap old) {
|
||||
assert(display() != 0);
|
||||
|
||||
if (texture() == (BTexture::Flat | BTexture::Solid))
|
||||
return None;
|
||||
if (texture() == BTexture::Parent_Relative)
|
||||
return ParentRelative;
|
||||
|
||||
if (screen() == ~(0u))
|
||||
scrn = DefaultScreen(display()->getXDisplay());
|
||||
|
||||
assert(ctrl != 0);
|
||||
Pixmap ret = ctrl->renderImage(width, height, *this);
|
||||
|
||||
if (old)
|
||||
ctrl->removeImage(old);
|
||||
|
||||
return ret;
|
||||
}
|
108
src/Texture.hh
Normal file
108
src/Texture.hh
Normal file
|
@ -0,0 +1,108 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Texture.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh at debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Bradley T Hughes <bhughes at trolltech.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef TEXTURE_HH
|
||||
#define TEXTURE_HH
|
||||
|
||||
#include "Color.hh"
|
||||
#include "Util.hh"
|
||||
class BImageControl;
|
||||
|
||||
#include <string>
|
||||
|
||||
class BTexture {
|
||||
public:
|
||||
enum Type {
|
||||
// bevel options
|
||||
Flat = (1l<<0),
|
||||
Sunken = (1l<<1),
|
||||
Raised = (1l<<2),
|
||||
// textures
|
||||
Solid = (1l<<3),
|
||||
Gradient = (1l<<4),
|
||||
// gradients
|
||||
Horizontal = (1l<<5),
|
||||
Vertical = (1l<<6),
|
||||
Diagonal = (1l<<7),
|
||||
CrossDiagonal = (1l<<8),
|
||||
Rectangle = (1l<<9),
|
||||
Pyramid = (1l<<10),
|
||||
PipeCross = (1l<<11),
|
||||
Elliptic = (1l<<12),
|
||||
// bevel types
|
||||
Bevel1 = (1l<<13),
|
||||
Bevel2 = (1l<<14),
|
||||
// inverted image
|
||||
Invert = (1l<<15),
|
||||
// parent relative image
|
||||
Parent_Relative = (1l<<16),
|
||||
// fake interlaced image
|
||||
Interlaced = (1l<<17)
|
||||
};
|
||||
|
||||
BTexture(const BaseDisplay * const _display = 0,
|
||||
unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
|
||||
BTexture(const std::string &_description,
|
||||
const BaseDisplay * const _display = 0,
|
||||
unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
|
||||
|
||||
void setColor(const BColor &_color);
|
||||
void setColorTo(const BColor &_colorTo) { ct = _colorTo; }
|
||||
|
||||
const BColor &color(void) const { return c; }
|
||||
const BColor &colorTo(void) const { return ct; }
|
||||
const BColor &lightColor(void) const { return lc; }
|
||||
const BColor &shadowColor(void) const { return sc; }
|
||||
|
||||
unsigned long texture(void) const { return t; }
|
||||
void setTexture(const unsigned long _texture) { t = _texture; }
|
||||
void addTexture(const unsigned long _texture) { t |= _texture; }
|
||||
|
||||
BTexture &operator=(const BTexture &tt);
|
||||
inline bool operator==(const BTexture &tt)
|
||||
{ return (c == tt.c && ct == tt.ct && lc == tt.lc &&
|
||||
sc == tt.sc && t == tt.t); }
|
||||
inline bool operator!=(const BTexture &tt)
|
||||
{ return (! operator==(tt)); }
|
||||
|
||||
const BaseDisplay *display(void) const { return dpy; }
|
||||
unsigned int screen(void) const { return scrn; }
|
||||
void setDisplay(const BaseDisplay * const _display,
|
||||
const unsigned int _screen);
|
||||
void setImageControl(BImageControl* _ctrl) { ctrl = _ctrl; }
|
||||
const std::string &description(void) const { return descr; }
|
||||
void setDescription(const std::string &d);
|
||||
|
||||
Pixmap render(const unsigned int width, const unsigned int height,
|
||||
const Pixmap old = 0);
|
||||
|
||||
private:
|
||||
BColor c, ct, lc, sc;
|
||||
std::string descr;
|
||||
unsigned long t;
|
||||
const BaseDisplay *dpy;
|
||||
BImageControl *ctrl;
|
||||
unsigned int scrn;
|
||||
};
|
||||
|
||||
#endif // TEXTURE_HH
|
82
src/Timer.cc
82
src/Timer.cc
|
@ -1,5 +1,6 @@
|
|||
// Timer.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Timer.cc for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,60 +21,91 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "BaseDisplay.h"
|
||||
#include "Timer.h"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Timer.hh"
|
||||
#include "Util.hh"
|
||||
|
||||
BTimer::BTimer(BaseDisplay &d, TimeoutHandler &h) : display(d), handler(h) {
|
||||
once = timing = False;
|
||||
BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) {
|
||||
manager = m;
|
||||
handler = h;
|
||||
|
||||
recur = timing = False;
|
||||
}
|
||||
|
||||
|
||||
BTimer::~BTimer(void) {
|
||||
if (timing) stop();
|
||||
}
|
||||
|
||||
|
||||
void BTimer::setTimeout(long t) {
|
||||
_timeout.tv_sec = t / 1000;
|
||||
_timeout.tv_usec = t;
|
||||
_timeout.tv_usec -= (_timeout.tv_sec * 1000);
|
||||
_timeout.tv_usec = t % 1000;
|
||||
_timeout.tv_usec *= 1000;
|
||||
if (timing) {
|
||||
display.removeTimer(this);
|
||||
display.addTimer(this); // reorder the display
|
||||
}
|
||||
}
|
||||
|
||||
void BTimer::setTimeout(timeval t) {
|
||||
|
||||
void BTimer::setTimeout(const timeval &t) {
|
||||
_timeout.tv_sec = t.tv_sec;
|
||||
_timeout.tv_usec = t.tv_usec;
|
||||
}
|
||||
|
||||
|
||||
void BTimer::start(void) {
|
||||
gettimeofday(&_start, 0);
|
||||
|
||||
if (! timing) {
|
||||
timing = True;
|
||||
display.addTimer(this);
|
||||
manager->addTimer(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BTimer::stop(void) {
|
||||
if (timing) {
|
||||
timing = False;
|
||||
timing = False;
|
||||
|
||||
display.removeTimer(this);
|
||||
}
|
||||
manager->removeTimer(this);
|
||||
}
|
||||
|
||||
|
||||
void BTimer::halt(void) {
|
||||
timing = False;
|
||||
}
|
||||
|
||||
|
||||
void BTimer::fireTimeout(void) {
|
||||
handler.timeout();
|
||||
if (handler)
|
||||
handler->timeout();
|
||||
}
|
||||
|
||||
|
||||
timeval BTimer::timeRemaining(const timeval &tm) const {
|
||||
timeval ret = endpoint();
|
||||
|
||||
ret.tv_sec -= tm.tv_sec;
|
||||
ret.tv_usec -= tm.tv_usec;
|
||||
|
||||
return normalizeTimeval(ret);
|
||||
}
|
||||
|
||||
|
||||
timeval BTimer::endpoint(void) const {
|
||||
timeval ret;
|
||||
|
||||
ret.tv_sec = _start.tv_sec + _timeout.tv_sec;
|
||||
ret.tv_usec = _start.tv_usec + _timeout.tv_usec;
|
||||
|
||||
return normalizeTimeval(ret);
|
||||
}
|
||||
|
||||
|
||||
bool BTimer::shouldFire(const timeval &tm) const {
|
||||
timeval end = endpoint();
|
||||
|
||||
return !((tm.tv_sec < end.tv_sec) ||
|
||||
(tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec));
|
||||
}
|
||||
|
|
78
src/Timer.h
78
src/Timer.h
|
@ -1,78 +0,0 @@
|
|||
// Timer.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Timer_hh
|
||||
#define __Timer_hh
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
|
||||
// forward declaration
|
||||
class BTimer;
|
||||
class TimeoutHandler;
|
||||
class BaseDisplay;
|
||||
|
||||
class TimeoutHandler {
|
||||
public:
|
||||
virtual void timeout(void) = 0;
|
||||
};
|
||||
|
||||
class BTimer {
|
||||
friend class BaseDisplay;
|
||||
private:
|
||||
BaseDisplay &display;
|
||||
TimeoutHandler &handler;
|
||||
int timing, once;
|
||||
|
||||
timeval _start, _timeout;
|
||||
|
||||
protected:
|
||||
void fireTimeout(void);
|
||||
|
||||
public:
|
||||
BTimer(BaseDisplay &, TimeoutHandler &);
|
||||
virtual ~BTimer(void);
|
||||
|
||||
inline const int &isTiming(void) const { return timing; }
|
||||
inline const int &doOnce(void) const { return once; }
|
||||
|
||||
inline const timeval &getTimeout(void) const { return _timeout; }
|
||||
inline const timeval &getStartTime(void) const { return _start; }
|
||||
|
||||
inline void fireOnce(int o) { once = o; }
|
||||
|
||||
void setTimeout(long);
|
||||
void setTimeout(timeval);
|
||||
void start(void);
|
||||
void stop(void);
|
||||
};
|
||||
|
||||
#endif // __Timer_hh
|
||||
|
131
src/Timer.hh
Normal file
131
src/Timer.hh
Normal file
|
@ -0,0 +1,131 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Timer.hh for Blackbox - An X11 Window Manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef _BLACKBOX_Timer_hh
|
||||
#define _BLACKBOX_Timer_hh
|
||||
|
||||
extern "C" {
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
class TimerQueueManager;
|
||||
|
||||
class TimeoutHandler {
|
||||
public:
|
||||
virtual void timeout(void) = 0;
|
||||
};
|
||||
|
||||
class BTimer {
|
||||
private:
|
||||
TimerQueueManager *manager;
|
||||
TimeoutHandler *handler;
|
||||
bool timing, recur;
|
||||
|
||||
timeval _start, _timeout;
|
||||
|
||||
BTimer(const BTimer&);
|
||||
BTimer& operator=(const BTimer&);
|
||||
|
||||
public:
|
||||
BTimer(TimerQueueManager *m, TimeoutHandler *h);
|
||||
virtual ~BTimer(void);
|
||||
|
||||
void fireTimeout(void);
|
||||
|
||||
inline bool isTiming(void) const { return timing; }
|
||||
inline bool isRecurring(void) const { return recur; }
|
||||
|
||||
inline const timeval &getTimeout(void) const { return _timeout; }
|
||||
inline const timeval &getStartTime(void) const { return _start; }
|
||||
|
||||
timeval timeRemaining(const timeval &tm) const;
|
||||
bool shouldFire(const timeval &tm) const;
|
||||
timeval endpoint(void) const;
|
||||
|
||||
inline void recurring(bool b) { recur = b; }
|
||||
|
||||
void setTimeout(long t);
|
||||
void setTimeout(const timeval &t);
|
||||
|
||||
void start(void); // manager acquires timer
|
||||
void stop(void); // manager releases timer
|
||||
void halt(void); // halts the timer
|
||||
|
||||
bool operator<(const BTimer& other) const
|
||||
{ return shouldFire(other.endpoint()); }
|
||||
};
|
||||
|
||||
|
||||
#include <queue>
|
||||
#include <algorithm>
|
||||
|
||||
template <class _Tp, class _Sequence, class _Compare>
|
||||
class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> {
|
||||
public:
|
||||
typedef std::priority_queue<_Tp, _Sequence, _Compare> _Base;
|
||||
|
||||
_timer_queue(void): _Base() {}
|
||||
~_timer_queue(void) {}
|
||||
|
||||
void release(const _Tp& value) {
|
||||
c.erase(std::remove(c.begin(), c.end(), value), c.end());
|
||||
// after removing the item we need to make the heap again
|
||||
std::make_heap(c.begin(), c.end(), comp);
|
||||
}
|
||||
bool empty(void) const { return _Base::empty(); }
|
||||
size_t size(void) const { return _Base::size(); }
|
||||
void push(const _Tp& value) { _Base::push(value); }
|
||||
void pop(void) { _Base::pop(); }
|
||||
const _Tp& top(void) const { return _Base::top(); }
|
||||
private:
|
||||
// no copying!
|
||||
_timer_queue(const _timer_queue&) {}
|
||||
_timer_queue& operator=(const _timer_queue&) {}
|
||||
};
|
||||
|
||||
struct TimerLessThan {
|
||||
bool operator()(const BTimer* const l, const BTimer* const r) const {
|
||||
return *r < *l;
|
||||
}
|
||||
};
|
||||
|
||||
#include <deque>
|
||||
typedef _timer_queue<BTimer*, std::deque<BTimer*>, TimerLessThan> TimerQueue;
|
||||
|
||||
class TimerQueueManager {
|
||||
public:
|
||||
virtual void addTimer(BTimer* timer) = 0;
|
||||
virtual void removeTimer(BTimer* timer) = 0;
|
||||
};
|
||||
|
||||
#endif // _BLACKBOX_Timer_hh
|
2096
src/Toolbar.cc
2096
src/Toolbar.cc
File diff suppressed because it is too large
Load diff
176
src/Toolbar.h
176
src/Toolbar.h
|
@ -1,176 +0,0 @@
|
|||
// Toolbar.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Toolbar_hh
|
||||
#define __Toolbar_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Timer.h"
|
||||
#include "Resource.h"
|
||||
#include "Screen.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
// forward declaration
|
||||
class Toolbar;
|
||||
|
||||
class Toolbarmenu : public Basemenu {
|
||||
private:
|
||||
class Placementmenu : public Basemenu {
|
||||
private:
|
||||
Toolbarmenu &toolbarmenu;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
public:
|
||||
Placementmenu(Toolbarmenu &);
|
||||
};
|
||||
|
||||
Toolbar &toolbar;
|
||||
Placementmenu *placementmenu;
|
||||
|
||||
friend class Placementmenu;
|
||||
friend class Toolbar;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void internal_hide();
|
||||
virtual void setValues();
|
||||
|
||||
public:
|
||||
Toolbarmenu(Toolbar &);
|
||||
~Toolbarmenu();
|
||||
|
||||
inline Basemenu *getPlacementmenu() { return placementmenu; }
|
||||
|
||||
void reconfigure();
|
||||
};
|
||||
|
||||
|
||||
class Toolbar : public TimeoutHandler {
|
||||
private:
|
||||
bool m_ontop, m_editing, m_hidden, m_autohide;
|
||||
int m_width_percent, m_placement;
|
||||
Display *display;
|
||||
|
||||
struct frame {
|
||||
unsigned long button_pixel, pbutton_pixel;
|
||||
Pixmap base, label, wlabel, clk, button, pbutton;
|
||||
Window window, workspace_label, window_label, clock, psbutton, nsbutton,
|
||||
pwbutton, nwbutton;
|
||||
|
||||
int x, y, x_hidden, y_hidden, hour, minute, grab_x, grab_y;
|
||||
unsigned int width, height, window_label_w, workspace_label_w, clock_w,
|
||||
button_w, bevel_w, label_h;
|
||||
} frame;
|
||||
|
||||
class HideHandler : public TimeoutHandler {
|
||||
public:
|
||||
Toolbar *toolbar;
|
||||
virtual void timeout();
|
||||
} hide_handler;
|
||||
|
||||
Openbox &openbox;
|
||||
BScreen &screen;
|
||||
Resource &config;
|
||||
BImageControl *image_ctrl;
|
||||
BTimer *clock_timer, *hide_timer;
|
||||
Toolbarmenu *toolbarmenu;
|
||||
|
||||
char *new_workspace_name;
|
||||
size_t new_name_pos;
|
||||
|
||||
friend class HideHandler;
|
||||
friend class Toolbarmenu;
|
||||
friend class Toolbarmenu::Placementmenu;
|
||||
|
||||
|
||||
public:
|
||||
Toolbar(BScreen &, Resource &);
|
||||
virtual ~Toolbar();
|
||||
|
||||
inline Toolbarmenu *getMenu() { return toolbarmenu; }
|
||||
|
||||
inline const Window &getWindowID() const { return frame.window; }
|
||||
|
||||
//inline unsigned int getWidth() const { return frame.width; }
|
||||
//inline unsigned int getHeight() const { return frame.height; }
|
||||
unsigned int getExposedHeight() const;
|
||||
|
||||
//int getX() const;
|
||||
//int getY() const;
|
||||
|
||||
Rect area() const;
|
||||
//Size size() const { return area().size(); }
|
||||
//Point origin() const { return area().origin(); }
|
||||
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void buttonReleaseEvent(XButtonEvent *);
|
||||
void enterNotifyEvent(XCrossingEvent *);
|
||||
void leaveNotifyEvent(XCrossingEvent *);
|
||||
void exposeEvent(XExposeEvent *);
|
||||
void keyPressEvent(XKeyEvent *);
|
||||
|
||||
void redrawWindowLabel(Bool = False);
|
||||
void redrawWorkspaceLabel(Bool = False);
|
||||
void redrawPrevWorkspaceButton(Bool = False, Bool = False);
|
||||
void redrawNextWorkspaceButton(Bool = False, Bool = False);
|
||||
void redrawPrevWindowButton(Bool = False, Bool = False);
|
||||
void redrawNextWindowButton(Bool = False, Bool = False);
|
||||
void edit();
|
||||
void reconfigure();
|
||||
void load();
|
||||
void save();
|
||||
void mapToolbar();
|
||||
void unMapToolbar();
|
||||
#ifdef HAVE_STRFTIME
|
||||
void checkClock(Bool = False);
|
||||
#else // HAVE_STRFTIME
|
||||
void checkClock(Bool = False, Bool = False);
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
virtual void timeout();
|
||||
|
||||
inline bool onTop() const { return m_ontop; }
|
||||
void setOnTop(bool);
|
||||
|
||||
inline bool autoHide() const { return m_autohide; }
|
||||
void setAutoHide(bool);
|
||||
|
||||
inline int widthPercent() const { return m_width_percent; }
|
||||
void setWidthPercent(int);
|
||||
|
||||
inline int placement() const { return m_placement; }
|
||||
void setPlacement(int);
|
||||
|
||||
inline bool isEditing() const { return m_editing; }
|
||||
inline bool isHidden() const { return m_hidden; }
|
||||
|
||||
enum { TopLeft = 1, BottomLeft, TopCenter,
|
||||
BottomCenter, TopRight, BottomRight };
|
||||
};
|
||||
|
||||
|
||||
#endif // __Toolbar_hh
|
173
src/Toolbar.hh
Normal file
173
src/Toolbar.hh
Normal file
|
@ -0,0 +1,173 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Toolbar.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Toolbar_hh
|
||||
#define __Toolbar_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include "Screen.hh"
|
||||
#include "Basemenu.hh"
|
||||
#include "Timer.hh"
|
||||
|
||||
// forward declaration
|
||||
class Toolbar;
|
||||
|
||||
class Toolbarmenu : public Basemenu {
|
||||
private:
|
||||
class Placementmenu : public Basemenu {
|
||||
private:
|
||||
Placementmenu(const Placementmenu&);
|
||||
Placementmenu& operator=(const Placementmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Placementmenu(Toolbarmenu *tm);
|
||||
};
|
||||
|
||||
Toolbar *toolbar;
|
||||
Placementmenu *placementmenu;
|
||||
|
||||
friend class Placementmenu;
|
||||
friend class Toolbar;
|
||||
|
||||
Toolbarmenu(const Toolbarmenu&);
|
||||
Toolbarmenu& operator=(const Toolbarmenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
virtual void internal_hide(void);
|
||||
|
||||
public:
|
||||
Toolbarmenu(Toolbar *tb);
|
||||
~Toolbarmenu(void);
|
||||
|
||||
inline Basemenu *getPlacementmenu(void) { return placementmenu; }
|
||||
|
||||
void reconfigure(void);
|
||||
};
|
||||
|
||||
|
||||
class Toolbar : public TimeoutHandler {
|
||||
private:
|
||||
bool on_top, editing, hidden, do_auto_hide;
|
||||
Display *display;
|
||||
|
||||
struct ToolbarFrame {
|
||||
unsigned long button_pixel, pbutton_pixel;
|
||||
Pixmap base, label, wlabel, clk, button, pbutton;
|
||||
Window window, workspace_label, window_label, clock, psbutton, nsbutton,
|
||||
pwbutton, nwbutton;
|
||||
|
||||
int x_hidden, y_hidden, hour, minute, grab_x, grab_y;
|
||||
unsigned int window_label_w, workspace_label_w, clock_w,
|
||||
button_w, bevel_w, label_h;
|
||||
|
||||
Rect rect;
|
||||
} frame;
|
||||
|
||||
class HideHandler : public TimeoutHandler {
|
||||
public:
|
||||
Toolbar *toolbar;
|
||||
|
||||
virtual void timeout(void);
|
||||
} hide_handler;
|
||||
|
||||
Blackbox *blackbox;
|
||||
BScreen *screen;
|
||||
BTimer *clock_timer, *hide_timer;
|
||||
Toolbarmenu *toolbarmenu;
|
||||
Strut strut;
|
||||
|
||||
std::string new_workspace_name;
|
||||
size_t new_name_pos;
|
||||
|
||||
friend class HideHandler;
|
||||
friend class Toolbarmenu;
|
||||
friend class Toolbarmenu::Placementmenu;
|
||||
|
||||
void redrawPrevWorkspaceButton(bool pressed = False, bool redraw = False);
|
||||
void redrawNextWorkspaceButton(bool pressed = False, bool redraw = False);
|
||||
void redrawPrevWindowButton(bool preseed = False, bool redraw = False);
|
||||
void redrawNextWindowButton(bool preseed = False, bool redraw = False);
|
||||
|
||||
void updateStrut(void);
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
void checkClock(bool redraw = False);
|
||||
#else // HAVE_STRFTIME
|
||||
void checkClock(bool redraw = False, bool date = False);
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
Toolbar(const Toolbar&);
|
||||
Toolbar& operator=(const Toolbar&);
|
||||
|
||||
public:
|
||||
Toolbar(BScreen *scrn);
|
||||
virtual ~Toolbar(void);
|
||||
|
||||
inline Toolbarmenu *getMenu(void) { return toolbarmenu; }
|
||||
|
||||
inline bool isEditing(void) const { return editing; }
|
||||
inline bool isOnTop(void) const { return on_top; }
|
||||
inline bool isHidden(void) const { return hidden; }
|
||||
inline bool doAutoHide(void) const { return do_auto_hide; }
|
||||
|
||||
inline Window getWindowID(void) const { return frame.window; }
|
||||
|
||||
inline const Rect& getRect(void) const { return frame.rect; }
|
||||
inline unsigned int getWidth(void) const { return frame.rect.width(); }
|
||||
inline unsigned int getHeight(void) const { return frame.rect.height(); }
|
||||
inline unsigned int getExposedHeight(void) const
|
||||
{ return ((do_auto_hide) ? frame.bevel_w : frame.rect.height()); }
|
||||
inline int getX(void) const
|
||||
{ return ((hidden) ? frame.x_hidden : frame.rect.x()); }
|
||||
inline int getY(void) const
|
||||
{ return ((hidden) ? frame.y_hidden : frame.rect.y()); }
|
||||
|
||||
void buttonPressEvent(XButtonEvent *be);
|
||||
void buttonReleaseEvent(XButtonEvent *re);
|
||||
void enterNotifyEvent(XCrossingEvent * /*unused*/);
|
||||
void leaveNotifyEvent(XCrossingEvent * /*unused*/);
|
||||
void exposeEvent(XExposeEvent *ee);
|
||||
void keyPressEvent(XKeyEvent *ke);
|
||||
|
||||
void edit(void);
|
||||
void reconfigure(void);
|
||||
void toggleAutoHide(void);
|
||||
|
||||
void redrawWindowLabel(bool redraw = False);
|
||||
void redrawWorkspaceLabel(bool redraw = False);
|
||||
|
||||
virtual void timeout(void);
|
||||
|
||||
enum { TopLeft = 1, BottomLeft, TopCenter,
|
||||
BottomCenter, TopRight, BottomRight };
|
||||
};
|
||||
|
||||
|
||||
#endif // __Toolbar_hh
|
214
src/Util.cc
214
src/Util.cc
|
@ -1,8 +1,7 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Util.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens (ben at orodu.net)
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry (shaleh at debian.org)
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
|
||||
// Util.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000, 2002 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -22,47 +21,202 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "../config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
extern "C" {
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif // HAVE_UNISTD_H
|
||||
#if defined(HAVE_PROCESS_H) && defined(__EMX__)
|
||||
# include <process.h>
|
||||
#endif // HAVE_PROCESS_H __EMX__
|
||||
}
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "Util.hh"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
void Rect::setX(int __x) {
|
||||
_x2 += __x - _x1;
|
||||
_x1 = __x;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setY(int __y)
|
||||
{
|
||||
_y2 += __y - _y1;
|
||||
_y1 = __y;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setPos(int __x, int __y) {
|
||||
_x2 += __x - _x1;
|
||||
_x1 = __x;
|
||||
_y2 += __y - _y1;
|
||||
_y1 = __y;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setWidth(unsigned int __w) {
|
||||
_x2 = __w + _x1 - 1;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setHeight(unsigned int __h) {
|
||||
_y2 = __h + _y1 - 1;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setSize(unsigned int __w, unsigned int __h) {
|
||||
_x2 = __w + _x1 - 1;
|
||||
_y2 = __h + _y1 - 1;
|
||||
}
|
||||
|
||||
|
||||
void Rect::setRect(int __x, int __y, unsigned int __w, unsigned int __h) {
|
||||
*this = Rect(__x, __y, __w, __h);
|
||||
}
|
||||
|
||||
|
||||
void Rect::setCoords(int __l, int __t, int __r, int __b) {
|
||||
_x1 = __l;
|
||||
_y1 = __t;
|
||||
_x2 = __r;
|
||||
_y2 = __b;
|
||||
}
|
||||
|
||||
|
||||
Rect Rect::operator|(const Rect &a) const {
|
||||
Rect b;
|
||||
|
||||
b._x1 = std::min(_x1, a._x1);
|
||||
b._y1 = std::min(_y1, a._y1);
|
||||
b._x2 = std::max(_x2, a._x2);
|
||||
b._y2 = std::max(_y2, a._y2);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
Rect Rect::operator&(const Rect &a) const {
|
||||
Rect b;
|
||||
|
||||
b._x1 = std::max(_x1, a._x1);
|
||||
b._y1 = std::max(_y1, a._y1);
|
||||
b._x2 = std::min(_x2, a._x2);
|
||||
b._y2 = std::min(_y2, a._y2);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
bool Rect::intersects(const Rect &a) const {
|
||||
return std::max(_x1, a._x1) <= std::min(_x2, a._x2) &&
|
||||
std::max(_y1, a._y1) <= std::min(_y2, a._y2);
|
||||
}
|
||||
|
||||
|
||||
string expandTilde(const string& s) {
|
||||
if (s[0] != '~') return s;
|
||||
|
||||
const char* const home = getenv("HOME");
|
||||
if (home == NULL) return s;
|
||||
|
||||
return string(home + s.substr(s.find('/')));
|
||||
}
|
||||
|
||||
|
||||
void bexec(const string& command, const string& displaystring) {
|
||||
#ifndef __EMX__
|
||||
void bexec(const char *command, char* displaystring) {
|
||||
if (! fork()) {
|
||||
setsid();
|
||||
putenv(displaystring);
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||
int ret = putenv(const_cast<char *>(displaystring.c_str()));
|
||||
assert(ret != -1);
|
||||
string cmd = "exec ";
|
||||
cmd += command;
|
||||
execl("/bin/sh", "/bin/sh", "-c", cmd.c_str(), NULL);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
#else // __EMX__
|
||||
spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", command, NULL);
|
||||
#endif // !__EMX__
|
||||
|
||||
|
||||
char *bstrdup(const char *s) {
|
||||
const int l = strlen(s) + 1;
|
||||
char *n = new char[l];
|
||||
strncpy(n, s, l);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
#ifndef HAVE_BASENAME
|
||||
char *basename (char *s) {
|
||||
char *save = s;
|
||||
|
||||
while (*s) if (*s++ == '/') save = s;
|
||||
|
||||
return save;
|
||||
string basename (const string& path) {
|
||||
string::size_type slash = path.rfind('/');
|
||||
if (slash == string::npos)
|
||||
return path;
|
||||
return path.substr(slash+1);
|
||||
}
|
||||
#endif // HAVE_BASENAME
|
||||
|
||||
|
||||
string textPropertyToString(Display *display, XTextProperty& text_prop) {
|
||||
string ret;
|
||||
|
||||
if (text_prop.value && text_prop.nitems > 0) {
|
||||
ret = (char *) text_prop.value;
|
||||
if (text_prop.encoding != XA_STRING) {
|
||||
text_prop.nitems = strlen((char *) text_prop.value);
|
||||
|
||||
char **list;
|
||||
int num;
|
||||
if (XmbTextPropertyToTextList(display, &text_prop,
|
||||
&list, &num) == Success &&
|
||||
num > 0 && *list) {
|
||||
ret = *list;
|
||||
XFreeStringList(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
timeval normalizeTimeval(const timeval &tm) {
|
||||
timeval ret = tm;
|
||||
|
||||
while (ret.tv_usec < 0) {
|
||||
if (ret.tv_sec > 0) {
|
||||
--ret.tv_sec;
|
||||
ret.tv_usec += 1000000;
|
||||
} else {
|
||||
ret.tv_usec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.tv_usec >= 1000000) {
|
||||
ret.tv_sec += ret.tv_usec / 1000000;
|
||||
ret.tv_usec %= 1000000;
|
||||
}
|
||||
|
||||
if (ret.tv_sec < 0) ret.tv_sec = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
39
src/Util.h
39
src/Util.h
|
@ -1,39 +0,0 @@
|
|||
// Util.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens (ben@orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Util_hh
|
||||
#define __Util_hh
|
||||
|
||||
#ifdef DEBUG
|
||||
# include <assert.h>
|
||||
# define ASSERT(x) assert(x)
|
||||
#else // !DEBUG
|
||||
# define ASSERT(x)
|
||||
#endif // DEBUG
|
||||
|
||||
struct PointerAssassin {
|
||||
template<typename T>
|
||||
inline void operator()(const T ptr) const {
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __Util_hh
|
102
src/Util.hh
Normal file
102
src/Util.hh
Normal file
|
@ -0,0 +1,102 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Util.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef _BLACKBOX_UTIL_HH
|
||||
#define _BLACKBOX_UTIL_HH
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class Rect {
|
||||
public:
|
||||
inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
|
||||
inline Rect(int __x, int __y, unsigned int __w, unsigned int __h)
|
||||
: _x1(__x), _y1(__y), _x2(__w + __x - 1), _y2(__h + __y - 1) { }
|
||||
inline explicit Rect(const XRectangle& xrect)
|
||||
: _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1),
|
||||
_y2(xrect.height + xrect.y - 1) { }
|
||||
|
||||
inline int left(void) const { return _x1; }
|
||||
inline int top(void) const { return _y1; }
|
||||
inline int right(void) const { return _x2; }
|
||||
inline int bottom(void) const { return _y2; }
|
||||
|
||||
inline int x(void) const { return _x1; }
|
||||
inline int y(void) const { return _y1; }
|
||||
void setX(int __x);
|
||||
void setY(int __y);
|
||||
void setPos(int __x, int __y);
|
||||
|
||||
inline unsigned int width(void) const { return _x2 - _x1 + 1; }
|
||||
inline unsigned int height(void) const { return _y2 - _y1 + 1; }
|
||||
void setWidth(unsigned int __w);
|
||||
void setHeight(unsigned int __h);
|
||||
void setSize(unsigned int __w, unsigned int __h);
|
||||
|
||||
void setRect(int __x, int __y, unsigned int __w, unsigned int __h);
|
||||
|
||||
void setCoords(int __l, int __t, int __r, int __b);
|
||||
|
||||
inline bool operator==(const Rect &a)
|
||||
{ return _x1 == a._x1 && _y1 == a._y1 && _x2 == a._x2 && _y2 == a._y2; }
|
||||
inline bool operator!=(const Rect &a) { return ! operator==(a); }
|
||||
|
||||
Rect operator|(const Rect &a) const;
|
||||
Rect operator&(const Rect &a) const;
|
||||
inline Rect &operator|=(const Rect &a) { *this = *this | a; return *this; }
|
||||
inline Rect &operator&=(const Rect &a) { *this = *this & a; return *this; }
|
||||
|
||||
inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; }
|
||||
|
||||
bool intersects(const Rect &a) const;
|
||||
|
||||
private:
|
||||
int _x1, _y1, _x2, _y2;
|
||||
};
|
||||
|
||||
/* XXX: this needs autoconf help */
|
||||
const unsigned int BSENTINEL = 65535;
|
||||
|
||||
std::string expandTilde(const std::string& s);
|
||||
|
||||
void bexec(const std::string& command, const std::string& displaystring);
|
||||
|
||||
#ifndef HAVE_BASENAME
|
||||
std::string basename(const std::string& path);
|
||||
#endif
|
||||
|
||||
std::string textPropertyToString(Display *display, XTextProperty& text_prop);
|
||||
|
||||
struct timeval; // forward declare to avoid the header
|
||||
timeval normalizeTimeval(const timeval &tm);
|
||||
|
||||
struct PointerAssassin {
|
||||
template<typename T>
|
||||
inline void operator()(const T ptr) const {
|
||||
delete ptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
3919
src/Window.cc
3919
src/Window.cc
File diff suppressed because it is too large
Load diff
361
src/Window.h
361
src/Window.h
|
@ -1,361 +0,0 @@
|
|||
// Window.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Window_hh
|
||||
#define __Window_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef SHAPE
|
||||
# include <X11/extensions/shape.h>
|
||||
#endif // SHAPE
|
||||
|
||||
#include "BaseDisplay.h"
|
||||
#include "Timer.h"
|
||||
#include "Windowmenu.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
// forward declaration
|
||||
class OpenboxWindow;
|
||||
|
||||
#define MwmHintsFunctions (1l << 0)
|
||||
#define MwmHintsDecorations (1l << 1)
|
||||
|
||||
#define MwmFuncAll (1l << 0)
|
||||
#define MwmFuncResize (1l << 1)
|
||||
#define MwmFuncMove (1l << 2)
|
||||
#define MwmFuncIconify (1l << 3)
|
||||
#define MwmFuncMaximize (1l << 4)
|
||||
#define MwmFuncClose (1l << 5)
|
||||
|
||||
#define MwmDecorAll (1l << 0)
|
||||
#define MwmDecorBorder (1l << 1)
|
||||
#define MwmDecorHandle (1l << 2)
|
||||
#define MwmDecorTitle (1l << 3)
|
||||
#define MwmDecorMenu (1l << 4)
|
||||
#define MwmDecorIconify (1l << 5)
|
||||
#define MwmDecorMaximize (1l << 6)
|
||||
|
||||
// this structure only contains 3 elements... the Motif 2.0 structure contains
|
||||
// 5... we only need the first 3... so that is all we will define
|
||||
typedef struct MwmHints {
|
||||
unsigned long flags, functions, decorations;
|
||||
} MwmHints;
|
||||
|
||||
#define PropMwmHintsElements 3
|
||||
|
||||
|
||||
class OpenboxWindow : public TimeoutHandler {
|
||||
private:
|
||||
BImageControl *image_ctrl;
|
||||
Openbox &openbox;
|
||||
BScreen *screen;
|
||||
Display *display;
|
||||
BTimer *timer;
|
||||
OpenboxAttributes openbox_attrib;
|
||||
|
||||
Time lastButtonPressTime; // used for double clicks, when were we clicked
|
||||
Windowmenu *windowmenu;
|
||||
|
||||
int window_number, workspace_number;
|
||||
unsigned long current_state;
|
||||
bool place_window; // place the window ourselves when mapped
|
||||
|
||||
enum FocusMode { F_NoInput = 0, F_Passive,
|
||||
F_LocallyActive, F_GloballyActive };
|
||||
FocusMode focus_mode;
|
||||
|
||||
enum ResizeZones {
|
||||
ZoneTop = 1 << 0,
|
||||
ZoneBottom = 1 << 1,
|
||||
ZoneLeft = 1 << 2,
|
||||
ZoneRight = 1 << 3
|
||||
};
|
||||
unsigned int resize_zone; // bitmask of ResizeZones values
|
||||
|
||||
struct _flags {
|
||||
Bool moving, // is moving?
|
||||
resizing, // is resizing?
|
||||
shaded, // is shaded?
|
||||
visible, // is visible?
|
||||
iconic, // is iconified?
|
||||
transient, // is a transient window?
|
||||
focused, // has focus?
|
||||
stuck, // is omnipresent
|
||||
modal, // is modal? (must be dismissed to continue)
|
||||
send_focus_message, // should we send focus messages to our client?
|
||||
shaped, // does the frame use the shape extension?
|
||||
managed; // under openbox's control?
|
||||
// maximize is special, the number corresponds
|
||||
// with a mouse button
|
||||
// if 0, not maximized
|
||||
unsigned int maximized; // 1 = HorizVert, 2 = Vertical, 3 = Horizontal
|
||||
} flags;
|
||||
|
||||
struct _client {
|
||||
OpenboxWindow *transient_for, // which window are we a transient for?
|
||||
*transient; // which window is our transient?
|
||||
|
||||
Window window, // the client's window
|
||||
window_group; // the client's window group
|
||||
|
||||
char *title, *icon_title;
|
||||
size_t title_len; // strlen(title)
|
||||
|
||||
int x, y,
|
||||
old_bw; // client's borderwidth
|
||||
|
||||
unsigned int width, height,
|
||||
title_text_w, // width as rendered in the current font
|
||||
min_width, min_height, // can not be resized smaller
|
||||
max_width, max_height, // can not be resized larger
|
||||
width_inc, height_inc, // increment step
|
||||
min_aspect_x, min_aspect_y, // minimum aspect ratio
|
||||
max_aspect_x, max_aspect_y, // maximum aspect ratio
|
||||
base_width, base_height,
|
||||
win_gravity;
|
||||
|
||||
unsigned long initial_state, normal_hint_flags, wm_hint_flags;
|
||||
|
||||
MwmHints *mwm_hint;
|
||||
OpenboxHints *openbox_hint;
|
||||
} client;
|
||||
|
||||
struct _functions {
|
||||
Bool resize, move, iconify, maximize, close;
|
||||
} functions;
|
||||
|
||||
/*
|
||||
* client window = the application's window
|
||||
* frame window = the window drawn around the outside of the client window
|
||||
* by the window manager which contains items like the
|
||||
* titlebar and close button
|
||||
* title = the titlebar drawn above the client window, it displays the
|
||||
* window's name and any buttons for interacting with the window,
|
||||
* such as iconify, maximize, and close
|
||||
* label = the window in the titlebar where the title is drawn
|
||||
* buttons = maximize, iconify, close
|
||||
* handle = the bar drawn at the bottom of the window, which contains the
|
||||
* left and right grips used for resizing the window
|
||||
* grips = the smaller reactangles in the handle, one of each side of it.
|
||||
* When clicked and dragged, these resize the window interactively
|
||||
* border = the line drawn around the outside edge of the frame window,
|
||||
* between the title, the bordered client window, and the handle.
|
||||
* Also drawn between the grips and the handle
|
||||
*/
|
||||
|
||||
/*
|
||||
* what decorations do we have?
|
||||
* this is based on the type of the client window as well as user input
|
||||
* the menu is not really decor, but it goes hand in hand with the decor
|
||||
*/
|
||||
struct _decorations {
|
||||
Bool titlebar, handle, border, iconify, maximize, close, menu;
|
||||
} decorations;
|
||||
|
||||
struct _frame {
|
||||
// u -> unfocused, f -> has focus
|
||||
unsigned long ulabel_pixel, flabel_pixel, utitle_pixel,
|
||||
ftitle_pixel, uhandle_pixel, fhandle_pixel, ubutton_pixel,
|
||||
fbutton_pixel, pbutton_pixel, uborder_pixel, fborder_pixel,
|
||||
ugrip_pixel, fgrip_pixel;
|
||||
Pixmap ulabel, flabel, utitle, ftitle, uhandle, fhandle,
|
||||
ubutton, fbutton, pbutton, ugrip, fgrip;
|
||||
|
||||
Window window, // the frame
|
||||
plate, // holds the client
|
||||
title,
|
||||
label,
|
||||
handle,
|
||||
close_button, iconify_button, maximize_button,
|
||||
right_grip, left_grip;
|
||||
|
||||
|
||||
unsigned int resize_w, resize_h;
|
||||
int resize_x, resize_y, // size and location of box drawn while resizing
|
||||
move_x, move_y; // location of box drawn while moving
|
||||
|
||||
int x, y,
|
||||
grab_x, grab_y, // where was the window when it was grabbed?
|
||||
y_border, y_handle; // where within frame is the border and handle
|
||||
|
||||
unsigned int width, height, title_h, label_w, label_h, handle_h,
|
||||
button_w, button_h, grip_w, grip_h, mwm_border_w, border_h, border_w,
|
||||
bevel_w;
|
||||
} frame;
|
||||
|
||||
protected:
|
||||
Bool getState();
|
||||
Window createToplevelWindow(int x, int y, unsigned int width,
|
||||
unsigned int height, unsigned int borderwidth);
|
||||
Window createChildWindow(Window parent, Cursor = None);
|
||||
|
||||
void getWMName();
|
||||
void getWMIconName();
|
||||
void getWMNormalHints();
|
||||
void getWMProtocols();
|
||||
void getWMHints();
|
||||
void getMWMHints();
|
||||
void getOpenboxHints();
|
||||
void setNetWMAttributes();
|
||||
void associateClientWindow();
|
||||
void decorate();
|
||||
void decorateLabel();
|
||||
void positionButtons();
|
||||
void positionWindows();
|
||||
void createCloseButton();
|
||||
void createIconifyButton();
|
||||
void createMaximizeButton();
|
||||
void redrawLabel();
|
||||
void redrawAllButtons();
|
||||
void redrawCloseButton(Bool);
|
||||
void redrawIconifyButton(Bool);
|
||||
void redrawMaximizeButton(Bool);
|
||||
void restoreGravity();
|
||||
void setGravityOffsets();
|
||||
void setState(unsigned long);
|
||||
void upsize();
|
||||
void downsize();
|
||||
void right_fixsize(int *gx = 0, int *gy = 0);
|
||||
void left_fixsize(int *gx = 0, int *gy = 0);
|
||||
void doMove(int x, int y);
|
||||
|
||||
|
||||
public:
|
||||
OpenboxWindow(Openbox &b, Window w, BScreen *s = (BScreen *) 0);
|
||||
virtual ~OpenboxWindow();
|
||||
|
||||
inline Bool isTransient() const { return flags.transient; }
|
||||
inline Bool isFocused() const { return flags.focused; }
|
||||
inline Bool isVisible() const { return flags.visible; }
|
||||
inline Bool isIconic() const { return flags.iconic; }
|
||||
inline Bool isShaded() const { return flags.shaded; }
|
||||
inline Bool isMaximized() const { return flags.maximized; }
|
||||
inline Bool isMaximizedFull() const { return flags.maximized == 1; }
|
||||
inline Bool isStuck() const { return flags.stuck; }
|
||||
inline Bool isIconifiable() const { return functions.iconify; }
|
||||
inline Bool isMaximizable() const { return functions.maximize; }
|
||||
inline Bool isResizable() const { return functions.resize; }
|
||||
inline Bool isClosable() const { return functions.close; }
|
||||
|
||||
inline Bool hasTitlebar() const { return decorations.titlebar; }
|
||||
inline Bool hasTransient() const
|
||||
{ return ((client.transient) ? True : False); }
|
||||
|
||||
inline OpenboxWindow *getTransient() { return client.transient; }
|
||||
inline OpenboxWindow *getTransientFor() { return client.transient_for; }
|
||||
|
||||
inline BScreen *getScreen() { return screen; }
|
||||
|
||||
inline const Window &getFrameWindow() const { return frame.window; }
|
||||
inline const Window &getClientWindow() const { return client.window; }
|
||||
|
||||
inline Windowmenu * getWindowmenu() { return windowmenu; }
|
||||
|
||||
inline char **getTitle() { return &client.title; }
|
||||
inline char **getIconTitle() { return &client.icon_title; }
|
||||
//inline const int &getXFrame() const { return frame.x; }
|
||||
//inline const int &getYFrame() const { return frame.y; }
|
||||
//inline const int &getXClient() const { return client.x; }
|
||||
//inline const int &getYClient() const { return client.y; }
|
||||
inline const int &getWorkspaceNumber() const { return workspace_number; }
|
||||
inline const int &getWindowNumber() const { return window_number; }
|
||||
|
||||
//inline const unsigned int &getWidth() const { return frame.width; }
|
||||
//inline const unsigned int &getHeight() const {
|
||||
// if (!flags.shaded)
|
||||
// return frame.height;
|
||||
// else
|
||||
// return frame.title_h;
|
||||
//}
|
||||
//inline const unsigned int &getClientHeight() const
|
||||
//{ return client.height; }
|
||||
//inline const unsigned int &getClientWidth() const
|
||||
//{ return client.width; }
|
||||
inline const unsigned int &getTitleHeight() const
|
||||
{ return frame.title_h; }
|
||||
|
||||
//inline const Point origin() const {
|
||||
// return Point(frame.x, frame.y);
|
||||
//}
|
||||
//inline const Point clientOrigin() const {
|
||||
// return Point(client.x, client.y);
|
||||
//}
|
||||
//inline const Size size() const {
|
||||
// return Size(frame.width, flags.shaded ? frame.title_h : frame.height);
|
||||
//}
|
||||
//inline const Size clientSize() const {
|
||||
// return Size(client.width, client.height);
|
||||
//}
|
||||
inline const Rect area() const {
|
||||
return Rect(frame.x, frame.y, frame.width,
|
||||
flags.shaded ? frame.title_h : frame.height);
|
||||
}
|
||||
inline const Rect clientArea() const {
|
||||
return Rect(client.x, client.y, client.width, client.height);
|
||||
}
|
||||
|
||||
inline void setWindowNumber(int n) { window_number = n; }
|
||||
|
||||
bool validateClient();
|
||||
bool setInputFocus();
|
||||
|
||||
void setFocusFlag(Bool);
|
||||
void iconify();
|
||||
void deiconify(bool reassoc = true, bool raise = true, bool initial = false);
|
||||
void close();
|
||||
void withdraw();
|
||||
void maximize(unsigned int button);
|
||||
void shade();
|
||||
void stick();
|
||||
void unstick();
|
||||
void reconfigure();
|
||||
void installColormap(Bool);
|
||||
void restore();
|
||||
void configure(int dx, int dy, unsigned int dw, unsigned int dh);
|
||||
void setWorkspace(int n);
|
||||
void changeOpenboxHints(OpenboxHints *);
|
||||
void restoreAttributes();
|
||||
|
||||
void startMove(int x, int y);
|
||||
void endMove();
|
||||
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void buttonReleaseEvent(XButtonEvent *);
|
||||
void motionNotifyEvent(XMotionEvent *);
|
||||
void destroyNotifyEvent(XDestroyWindowEvent *);
|
||||
void mapRequestEvent(XMapRequestEvent *);
|
||||
void mapNotifyEvent(XMapEvent *);
|
||||
void unmapNotifyEvent(XUnmapEvent *);
|
||||
void propertyNotifyEvent(Atom);
|
||||
void exposeEvent(XExposeEvent *);
|
||||
void configureRequestEvent(XConfigureRequestEvent *);
|
||||
|
||||
#ifdef SHAPE
|
||||
void shapeEvent(XShapeEvent *);
|
||||
#endif // SHAPE
|
||||
|
||||
virtual void timeout();
|
||||
};
|
||||
|
||||
|
||||
#endif // __Window_hh
|
363
src/Window.hh
Normal file
363
src/Window.hh
Normal file
|
@ -0,0 +1,363 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Window.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Window_hh
|
||||
#define __Window_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef SHAPE
|
||||
# include <X11/extensions/shape.h>
|
||||
#endif // SHAPE
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Timer.hh"
|
||||
#include "Util.hh"
|
||||
#include "Windowmenu.hh"
|
||||
|
||||
#define MwmHintsFunctions (1l << 0)
|
||||
#define MwmHintsDecorations (1l << 1)
|
||||
|
||||
#define MwmFuncAll (1l << 0)
|
||||
#define MwmFuncResize (1l << 1)
|
||||
#define MwmFuncMove (1l << 2)
|
||||
#define MwmFuncIconify (1l << 3)
|
||||
#define MwmFuncMaximize (1l << 4)
|
||||
#define MwmFuncClose (1l << 5)
|
||||
|
||||
#define MwmDecorAll (1l << 0)
|
||||
#define MwmDecorBorder (1l << 1)
|
||||
#define MwmDecorHandle (1l << 2)
|
||||
#define MwmDecorTitle (1l << 3)
|
||||
#define MwmDecorMenu (1l << 4) // not used
|
||||
#define MwmDecorIconify (1l << 5)
|
||||
#define MwmDecorMaximize (1l << 6)
|
||||
|
||||
// this structure only contains 3 elements... the Motif 2.0 structure contains
|
||||
// 5... we only need the first 3... so that is all we will define
|
||||
typedef struct MwmHints {
|
||||
unsigned long flags, functions, decorations;
|
||||
} MwmHints;
|
||||
|
||||
#define PropMwmHintsElements 3
|
||||
|
||||
class BWindowGroup {
|
||||
private:
|
||||
Blackbox *blackbox;
|
||||
Window group;
|
||||
BlackboxWindowList windowList;
|
||||
|
||||
public:
|
||||
BWindowGroup(Blackbox *b, Window _group);
|
||||
~BWindowGroup(void);
|
||||
|
||||
inline Window groupWindow(void) const { return group; }
|
||||
|
||||
inline bool empty(void) const { return windowList.empty(); }
|
||||
|
||||
void addWindow(BlackboxWindow *w) { windowList.push_back(w); }
|
||||
void removeWindow(BlackboxWindow *w) { windowList.remove(w); }
|
||||
|
||||
/*
|
||||
find a window on the specified screen. the focused window (if any) is
|
||||
checked first, otherwise the first matching window found is returned.
|
||||
transients are returned only if allow_transients is True.
|
||||
*/
|
||||
BlackboxWindow *find(BScreen *screen, bool allow_transients = False) const;
|
||||
};
|
||||
|
||||
|
||||
class BlackboxWindow : public TimeoutHandler {
|
||||
public:
|
||||
enum Function { Func_Resize = (1l << 0),
|
||||
Func_Move = (1l << 1),
|
||||
Func_Iconify = (1l << 2),
|
||||
Func_Maximize = (1l << 3),
|
||||
Func_Close = (1l << 4) };
|
||||
typedef unsigned int FunctionFlags;
|
||||
|
||||
enum Decoration { Decor_Titlebar = (1l << 0),
|
||||
Decor_Handle = (1l << 1),
|
||||
Decor_Border = (1l << 2),
|
||||
Decor_Iconify = (1l << 3),
|
||||
Decor_Maximize = (1l << 4),
|
||||
Decor_Close = (1l << 5) };
|
||||
typedef unsigned int DecorationFlags;
|
||||
|
||||
private:
|
||||
Blackbox *blackbox;
|
||||
BScreen *screen;
|
||||
BTimer *timer;
|
||||
BlackboxAttributes blackbox_attrib;
|
||||
|
||||
Time lastButtonPressTime; // used for double clicks, when were we clicked
|
||||
Windowmenu *windowmenu;
|
||||
|
||||
unsigned int window_number;
|
||||
unsigned long current_state;
|
||||
|
||||
enum FocusMode { F_NoInput = 0, F_Passive,
|
||||
F_LocallyActive, F_GloballyActive };
|
||||
FocusMode focus_mode;
|
||||
|
||||
struct _flags {
|
||||
bool moving, // is moving?
|
||||
resizing, // is resizing?
|
||||
shaded, // is shaded?
|
||||
visible, // is visible?
|
||||
iconic, // is iconified?
|
||||
focused, // has focus?
|
||||
stuck, // is omnipresent
|
||||
modal, // is modal? (must be dismissed to continue)
|
||||
send_focus_message, // should we send focus messages to our client?
|
||||
shaped; // does the frame use the shape extension?
|
||||
unsigned int maximized; // maximize is special, the number corresponds
|
||||
// with a mouse button
|
||||
// if 0, not maximized
|
||||
// 1 = HorizVert, 2 = Vertical, 3 = Horizontal
|
||||
} flags;
|
||||
|
||||
struct _client {
|
||||
Window window, // the client's window
|
||||
window_group;
|
||||
BlackboxWindow *transient_for; // which window are we a transient for?
|
||||
BlackboxWindowList transientList; // which windows are our transients?
|
||||
|
||||
std::string title, icon_title;
|
||||
|
||||
Rect rect;
|
||||
|
||||
int old_bw; // client's borderwidth
|
||||
|
||||
unsigned int
|
||||
min_width, min_height, // can not be resized smaller
|
||||
max_width, max_height, // can not be resized larger
|
||||
width_inc, height_inc, // increment step
|
||||
min_aspect_x, min_aspect_y, // minimum aspect ratio
|
||||
max_aspect_x, max_aspect_y, // maximum aspect ratio
|
||||
base_width, base_height,
|
||||
win_gravity;
|
||||
|
||||
unsigned long initial_state, normal_hint_flags, wm_hint_flags;
|
||||
} client;
|
||||
|
||||
FunctionFlags functions;
|
||||
/*
|
||||
* what decorations do we have?
|
||||
* this is based on the type of the client window as well as user input
|
||||
* the menu is not really decor, but it goes hand in hand with the decor
|
||||
*/
|
||||
DecorationFlags decorations;
|
||||
|
||||
/*
|
||||
* client window = the application's window
|
||||
* frame window = the window drawn around the outside of the client window
|
||||
* by the window manager which contains items like the
|
||||
* titlebar and close button
|
||||
* title = the titlebar drawn above the client window, it displays the
|
||||
* window's name and any buttons for interacting with the window,
|
||||
* such as iconify, maximize, and close
|
||||
* label = the window in the titlebar where the title is drawn
|
||||
* buttons = maximize, iconify, close
|
||||
* handle = the bar drawn at the bottom of the window, which contains the
|
||||
* left and right grips used for resizing the window
|
||||
* grips = the smaller reactangles in the handle, one of each side of it.
|
||||
* When clicked and dragged, these resize the window interactively
|
||||
* border = the line drawn around the outside edge of the frame window,
|
||||
* between the title, the bordered client window, and the handle.
|
||||
* Also drawn between the grips and the handle
|
||||
*/
|
||||
|
||||
struct _frame {
|
||||
// u -> unfocused, f -> has focus
|
||||
unsigned long ulabel_pixel, flabel_pixel, utitle_pixel,
|
||||
ftitle_pixel, uhandle_pixel, fhandle_pixel, ubutton_pixel,
|
||||
fbutton_pixel, pbutton_pixel, uborder_pixel, fborder_pixel,
|
||||
ugrip_pixel, fgrip_pixel;
|
||||
Pixmap ulabel, flabel, utitle, ftitle, uhandle, fhandle,
|
||||
ubutton, fbutton, pbutton, ugrip, fgrip;
|
||||
|
||||
Window window, // the frame
|
||||
plate, // holds the client
|
||||
title,
|
||||
label,
|
||||
handle,
|
||||
close_button, iconify_button, maximize_button,
|
||||
right_grip, left_grip;
|
||||
|
||||
/*
|
||||
* size and location of the box drawn while the window dimensions or
|
||||
* location is being changed, ie. resized or moved
|
||||
*/
|
||||
Rect changing;
|
||||
|
||||
Rect rect; // frame geometry
|
||||
Strut margin; // margins between the frame and client
|
||||
|
||||
int grab_x, grab_y; // where was the window when it was grabbed?
|
||||
|
||||
unsigned int inside_w, inside_h, // window w/h without border_w
|
||||
title_h, label_w, label_h, handle_h,
|
||||
button_w, grip_w, mwm_border_w, border_w,
|
||||
bevel_w;
|
||||
} frame;
|
||||
|
||||
BlackboxWindow(const BlackboxWindow&);
|
||||
BlackboxWindow& operator=(const BlackboxWindow&);
|
||||
|
||||
bool getState(void);
|
||||
Window createToplevelWindow();
|
||||
Window createChildWindow(Window parent, Cursor = None);
|
||||
|
||||
void getWMName(void);
|
||||
void getWMIconName(void);
|
||||
void getWMNormalHints(void);
|
||||
void getWMProtocols(void);
|
||||
void getWMHints(void);
|
||||
void getMWMHints(void);
|
||||
bool getBlackboxHints(void);
|
||||
void getTransientInfo(void);
|
||||
void setNetWMAttributes(void);
|
||||
void associateClientWindow(void);
|
||||
void decorate(void);
|
||||
void decorateLabel(void);
|
||||
void positionButtons(bool redecorate_label = False);
|
||||
void positionWindows(void);
|
||||
void createHandle(void);
|
||||
void destroyHandle(void);
|
||||
void createTitlebar(void);
|
||||
void destroyTitlebar(void);
|
||||
void createCloseButton(void);
|
||||
void destroyCloseButton(void);
|
||||
void createIconifyButton(void);
|
||||
void destroyIconifyButton(void);
|
||||
void createMaximizeButton(void);
|
||||
void destroyMaximizeButton(void);
|
||||
void redrawLabel(void);
|
||||
void redrawAllButtons(void);
|
||||
void redrawCloseButton(bool pressed);
|
||||
void redrawIconifyButton(bool pressed);
|
||||
void redrawMaximizeButton(bool pressed);
|
||||
void restoreGravity(void);
|
||||
void setGravityOffsets(void);
|
||||
void setState(unsigned long new_state);
|
||||
void upsize(void);
|
||||
|
||||
enum Corner { TopLeft, TopRight };
|
||||
void constrain(Corner anchor, int *pw = 0, int *ph = 0);
|
||||
|
||||
public:
|
||||
BlackboxWindow(Blackbox *b, Window w, BScreen *s);
|
||||
virtual ~BlackboxWindow(void);
|
||||
|
||||
inline bool isTransient(void) const { return client.transient_for != 0; }
|
||||
inline bool isFocused(void) const { return flags.focused; }
|
||||
inline bool isVisible(void) const { return flags.visible; }
|
||||
inline bool isIconic(void) const { return flags.iconic; }
|
||||
inline bool isShaded(void) const { return flags.shaded; }
|
||||
inline bool isMaximized(void) const { return flags.maximized; }
|
||||
inline bool isStuck(void) const { return flags.stuck; }
|
||||
inline bool isIconifiable(void) const { return functions & Func_Iconify; }
|
||||
inline bool isMaximizable(void) const { return functions & Func_Maximize; }
|
||||
inline bool isResizable(void) const { return functions & Func_Resize; }
|
||||
inline bool isClosable(void) const { return functions & Func_Close; }
|
||||
|
||||
inline bool hasTitlebar(void) const { return decorations & Decor_Titlebar; }
|
||||
|
||||
inline const BlackboxWindowList &getTransients(void) const
|
||||
{ return client.transientList; }
|
||||
BlackboxWindow *getTransientFor(void) const;
|
||||
|
||||
inline BScreen *getScreen(void) { return screen; }
|
||||
|
||||
inline Window getFrameWindow(void) const { return frame.window; }
|
||||
inline Window getClientWindow(void) const { return client.window; }
|
||||
inline Window getGroupWindow(void) const { return client.window_group; }
|
||||
|
||||
inline Windowmenu * getWindowmenu(void) { return windowmenu; }
|
||||
|
||||
inline const char *getTitle(void) const
|
||||
{ return client.title.c_str(); }
|
||||
inline const char *getIconTitle(void) const
|
||||
{ return client.icon_title.c_str(); }
|
||||
|
||||
inline unsigned int getWorkspaceNumber(void) const
|
||||
{ return blackbox_attrib.workspace; }
|
||||
inline unsigned int getWindowNumber(void) const { return window_number; }
|
||||
|
||||
inline const Rect &frameRect(void) const { return frame.rect; }
|
||||
inline const Rect &clientRect(void) const { return client.rect; }
|
||||
|
||||
inline unsigned int getTitleHeight(void) const
|
||||
{ return frame.title_h; }
|
||||
|
||||
inline void setWindowNumber(int n) { window_number = n; }
|
||||
|
||||
bool validateClient(void);
|
||||
bool setInputFocus(void);
|
||||
|
||||
void setFocusFlag(bool focus);
|
||||
void iconify(void);
|
||||
void deiconify(bool reassoc = True, bool raise = True);
|
||||
void show(void);
|
||||
void close(void);
|
||||
void withdraw(void);
|
||||
void maximize(unsigned int button);
|
||||
void remaximize(void);
|
||||
void shade(void);
|
||||
void stick(void);
|
||||
void unstick(void);
|
||||
void reconfigure(void);
|
||||
void updateFocusModel(void);
|
||||
void installColormap(bool install);
|
||||
void restore(bool remap);
|
||||
void configure(int dx, int dy, unsigned int dw, unsigned int dh);
|
||||
void setWorkspace(unsigned int n);
|
||||
void changeBlackboxHints(BlackboxHints *net);
|
||||
void restoreAttributes(void);
|
||||
|
||||
void buttonPressEvent(XButtonEvent *be);
|
||||
void buttonReleaseEvent(XButtonEvent *re);
|
||||
void motionNotifyEvent(XMotionEvent *me);
|
||||
void destroyNotifyEvent(XDestroyWindowEvent */*unused*/);
|
||||
void mapRequestEvent(XMapRequestEvent *mre);
|
||||
void unmapNotifyEvent(XUnmapEvent */*unused*/);
|
||||
void reparentNotifyEvent(XReparentEvent */*unused*/);
|
||||
void propertyNotifyEvent(Atom atom);
|
||||
void exposeEvent(XExposeEvent *ee);
|
||||
void configureRequestEvent(XConfigureRequestEvent *cr);
|
||||
|
||||
#ifdef SHAPE
|
||||
void configureShape(void);
|
||||
void shapeEvent(XShapeEvent * /*unused*/);
|
||||
#endif // SHAPE
|
||||
|
||||
virtual void timeout(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Window_hh
|
|
@ -1,5 +1,6 @@
|
|||
// Windowmenu.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Windowmenu.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,37 +21,32 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "i18n.h"
|
||||
#include "openbox.h"
|
||||
#include "Screen.h"
|
||||
#include "Window.h"
|
||||
#include "Windowmenu.h"
|
||||
#include "Workspace.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
extern "C" {
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif // HAVE_STRING_H
|
||||
}
|
||||
|
||||
#include "i18n.hh"
|
||||
#include "blackbox.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Window.hh"
|
||||
#include "Windowmenu.hh"
|
||||
#include "Workspace.hh"
|
||||
|
||||
|
||||
Windowmenu::Windowmenu(OpenboxWindow &win) : Basemenu(*win.getScreen()),
|
||||
window(win), screen(*win.getScreen())
|
||||
{
|
||||
Windowmenu::Windowmenu(BlackboxWindow *win) : Basemenu(win->getScreen()) {
|
||||
window = win;
|
||||
|
||||
setTitleVisibility(False);
|
||||
setMovable(False);
|
||||
setInternalMenu();
|
||||
|
||||
sendToMenu = new SendtoWorkspacemenu(*this);
|
||||
sendToMenu = new SendtoWorkspacemenu(this);
|
||||
insert(i18n(WindowmenuSet, WindowmenuSendTo, "Send To ..."),
|
||||
sendToMenu);
|
||||
insert(i18n(WindowmenuSet, WindowmenuShade, "Shade"),
|
||||
|
@ -72,10 +68,10 @@ window(win), screen(*win.getScreen())
|
|||
|
||||
update();
|
||||
|
||||
setItemEnabled(1, window.hasTitlebar());
|
||||
setItemEnabled(2, window.isIconifiable());
|
||||
setItemEnabled(3, window.isMaximizable());
|
||||
setItemEnabled(8, window.isClosable());
|
||||
setItemEnabled(1, window->hasTitlebar());
|
||||
setItemEnabled(2, window->isIconifiable());
|
||||
setItemEnabled(3, window->isMaximizable());
|
||||
setItemEnabled(8, window->isClosable());
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,71 +81,64 @@ Windowmenu::~Windowmenu(void) {
|
|||
|
||||
|
||||
void Windowmenu::show(void) {
|
||||
if (isItemEnabled(1)) setItemSelected(1, window.isShaded());
|
||||
if (isItemEnabled(3)) setItemSelected(3, window.isMaximized());
|
||||
if (isItemEnabled(6)) setItemSelected(6, window.isStuck());
|
||||
if (isItemEnabled(1)) setItemSelected(1, window->isShaded());
|
||||
if (isItemEnabled(3)) setItemSelected(3, window->isMaximized());
|
||||
if (isItemEnabled(6)) setItemSelected(6, window->isStuck());
|
||||
|
||||
Basemenu::show();
|
||||
}
|
||||
|
||||
|
||||
void Windowmenu::itemSelected(int button, int index) {
|
||||
void Windowmenu::itemSelected(int button, unsigned int index) {
|
||||
BasemenuItem *item = find(index);
|
||||
|
||||
/* Added by Scott Moynes, April 8, 2002
|
||||
Ignore the middle button for every item except the maximize
|
||||
button in the window menu. Maximize needs it for
|
||||
horizontal/vertical maximize, however, for the others it is
|
||||
inconsistent with the rest of the window behaviour.
|
||||
*/
|
||||
if(button != 2) {
|
||||
hide();
|
||||
switch (item->function()) {
|
||||
case BScreen::WindowShade:
|
||||
window.shade();
|
||||
break;
|
||||
hide();
|
||||
switch (item->function()) {
|
||||
case BScreen::WindowShade:
|
||||
window->shade();
|
||||
break;
|
||||
|
||||
case BScreen::WindowIconify:
|
||||
window.iconify();
|
||||
break;
|
||||
case BScreen::WindowIconify:
|
||||
window->iconify();
|
||||
break;
|
||||
|
||||
case BScreen::WindowMaximize:
|
||||
window.maximize((unsigned int) button);
|
||||
break;
|
||||
case BScreen::WindowMaximize:
|
||||
window->maximize(button);
|
||||
break;
|
||||
|
||||
case BScreen::WindowClose:
|
||||
window.close();
|
||||
break;
|
||||
case BScreen::WindowClose:
|
||||
window->close();
|
||||
break;
|
||||
|
||||
case BScreen::WindowRaise:
|
||||
screen.getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window);
|
||||
break;
|
||||
case BScreen::WindowRaise: {
|
||||
Workspace *wkspc = getScreen()->getWorkspace(window->getWorkspaceNumber());
|
||||
wkspc->raiseWindow(window);
|
||||
}
|
||||
break;
|
||||
|
||||
case BScreen::WindowLower:
|
||||
screen.getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window);
|
||||
break;
|
||||
case BScreen::WindowLower: {
|
||||
Workspace *wkspc = getScreen()->getWorkspace(window->getWorkspaceNumber());
|
||||
wkspc->lowerWindow(window);
|
||||
}
|
||||
break;
|
||||
|
||||
case BScreen::WindowStick:
|
||||
window.stick();
|
||||
break;
|
||||
case BScreen::WindowStick:
|
||||
window->stick();
|
||||
break;
|
||||
|
||||
case BScreen::WindowKill:
|
||||
XKillClient(screen.getBaseDisplay().getXDisplay(),
|
||||
window.getClientWindow());
|
||||
break;
|
||||
}
|
||||
} else if (item->function() == BScreen::WindowMaximize) {
|
||||
hide();
|
||||
window.maximize((unsigned int) button);
|
||||
case BScreen::WindowKill:
|
||||
XKillClient(getScreen()->getBaseDisplay()->getXDisplay(),
|
||||
window->getClientWindow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Windowmenu::reconfigure(void) {
|
||||
setItemEnabled(1, window.hasTitlebar());
|
||||
setItemEnabled(2, window.isIconifiable());
|
||||
setItemEnabled(3, window.isMaximizable());
|
||||
setItemEnabled(8, window.isClosable());
|
||||
setItemEnabled(1, window->hasTitlebar());
|
||||
setItemEnabled(2, window->isIconifiable());
|
||||
setItemEnabled(3, window->isMaximizable());
|
||||
setItemEnabled(8, window->isClosable());
|
||||
|
||||
sendToMenu->reconfigure();
|
||||
|
||||
|
@ -157,39 +146,51 @@ void Windowmenu::reconfigure(void) {
|
|||
}
|
||||
|
||||
|
||||
Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu &w)
|
||||
: Basemenu(w.screen), windowmenu(w) {
|
||||
setTitleVisibility(False);
|
||||
setMovable(False);
|
||||
setInternalMenu();
|
||||
update();
|
||||
}
|
||||
Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(Windowmenu *w)
|
||||
: Basemenu(w->getScreen()) {
|
||||
|
||||
window = w->window;
|
||||
|
||||
setTitleVisibility(False);
|
||||
setMovable(False);
|
||||
setInternalMenu();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, int index) {
|
||||
void Windowmenu::SendtoWorkspacemenu::itemSelected(int button,
|
||||
unsigned int index) {
|
||||
if (button > 2) return;
|
||||
|
||||
if (index <= windowmenu.screen.getWorkspaceCount()) {
|
||||
if (index == windowmenu.screen.getCurrentWorkspaceID()) return;
|
||||
if (windowmenu.window.isStuck()) windowmenu.window.stick();
|
||||
if (index <= getScreen()->getWorkspaceCount()) {
|
||||
if (index == getScreen()->getCurrentWorkspaceID()) return;
|
||||
if (window->isStuck()) window->stick();
|
||||
|
||||
if (button == 1) windowmenu.window.withdraw();
|
||||
windowmenu.screen.reassociateWindow(&(windowmenu.window), index, True);
|
||||
if (button == 2) windowmenu.screen.changeWorkspaceID(index);
|
||||
if (button == 1) window->withdraw();
|
||||
getScreen()->reassociateWindow(window, index, True);
|
||||
if (button == 2) getScreen()->changeWorkspaceID(index);
|
||||
}
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void Windowmenu::SendtoWorkspacemenu::update(void) {
|
||||
int i, r = getCount();
|
||||
|
||||
if (r != 0)
|
||||
for (i = 0; i < r; ++i)
|
||||
unsigned int i, r = getCount(),
|
||||
workspace_count = getScreen()->getWorkspaceCount();
|
||||
if (r > workspace_count) {
|
||||
for (i = r; i < workspace_count; ++i)
|
||||
remove(0);
|
||||
r = getCount();
|
||||
}
|
||||
|
||||
for (i = 0; i < windowmenu.screen.getWorkspaceCount(); ++i)
|
||||
insert(windowmenu.screen.getWorkspace(i)->getName());
|
||||
for (i = 0; i < workspace_count; ++i) {
|
||||
if (r < workspace_count) {
|
||||
insert(getScreen()->getWorkspace(i)->getName());
|
||||
++r;
|
||||
} else {
|
||||
changeItemLabel(i, getScreen()->getWorkspace(i)->getName());
|
||||
}
|
||||
}
|
||||
|
||||
Basemenu::update();
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
// Windowmenu.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Windowmenu_hh
|
||||
#define __Windowmenu_hh
|
||||
|
||||
#include "Basemenu.h"
|
||||
|
||||
// forward declaration
|
||||
class Windowmenu;
|
||||
class SendtoWorkspaceMenu;
|
||||
|
||||
class Openbox;
|
||||
class OpenboxWindow;
|
||||
class Toolbar;
|
||||
|
||||
class Windowmenu : public Basemenu {
|
||||
private:
|
||||
OpenboxWindow &window;
|
||||
BScreen &screen;
|
||||
|
||||
class SendtoWorkspacemenu : public Basemenu {
|
||||
private:
|
||||
Windowmenu &windowmenu;
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
public:
|
||||
SendtoWorkspacemenu(Windowmenu &);
|
||||
|
||||
void update(void);
|
||||
|
||||
virtual void show(void);
|
||||
};
|
||||
|
||||
SendtoWorkspacemenu *sendToMenu;
|
||||
|
||||
friend class SendtoWorkspacemenu;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
|
||||
|
||||
public:
|
||||
Windowmenu(OpenboxWindow &);
|
||||
virtual ~Windowmenu(void);
|
||||
|
||||
inline Basemenu *getSendToMenu(void) { return (Basemenu *) sendToMenu; }
|
||||
|
||||
void reconfigure(void);
|
||||
void setClosable(void);
|
||||
|
||||
virtual void show(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Windowmenu_hh
|
866
src/Workspace.cc
866
src/Workspace.cc
File diff suppressed because it is too large
Load diff
|
@ -1,94 +0,0 @@
|
|||
// Workspace.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Workspace_hh
|
||||
#define __Workspace_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
class BScreen;
|
||||
class Clientmenu;
|
||||
class Workspace;
|
||||
class OpenboxWindow;
|
||||
class Size;
|
||||
class Rect;
|
||||
|
||||
class Workspace {
|
||||
private:
|
||||
BScreen &screen;
|
||||
Clientmenu *clientmenu;
|
||||
|
||||
typedef std::vector<OpenboxWindow *> winVect;
|
||||
winVect _windows;
|
||||
typedef std::list<OpenboxWindow *> winList;
|
||||
winList _zorder;
|
||||
|
||||
char *name;
|
||||
int id, cascade_x, cascade_y;
|
||||
|
||||
OpenboxWindow *_focused, *_last; // last is the same as focused except
|
||||
// that when focus is removed from all
|
||||
// windows on the workspace, last doesnt
|
||||
// change to NULL
|
||||
|
||||
protected:
|
||||
void placeWindow(OpenboxWindow &);
|
||||
Point *bestFitPlacement(const Size &win_size, const Rect &space);
|
||||
Point *underMousePlacement(const Size &win_size, const Rect &space);
|
||||
Point *rowSmartPlacement(const Size &win_size, const Rect &space);
|
||||
Point *colSmartPlacement(const Size &win_size, const Rect &space);
|
||||
Point *const cascadePlacement(const OpenboxWindow &window, const Rect &space);
|
||||
|
||||
public:
|
||||
Workspace(BScreen &, int = 0);
|
||||
~Workspace(void);
|
||||
|
||||
inline BScreen &getScreen(void) { return screen; }
|
||||
inline Clientmenu *getMenu(void) { return clientmenu; }
|
||||
inline const char *getName(void) const { return name; }
|
||||
inline int getWorkspaceID(void) const { return id; }
|
||||
inline OpenboxWindow *focusedWindow() { return _focused; }
|
||||
inline OpenboxWindow *lastFocusedWindow() { return _last; }
|
||||
void focusWindow(OpenboxWindow *win);
|
||||
OpenboxWindow *getWindow(int);
|
||||
bool isCurrent(void);
|
||||
int addWindow(OpenboxWindow *, bool = false);
|
||||
int removeWindow(OpenboxWindow *);
|
||||
int getCount(void);
|
||||
void showAll(void);
|
||||
void hideAll(void);
|
||||
void removeAll(void);
|
||||
void raiseWindow(OpenboxWindow *);
|
||||
void lowerWindow(OpenboxWindow *);
|
||||
void reconfigure();
|
||||
void update();
|
||||
void setCurrent(void);
|
||||
void setName(const char *);
|
||||
void shutdown(void);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Workspace_hh
|
||||
|
109
src/Workspace.hh
Normal file
109
src/Workspace.hh
Normal file
|
@ -0,0 +1,109 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// Workspace.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __Workspace_hh
|
||||
#define __Workspace_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class BScreen;
|
||||
class Clientmenu;
|
||||
class Workspace;
|
||||
class BlackboxWindow;
|
||||
class Netizen;
|
||||
|
||||
typedef std::list<BlackboxWindow*> BlackboxWindowList;
|
||||
typedef std::vector<Window> StackVector;
|
||||
|
||||
class Workspace {
|
||||
private:
|
||||
BScreen *screen;
|
||||
BlackboxWindow *lastfocus;
|
||||
Clientmenu *clientmenu;
|
||||
|
||||
BlackboxWindowList stackingList, windowList;
|
||||
|
||||
std::string name;
|
||||
unsigned int id;
|
||||
int cascade_x, cascade_y;
|
||||
|
||||
Workspace(const Workspace&);
|
||||
Workspace& operator=(const Workspace&);
|
||||
|
||||
void raiseTransients(const BlackboxWindow * const win,
|
||||
StackVector::iterator &stack);
|
||||
void lowerTransients(const BlackboxWindow * const win,
|
||||
StackVector::iterator &stack);
|
||||
|
||||
void placeWindow(BlackboxWindow *win);
|
||||
bool cascadePlacement(Rect& win, const Rect& availableArea);
|
||||
bool smartPlacement(Rect& win, const Rect& availableArea);
|
||||
|
||||
public:
|
||||
Workspace(BScreen *scrn, unsigned int i = 0);
|
||||
|
||||
inline BScreen *getScreen(void) { return screen; }
|
||||
|
||||
inline BlackboxWindow *getLastFocusedWindow(void) { return lastfocus; }
|
||||
|
||||
inline Clientmenu *getMenu(void) { return clientmenu; }
|
||||
|
||||
inline const std::string& getName(void) const { return name; }
|
||||
|
||||
inline unsigned int getID(void) const { return id; }
|
||||
|
||||
inline void setLastFocusedWindow(BlackboxWindow *w) { lastfocus = w; }
|
||||
|
||||
BlackboxWindow* getWindow(unsigned int index);
|
||||
BlackboxWindow* getNextWindowInList(BlackboxWindow *w);
|
||||
BlackboxWindow* getPrevWindowInList(BlackboxWindow *w);
|
||||
BlackboxWindow* getTopWindowOnStack(void) const;
|
||||
void sendWindowList(Netizen &n);
|
||||
|
||||
bool isCurrent(void) const;
|
||||
bool isLastWindow(const BlackboxWindow* w) const;
|
||||
|
||||
void addWindow(BlackboxWindow *w, bool place = False);
|
||||
unsigned int removeWindow(BlackboxWindow *w);
|
||||
unsigned int getCount(void) const;
|
||||
|
||||
void showAll(void);
|
||||
void hideAll(void);
|
||||
void removeAll(void);
|
||||
void raiseWindow(BlackboxWindow *w);
|
||||
void lowerWindow(BlackboxWindow *w);
|
||||
void reconfigure(void);
|
||||
void updateFocusModel(void);
|
||||
void setCurrent(void);
|
||||
void setName(const std::string& new_name);
|
||||
};
|
||||
|
||||
|
||||
#endif // __Workspace_hh
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// Workspacemenu.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// Workspacemenu.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,48 +21,41 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "i18n.h"
|
||||
#include "openbox.h"
|
||||
#include "Screen.h"
|
||||
#include "Toolbar.h"
|
||||
#include "Workspacemenu.h"
|
||||
#include "Workspace.h"
|
||||
#include "i18n.hh"
|
||||
#include "blackbox.hh"
|
||||
#include "Screen.hh"
|
||||
#include "Toolbar.hh"
|
||||
#include "Workspacemenu.hh"
|
||||
#include "Workspace.hh"
|
||||
|
||||
|
||||
Workspacemenu::Workspacemenu(BScreen &scrn) : Basemenu(scrn), screen(scrn) {
|
||||
Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) {
|
||||
setInternalMenu();
|
||||
|
||||
setLabel(i18n(WorkspacemenuSet, WorkspacemenuWorkspacesTitle,
|
||||
"Workspaces"));
|
||||
insert(i18n(WorkspacemenuSet, WorkspacemenuNewWorkspace,
|
||||
"New Workspace"));
|
||||
insert(i18n(WorkspacemenuSet, WorkspacemenuRemoveLast,
|
||||
"Remove Last"));
|
||||
setLabel(i18n(WorkspacemenuSet, WorkspacemenuWorkspacesTitle, "Workspaces"));
|
||||
insert(i18n(WorkspacemenuSet, WorkspacemenuNewWorkspace, "New Workspace"));
|
||||
insert(i18n(WorkspacemenuSet, WorkspacemenuRemoveLast, "Remove Last"));
|
||||
}
|
||||
|
||||
|
||||
void Workspacemenu::itemSelected(int button, int index) {
|
||||
void Workspacemenu::itemSelected(int button, unsigned int index) {
|
||||
if (button != 1)
|
||||
return;
|
||||
|
||||
if (index == 0)
|
||||
screen.addWorkspace();
|
||||
else if (index == 1)
|
||||
screen.removeLastWorkspace();
|
||||
else if ((screen.getCurrentWorkspace()->getWorkspaceID() !=
|
||||
(index - 2)) && ((index - 2) < screen.getWorkspaceCount()))
|
||||
screen.changeWorkspaceID(index - 2);
|
||||
|
||||
if (! (screen.getWorkspacemenu()->isTorn() || isTorn()))
|
||||
if (index == 0) {
|
||||
getScreen()->addWorkspace();
|
||||
} else if (index == 1) {
|
||||
getScreen()->removeLastWorkspace();
|
||||
} else {
|
||||
index -= 2;
|
||||
const Workspace* const wkspc = getScreen()->getCurrentWorkspace();
|
||||
if (wkspc->getID() != index && index < getScreen()->getWorkspaceCount())
|
||||
getScreen()->changeWorkspaceID(index);
|
||||
}
|
||||
if (! (getScreen()->getWorkspacemenu()->isTorn() || isTorn()))
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// WorkspaceMenu.h for Openbox - an X11 Window manager
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// WorkspaceMenu.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -23,7 +24,7 @@
|
|||
#ifndef __Workspacemenu_hh
|
||||
#define __Workspacemenu_hh
|
||||
|
||||
#include "Basemenu.h"
|
||||
#include "Basemenu.hh"
|
||||
|
||||
// forward declaration
|
||||
class Workspacemenu;
|
||||
|
@ -31,13 +32,14 @@ class Toolbar;
|
|||
|
||||
class Workspacemenu : public Basemenu {
|
||||
private:
|
||||
BScreen &screen;
|
||||
Workspacemenu(const Workspacemenu&);
|
||||
Workspacemenu& operator=(const Workspacemenu&);
|
||||
|
||||
protected:
|
||||
virtual void itemSelected(int, int);
|
||||
virtual void itemSelected(int button, unsigned int index);
|
||||
|
||||
public:
|
||||
Workspacemenu(BScreen &);
|
||||
Workspacemenu(BScreen *scrn);
|
||||
};
|
||||
|
||||
|
348
src/XAtom.cc
348
src/XAtom.cc
|
@ -1,348 +0,0 @@
|
|||
// XAtom.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Jansens (xor at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "XAtom.h"
|
||||
#include "openbox.h"
|
||||
#include "Screen.h"
|
||||
#include "Util.h"
|
||||
|
||||
XAtom::XAtom(Openbox &ob) {
|
||||
_display = ob.getXDisplay();
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
openbox_pid = getAtom("_BLACKBOX_PID");
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
wm_colormap_windows = getAtom("WM_COLORMAP_WINDOWS");
|
||||
wm_protocols = getAtom("WM_PROTOCOLS");
|
||||
wm_state = getAtom("WM_STATE");
|
||||
wm_change_state = getAtom("WM_CHANGE_STATE");
|
||||
wm_delete_window = getAtom("WM_DELETE_WINDOW");
|
||||
wm_take_focus = getAtom("WM_TAKE_FOCUS");
|
||||
motif_wm_hints = getAtom("_MOTIF_WM_HINTS");
|
||||
openbox_hints = getAtom("_BLACKBOX_HINTS");
|
||||
openbox_attributes = getAtom("_BLACKBOX_ATTRIBUTES");
|
||||
openbox_change_attributes = getAtom("_BLACKBOX_CHANGE_ATTRIBUTES");
|
||||
|
||||
openbox_structure_messages = getAtom("_BLACKBOX_STRUCTURE_MESSAGES");
|
||||
openbox_notify_startup = getAtom("_BLACKBOX_NOTIFY_STARTUP");
|
||||
openbox_notify_window_add = getAtom("_BLACKBOX_NOTIFY_WINDOW_ADD");
|
||||
openbox_notify_window_del = getAtom("_BLACKBOX_NOTIFY_WINDOW_DEL");
|
||||
openbox_notify_current_workspace =
|
||||
getAtom("_BLACKBOX_NOTIFY_CURRENT_WORKSPACE");
|
||||
openbox_notify_workspace_count = getAtom("_BLACKBOX_NOTIFY_WORKSPACE_COUNT");
|
||||
openbox_notify_window_focus = getAtom("_BLACKBOX_NOTIFY_WINDOW_FOCUS");
|
||||
openbox_notify_window_raise = getAtom("_BLACKBOX_NOTIFY_WINDOW_RAISE");
|
||||
openbox_notify_window_lower = getAtom("_BLACKBOX_NOTIFY_WINDOW_LOWER");
|
||||
|
||||
openbox_change_workspace = getAtom("_BLACKBOX_CHANGE_WORKSPACE");
|
||||
openbox_change_window_focus = getAtom("_BLACKBOX_CHANGE_WINDOW_FOCUS");
|
||||
openbox_cycle_window_focus = getAtom("_BLACKBOX_CYCLE_WINDOW_FOCUS");
|
||||
|
||||
net_supported = getAtom("_NET_SUPPORTED");
|
||||
net_client_list = getAtom("_NET_CLIENT_LIST");
|
||||
net_client_list_stacking = getAtom("_NET_CLIENT_LIST_STACKING");
|
||||
net_number_of_desktops = getAtom("_NET_NUMBER_OF_DESKTOPS");
|
||||
net_desktop_geometry = getAtom("_NET_DESKTOP_GEOMETRY");
|
||||
net_desktop_viewport = getAtom("_NET_DESKTOP_VIEWPORT");
|
||||
net_current_desktop = getAtom("_NET_CURRENT_DESKTOP");
|
||||
net_desktop_names = getAtom("_NET_DESKTOP_NAMES");
|
||||
net_active_window = getAtom("_NET_ACTIVE_WINDOW");
|
||||
net_workarea = getAtom("_NET_WORKAREA");
|
||||
net_supporting_wm_check = getAtom("_NET_SUPPORTING_WM_CHECK");
|
||||
net_virtual_roots = getAtom("_NET_VIRTUAL_ROOTS");
|
||||
|
||||
net_close_window = getAtom("_NET_CLOSE_WINDOW");
|
||||
net_wm_moveresize = getAtom("_NET_WM_MOVERESIZE");
|
||||
|
||||
net_properties = getAtom("_NET_PROPERTIES");
|
||||
net_wm_name = getAtom("_NET_WM_NAME");
|
||||
net_wm_desktop = getAtom("_NET_WM_DESKTOP");
|
||||
net_wm_window_type = getAtom("_NET_WM_WINDOW_TYPE");
|
||||
net_wm_state = getAtom("_NET_WM_STATE");
|
||||
net_wm_strut = getAtom("_NET_WM_STRUT");
|
||||
net_wm_icon_geometry = getAtom("_NET_WM_ICON_GEOMETRY");
|
||||
net_wm_icon = getAtom("_NET_WM_ICON");
|
||||
net_wm_pid = getAtom("_NET_WM_PID");
|
||||
net_wm_handled_icons = getAtom("_NET_WM_HANDLED_ICONS");
|
||||
|
||||
net_wm_ping = getAtom("_NET_WM_PING");
|
||||
|
||||
for (unsigned int s = 0, c = ob.managedScreenCount(); s < c; ++s)
|
||||
setSupported( static_cast<ScreenInfo*>(ob.getScreen(s)) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* clean up the class' members
|
||||
*/
|
||||
XAtom::~XAtom() {
|
||||
while (!_support_windows.empty()) {
|
||||
// make sure we aren't fucking with this somewhere
|
||||
ASSERT(_support_windows.back() != None);
|
||||
XDestroyWindow(_display, _support_windows.back());
|
||||
_support_windows.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an atom from the Xserver, creating it if necessary.
|
||||
*/
|
||||
Atom XAtom::getAtom(const char *name) const {
|
||||
return XInternAtom(_display, name, False);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets which atoms are supported for NETWM, by Openbox, on the root window.
|
||||
*/
|
||||
void XAtom::setSupported(const ScreenInfo *screen) {
|
||||
// create the netwm support window
|
||||
Window w = XCreateSimpleWindow(_display, screen->getRootWindow(),
|
||||
0, 0, 1, 1, 0, 0, 0);
|
||||
ASSERT(w != None);
|
||||
_support_windows.push_back(w);
|
||||
|
||||
// we don't support any yet..
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Internal setValue used by all typed setValue functions.
|
||||
* Sets a window property on a window, optionally appending to the existing
|
||||
* value.
|
||||
*/
|
||||
void XAtom::setValue(Window win, Atom atom, Atom type, unsigned char* data,
|
||||
int size, int nelements, bool append) const {
|
||||
ASSERT(win != None); ASSERT(atom != None); ASSERT(type != None);
|
||||
ASSERT(data != (unsigned char *) 0);
|
||||
ASSERT(size == 8 || size == 16 || size == 32);
|
||||
ASSERT(nelements > 0);
|
||||
XChangeProperty(_display, win, atom, type, size,
|
||||
(append ? PropModeAppend : PropModeReplace),
|
||||
data, nelements);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set a 32-bit CARDINAL property value on a window.
|
||||
*/
|
||||
void XAtom::setCardValue(Window win, Atom atom, long value) const {
|
||||
setValue(win, atom, XA_CARDINAL, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set an Atom property value on a window.
|
||||
*/
|
||||
void XAtom::setAtomValue(Window win, Atom atom, Atom value) const {
|
||||
setValue(win, atom, XA_ATOM, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set a Window property value on a window.
|
||||
*/
|
||||
void XAtom::setWindowValue(Window win, Atom atom, Window value) const {
|
||||
setValue(win, atom, XA_WINDOW, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set a Pixmap property value on a window.
|
||||
*/
|
||||
void XAtom::setPixmapValue(Window win, Atom atom, Pixmap value) const {
|
||||
setValue(win, atom, XA_PIXMAP, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set a string property value on a window.
|
||||
*/
|
||||
void XAtom::setStringValue(Window win, Atom atom,
|
||||
const std::string &value) const {
|
||||
setValue(win, atom, XA_STRING,
|
||||
const_cast<unsigned char*>
|
||||
(reinterpret_cast<const unsigned char*>(value.c_str())),
|
||||
8, value.size(), false);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add elements to a 32-bit CARDINAL property value on a window.
|
||||
*/
|
||||
void XAtom::addCardValue(Window win, Atom atom, long value) const {
|
||||
setValue(win, atom, XA_CARDINAL, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add elements to an Atom property value on a window.
|
||||
*/
|
||||
void XAtom::addAtomValue(Window win, Atom atom, Atom value) const {
|
||||
setValue(win, atom, XA_ATOM, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add elements to a Window property value on a window.
|
||||
*/
|
||||
void XAtom::addWindowValue(Window win, Atom atom, Window value) const {
|
||||
setValue(win, atom, XA_WINDOW, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add elements to a Pixmap property value on a window.
|
||||
*/
|
||||
void XAtom::addPixmapValue(Window win, Atom atom, Pixmap value) const {
|
||||
setValue(win, atom, XA_PIXMAP, reinterpret_cast<unsigned char*>(&value),
|
||||
32, 1, true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add characters to a string property value on a window.
|
||||
*/
|
||||
void XAtom::addStringValue(Window win, Atom atom,
|
||||
const std::string &value) const {
|
||||
setValue(win, atom, XA_STRING,
|
||||
const_cast<unsigned char*>
|
||||
(reinterpret_cast<const unsigned char *>
|
||||
(value.c_str())),
|
||||
8, value.size(), true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Internal getValue function used by all of the typed getValue functions.
|
||||
* Gets an property's value from a window.
|
||||
* Returns true if the property was successfully retrieved; false if the
|
||||
* property did not exist on the window, or has a different type/size format
|
||||
* than the user tried to retrieve.
|
||||
*/
|
||||
bool XAtom::getValue(Window win, Atom atom, Atom type, unsigned long *nelements,
|
||||
unsigned char **value, int size) const {
|
||||
unsigned char *c_val; // value alloc'd with c malloc
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
unsigned long ret_bytes;
|
||||
XGetWindowProperty(_display, win, atom, 0l, 1l, False, AnyPropertyType,
|
||||
&ret_type, &ret_size, nelements, &ret_bytes,
|
||||
&c_val); // try get the first element
|
||||
if (ret_type == None)
|
||||
// the property does not exist on the window
|
||||
return false;
|
||||
if (ret_type != type || ret_size != size) {
|
||||
// wrong data in property
|
||||
XFree(c_val);
|
||||
return false;
|
||||
}
|
||||
// the data is correct, now, is there more than 1 element?
|
||||
if (ret_bytes == 0) {
|
||||
// we got the whole property's value
|
||||
*value = new unsigned char[*nelements * size/8 + 1];
|
||||
memcpy(*value, c_val, *nelements * size/8 + 1);
|
||||
XFree(c_val);
|
||||
return true;
|
||||
}
|
||||
// get the entire property since it is larger than one long
|
||||
free(c_val);
|
||||
// the number of longs that need to be retreived to get the property's entire
|
||||
// value. The last + 1 is the first long that we retrieved above.
|
||||
const int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1;
|
||||
XGetWindowProperty(_display, win, atom, 0l, remain, False, type, &ret_type,
|
||||
&ret_size, nelements, &ret_bytes, &c_val);
|
||||
ASSERT(ret_bytes == 0);
|
||||
*value = new unsigned char[*nelements * size/8 + 1];
|
||||
memcpy(*value, c_val, *nelements * size/8 + 1);
|
||||
XFree(c_val);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets a 32-bit Cardinal property's value from a window.
|
||||
*/
|
||||
bool XAtom::getCardValue(Window win, Atom atom, unsigned long *nelements,
|
||||
long **value) const {
|
||||
return XAtom::getValue(win, atom, XA_CARDINAL, nelements,
|
||||
reinterpret_cast<unsigned char **>(value), 32);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets an Atom property's value from a window.
|
||||
*/
|
||||
bool XAtom::getAtomValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Atom **value) const {
|
||||
return XAtom::getValue(win, atom, XA_ATOM, nelements,
|
||||
reinterpret_cast<unsigned char **>(value), 32);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets an Window property's value from a window.
|
||||
*/
|
||||
bool XAtom::getWindowValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Window **value) const {
|
||||
return XAtom::getValue(win, atom, XA_WINDOW, nelements,
|
||||
reinterpret_cast<unsigned char **>(value), 32);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets an Pixmap property's value from a window.
|
||||
*/
|
||||
bool XAtom::getPixmapValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Pixmap **value) const {
|
||||
return XAtom::getValue(win, atom, XA_PIXMAP, nelements,
|
||||
reinterpret_cast<unsigned char **>(value), 32);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets an string property's value from a window.
|
||||
*/
|
||||
bool XAtom::getStringValue(Window win, Atom atom, std::string &value) const {
|
||||
unsigned char *data;
|
||||
unsigned long nelements;
|
||||
bool ret = XAtom::getValue(win, atom, XA_STRING, &nelements, &data, 8);
|
||||
if (ret)
|
||||
value = reinterpret_cast<char*>(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Removes a property entirely from a window.
|
||||
*/
|
||||
void XAtom::eraseValue(Window win, Atom atom) const {
|
||||
XDeleteProperty(_display, win, atom);
|
||||
}
|
238
src/XAtom.h
238
src/XAtom.h
|
@ -1,238 +0,0 @@
|
|||
// XAtom.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __XAtom_h
|
||||
#define __XAtom_h
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Openbox;
|
||||
class ScreenInfo;
|
||||
|
||||
class XAtom {
|
||||
typedef std::vector<Window> SupportWindows;
|
||||
|
||||
Display *_display;
|
||||
// windows used to specify support for NETWM
|
||||
SupportWindows _support_windows;
|
||||
|
||||
Atom
|
||||
#ifdef HAVE_GETPID
|
||||
openbox_pid,
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
// window hints
|
||||
wm_colormap_windows,
|
||||
wm_protocols,
|
||||
wm_state,
|
||||
wm_delete_window,
|
||||
wm_take_focus,
|
||||
wm_change_state,
|
||||
motif_wm_hints,
|
||||
openbox_attributes,
|
||||
openbox_change_attributes,
|
||||
openbox_hints,
|
||||
|
||||
// blackbox-protocol atoms (wm -> client)
|
||||
openbox_structure_messages,
|
||||
openbox_notify_startup,
|
||||
openbox_notify_window_add,
|
||||
openbox_notify_window_del,
|
||||
openbox_notify_window_focus,
|
||||
openbox_notify_current_workspace,
|
||||
openbox_notify_workspace_count,
|
||||
openbox_notify_window_raise,
|
||||
openbox_notify_window_lower,
|
||||
// blackbox-protocol atoms (client -> wm)
|
||||
openbox_change_workspace,
|
||||
openbox_change_window_focus,
|
||||
openbox_cycle_window_focus,
|
||||
|
||||
// NETWM atoms
|
||||
// root window properties
|
||||
net_supported,
|
||||
net_client_list,
|
||||
net_client_list_stacking,
|
||||
net_number_of_desktops,
|
||||
net_desktop_geometry,
|
||||
net_desktop_viewport,
|
||||
net_current_desktop,
|
||||
net_desktop_names,
|
||||
net_active_window,
|
||||
net_workarea,
|
||||
net_supporting_wm_check,
|
||||
net_virtual_roots,
|
||||
// root window messages
|
||||
net_close_window,
|
||||
net_wm_moveresize,
|
||||
// application window properties
|
||||
net_properties,
|
||||
net_wm_name,
|
||||
net_wm_desktop,
|
||||
net_wm_window_type,
|
||||
net_wm_state,
|
||||
net_wm_strut,
|
||||
net_wm_icon_geometry,
|
||||
net_wm_icon,
|
||||
net_wm_pid,
|
||||
net_wm_handled_icons,
|
||||
// application protocols
|
||||
net_wm_ping;
|
||||
|
||||
Atom getAtom(const char *name) const;
|
||||
void setSupported(const ScreenInfo *screen);
|
||||
|
||||
void setValue(Window win, Atom atom, Atom type, unsigned char *data,
|
||||
int size, int nelements, bool append) const;
|
||||
bool getValue(Window win, Atom atom, Atom type, unsigned long *nelements,
|
||||
unsigned char **value, int size) const;
|
||||
|
||||
// no copying!!
|
||||
XAtom(const XAtom &);
|
||||
XAtom& operator=(const XAtom&);
|
||||
|
||||
public:
|
||||
XAtom(Openbox &ob);
|
||||
virtual ~XAtom();
|
||||
|
||||
void setCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
|
||||
void setAtomValue(Window win, Atom atom, Atom value) const;
|
||||
void setWindowValue(Window win, Atom atom, Window value) const;
|
||||
void setPixmapValue(Window win, Atom atom, Pixmap value) const;
|
||||
void setStringValue(Window win, Atom atom, const std::string &value) const;
|
||||
|
||||
void addCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL
|
||||
void addAtomValue(Window win, Atom atom, Atom value) const;
|
||||
void addWindowValue(Window win, Atom atom, Window value) const;
|
||||
void addPixmapValue(Window win, Atom atom, Pixmap value) const;
|
||||
void addStringValue(Window win, Atom atom, const std::string &value) const;
|
||||
|
||||
// the 'value' is allocated inside the function and
|
||||
// delete [] value needs to be called when you are done with it.
|
||||
// teh 'value' array returned is null terminated, and has 'nelements'
|
||||
// elements in it plus the null.
|
||||
bool getCardValue(Window win, Atom atom, unsigned long *nelements,
|
||||
long **value) const; // 32-bit CARDINAL
|
||||
bool getAtomValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Atom **value) const;
|
||||
bool getWindowValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Window **value) const;
|
||||
bool getPixmapValue(Window win, Atom atom, unsigned long *nelements,
|
||||
Pixmap **value) const;
|
||||
bool getStringValue(Window win, Atom atom, std::string &value) const;
|
||||
|
||||
void eraseValue(Window win, Atom atom) const;
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
inline Atom openboxPid() const { return openbox_pid; }
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
inline Atom wmChangeState() const { return wm_change_state; }
|
||||
inline Atom wmState() const { return wm_state; }
|
||||
inline Atom wmDelete() const { return wm_delete_window; }
|
||||
inline Atom wmProtocols() const { return wm_protocols; }
|
||||
inline Atom wmTakeFocus() const { return wm_take_focus; }
|
||||
inline Atom wmColormap() const { return wm_colormap_windows; }
|
||||
inline Atom motifWMHints() const { return motif_wm_hints; }
|
||||
|
||||
// this atom is for normal app->WM hints about decorations, stacking,
|
||||
// starting workspace etc...
|
||||
inline Atom openboxHints() const { return openbox_hints;}
|
||||
|
||||
// these atoms are for normal app->WM interaction beyond the scope of the
|
||||
// ICCCM...
|
||||
inline Atom openboxAttributes() const { return openbox_attributes; }
|
||||
inline Atom openboxChangeAttributes() const
|
||||
{ return openbox_change_attributes; }
|
||||
|
||||
// these atoms are for window->WM interaction, with more control and
|
||||
// information on window "structure"... common examples are
|
||||
// notifying apps when windows are raised/lowered... when the user changes
|
||||
// workspaces... i.e. "pager talk"
|
||||
inline Atom openboxStructureMessages() const
|
||||
{ return openbox_structure_messages; }
|
||||
|
||||
inline Atom openboxNotifyStartup() const
|
||||
{ return openbox_notify_startup; }
|
||||
inline Atom openboxNotifyWindowAdd() const
|
||||
{ return openbox_notify_window_add; }
|
||||
inline Atom openboxNotifyWindowDel() const
|
||||
{ return openbox_notify_window_del; }
|
||||
inline Atom openboxNotifyWindowFocus() const
|
||||
{ return openbox_notify_window_focus; }
|
||||
inline Atom openboxNotifyCurrentWorkspace() const
|
||||
{ return openbox_notify_current_workspace; }
|
||||
inline Atom openboxNotifyWorkspaceCount() const
|
||||
{ return openbox_notify_workspace_count; }
|
||||
inline Atom openboxNotifyWindowRaise() const
|
||||
{ return openbox_notify_window_raise; }
|
||||
inline Atom openboxNotifyWindowLower() const
|
||||
{ return openbox_notify_window_lower; }
|
||||
|
||||
// atoms to change that request changes to the desktop environment during
|
||||
// runtime... these messages can be sent by any client... as the sending
|
||||
// client window id is not included in the ClientMessage event...
|
||||
inline Atom openboxChangeWorkspace() const
|
||||
{ return openbox_change_workspace; }
|
||||
inline Atom openboxChangeWindowFocus() const
|
||||
{ return openbox_change_window_focus; }
|
||||
inline Atom openboxCycleWindowFocus() const
|
||||
{ return openbox_cycle_window_focus; }
|
||||
|
||||
// root window properties
|
||||
inline Atom netClientList() const { return net_client_list; }
|
||||
inline Atom netClientListStacking() const { return net_client_list_stacking; }
|
||||
inline Atom netNumberOfDesktops() const { return net_number_of_desktops; }
|
||||
inline Atom netDesktopGeometry() const { return net_desktop_geometry; }
|
||||
inline Atom netDesktopViewport() const { return net_desktop_viewport; }
|
||||
inline Atom netCurrentDesktop() const { return net_current_desktop; }
|
||||
inline Atom netDesktopNames() const { return net_desktop_names; }
|
||||
inline Atom netActiveWindow() const { return net_active_window; }
|
||||
inline Atom netWorkarea() const { return net_workarea; }
|
||||
inline Atom netSupportingWMCheck() const { return net_supporting_wm_check; }
|
||||
inline Atom netVirtualRoots() const { return net_virtual_roots; }
|
||||
|
||||
// root window messages
|
||||
inline Atom netCloseWindow() const { return net_close_window; }
|
||||
inline Atom netWMMoveResize() const { return net_wm_moveresize; }
|
||||
|
||||
// application window properties
|
||||
inline Atom netProperties() const { return net_properties; }
|
||||
inline Atom netWMName() const { return net_wm_name; }
|
||||
inline Atom netWMDesktop() const { return net_wm_desktop; }
|
||||
inline Atom netWMWindowType() const { return net_wm_window_type; }
|
||||
inline Atom netWMState() const { return net_wm_state; }
|
||||
inline Atom netWMStrut() const { return net_wm_strut; }
|
||||
inline Atom netWMIconGeometry() const { return net_wm_icon_geometry; }
|
||||
inline Atom netWMIcon() const { return net_wm_icon; }
|
||||
inline Atom netWMPid() const { return net_wm_pid; }
|
||||
inline Atom netWMHandledIcons() const { return net_wm_handled_icons; }
|
||||
|
||||
// application protocols
|
||||
inline Atom netWMPing() const { return net_wm_ping; }
|
||||
};
|
||||
|
||||
#endif // __XAtom_h
|
260
src/XDisplay.cc
260
src/XDisplay.cc
|
@ -1,260 +0,0 @@
|
|||
// XDisplay.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifdef SHAPE
|
||||
# include <X11/extensions/shape.h>
|
||||
#endif
|
||||
|
||||
#include "XDisplay.h"
|
||||
#include "Util.h"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
std::string XDisplay::_app_name;
|
||||
Window XDisplay::_last_bad_window = None;
|
||||
|
||||
/*
|
||||
* X error handler to handle all X errors while the application is
|
||||
* running.
|
||||
*/
|
||||
int XDisplay::errorHandler(Display *d, XErrorEvent *e) {
|
||||
#ifdef DEBUG
|
||||
char errtxt[128];
|
||||
XGetErrorText(d, e->error_code, errtxt, sizeof(errtxt)/sizeof(char));
|
||||
cerr << _app_name.c_str() << ": X error: " <<
|
||||
errtxt << "(" << e->error_code << ") opcodes " <<
|
||||
e->request_code << "/" << e->minor_code << endl;
|
||||
cerr.flags(std::ios_base::hex);
|
||||
cerr << " resource 0x" << e->resourceid << endl;
|
||||
cerr.flags(std::ios_base::dec);
|
||||
#endif
|
||||
|
||||
if (e->error_code == BadWindow)
|
||||
_last_bad_window = e->resourceid;
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
XDisplay::XDisplay(const std::string &application_name, const char *dpyname) {
|
||||
_app_name = application_name;
|
||||
_grabs = 0;
|
||||
_hasshape = false;
|
||||
|
||||
_display = XOpenDisplay(dpyname);
|
||||
if (_display == NULL) {
|
||||
cerr << "Could not open display. Connection to X server failed.\n";
|
||||
::exit(2);
|
||||
}
|
||||
if (-1 == fcntl(ConnectionNumber(_display), F_SETFD, 1)) {
|
||||
cerr << "Could not mark display connection as close-on-exec.\n";
|
||||
::exit(2);
|
||||
}
|
||||
_name = XDisplayName(dpyname);
|
||||
|
||||
XSetErrorHandler(errorHandler);
|
||||
|
||||
#ifdef SHAPE
|
||||
int waste;
|
||||
_hasshape = XShapeQueryExtension(_display, &_shape_event_base, &waste);
|
||||
#endif // SHAPE
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
getLockModifiers();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
XDisplay::~XDisplay() {
|
||||
std::for_each(_screens.begin(), _screens.end(), PointerAssassin());
|
||||
XCloseDisplay(_display);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Grab the X server
|
||||
*/
|
||||
void XDisplay::grab() {
|
||||
if (_grabs++ == 0)
|
||||
XGrabServer(_display);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Release the X server from a grab
|
||||
*/
|
||||
void XDisplay::ungrab() {
|
||||
if (--_grabs == 0)
|
||||
XUngrabServer(_display);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets the next event on the queue from the X server.
|
||||
*
|
||||
* Returns: true if e contains a new event; false if there is no event to be
|
||||
* returned.
|
||||
*/
|
||||
bool XDisplay::nextEvent(XEvent &e) {
|
||||
if(!XPending(_display))
|
||||
return false;
|
||||
XNextEvent(_display, &e);
|
||||
if (_last_bad_window != None) {
|
||||
if (e.xany.window == _last_bad_window) {
|
||||
cerr << "XDisplay::nextEvent(): Removing event for bad window from " <<
|
||||
"event queue\n";
|
||||
return false;
|
||||
} else
|
||||
_last_bad_window = None;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int XDisplay::connectionNumber() const {
|
||||
return ConnectionNumber(_display);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creates a font cursor in the X server and returns it.
|
||||
*/
|
||||
Cursor createCursor(unsigned int shape) const {
|
||||
return XCreateFontCursor(_display, shape);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
void XDisplay::getLockModifers() {
|
||||
NumLockMask = ScrollLockMask = 0;
|
||||
|
||||
const XModifierKeymap* const modmap = XGetModifierMapping(display);
|
||||
if (modmap && modmap->max_keypermod > 0) {
|
||||
const int mask_table[] = {
|
||||
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
};
|
||||
const size_t size = (sizeof(mask_table) / sizeof(mask_table[0])) *
|
||||
modmap->max_keypermod;
|
||||
// get the values of the keyboard lock modifiers
|
||||
// Note: Caps lock is not retrieved the same way as Scroll and Num lock
|
||||
// since it doesn't need to be.
|
||||
const KeyCode num_lock_code = XKeysymToKeycode(display, XK_Num_Lock);
|
||||
const KeyCode scroll_lock_code = XKeysymToKeycode(display, XK_Scroll_Lock);
|
||||
|
||||
for (size_t cnt = 0; cnt < size; ++cnt) {
|
||||
if (! modmap->modifiermap[cnt]) continue;
|
||||
|
||||
if (num_lock_code == modmap->modifiermap[cnt])
|
||||
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
if (scroll_lock_code == modmap->modifiermap[cnt])
|
||||
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
|
||||
MaskList[0] = 0;
|
||||
MaskList[1] = LockMask;
|
||||
MaskList[2] = NumLockMask;
|
||||
MaskList[3] = ScrollLockMask;
|
||||
MaskList[4] = LockMask | NumLockMask;
|
||||
MaskList[5] = NumLockMask | ScrollLockMask;
|
||||
MaskList[6] = LockMask | ScrollLockMask;
|
||||
MaskList[7] = LockMask | NumLockMask | ScrollLockMask;
|
||||
|
||||
if (modmap) XFreeModifiermap(const_cast<XModifierKeymap*>(modmap));
|
||||
}
|
||||
#endif // NOCLOBBER
|
||||
|
||||
unsigned int XDisplay::stripModifiers(const unsigned int state) const {
|
||||
#ifndef NOCLOBBER
|
||||
return state &= ~(NumLockMask() | ScrollLockMask | LockMask);
|
||||
#else
|
||||
return state &= ~LockMask;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Verifies that a window has not requested to be destroyed/unmapped, so
|
||||
* if it is a valid window or not.
|
||||
* Returns: true if the window is valid; false if it is no longer valid.
|
||||
*/
|
||||
bool XDisplay::validateWindow(Window window) {
|
||||
XEvent event;
|
||||
if (XCheckTypedWindowEvent(_display, window, DestroyNotify, &event)) {
|
||||
XPutBackEvent(display, &event);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Grabs a button, but also grabs the button in every possible combination with
|
||||
* the keyboard lock keys, so that they do not cancel out the event.
|
||||
*/
|
||||
void BaseDisplay::grabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window, Bool owner_events,
|
||||
unsigned int event_mask, int pointer_mode,
|
||||
int keybaord_mode, Window confine_to,
|
||||
Cursor cursor) const
|
||||
{
|
||||
#ifndef NOCLOBBER
|
||||
for (size_t cnt = 0; cnt < 8; ++cnt)
|
||||
XGrabButton(_display, button, modifiers | MaskList[cnt], grab_window,
|
||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||
confine_to, cursor);
|
||||
#else // NOCLOBBER
|
||||
XGrabButton(_display, button, modifiers, grab_window,
|
||||
owner_events, event_mask, pointer_mode, keybaord_mode,
|
||||
confine_to, cursor);
|
||||
#endif // NOCLOBBER
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Releases the grab on a button, and ungrabs all possible combinations of the
|
||||
* keyboard lock keys.
|
||||
*/
|
||||
void BaseDisplay::ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const {
|
||||
#ifndef NOCLOBBER
|
||||
for (size_t cnt = 0; cnt < 8; ++cnt)
|
||||
XUngrabButton(display, button, modifiers | MaskList[cnt], grab_window);
|
||||
#else // NOCLOBBER
|
||||
XUngrabButton(display, button, modifiers, grab_window);
|
||||
#endif // NOCLOBBER
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
// XDisplay.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __XDisplay_h
|
||||
#define __XDisplay_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "XAtom.h"
|
||||
#include "XScreen.h"
|
||||
|
||||
class XDisplay {
|
||||
friend XAtom::XAtom(const XDisplay *);
|
||||
friend XScreen::XScreen(const XDisplay *, const unsigned int);
|
||||
|
||||
private:
|
||||
Display *_display;
|
||||
std::string _name;
|
||||
unsigned int _grabs;
|
||||
bool _hasshape;
|
||||
int _shape_event_base;
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
// the server's values for the lock key modifiers
|
||||
void getLockModifiers();
|
||||
unsigned int MaskList[8];
|
||||
// the masks of the modifiers which are ignored in button events.
|
||||
int NumLockMask, ScrollLockMask;
|
||||
#endif // NOCLOBBER
|
||||
|
||||
|
||||
// X error handling
|
||||
static int errorHandler(Display *d, XErrorEvent *e);
|
||||
static std::string _app_name;
|
||||
static Window _last_bad_window;
|
||||
|
||||
// no copying!!
|
||||
XDisplay(const XDisplay &);
|
||||
XDisplay& operator=(const XDisplay&);
|
||||
|
||||
protected:
|
||||
virtual void process_event(XEvent *) = 0;
|
||||
|
||||
public:
|
||||
XDisplay(const std::string &application_name, const char *dpyname = 0);
|
||||
virtual ~XDisplay();
|
||||
|
||||
inline virtual unsigned int screenCount() const
|
||||
{ return ScreenCount(_display); }
|
||||
|
||||
inline bool hasShape() const { return _hasshape; }
|
||||
inline int shapeEventBase() const { return _shape_event_base; }
|
||||
|
||||
//inline Display *display() const { return _display; }
|
||||
|
||||
inline std::string applicationName() const { return _app_name; }
|
||||
inline std::string name() const { return _name; }
|
||||
|
||||
void grab();
|
||||
void ungrab();
|
||||
|
||||
bool nextEvent(XEvent &e);
|
||||
|
||||
int connectionNumber() const;
|
||||
|
||||
Cursor createCursor(unsigned int shape) const;
|
||||
|
||||
unsigned int stripModifiers(const unsigned int state) const;
|
||||
|
||||
// these belong in Xwindow
|
||||
const bool validateWindow(Window);
|
||||
void grabButton(unsigned int, unsigned int, Window, Bool, unsigned int, int,
|
||||
int, Window, Cursor) const;
|
||||
void ungrabButton(unsigned int button, unsigned int modifiers,
|
||||
Window grab_window) const;
|
||||
};
|
||||
|
||||
#endif // _XDisplay_h
|
|
@ -1,86 +0,0 @@
|
|||
// XScreen.cc for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include "XScreen.h"
|
||||
#include "XDisplay.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
XScreen::XScreen(const XDisplay *display, const unsigned int number) {
|
||||
_display = display->_display;
|
||||
_number = number;
|
||||
|
||||
_root = RootWindow(_display, _number);
|
||||
_size = Size(WidthOfScreen(ScreenOfDisplay(_display, _number)),
|
||||
HeightOfScreen(ScreenOfDisplay(_display, _number)));
|
||||
setColorData();
|
||||
}
|
||||
|
||||
|
||||
XScreen::~XScreen() {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This sets up the _depth, _visual, and _colormap properties.
|
||||
*/
|
||||
void XScreen::setColorData() {
|
||||
_depth = DefaultDepth(_display, _number);
|
||||
_visual = (Visual *) 0;
|
||||
|
||||
// search for a TrueColor Visual. If we can't find one, use the default
|
||||
// visual for the screen
|
||||
XVisualInfo vinfo_template, *vinfo_return;
|
||||
int vinfo_nitems;
|
||||
|
||||
vinfo_template.screen = _number;
|
||||
vinfo_template.c_class = TrueColor;
|
||||
|
||||
vinfo_return = XGetVisualInfo(_display, VisualScreenMask | VisualClassMask,
|
||||
&vinfo_template, &vinfo_nitems);
|
||||
if (vinfo_return && vinfo_nitems > 0) {
|
||||
for (int i = 0; i < vinfo_nitems; i++)
|
||||
if (_depth < (vinfo_return + i)->depth) {
|
||||
_depth = (vinfo_return + i)->depth;
|
||||
_visual = (vinfo_return + i)->visual;
|
||||
}
|
||||
XFree(vinfo_return);
|
||||
}
|
||||
if (_visual)
|
||||
_colormap = XCreateColormap(_display, _root, _visual, AllocNone);
|
||||
else {
|
||||
_visual = DefaultVisual(_display, _number);
|
||||
_colormap = DefaultColormap(_display, _number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creates a window on screen.
|
||||
*/
|
||||
Window createWindow(Window parent, const Rect &area, int borderw,
|
||||
unsigned int winclass, unsigned long attrib_mask,
|
||||
XSetWindowAttributes *attrib) const {
|
||||
return XCreateWindow(_display, parent,
|
||||
area.x(), area.y(), area.w(), area.h(),
|
||||
borderw, depth(), winclass, visual(),
|
||||
attrib_mask, attrib);
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
// XScreen.h for Openbox
|
||||
// Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __XScreen_h
|
||||
#define __XScreen_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include "Geometry.h"
|
||||
|
||||
class XDisplay;
|
||||
|
||||
class XScreen {
|
||||
private:
|
||||
Display *_display;
|
||||
unsigned int _number;
|
||||
Visual *_visual;
|
||||
Window _root;
|
||||
Colormap _colormap;
|
||||
int _depth;
|
||||
Size _size;
|
||||
|
||||
void setColorData();
|
||||
|
||||
// no copying!!
|
||||
XScreen(const XScreen &);
|
||||
XScreen& operator=(const XScreen&);
|
||||
|
||||
public:
|
||||
XScreen(const XDisplay *display, const unsigned int number);
|
||||
virtual ~XScreen();
|
||||
|
||||
inline Visual *visual() const { return _visual; }
|
||||
inline Window rootWindow() const { return _root; }
|
||||
inline Colormap colormap() const { return _colormap; }
|
||||
inline unsigned int depth() const { return _depth; }
|
||||
inline unsigned int number() const { return _number; }
|
||||
inline const Size &size() const { return _size; }
|
||||
|
||||
Window createWindow(Window parent, const Rect &area, int borderw,
|
||||
unsigned int winclass,
|
||||
unsigned long attrib_mask,
|
||||
XSetWindowAttributes *attrib) const;
|
||||
};
|
||||
|
||||
#endif // __XScreen_h
|
1680
src/blackbox.cc
Normal file
1680
src/blackbox.cc
Normal file
File diff suppressed because it is too large
Load diff
410
src/blackbox.hh
Normal file
410
src/blackbox.hh
Normal file
|
@ -0,0 +1,410 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// blackbox.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __blackbox_hh
|
||||
#define __blackbox_hh
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "i18n.hh"
|
||||
#include "BaseDisplay.hh"
|
||||
#include "Timer.hh"
|
||||
|
||||
#define AttribShaded (1l << 0)
|
||||
#define AttribMaxHoriz (1l << 1)
|
||||
#define AttribMaxVert (1l << 2)
|
||||
#define AttribOmnipresent (1l << 3)
|
||||
#define AttribWorkspace (1l << 4)
|
||||
#define AttribStack (1l << 5)
|
||||
#define AttribDecoration (1l << 6)
|
||||
|
||||
#define StackTop (0)
|
||||
#define StackNormal (1)
|
||||
#define StackBottom (2)
|
||||
|
||||
#define DecorNone (0)
|
||||
#define DecorNormal (1)
|
||||
#define DecorTiny (2)
|
||||
#define DecorTool (3)
|
||||
|
||||
struct BlackboxHints {
|
||||
unsigned long flags, attrib, workspace, stack, decoration;
|
||||
};
|
||||
|
||||
struct BlackboxAttributes {
|
||||
unsigned long flags, attrib, workspace, stack, decoration;
|
||||
int premax_x, premax_y;
|
||||
unsigned int premax_w, premax_h;
|
||||
};
|
||||
|
||||
#define PropBlackboxHintsElements (5)
|
||||
#define PropBlackboxAttributesElements (9)
|
||||
|
||||
|
||||
//forward declaration
|
||||
class BScreen;
|
||||
class Blackbox;
|
||||
class BlackboxWindow;
|
||||
class BWindowGroup;
|
||||
class Basemenu;
|
||||
class Toolbar;
|
||||
class Slit;
|
||||
|
||||
extern I18n i18n;
|
||||
|
||||
class Blackbox : public BaseDisplay, public TimeoutHandler {
|
||||
private:
|
||||
struct BCursor {
|
||||
Cursor session, move, ll_angle, lr_angle;
|
||||
};
|
||||
BCursor cursor;
|
||||
|
||||
struct MenuTimestamp {
|
||||
std::string filename;
|
||||
time_t timestamp;
|
||||
};
|
||||
|
||||
struct BResource {
|
||||
Time double_click_interval;
|
||||
|
||||
std::string menu_file, style_file;
|
||||
int colors_per_channel;
|
||||
timeval auto_raise_delay;
|
||||
unsigned long cache_life, cache_max;
|
||||
} resource;
|
||||
|
||||
typedef std::map<Window, BlackboxWindow*> WindowLookup;
|
||||
typedef WindowLookup::value_type WindowLookupPair;
|
||||
WindowLookup windowSearchList;
|
||||
|
||||
typedef std::map<Window, BWindowGroup*> GroupLookup;
|
||||
typedef GroupLookup::value_type GroupLookupPair;
|
||||
GroupLookup groupSearchList;
|
||||
|
||||
typedef std::map<Window, Basemenu*> MenuLookup;
|
||||
typedef MenuLookup::value_type MenuLookupPair;
|
||||
MenuLookup menuSearchList;
|
||||
|
||||
typedef std::map<Window, Toolbar*> ToolbarLookup;
|
||||
typedef ToolbarLookup::value_type ToolbarLookupPair;
|
||||
ToolbarLookup toolbarSearchList;
|
||||
|
||||
typedef std::map<Window, Slit*> SlitLookup;
|
||||
typedef SlitLookup::value_type SlitLookupPair;
|
||||
SlitLookup slitSearchList;
|
||||
|
||||
typedef std::list<MenuTimestamp*> MenuTimestampList;
|
||||
MenuTimestampList menuTimestamps;
|
||||
|
||||
typedef std::list<BScreen*> ScreenList;
|
||||
ScreenList screenList;
|
||||
|
||||
BScreen *active_screen;
|
||||
BlackboxWindow *focused_window;
|
||||
BTimer *timer;
|
||||
|
||||
bool no_focus, reconfigure_wait, reread_menu_wait;
|
||||
Time last_time;
|
||||
char **argv;
|
||||
std::string rc_file;
|
||||
|
||||
Atom xa_wm_colormap_windows, xa_wm_protocols, xa_wm_state,
|
||||
xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state,
|
||||
motif_wm_hints;
|
||||
|
||||
// NETAttributes
|
||||
Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints;
|
||||
#ifdef HAVE_GETPID
|
||||
Atom blackbox_pid;
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
// NETStructureMessages
|
||||
Atom blackbox_structure_messages, blackbox_notify_startup,
|
||||
blackbox_notify_window_add, blackbox_notify_window_del,
|
||||
blackbox_notify_window_focus, blackbox_notify_current_workspace,
|
||||
blackbox_notify_workspace_count, blackbox_notify_window_raise,
|
||||
blackbox_notify_window_lower;
|
||||
|
||||
// message_types for client -> wm messages
|
||||
Atom blackbox_change_workspace, blackbox_change_window_focus,
|
||||
blackbox_cycle_window_focus;
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
// root window properties
|
||||
Atom net_supported, net_client_list, net_client_list_stacking,
|
||||
net_number_of_desktops, net_desktop_geometry, net_desktop_viewport,
|
||||
net_current_desktop, net_desktop_names, net_active_window, net_workarea,
|
||||
net_supporting_wm_check, net_virtual_roots;
|
||||
|
||||
// root window messages
|
||||
Atom net_close_window, net_wm_moveresize;
|
||||
|
||||
// application window properties
|
||||
Atom net_properties, net_wm_name, net_wm_desktop, net_wm_window_type,
|
||||
net_wm_state, net_wm_strut, net_wm_icon_geometry, net_wm_icon, net_wm_pid,
|
||||
net_wm_handled_icons;
|
||||
|
||||
// application protocols
|
||||
Atom net_wm_ping;
|
||||
#endif // NEWWMSPEC
|
||||
|
||||
Blackbox(const Blackbox&);
|
||||
Blackbox& operator=(const Blackbox&);
|
||||
|
||||
void load_rc(void);
|
||||
void save_rc(void);
|
||||
void reload_rc(void);
|
||||
void real_rereadMenu(void);
|
||||
void real_reconfigure(void);
|
||||
|
||||
void init_icccm(void);
|
||||
|
||||
virtual void process_event(XEvent *);
|
||||
|
||||
|
||||
public:
|
||||
Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0);
|
||||
virtual ~Blackbox(void);
|
||||
|
||||
Basemenu *searchMenu(Window window);
|
||||
BWindowGroup *searchGroup(Window window);
|
||||
BlackboxWindow *searchWindow(Window window);
|
||||
BScreen *searchScreen(Window window);
|
||||
Toolbar *searchToolbar(Window);
|
||||
Slit *searchSlit(Window);
|
||||
|
||||
void saveMenuSearch(Window window, Basemenu *data);
|
||||
void saveWindowSearch(Window window, BlackboxWindow *data);
|
||||
void saveGroupSearch(Window window, BWindowGroup *data);
|
||||
void saveToolbarSearch(Window window, Toolbar *data);
|
||||
void saveSlitSearch(Window window, Slit *data);
|
||||
void removeMenuSearch(Window window);
|
||||
void removeWindowSearch(Window window);
|
||||
void removeGroupSearch(Window window);
|
||||
void removeToolbarSearch(Window window);
|
||||
void removeSlitSearch(Window window);
|
||||
|
||||
inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
|
||||
|
||||
inline const Time &getDoubleClickInterval(void) const
|
||||
{ return resource.double_click_interval; }
|
||||
inline const Time &getLastTime(void) const { return last_time; }
|
||||
|
||||
inline const char *getStyleFilename(void) const
|
||||
{ return resource.style_file.c_str(); }
|
||||
inline const char *getMenuFilename(void) const
|
||||
{ return resource.menu_file.c_str(); }
|
||||
|
||||
inline int getColorsPerChannel(void) const
|
||||
{ return resource.colors_per_channel; }
|
||||
|
||||
inline const timeval &getAutoRaiseDelay(void) const
|
||||
{ return resource.auto_raise_delay; }
|
||||
|
||||
inline unsigned long getCacheLife(void) const
|
||||
{ return resource.cache_life; }
|
||||
inline unsigned long getCacheMax(void) const
|
||||
{ return resource.cache_max; }
|
||||
|
||||
inline void setNoFocus(bool f) { no_focus = f; }
|
||||
|
||||
inline Cursor getSessionCursor(void) const
|
||||
{ return cursor.session; }
|
||||
inline Cursor getMoveCursor(void) const
|
||||
{ return cursor.move; }
|
||||
inline Cursor getLowerLeftAngleCursor(void) const
|
||||
{ return cursor.ll_angle; }
|
||||
inline Cursor getLowerRightAngleCursor(void) const
|
||||
{ return cursor.lr_angle; }
|
||||
|
||||
void setFocusedWindow(BlackboxWindow *w);
|
||||
void shutdown(void);
|
||||
void load_rc(BScreen *screen);
|
||||
void saveStyleFilename(const std::string& filename);
|
||||
void saveMenuFilename(const std::string& filename);
|
||||
void restart(const char *prog = 0);
|
||||
void reconfigure(void);
|
||||
void rereadMenu(void);
|
||||
void checkMenu(void);
|
||||
|
||||
bool validateWindow(Window window);
|
||||
|
||||
virtual bool handleSignal(int sig);
|
||||
|
||||
virtual void timeout(void);
|
||||
|
||||
#ifndef HAVE_STRFTIME
|
||||
enum { B_AmericanDate = 1, B_EuropeanDate };
|
||||
#endif // HAVE_STRFTIME
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
inline Atom getBlackboxPidAtom(void) const { return blackbox_pid; }
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
inline Atom getWMChangeStateAtom(void) const
|
||||
{ return xa_wm_change_state; }
|
||||
inline Atom getWMStateAtom(void) const
|
||||
{ return xa_wm_state; }
|
||||
inline Atom getWMDeleteAtom(void) const
|
||||
{ return xa_wm_delete_window; }
|
||||
inline Atom getWMProtocolsAtom(void) const
|
||||
{ return xa_wm_protocols; }
|
||||
inline Atom getWMTakeFocusAtom(void) const
|
||||
{ return xa_wm_take_focus; }
|
||||
inline Atom getWMColormapAtom(void) const
|
||||
{ return xa_wm_colormap_windows; }
|
||||
inline Atom getMotifWMHintsAtom(void) const
|
||||
{ return motif_wm_hints; }
|
||||
|
||||
// this atom is for normal app->WM hints about decorations, stacking,
|
||||
// starting workspace etc...
|
||||
inline Atom getBlackboxHintsAtom(void) const
|
||||
{ return blackbox_hints;}
|
||||
|
||||
// these atoms are for normal app->WM interaction beyond the scope of the
|
||||
// ICCCM...
|
||||
inline Atom getBlackboxAttributesAtom(void) const
|
||||
{ return blackbox_attributes; }
|
||||
inline Atom getBlackboxChangeAttributesAtom(void) const
|
||||
{ return blackbox_change_attributes; }
|
||||
|
||||
// these atoms are for window->WM interaction, with more control and
|
||||
// information on window "structure"... common examples are
|
||||
// notifying apps when windows are raised/lowered... when the user changes
|
||||
// workspaces... i.e. "pager talk"
|
||||
inline Atom getBlackboxStructureMessagesAtom(void) const
|
||||
{ return blackbox_structure_messages; }
|
||||
|
||||
// *Notify* portions of the NETStructureMessages protocol
|
||||
inline Atom getBlackboxNotifyStartupAtom(void) const
|
||||
{ return blackbox_notify_startup; }
|
||||
inline Atom getBlackboxNotifyWindowAddAtom(void) const
|
||||
{ return blackbox_notify_window_add; }
|
||||
inline Atom getBlackboxNotifyWindowDelAtom(void) const
|
||||
{ return blackbox_notify_window_del; }
|
||||
inline Atom getBlackboxNotifyWindowFocusAtom(void) const
|
||||
{ return blackbox_notify_window_focus; }
|
||||
inline Atom getBlackboxNotifyCurrentWorkspaceAtom(void) const
|
||||
{ return blackbox_notify_current_workspace; }
|
||||
inline Atom getBlackboxNotifyWorkspaceCountAtom(void) const
|
||||
{ return blackbox_notify_workspace_count; }
|
||||
inline Atom getBlackboxNotifyWindowRaiseAtom(void) const
|
||||
{ return blackbox_notify_window_raise; }
|
||||
inline Atom getBlackboxNotifyWindowLowerAtom(void) const
|
||||
{ return blackbox_notify_window_lower; }
|
||||
|
||||
// atoms to change that request changes to the desktop environment during
|
||||
// runtime... these messages can be sent by any client... as the sending
|
||||
// client window id is not included in the ClientMessage event...
|
||||
inline Atom getBlackboxChangeWorkspaceAtom(void) const
|
||||
{ return blackbox_change_workspace; }
|
||||
inline Atom getBlackboxChangeWindowFocusAtom(void) const
|
||||
{ return blackbox_change_window_focus; }
|
||||
inline Atom getBlackboxCycleWindowFocusAtom(void) const
|
||||
{ return blackbox_cycle_window_focus; }
|
||||
|
||||
#ifdef NEWWMSPEC
|
||||
// root window properties
|
||||
inline Atom getNETSupportedAtom(void) const
|
||||
{ return net_supported; }
|
||||
inline Atom getNETClientListAtom(void) const
|
||||
{ return net_client_list; }
|
||||
inline Atom getNETClientListStackingAtom(void) const
|
||||
{ return net_client_list_stacking; }
|
||||
inline Atom getNETNumberOfDesktopsAtom(void) const
|
||||
{ return net_number_of_desktops; }
|
||||
inline Atom getNETDesktopGeometryAtom(void) const
|
||||
{ return net_desktop_geometry; }
|
||||
inline Atom getNETDesktopViewportAtom(void) const
|
||||
{ return net_desktop_viewport; }
|
||||
inline Atom getNETCurrentDesktopAtom(void) const
|
||||
{ return net_current_desktop; }
|
||||
inline Atom getNETDesktopNamesAtom(void) const
|
||||
{ return net_desktop_names; }
|
||||
inline Atom getNETActiveWindowAtom(void) const
|
||||
{ return net_active_window; }
|
||||
inline Atom getNETWorkareaAtom(void) const
|
||||
{ return net_workarea; }
|
||||
inline Atom getNETSupportingWMCheckAtom(void) const
|
||||
{ return net_supporting_wm_check; }
|
||||
inline Atom getNETVirtualRootsAtom(void) const
|
||||
{ return net_virtual_roots; }
|
||||
|
||||
// root window messages
|
||||
inline Atom getNETCloseWindowAtom(void) const
|
||||
{ return net_close_window; }
|
||||
inline Atom getNETWMMoveResizeAtom(void) const
|
||||
{ return net_wm_moveresize; }
|
||||
|
||||
// application window properties
|
||||
inline Atom getNETPropertiesAtom(void) const
|
||||
{ return net_properties; }
|
||||
inline Atom getNETWMNameAtom(void) const
|
||||
{ return net_wm_name; }
|
||||
inline Atom getNETWMDesktopAtom(void) const
|
||||
{ return net_wm_desktop; }
|
||||
inline Atom getNETWMWindowTypeAtom(void) const
|
||||
{ return net_wm_window_type; }
|
||||
inline Atom getNETWMStateAtom(void) const
|
||||
{ return net_wm_state; }
|
||||
inline Atom getNETWMStrutAtom(void) const
|
||||
{ return net_wm_strut; }
|
||||
inline Atom getNETWMIconGeometryAtom(void) const
|
||||
{ return net_wm_icon_geometry; }
|
||||
inline Atom getNETWMIconAtom(void) const
|
||||
{ return net_wm_icon; }
|
||||
inline Atom getNETWMPidAtom(void) const
|
||||
{ return net_wm_pid; }
|
||||
inline Atom getNETWMHandledIconsAtom(void) const
|
||||
{ return net_wm_handled_icons; }
|
||||
|
||||
// application protocols
|
||||
inline Atom getNETWMPingAtom(void) const
|
||||
{ return net_wm_ping; }
|
||||
#endif // NEWWMSPEC
|
||||
};
|
||||
|
||||
|
||||
#endif // __blackbox_hh
|
|
@ -1,788 +0,0 @@
|
|||
/**************************************************************
|
||||
* Original:
|
||||
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
|
||||
* A bombproof version of doprnt (dopr) included.
|
||||
* Sigh. This sort of thing is always nasty do deal with. Note that
|
||||
* the version here does not include floating point...
|
||||
*
|
||||
* snprintf() is used instead of sprintf() as it does limit checks
|
||||
* for string length. This covers a nasty loophole.
|
||||
*
|
||||
* The other functions are there to prevent NULL pointers from
|
||||
* causing nast effects.
|
||||
*
|
||||
* More Recently:
|
||||
* Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43
|
||||
* This was ugly. It is still ugly. I opted out of floating point
|
||||
* numbers, but the formatter understands just about everything
|
||||
* from the normal C string format, at least as far as I can tell from
|
||||
* the Solaris 2.5 printf(3S) man page.
|
||||
*
|
||||
* Brandon Long <blong@fiction.net> 10/22/97 for mutt 0.87.1
|
||||
* Ok, added some minimal floating point support, which means this
|
||||
* probably requires libm on most operating systems. Don't yet
|
||||
* support the exponent (e,E) and sigfig (g,G). Also, fmtint()
|
||||
* was pretty badly broken, it just wasn't being exercised in ways
|
||||
* which showed it, so that's been fixed. Also, formated the code
|
||||
* to mutt conventions, and removed dead code left over from the
|
||||
* original. Also, there is now a builtin-test, just compile with:
|
||||
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
||||
* and run snprintf for results.
|
||||
*
|
||||
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
|
||||
* The PGP code was using unsigned hexadecimal formats.
|
||||
* Unfortunately, unsigned formats simply didn't work.
|
||||
*
|
||||
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
|
||||
* The original code assumed that both snprintf() and vsnprintf() were
|
||||
* missing. Some systems only have snprintf() but not vsnprintf(), so
|
||||
* the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
|
||||
|
||||
#include <string.h>
|
||||
# include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Define this as a fall through, HAVE_STDARG_H is probably already set */
|
||||
|
||||
#define HAVE_VARARGS_H
|
||||
|
||||
/* varargs declarations: */
|
||||
|
||||
#if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap, f)
|
||||
# define VA_SHIFT(v,t) ; /* no-op for ANSI */
|
||||
# define VA_END va_end(ap)
|
||||
#else
|
||||
# if defined(HAVE_VARARGS_H)
|
||||
# include <varargs.h>
|
||||
# undef HAVE_STDARGS
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap) /* f is ignored! */
|
||||
# define VA_SHIFT(v,t) v = va_arg(ap,t)
|
||||
# define VA_END va_end(ap)
|
||||
# else
|
||||
/*XX ** NO VARARGS ** XX*/
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*int snprintf (char *str, size_t count, const char *fmt, ...);*/
|
||||
/*int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);*/
|
||||
|
||||
static void dopr (char *buffer, size_t maxlen, const char *format,
|
||||
va_list args);
|
||||
static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max);
|
||||
static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags);
|
||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long double fvalue, int min, int max, int flags);
|
||||
static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
|
||||
|
||||
/*
|
||||
* dopr(): poor man's version of doprintf
|
||||
*/
|
||||
|
||||
/* format read states */
|
||||
#define DP_S_DEFAULT 0
|
||||
#define DP_S_FLAGS 1
|
||||
#define DP_S_MIN 2
|
||||
#define DP_S_DOT 3
|
||||
#define DP_S_MAX 4
|
||||
#define DP_S_MOD 5
|
||||
#define DP_S_CONV 6
|
||||
#define DP_S_DONE 7
|
||||
|
||||
/* format flags - Bits */
|
||||
#define DP_F_MINUS (1 << 0)
|
||||
#define DP_F_PLUS (1 << 1)
|
||||
#define DP_F_SPACE (1 << 2)
|
||||
#define DP_F_NUM (1 << 3)
|
||||
#define DP_F_ZERO (1 << 4)
|
||||
#define DP_F_UP (1 << 5)
|
||||
#define DP_F_UNSIGNED (1 << 6)
|
||||
|
||||
/* Conversion Flags */
|
||||
#define DP_C_SHORT 1
|
||||
#define DP_C_LONG 2
|
||||
#define DP_C_LDOUBLE 3
|
||||
|
||||
#define char_to_int(p) (p - '0')
|
||||
#define MAX(p,q) ((p >= q) ? p : q)
|
||||
|
||||
static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
{
|
||||
char ch;
|
||||
long value;
|
||||
long double fvalue;
|
||||
char *strvalue;
|
||||
int min;
|
||||
int max;
|
||||
int state;
|
||||
int flags;
|
||||
int cflags;
|
||||
size_t currlen;
|
||||
|
||||
state = DP_S_DEFAULT;
|
||||
currlen = flags = cflags = min = 0;
|
||||
max = -1;
|
||||
ch = *format++;
|
||||
|
||||
while (state != DP_S_DONE)
|
||||
{
|
||||
if ((ch == '\0') || (currlen >= maxlen))
|
||||
state = DP_S_DONE;
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case DP_S_DEFAULT:
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
dopr_outch (buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
switch (ch)
|
||||
{
|
||||
case '-':
|
||||
flags |= DP_F_MINUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '+':
|
||||
flags |= DP_F_PLUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case ' ':
|
||||
flags |= DP_F_SPACE;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '#':
|
||||
flags |= DP_F_NUM;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '0':
|
||||
flags |= DP_F_ZERO;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
state = DP_S_MIN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DP_S_MIN:
|
||||
if (isdigit((unsigned char)ch))
|
||||
{
|
||||
min = 10*min + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
min = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_DOT;
|
||||
}
|
||||
else
|
||||
state = DP_S_DOT;
|
||||
break;
|
||||
case DP_S_DOT:
|
||||
if (ch == '.')
|
||||
{
|
||||
state = DP_S_MAX;
|
||||
ch = *format++;
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MAX:
|
||||
if (isdigit((unsigned char)ch))
|
||||
{
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
max = 10*max + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
max = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_MOD;
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MOD:
|
||||
/* Currently, we don't support Long Long, bummer */
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
cflags = DP_C_SHORT;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'l':
|
||||
cflags = DP_C_LONG;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'L':
|
||||
cflags = DP_C_LDOUBLE;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
state = DP_S_CONV;
|
||||
break;
|
||||
case DP_S_CONV:
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, long int);
|
||||
else
|
||||
value = va_arg (args, int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
break;
|
||||
case 'o':
|
||||
flags |= DP_F_UNSIGNED;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
|
||||
break;
|
||||
case 'u':
|
||||
flags |= DP_F_UNSIGNED;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
break;
|
||||
case 'X':
|
||||
flags |= DP_F_UP;
|
||||
case 'x':
|
||||
flags |= DP_F_UNSIGNED;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned short int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
|
||||
break;
|
||||
case 'f':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
/* um, floating point? */
|
||||
fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
|
||||
break;
|
||||
case 'E':
|
||||
flags |= DP_F_UP;
|
||||
case 'e':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
break;
|
||||
case 'G':
|
||||
flags |= DP_F_UP;
|
||||
case 'g':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
break;
|
||||
case 'c':
|
||||
dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg (args, char *);
|
||||
if (max < 0)
|
||||
max = maxlen; /* ie, no max */
|
||||
fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
|
||||
break;
|
||||
case 'p':
|
||||
strvalue = va_arg (args, void *);
|
||||
fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
|
||||
break;
|
||||
case 'n':
|
||||
if (cflags == DP_C_SHORT)
|
||||
{
|
||||
short int *num;
|
||||
num = va_arg (args, short int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else if (cflags == DP_C_LONG)
|
||||
{
|
||||
long int *num;
|
||||
num = va_arg (args, long int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
int *num;
|
||||
num = va_arg (args, int *);
|
||||
*num = currlen;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
dopr_outch (buffer, &currlen, maxlen, ch);
|
||||
break;
|
||||
case 'w':
|
||||
/* not supported yet, treat as next char */
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
/* Unknown, skip */
|
||||
break;
|
||||
}
|
||||
ch = *format++;
|
||||
state = DP_S_DEFAULT;
|
||||
flags = cflags = min = 0;
|
||||
max = -1;
|
||||
break;
|
||||
case DP_S_DONE:
|
||||
break;
|
||||
default:
|
||||
/* hmm? */
|
||||
break; /* some picky compilers need this */
|
||||
}
|
||||
}
|
||||
if (currlen < maxlen - 1)
|
||||
buffer[currlen] = '\0';
|
||||
else
|
||||
buffer[maxlen - 1] = '\0';
|
||||
}
|
||||
|
||||
static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max)
|
||||
{
|
||||
int padlen, strln; /* amount to pad */
|
||||
int cnt = 0;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
value = "<NULL>";
|
||||
}
|
||||
|
||||
for (strln = 0; value[strln]; ++strln); /* strlen */
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justify */
|
||||
|
||||
while ((padlen > 0) && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
++cnt;
|
||||
}
|
||||
while (*value && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, *value++);
|
||||
++cnt;
|
||||
}
|
||||
while ((padlen < 0) && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
||||
|
||||
static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
unsigned long uvalue;
|
||||
char convert[20];
|
||||
int place = 0;
|
||||
int spadlen = 0; /* amount to space pad */
|
||||
int zpadlen = 0; /* amount to zero pad */
|
||||
int caps = 0;
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
uvalue = value;
|
||||
|
||||
if(!(flags & DP_F_UNSIGNED))
|
||||
{
|
||||
if( value < 0 ) {
|
||||
signvalue = '-';
|
||||
uvalue = -value;
|
||||
}
|
||||
else
|
||||
if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else
|
||||
if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
}
|
||||
|
||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||
|
||||
do {
|
||||
convert[place++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")
|
||||
[uvalue % (unsigned)base ];
|
||||
uvalue = (uvalue / (unsigned)base );
|
||||
} while(uvalue && (place < 20));
|
||||
if (place == 20) place--;
|
||||
convert[place] = 0;
|
||||
|
||||
zpadlen = max - place;
|
||||
spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
|
||||
if (zpadlen < 0) zpadlen = 0;
|
||||
if (spadlen < 0) spadlen = 0;
|
||||
if (flags & DP_F_ZERO)
|
||||
{
|
||||
zpadlen = MAX(zpadlen, spadlen);
|
||||
spadlen = 0;
|
||||
}
|
||||
if (flags & DP_F_MINUS)
|
||||
spadlen = -spadlen; /* Left Justifty */
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
|
||||
zpadlen, spadlen, min, max, place));
|
||||
#endif
|
||||
|
||||
/* Spaces */
|
||||
while (spadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* Sign */
|
||||
if (signvalue)
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
/* Zeros */
|
||||
if (zpadlen > 0)
|
||||
{
|
||||
while (zpadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
}
|
||||
|
||||
/* Digits */
|
||||
while (place > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, convert[--place]);
|
||||
|
||||
/* Left Justified spaces */
|
||||
while (spadlen < 0) {
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++spadlen;
|
||||
}
|
||||
}
|
||||
|
||||
static long double abs_val (long double value)
|
||||
{
|
||||
long double result = value;
|
||||
|
||||
if (value < 0)
|
||||
result = -value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static long double pow10 (int exp)
|
||||
{
|
||||
long double result = 1;
|
||||
|
||||
while (exp)
|
||||
{
|
||||
result *= 10;
|
||||
exp--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static long round (long double value)
|
||||
{
|
||||
long intpart;
|
||||
|
||||
intpart = value;
|
||||
value = value - intpart;
|
||||
if (value >= 0.5)
|
||||
intpart++;
|
||||
|
||||
return intpart;
|
||||
}
|
||||
|
||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long double fvalue, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
long double ufvalue;
|
||||
char iconvert[20];
|
||||
char fconvert[20];
|
||||
int iplace = 0;
|
||||
int fplace = 0;
|
||||
int padlen = 0; /* amount to pad */
|
||||
int zpadlen = 0;
|
||||
int caps = 0;
|
||||
long intpart;
|
||||
long fracpart;
|
||||
|
||||
/*
|
||||
* AIX manpage says the default is 0, but Solaris says the default
|
||||
* is 6, and sprintf on AIX defaults to 6
|
||||
*/
|
||||
if (max < 0)
|
||||
max = 6;
|
||||
|
||||
ufvalue = abs_val (fvalue);
|
||||
|
||||
if (fvalue < 0)
|
||||
signvalue = '-';
|
||||
else
|
||||
if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else
|
||||
if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
|
||||
#if 0
|
||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||
#endif
|
||||
|
||||
intpart = ufvalue;
|
||||
|
||||
/*
|
||||
* Sorry, we only support 9 digits past the decimal because of our
|
||||
* conversion method
|
||||
*/
|
||||
if (max > 9)
|
||||
max = 9;
|
||||
|
||||
/* We "cheat" by converting the fractional part to integer by
|
||||
* multiplying by a factor of 10
|
||||
*/
|
||||
fracpart = round ((pow10 (max)) * (ufvalue - intpart));
|
||||
|
||||
if (fracpart >= pow10 (max))
|
||||
{
|
||||
intpart++;
|
||||
fracpart -= pow10 (max);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
|
||||
#endif
|
||||
|
||||
/* Convert integer part */
|
||||
do {
|
||||
iconvert[iplace++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
|
||||
intpart = (intpart / 10);
|
||||
} while(intpart && (iplace < 20));
|
||||
if (iplace == 20) iplace--;
|
||||
iconvert[iplace] = 0;
|
||||
|
||||
/* Convert fractional part */
|
||||
do {
|
||||
fconvert[fplace++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
|
||||
fracpart = (fracpart / 10);
|
||||
} while(fracpart && (fplace < 20));
|
||||
if (fplace == 20) fplace--;
|
||||
fconvert[fplace] = 0;
|
||||
|
||||
/* -1 for decimal point, another -1 if we are printing a sign */
|
||||
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
|
||||
zpadlen = max - fplace;
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justifty */
|
||||
|
||||
if ((flags & DP_F_ZERO) && (padlen > 0))
|
||||
{
|
||||
if (signvalue)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
--padlen;
|
||||
signvalue = 0;
|
||||
}
|
||||
while (padlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--padlen;
|
||||
}
|
||||
}
|
||||
while (padlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
while (iplace > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
|
||||
/*
|
||||
* Decimal point. This should probably use locale to find the correct
|
||||
* char to print out.
|
||||
*/
|
||||
dopr_outch (buffer, currlen, maxlen, '.');
|
||||
|
||||
while (fplace > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
|
||||
while (zpadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (padlen < 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
}
|
||||
}
|
||||
|
||||
static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
|
||||
{
|
||||
if (*currlen < maxlen)
|
||||
buffer[(*currlen)++] = c;
|
||||
}
|
||||
#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
|
||||
{
|
||||
str[0] = 0;
|
||||
dopr(str, count, fmt, args);
|
||||
return(strlen(str));
|
||||
}
|
||||
#endif /* !HAVE_VSNPRINTF */
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
/* VARARGS3 */
|
||||
#ifdef HAVE_STDARGS
|
||||
int snprintf (char *str,size_t count,const char *fmt,...)
|
||||
#else
|
||||
int snprintf (va_alist) va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef HAVE_STDARGS
|
||||
char *str;
|
||||
size_t count;
|
||||
char *fmt;
|
||||
#endif
|
||||
VA_LOCAL_DECL;
|
||||
|
||||
VA_START (fmt);
|
||||
VA_SHIFT (str, char *);
|
||||
VA_SHIFT (count, size_t );
|
||||
VA_SHIFT (fmt, char *);
|
||||
(void) vsnprintf(str, count, fmt, ap);
|
||||
VA_END;
|
||||
return(strlen(str));
|
||||
}
|
||||
|
||||
#ifdef TEST_SNPRINTF
|
||||
#ifndef LONG_STRING
|
||||
#define LONG_STRING 1024
|
||||
#endif
|
||||
int main (void)
|
||||
{
|
||||
char buf1[LONG_STRING];
|
||||
char buf2[LONG_STRING];
|
||||
char *fp_fmt[] = {
|
||||
"%-1.5f",
|
||||
"%1.5f",
|
||||
"%123.9f",
|
||||
"%10.5f",
|
||||
"% 10.5f",
|
||||
"%+22.9f",
|
||||
"%+4.9f",
|
||||
"%01.3f",
|
||||
"%4f",
|
||||
"%3.1f",
|
||||
"%3.2f",
|
||||
NULL
|
||||
};
|
||||
double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
|
||||
0.9996, 1.996, 4.136, 0};
|
||||
char *int_fmt[] = {
|
||||
"%-1.5d",
|
||||
"%1.5d",
|
||||
"%123.9d",
|
||||
"%5.5d",
|
||||
"%10.5d",
|
||||
"% 10.5d",
|
||||
"%+22.33d",
|
||||
"%01.3d",
|
||||
"%4d",
|
||||
NULL
|
||||
};
|
||||
long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
|
||||
int x, y;
|
||||
int fail = 0;
|
||||
int num = 0;
|
||||
|
||||
printf ("Testing snprintf format codes against system sprintf...\n");
|
||||
|
||||
for (x = 0; fp_fmt[x] != NULL ; x++)
|
||||
for (y = 0; fp_nums[y] != 0 ; y++)
|
||||
{
|
||||
snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
|
||||
sprintf (buf2, fp_fmt[x], fp_nums[y]);
|
||||
if (strcmp (buf1, buf2))
|
||||
{
|
||||
printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
fp_fmt[x], buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
for (x = 0; int_fmt[x] != NULL ; x++)
|
||||
for (y = 0; int_nums[y] != 0 ; y++)
|
||||
{
|
||||
snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
|
||||
sprintf (buf2, int_fmt[x], int_nums[y]);
|
||||
if (strcmp (buf1, buf2))
|
||||
{
|
||||
printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
int_fmt[x], buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
printf ("%d tests failed out of %d.\n", fail, num);
|
||||
}
|
||||
#endif /* SNPRINTF_TEST */
|
||||
|
||||
#endif /* !HAVE_SNPRINTF */
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef _BSD_SNPRINTF_H
|
||||
#define _BSD_SNPRINTF_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h> /* For size_t */
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf(char *str, size_t count, const char *fmt, ...);
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
|
||||
|
||||
#endif /* _BSD_SNPRINTF_H */
|
37
src/i18n.cc
37
src/i18n.cc
|
@ -1,5 +1,5 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
||||
// i18n.cc for Openbox
|
||||
// i18n.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
|
@ -46,11 +46,17 @@ extern "C" {
|
|||
}
|
||||
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
#include "i18n.h"
|
||||
#include "i18n.hh"
|
||||
|
||||
I18n::I18n(const char *catalog) {
|
||||
mb = false;
|
||||
|
||||
// the rest of bb source uses True and False from X, so we continue that
|
||||
#define True true
|
||||
#define False false
|
||||
|
||||
I18n::I18n(void) {
|
||||
mb = False;
|
||||
#ifdef HAVE_SETLOCALE
|
||||
locale = setlocale(LC_ALL, "");
|
||||
if (! locale) {
|
||||
|
@ -61,7 +67,7 @@ I18n::I18n(const char *catalog) {
|
|||
} else {
|
||||
// MB_CUR_MAX returns the size of a char in the current locale
|
||||
if (MB_CUR_MAX > 1)
|
||||
mb = true;
|
||||
mb = True;
|
||||
// truncate any encoding off the end of the locale
|
||||
char *l = strchr(locale, '@');
|
||||
if (l) *l = '\0';
|
||||
|
@ -73,12 +79,10 @@ I18n::I18n(const char *catalog) {
|
|||
catalog_fd = (nl_catd) -1;
|
||||
#endif
|
||||
#endif // HAVE_SETLOCALE
|
||||
if (catalog)
|
||||
openCatalog(catalog);
|
||||
}
|
||||
|
||||
|
||||
I18n::~I18n() {
|
||||
I18n::~I18n(void) {
|
||||
#if defined(NLS) && defined(HAVE_CATCLOSE)
|
||||
if (catalog_fd != (nl_catd) -1)
|
||||
catclose(catalog_fd);
|
||||
|
@ -86,9 +90,9 @@ I18n::~I18n() {
|
|||
}
|
||||
|
||||
|
||||
#if defined(NLS) && defined(HAVE_CATOPEN)
|
||||
void I18n::openCatalog(const char *catalog) {
|
||||
std::string catalog_filename = LOCALEPATH;
|
||||
#if defined(NLS) && defined(HAVE_CATOPEN)
|
||||
string catalog_filename = LOCALEPATH;
|
||||
catalog_filename += '/';
|
||||
catalog_filename += locale;
|
||||
catalog_filename += '/';
|
||||
|
@ -102,21 +106,14 @@ void I18n::openCatalog(const char *catalog) {
|
|||
|
||||
if (catalog_fd == (nl_catd) -1)
|
||||
fprintf(stderr, "failed to open catalog, using default messages\n");
|
||||
}
|
||||
#else
|
||||
void I18n::openCatalog(const char *) {
|
||||
}
|
||||
#endif // HAVE_CATOPEN
|
||||
}
|
||||
|
||||
#if defined(NLS) && defined(HAVE_CATGETS)
|
||||
const char* I18n::operator()(int set, int msg, const char *msgString) const {
|
||||
#if defined(NLS) && defined(HAVE_CATGETS)
|
||||
if (catalog_fd != (nl_catd) -1)
|
||||
return catgets(catalog_fd, set, msg, msgString);
|
||||
else
|
||||
#endif
|
||||
return msgString;
|
||||
}
|
||||
#else
|
||||
const char* I18n::operator()(int, int, const char *msgString) const {
|
||||
return msgString;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// i18n.hh for Openbox
|
||||
// i18n.hh for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
|
@ -27,7 +27,7 @@
|
|||
// always include this just for the #defines
|
||||
// this keeps the calls to i18n->getMessage clean, otherwise we have to
|
||||
// add ifdefs to every call to getMessage
|
||||
#include "../nls/openbox-nls.h"
|
||||
#include "../nls/blackbox-nls.hh"
|
||||
|
||||
extern "C" {
|
||||
#ifdef HAVE_LOCALE_H
|
||||
|
@ -49,8 +49,8 @@ private:
|
|||
#endif
|
||||
|
||||
public:
|
||||
I18n(const char *catalog = 0);
|
||||
~I18n();
|
||||
I18n(void);
|
||||
~I18n(void);
|
||||
|
||||
inline bool multibyte(void) const { return mb; }
|
||||
|
||||
|
@ -58,6 +58,6 @@ public:
|
|||
void openCatalog(const char *catalog);
|
||||
};
|
||||
|
||||
extern I18n i18n; // located in main.cc
|
||||
extern I18n i18n;
|
||||
|
||||
#endif // __i18n_h
|
125
src/main.cc
125
src/main.cc
|
@ -1,5 +1,6 @@
|
|||
// main.cc for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||
// main.cc for Blackbox - an X11 Window manager
|
||||
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -20,27 +21,22 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif // _GNU_SOURCE
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "../config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
extern "C" {
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif // HAVE_STDLIB_H
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif // HAVE_STRING_H
|
||||
|
||||
|
@ -51,83 +47,62 @@
|
|||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif // HAVE_SYS_PARAM_H
|
||||
}
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 255
|
||||
#endif // MAXPATHLEN
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
#include "openbox.h"
|
||||
#include "i18n.h"
|
||||
#include "i18n.hh"
|
||||
#include "blackbox.hh"
|
||||
|
||||
I18n i18n("openbox.cat");
|
||||
|
||||
I18n i18n; // initialized in main
|
||||
|
||||
static void showHelp(int exitval) {
|
||||
// print program usage and command line options
|
||||
printf(i18n(mainSet, mainUsage,
|
||||
"Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
|
||||
"\t\t\t 2001 - 2002 Sean 'Shaleh' Perry\n\n"
|
||||
"\t\t\t 1997 - 2000 Brad Hughes\n\n"
|
||||
"Blackbox %s : (c) 2001 - 2002 Sean 'Shaleh' Perry\n"
|
||||
"\t\t\t 1997 - 2000, 2002 Brad Hughes\n\n"
|
||||
" -display <string>\t\tuse display connection.\n"
|
||||
" -rc <string>\t\t\tuse alternate resource file.\n"
|
||||
" -menu <string>\t\t\tuse alternate menu file.\n"
|
||||
" -version\t\t\tdisplay version and exit.\n"
|
||||
" -help\t\t\t\tdisplay this help text and exit.\n\n"),
|
||||
__openbox_version);
|
||||
__blackbox_version);
|
||||
|
||||
// some people have requested that we print out compile options
|
||||
// as well
|
||||
fprintf(stdout,i18n(mainSet, mainCompileOptions,
|
||||
"Compile time options:\n"
|
||||
" Debugging:\t\t\t%s\n"
|
||||
" Interlacing:\t\t\t%s\n"
|
||||
" Shape:\t\t\t%s\n"
|
||||
" Slit:\t\t\t\t%s\n"
|
||||
" 8bpp Ordered Dithering:\t%s\n"
|
||||
" Event Clobbering:\t\t%s\n\n"),
|
||||
printf(i18n(mainSet, mainCompileOptions,
|
||||
"Compile time options:\n"
|
||||
" Debugging:\t\t\t%s\n"
|
||||
" Shape:\t\t\t%s\n"
|
||||
" 8bpp Ordered Dithering:\t%s\n\n"),
|
||||
#ifdef DEBUG
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
#else // !DEBUG
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
#endif // DEBUG
|
||||
|
||||
#ifdef INTERLACE
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
#else // !INTERLACE
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
#endif // INTERLACE
|
||||
|
||||
#ifdef SHAPE
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
#else // !SHAPE
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
#endif // SHAPE
|
||||
|
||||
#ifdef SLIT
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
#else // !SLIT
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
#endif // SLIT
|
||||
|
||||
#ifdef ORDEREDPSEUDO
|
||||
i18n(CommonSet, CommonYes, "yes"),
|
||||
i18n(CommonSet, CommonYes, "yes")
|
||||
#else // !ORDEREDPSEUDO
|
||||
i18n(CommonSet, CommonNo, "no"),
|
||||
i18n(CommonSet, CommonNo, "no")
|
||||
#endif // ORDEREDPSEUDO
|
||||
);
|
||||
|
||||
#ifndef NOCLOBBER
|
||||
i18n(CommonSet, CommonYes, "yes")
|
||||
#else // !NOCLOBBER
|
||||
i18n(CommonSet, CommonNo, "no")
|
||||
#endif // NOCLOBBER
|
||||
);
|
||||
|
||||
::exit(exitval);
|
||||
::exit(exitval);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char *session_display = (char *) 0;
|
||||
char *rc_file = (char *) 0;
|
||||
char *menu_file = (char *) 0;
|
||||
|
||||
i18n.openCatalog("blackbox.cat");
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (! strcmp(argv[i], "-rc")) {
|
||||
|
@ -136,24 +111,12 @@ int main(int argc, char **argv) {
|
|||
if ((++i) >= argc) {
|
||||
fprintf(stderr,
|
||||
i18n(mainSet, mainRCRequiresArg,
|
||||
"error: '-rc' requires and argument\n"));
|
||||
"error: '-rc' requires and argument\n"));
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
rc_file = argv[i];
|
||||
} else if (! strcmp(argv[i], "-menu")) {
|
||||
// look for alternative menu file to use
|
||||
|
||||
if ((++i) >= argc) {
|
||||
fprintf(stderr,
|
||||
i18n(mainSet, mainMENURequiresArg,
|
||||
"error: '-menu' requires and argument\n"));
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
menu_file = argv[i];
|
||||
} else if (! strcmp(argv[i], "-display")) {
|
||||
// check for -display option... to run on a display other than the one
|
||||
// set by the environment variable DISPLAY
|
||||
|
@ -161,27 +124,25 @@ int main(int argc, char **argv) {
|
|||
if ((++i) >= argc) {
|
||||
fprintf(stderr,
|
||||
i18n(mainSet, mainDISPLAYRequiresArg,
|
||||
"error: '-display' requires an argument\n"));
|
||||
"error: '-display' requires an argument\n"));
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
session_display = argv[i];
|
||||
char dtmp[MAXPATHLEN];
|
||||
sprintf(dtmp, "DISPLAY=%s", session_display);
|
||||
string dtmp = "DISPLAY=";
|
||||
dtmp += session_display;
|
||||
|
||||
if (putenv(dtmp)) {
|
||||
fprintf(stderr,
|
||||
i18n(mainSet, mainWarnDisplaySet,
|
||||
"warning: couldn't set environment variable 'DISPLAY'\n"));
|
||||
if (putenv(const_cast<char*>(dtmp.c_str()))) {
|
||||
fprintf(stderr, i18n(mainSet, mainWarnDisplaySet,
|
||||
"warning: couldn't set environment variable 'DISPLAY'\n"));
|
||||
perror("putenv()");
|
||||
}
|
||||
} else if (! strcmp(argv[i], "-version")) {
|
||||
// print current version string
|
||||
printf("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"
|
||||
"\t\t 2001 - 2002 Sean 'Shaleh' Perry\n"
|
||||
"\t\t 1997 - 2000 Brad Hughes\n",
|
||||
__openbox_version);
|
||||
printf("Blackbox %s : (c) 2001 - 2002 Sean 'Shaleh' Perry\n",
|
||||
"\t\t\t 1997 - 2000 Brad Hughes\n"
|
||||
__blackbox_version);
|
||||
|
||||
::exit(0);
|
||||
} else if (! strcmp(argv[i], "-help")) {
|
||||
|
@ -195,8 +156,8 @@ int main(int argc, char **argv) {
|
|||
_chdir2(getenv("X11ROOT"));
|
||||
#endif // __EMX__
|
||||
|
||||
Openbox openbox(argc, argv, session_display, rc_file, menu_file);
|
||||
openbox.eventLoop();
|
||||
Blackbox blackbox(argv, session_display, rc_file);
|
||||
blackbox.eventLoop();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
|
1109
src/openbox.cc
1109
src/openbox.cc
File diff suppressed because it is too large
Load diff
239
src/openbox.h
239
src/openbox.h
|
@ -1,239 +0,0 @@
|
|||
// openbox.h for Openbox
|
||||
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
|
||||
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef __openbox_hh
|
||||
#define __openbox_hh
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif // HAVE_STDIO_H
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else // !TIME_WITH_SYS_TIME
|
||||
# ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else // !HAVE_SYS_TIME_H
|
||||
# include <time.h>
|
||||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
|
||||
#include "Resource.h"
|
||||
#include "BaseDisplay.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
//forward declaration
|
||||
class BScreen;
|
||||
class Openbox;
|
||||
class BImageControl;
|
||||
class OpenboxWindow;
|
||||
class Basemenu;
|
||||
class Toolbar;
|
||||
#ifdef SLIT
|
||||
class Slit;
|
||||
#endif // SLIT
|
||||
|
||||
template <class Z>
|
||||
class DataSearch {
|
||||
private:
|
||||
Window window;
|
||||
Z *data;
|
||||
|
||||
public:
|
||||
DataSearch(Window w, Z *d): window(w), data(d) {}
|
||||
|
||||
inline const Window &getWindow() const { return window; }
|
||||
inline Z *getData() { return data; }
|
||||
};
|
||||
|
||||
|
||||
class Openbox : public BaseDisplay, public TimeoutHandler {
|
||||
private:
|
||||
typedef struct MenuTimestamp {
|
||||
virtual ~MenuTimestamp() {
|
||||
if (filename != (char *) 0)
|
||||
delete [] filename;
|
||||
}
|
||||
char *filename;
|
||||
time_t timestamp;
|
||||
} MenuTimestamp;
|
||||
|
||||
struct resource {
|
||||
Time double_click_interval;
|
||||
|
||||
char *style_file;
|
||||
char *titlebar_layout;
|
||||
int colors_per_channel;
|
||||
timeval auto_raise_delay;
|
||||
unsigned long cache_life, cache_max;
|
||||
} resource;
|
||||
|
||||
typedef std::map<Window, OpenboxWindow*> WindowLookup;
|
||||
typedef WindowLookup::value_type WindowLookupPair;
|
||||
WindowLookup windowSearchList, groupSearchList;
|
||||
|
||||
typedef std::map<Window, Basemenu*> MenuLookup;
|
||||
typedef MenuLookup::value_type MenuLookupPair;
|
||||
MenuLookup menuSearchList;
|
||||
|
||||
typedef std::map<Window, Toolbar*> ToolbarLookup;
|
||||
typedef ToolbarLookup::value_type ToolbarLookupPair;
|
||||
ToolbarLookup toolbarSearchList;
|
||||
|
||||
#ifdef SLIT
|
||||
typedef std::map<Window, Slit*> SlitLookup;
|
||||
typedef SlitLookup::value_type SlitLookupPair;
|
||||
SlitLookup slitSearchList;
|
||||
#endif // SLIT
|
||||
|
||||
typedef std::list<MenuTimestamp*> MenuTimestampList;
|
||||
MenuTimestampList menuTimestamps;
|
||||
|
||||
typedef std::vector<BScreen*> ScreenList;
|
||||
ScreenList screenList;
|
||||
|
||||
BScreen *current_screen;
|
||||
OpenboxWindow *masked_window;
|
||||
BTimer *timer;
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
Atom openbox_pid;
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
Bool no_focus, reconfigure_wait, reread_menu_wait;
|
||||
Time last_time;
|
||||
Window masked;
|
||||
char *menu_file, *rc_file, **argv;
|
||||
int argc;
|
||||
Resource config;
|
||||
|
||||
|
||||
protected:
|
||||
void load();
|
||||
void save();
|
||||
void real_rereadMenu();
|
||||
void real_reconfigure();
|
||||
|
||||
virtual void process_event(XEvent *);
|
||||
|
||||
|
||||
public:
|
||||
Openbox(int, char **, char * = 0, char * = 0, char * = 0);
|
||||
virtual ~Openbox();
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
inline const Atom &getOpenboxPidAtom() const { return openbox_pid; }
|
||||
#endif // HAVE_GETPID
|
||||
|
||||
Basemenu *searchMenu(Window);
|
||||
|
||||
OpenboxWindow *searchGroup(Window, OpenboxWindow *);
|
||||
OpenboxWindow *searchWindow(Window);
|
||||
OpenboxWindow *focusedWindow();
|
||||
void focusWindow(OpenboxWindow *w);
|
||||
|
||||
inline BScreen *getScreen(unsigned int s) {
|
||||
ASSERT(s < screenList.size());
|
||||
return screenList[s];
|
||||
}
|
||||
BScreen *searchScreen(Window);
|
||||
inline unsigned int managedScreenCount() const {
|
||||
return screenList.size();
|
||||
}
|
||||
|
||||
inline Resource &getConfig() {
|
||||
return config;
|
||||
}
|
||||
inline const Time &getDoubleClickInterval() const
|
||||
{ return resource.double_click_interval; }
|
||||
inline const Time &getLastTime() const { return last_time; }
|
||||
|
||||
Toolbar *searchToolbar(Window);
|
||||
|
||||
inline const char *getStyleFilename() const
|
||||
{ return resource.style_file; }
|
||||
inline const char *getMenuFilename() const
|
||||
{ return menu_file; }
|
||||
void addMenuTimestamp(const char *filename);
|
||||
|
||||
inline const int &getColorsPerChannel() const
|
||||
{ return resource.colors_per_channel; }
|
||||
|
||||
inline const timeval &getAutoRaiseDelay() const
|
||||
{ return resource.auto_raise_delay; }
|
||||
|
||||
inline const char *getTitleBarLayout() const
|
||||
{ return resource.titlebar_layout; }
|
||||
|
||||
inline const unsigned long &getCacheLife() const
|
||||
{ return resource.cache_life; }
|
||||
inline const unsigned long &getCacheMax() const
|
||||
{ return resource.cache_max; }
|
||||
|
||||
inline OpenboxWindow *getMaskedWindow() const
|
||||
{ return masked_window; }
|
||||
inline void maskWindowEvents(Window w, OpenboxWindow *bw)
|
||||
{ masked = w; masked_window = bw; }
|
||||
inline void setNoFocus(Bool f) { no_focus = f; }
|
||||
|
||||
void shutdown();
|
||||
void setStyleFilename(const char *);
|
||||
void saveMenuSearch(Window, Basemenu *);
|
||||
void saveWindowSearch(Window, OpenboxWindow *);
|
||||
void saveToolbarSearch(Window, Toolbar *);
|
||||
void saveGroupSearch(Window, OpenboxWindow *);
|
||||
void removeMenuSearch(Window);
|
||||
void removeWindowSearch(Window);
|
||||
void removeToolbarSearch(Window);
|
||||
void removeGroupSearch(Window);
|
||||
void restart(const char * = 0);
|
||||
void reconfigure();
|
||||
void rereadMenu();
|
||||
void checkMenu();
|
||||
|
||||
virtual Bool handleSignal(int);
|
||||
|
||||
virtual void timeout();
|
||||
|
||||
#ifdef SLIT
|
||||
Slit *searchSlit(Window);
|
||||
|
||||
void saveSlitSearch(Window, Slit *);
|
||||
void removeSlitSearch(Window);
|
||||
#endif // SLIT
|
||||
|
||||
#ifndef HAVE_STRFTIME
|
||||
|
||||
enum { B_AmericanDate = 1, B_EuropeanDate };
|
||||
#endif // HAVE_STRFTIME
|
||||
};
|
||||
|
||||
|
||||
#endif // __openbox_hh
|
Loading…
Reference in a new issue