merge the C branch into HEAD
This commit is contained in:
parent
8ba0586bcb
commit
f8a47de5ec
170 changed files with 21886 additions and 1416 deletions
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = po data doc otk wrap src scripts tools
|
||||
SUBDIRS = po data themes doc render kernel engines python
|
||||
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
|
||||
|
||||
.PHONY: doc
|
||||
|
|
14
README.CVS
14
README.CVS
|
@ -1,7 +1,6 @@
|
|||
To build Openbox from CVS you need:
|
||||
|
||||
A C++ Compiler (GNU GCC/G++ 3.2+ suggested, 2.9x is not supported as it is not
|
||||
very compliant with the ISO C++ standards)
|
||||
A C Compiler (GNU GCC 3.2+ suggested)
|
||||
GNU Gettext 0.11.5
|
||||
GNU Autoconf 2.50+
|
||||
GNU Automake 1.7.1+ (1.7.1 has a bug fix for py-compile)
|
||||
|
@ -9,7 +8,7 @@ GNU Libtool
|
|||
Xft2 library/headers (devel package) (http://www.fontconfig.org)
|
||||
Xlib library/headers (devel package)
|
||||
Python library/headers (devel package) (http://www.python.org)
|
||||
SWIG 1.3.14+ (http://www.swig.org)
|
||||
Pkg-Config
|
||||
|
||||
I recommend the latest version of all these packages.
|
||||
|
||||
|
@ -19,10 +18,6 @@ Do the following to build and install Openbox in CVS:
|
|||
% ./configure
|
||||
% make all install
|
||||
|
||||
When building the SWIG generated wrappers (*_wrap.cc), a huge number of
|
||||
compiler warnings will be generated. Don't be phased by this, it doesn't mean
|
||||
anything is broken unless you get an actual error.
|
||||
|
||||
Don't try running it from the src/ directory without installing, it won't work.
|
||||
It needs to be installed before it is run.
|
||||
|
||||
|
@ -32,15 +27,14 @@ The installed binary is 'openbox3'.
|
|||
|
||||
----
|
||||
Here's the packages from Debian (sid):
|
||||
g++
|
||||
gcc
|
||||
gettext
|
||||
automake1.7
|
||||
autoconf
|
||||
libtool
|
||||
pkg-config
|
||||
libxft2-dev
|
||||
python-dev
|
||||
swig1.3
|
||||
|
||||
|
||||
----
|
||||
Check out the Wiki for how to configure Openbox 3:
|
||||
|
|
|
@ -7,7 +7,7 @@ sh() {
|
|||
sh autopoint --force # for GNU gettext
|
||||
sh libtoolize --copy --force --automake
|
||||
sh aclocal -I m4
|
||||
sh autoheader
|
||||
#sh autoheader
|
||||
sh autoconf
|
||||
sh automake --foreign --include-deps --add-missing --copy
|
||||
|
||||
|
|
5
c/.cvsignore
Normal file
5
c/.cvsignore
Normal file
|
@ -0,0 +1,5 @@
|
|||
ob3
|
||||
Makefile.in
|
||||
.libs
|
||||
.deps
|
||||
Makefile
|
34
c/Makefile.am
Normal file
34
c/Makefile.am
Normal file
|
@ -0,0 +1,34 @@
|
|||
localedir=$(datadir)/locale
|
||||
scriptdir = $(libdir)/openbox/python
|
||||
|
||||
CPPFLAGS=$(PYTHON_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
-DSCRIPTDIR=\"$(scriptdir)\" \
|
||||
-DG_LOG_DOMAIN=\"Openbox\"
|
||||
|
||||
LIBS=$(PYTHON_LIBS) $(GLIB_LIBS) @LIBS@
|
||||
|
||||
bin_PROGRAMS= ob3
|
||||
|
||||
ob3_LDADD=@LIBINTL@
|
||||
ob3_LDFLAGS=-export-dynamic
|
||||
ob3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c prop.c \
|
||||
python.c screen.c stacking.c xerror.c hooks.c eventdata.c obexport.c \
|
||||
clientwrap.c screenwrap.c kbind.c mbind.c
|
||||
|
||||
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
||||
openbox.h prop.h python.h screen.h stacking.h xerror.h hooks.h \
|
||||
eventdata.h clientwrap.h obexport.h screenwrap.h kbind.h mbind.h
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
#if CVS
|
||||
#ob3.i: $(wildcard *.h)
|
||||
# @touch $@
|
||||
|
||||
#ob3_wrap.c: ob3.i
|
||||
# $(SWIG) $(SWIG_PYTHON_OPT) $(filter -I%,$(CPPFLAGS)) -o $@ $<
|
||||
#endif
|
||||
|
||||
distclean-local:
|
||||
$(RM) *\~ *.orig *.rej .\#*
|
1869
c/client.c
Normal file
1869
c/client.c
Normal file
File diff suppressed because it is too large
Load diff
401
c/client.h
Normal file
401
c/client.h
Normal file
|
@ -0,0 +1,401 @@
|
|||
#ifndef __client_h
|
||||
#define __client_h
|
||||
|
||||
#include "geom.h"
|
||||
#include "obexport.h"
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct ClientWrap;
|
||||
struct Frame;
|
||||
|
||||
|
||||
/*! Holds an icon in ARGB format */
|
||||
typedef struct Icon {
|
||||
unsigned long w, h;
|
||||
unsigned long *data;
|
||||
} Icon;
|
||||
|
||||
/*! The MWM Hints as retrieved from the window property
|
||||
This structure only contains 3 elements, even though the Motif 2.0
|
||||
structure contains 5. We only use the first 3, so that is all gets
|
||||
defined.
|
||||
*/
|
||||
typedef struct MwmHints {
|
||||
/*! A bitmask of Client::MwmFlags values */
|
||||
unsigned long flags;
|
||||
/*! A bitmask of Client::MwmFunctions values */
|
||||
unsigned long functions;
|
||||
/*! A bitmask of Client::MwmDecorations values */
|
||||
unsigned long decorations;
|
||||
} MwmHints;
|
||||
/*! The number of elements in the Client::MwmHints struct */
|
||||
#define MWM_ELEMENTS 3
|
||||
|
||||
/*! Possible flags for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmFlag_Functions = 1 << 0, /*!< The MMW Hints define funcs */
|
||||
MwmFlag_Decorations = 1 << 1 /*!< The MWM Hints define decor */
|
||||
} MwmFlags;
|
||||
|
||||
/*! Possible functions for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmFunc_All = 1 << 0, /*!< All functions */
|
||||
MwmFunc_Resize = 1 << 1, /*!< Allow resizing */
|
||||
MwmFunc_Move = 1 << 2, /*!< Allow moving */
|
||||
MwmFunc_Iconify = 1 << 3, /*!< Allow to be iconfied */
|
||||
MwmFunc_Maximize = 1 << 4 /*!< Allow to be maximized */
|
||||
/*MwmFunc_Close = 1 << 5 /!< Allow to be closed */
|
||||
} MwmFunctions;
|
||||
|
||||
/*! Possible decorations for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmDecor_All = 1 << 0, /*!< All decorations */
|
||||
MwmDecor_Border = 1 << 1, /*!< Show a border */
|
||||
MwmDecor_Handle = 1 << 2, /*!< Show a handle (bottom) */
|
||||
MwmDecor_Title = 1 << 3, /*!< Show a titlebar */
|
||||
/*MwmDecor_Menu = 1 << 4, /!< Show a menu */
|
||||
MwmDecor_Iconify = 1 << 5, /*!< Show an iconify button */
|
||||
MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */
|
||||
} MemDecorations;
|
||||
|
||||
|
||||
typedef struct Client {
|
||||
Window window;
|
||||
|
||||
struct Frame *frame;
|
||||
|
||||
/*! The number of unmap events to ignore on the window */
|
||||
int ignore_unmaps;
|
||||
|
||||
/*! The id of the group the window belongs to */
|
||||
Window group;
|
||||
/*! Whether or not the client is a transient window. This is guaranteed to
|
||||
be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
|
||||
transient_for == NULL. */
|
||||
gboolean transient;
|
||||
/*! The client which this client is a transient (child) for */
|
||||
struct Client *transient_for;
|
||||
/*! The clients which are transients (children) of this client */
|
||||
GSList *transients;
|
||||
/*! The desktop on which the window resides (0xffffffff for all
|
||||
desktops) */
|
||||
unsigned int desktop;
|
||||
|
||||
/*! Normal window title */
|
||||
gchar *title;
|
||||
/*! Window title when iconified */
|
||||
gchar *icon_title;
|
||||
|
||||
/*! The application that created the window */
|
||||
gchar *res_name;
|
||||
/*! The class of the window, can used for grouping */
|
||||
gchar *res_class;
|
||||
/*! The specified role of the window, used for identification */
|
||||
gchar *role;
|
||||
|
||||
/*! The type of window (what its function is) */
|
||||
WindowType type;
|
||||
|
||||
/*! Position and size of the window
|
||||
This will not always be the actual position of the window on screen, it
|
||||
is, rather, the position requested by the client, to which the window's
|
||||
gravity is applied.
|
||||
*/
|
||||
Rect area;
|
||||
|
||||
/*! The window's strut
|
||||
The strut defines areas of the screen that are marked off-bounds for
|
||||
window placement. In theory, where this window exists.
|
||||
*/
|
||||
Strut strut;
|
||||
|
||||
/*! The logical size of the window
|
||||
The "logical" size of the window is refers to the user's perception of
|
||||
the size of the window, and is the value that should be displayed to the
|
||||
user. For example, with xterms, this value it the number of characters
|
||||
being displayed in the terminal, instead of the number of pixels.
|
||||
*/
|
||||
Size logical_size;
|
||||
|
||||
/*! Width of the border on the window.
|
||||
The window manager will set this to 0 while the window is being managed,
|
||||
but needs to restore it afterwards, so it is saved here.
|
||||
*/
|
||||
guint border_width;
|
||||
|
||||
/*! The minimum aspect ratio the client window can be sized to.
|
||||
A value of 0 means this is ignored.
|
||||
*/
|
||||
float min_ratio;
|
||||
/*! The maximum aspect ratio the client window can be sized to.
|
||||
A value of 0 means this is ignored.
|
||||
*/
|
||||
float max_ratio;
|
||||
|
||||
/*! The minimum size of the client window
|
||||
If the min is > the max, then the window is not resizable
|
||||
*/
|
||||
Size min_size;
|
||||
/*! The maximum size of the client window
|
||||
If the min is > the max, then the window is not resizable
|
||||
*/
|
||||
Size max_size;
|
||||
/*! The size of increments to resize the client window by */
|
||||
Size size_inc;
|
||||
/*! The base size of the client window
|
||||
This value should be subtracted from the window's actual size when
|
||||
displaying its size to the user, or working with its min/max size
|
||||
*/
|
||||
Size base_size;
|
||||
|
||||
/*! Window decoration and functionality hints */
|
||||
MwmHints mwmhints;
|
||||
|
||||
/*! Where to place the decorated window in relation to the undecorated
|
||||
window */
|
||||
int gravity;
|
||||
|
||||
/*! The state of the window, one of WithdrawnState, IconicState, or
|
||||
NormalState */
|
||||
long wmstate;
|
||||
|
||||
/*! True if the client supports the delete_window protocol */
|
||||
gboolean delete_window;
|
||||
|
||||
/*! Was the window's position requested by the application? if not, we
|
||||
should place the window ourselves when it first appears */
|
||||
gboolean positioned;
|
||||
|
||||
/*! Can the window receive input focus? */
|
||||
gboolean can_focus;
|
||||
/*! Urgency flag */
|
||||
gboolean urgent;
|
||||
/*! Notify the window when it receives focus? */
|
||||
gboolean focus_notify;
|
||||
/*! Does the client window have the input focus? */
|
||||
gboolean focused;
|
||||
|
||||
/*! The window uses shape extension to be non-rectangular? */
|
||||
gboolean shaped;
|
||||
|
||||
/*! The window is modal, so it must be processed before any windows it is
|
||||
related to can be focused */
|
||||
gboolean modal;
|
||||
/*! Only the window's titlebar is displayed */
|
||||
gboolean shaded;
|
||||
/*! The window is iconified */
|
||||
gboolean iconic;
|
||||
/*! The window is maximized to fill the screen vertically */
|
||||
gboolean max_vert;
|
||||
/*! The window is maximized to fill the screen horizontally */
|
||||
gboolean max_horz;
|
||||
/*! The window should not be displayed by pagers */
|
||||
gboolean skip_pager;
|
||||
/*! The window should not be displayed by taskbars */
|
||||
gboolean skip_taskbar;
|
||||
/*! The window is a 'fullscreen' window, and should be on top of all
|
||||
others */
|
||||
gboolean fullscreen;
|
||||
/*! The window should be on top of other windows of the same type */
|
||||
gboolean above;
|
||||
/*! The window should be underneath other windows of the same type */
|
||||
gboolean below;
|
||||
|
||||
/*! The layer in which the window will be stacked, windows in lower layers
|
||||
are always below windows in higher layers. */
|
||||
StackLayer layer;
|
||||
|
||||
/*! A bitmask of values in the Decoration enum
|
||||
The values in the variable are the decorations that the client wants to
|
||||
be displayed around it.
|
||||
*/
|
||||
int decorations;
|
||||
|
||||
/*! A bitmask of values in the Decoration enum.
|
||||
Specifies the decorations that should NOT be displayed on the client.
|
||||
*/
|
||||
int disabled_decorations;
|
||||
|
||||
/*! A bitmask of values in the Function enum
|
||||
The values in the variable specify the ways in which the user is allowed
|
||||
to modify this window.
|
||||
*/
|
||||
int functions;
|
||||
|
||||
/*! Icons for the client as specified on the client window */
|
||||
Icon *icons;
|
||||
/*! The number of icons in icons */
|
||||
int nicons;
|
||||
|
||||
/*! The icon for the client specified in the WMHints or the KWM hints */
|
||||
Pixmap pixmap_icon;
|
||||
/*! The mask for the pixmap_icon, or None if its not masked */
|
||||
Pixmap pixmap_icon_mask;
|
||||
|
||||
/* The instance of the wrapper class if one exists */
|
||||
struct ClientWrap *wrap;
|
||||
} Client;
|
||||
|
||||
extern GSList *client_list;
|
||||
extern GHashTable *client_map;
|
||||
|
||||
void client_startup();
|
||||
void client_shutdown();
|
||||
|
||||
/*! Manages all existing windows */
|
||||
void client_manage_all();
|
||||
/*! Manages a given window */
|
||||
void client_manage(Window win);
|
||||
/*! Unmanages all managed windows */
|
||||
void client_unmanage_all();
|
||||
/*! Unmanages a given client */
|
||||
void client_unmanage(Client *client);
|
||||
|
||||
/*! Sets the client list on the root window from the client_list */
|
||||
void client_set_list();
|
||||
|
||||
/*! Reapplies the maximized state to the window
|
||||
Use this to make the window readjust its maximized size to new
|
||||
surroundings (struts, etc). */
|
||||
void client_remaximize(Client *self);
|
||||
|
||||
/*! Shows the window if it should be shown, or hides it
|
||||
Used when changing desktops, the window's state, etc. */
|
||||
void client_showhide(Client *self);
|
||||
|
||||
/*! Returns if the window should be treated as a normal window.
|
||||
Some windows (desktops, docks, splash screens) have special rules applied
|
||||
to them in a number of places regarding focus or user interaction. */
|
||||
gboolean client_normal(Client *self);
|
||||
|
||||
/*! Internal version of the Client::resize function
|
||||
This also maintains things like the client's minsize, and size increments.
|
||||
@param anchor The corner to keep in the same position when resizing.
|
||||
@param x The x coordiante of the new position for the client.
|
||||
@param y The y coordiante of the new position for the client.
|
||||
@param w The width component of the new size for the client.
|
||||
@param h The height component of the new size for the client.
|
||||
@param user Specifies whether this is a user-requested change or a
|
||||
program requested change. For program requested changes, the
|
||||
constraints are not checked.
|
||||
@param final If user is true, then this should specify if this is a final
|
||||
configuration. e.g. Final should be FALSE if doing an
|
||||
interactive move/resize, and then be TRUE for the last call
|
||||
only.
|
||||
*/
|
||||
void client_configure(Client *self, Corner anchor, int x, int y, int w, int h,
|
||||
gboolean user, gboolean final);
|
||||
|
||||
/*! Fullscreen's or unfullscreen's the client window
|
||||
@param fs true if the window should be made fullscreen; false if it should
|
||||
be returned to normal state.
|
||||
@param savearea true to have the client's current size and position saved;
|
||||
otherwise, they are not. You should not save when mapping a
|
||||
new window that is set to fullscreen. This has no effect
|
||||
when restoring a window from fullscreen.
|
||||
*/
|
||||
void client_fullscreen(Client *self, gboolean fs, gboolean savearea);
|
||||
|
||||
/*! Iconifies or uniconifies the client window
|
||||
@param iconic true if the window should be iconified; false if it should be
|
||||
restored.
|
||||
@param curdesk If iconic is FALSE, then this determines if the window will
|
||||
be uniconified to the current viewable desktop (true) or to
|
||||
its previous desktop (false)
|
||||
*/
|
||||
void client_iconify(Client *self, gboolean iconic, gboolean curdesk);
|
||||
|
||||
/*! Maximize or unmaximize the client window
|
||||
@param max true if the window should be maximized; false if it should be
|
||||
returned to normal size.
|
||||
@param dir 0 to set both horz and vert, 1 to set horz, 2 to set vert.
|
||||
@param savearea true to have the client's current size and position saved;
|
||||
otherwise, they are not. You should not save when mapping a
|
||||
new window that is set to fullscreen. This has no effect
|
||||
when unmaximizing a window.
|
||||
*/
|
||||
void client_maximize(Client *self, gboolean max, int dir,
|
||||
gboolean savearea);
|
||||
|
||||
/*! Shades or unshades the client window
|
||||
@param shade true if the window should be shaded; false if it should be
|
||||
unshaded.
|
||||
*/
|
||||
void client_shade(Client *self, gboolean shade);
|
||||
|
||||
/*! Request the client to close its window. */
|
||||
void client_close(Client *self);
|
||||
|
||||
/*! Sends the window to the specified desktop */
|
||||
void client_set_desktop(Client *self, unsigned int target);
|
||||
|
||||
/*! Return a modal child of the client window
|
||||
@return A modal child of the client window, or 0 if none was found.
|
||||
*/
|
||||
Client *client_find_modal_child(Client *self);
|
||||
|
||||
/*! Validate client, by making sure no Destroy or Unmap events exist in
|
||||
the event queue for the window.
|
||||
@return true if the client is valid; false if the client has already
|
||||
been unmapped/destroyed, and so is invalid.
|
||||
*/
|
||||
gboolean client_validate(Client *self);
|
||||
|
||||
/*! Sets the wm_state to the specified value */
|
||||
void client_set_wm_state(Client *self, long state);
|
||||
|
||||
/*! Adjusts the window's net_state
|
||||
This should not be called as part of the window mapping process! It is for
|
||||
use when updating the state post-mapping.<br>
|
||||
client_apply_startup_state is used to do the same things during the mapping
|
||||
process.
|
||||
*/
|
||||
void client_set_state(Client *self, Atom action, long data1, long data2);
|
||||
|
||||
/*! Attempt to focus the client window */
|
||||
gboolean client_focus(Client *self);
|
||||
|
||||
/*! Remove focus from the client window */
|
||||
void client_unfocus(Client *self);
|
||||
|
||||
/*! Calculates the stacking layer for the client window */
|
||||
void client_calc_layer(Client *self);
|
||||
|
||||
/*! Updates the window's transient status, and any parents of it */
|
||||
void client_update_transient_for(Client *self);
|
||||
/*! Update the protocols that the window supports and adjusts things if they
|
||||
change */
|
||||
void client_update_protocols(Client *self);
|
||||
/*! Updates the WMNormalHints and adjusts things if they change */
|
||||
void client_update_normal_hints(Client *self);
|
||||
|
||||
/*! Updates the WMHints and adjusts things if they change
|
||||
@param initstate Whether to read the initial_state property from the
|
||||
WMHints. This should only be used during the mapping
|
||||
process.
|
||||
*/
|
||||
void client_update_wmhints(Client *self);
|
||||
/*! Updates the window's title */
|
||||
void client_update_title(Client *self);
|
||||
/*! Updates the window's icon title */
|
||||
void client_update_icon_title(Client *self);
|
||||
/*! Updates the window's application name and class */
|
||||
void client_update_class(Client *self);
|
||||
/*! Updates the strut for the client */
|
||||
void client_update_strut(Client *self);
|
||||
/*! Updates the window's icons */
|
||||
void client_update_icons(Client *self);
|
||||
/*! Updates the window's kwm icon */
|
||||
void client_update_kwm_icon(Client *self);
|
||||
|
||||
/*! Set up what decor should be shown on the window and what functions should
|
||||
be allowed (Client::_decorations and Client::_functions).
|
||||
This also updates the NET_WM_ALLOWED_ACTIONS hint.
|
||||
*/
|
||||
void client_setup_decor_and_functions(Client *self);
|
||||
|
||||
/*! Retrieves the window's type and sets Client->type */
|
||||
void client_get_type(Client *self);
|
||||
|
||||
#endif
|
792
c/clientwrap.c
Normal file
792
c/clientwrap.c
Normal file
|
@ -0,0 +1,792 @@
|
|||
#include "clientwrap.h"
|
||||
#include "client.h"
|
||||
#include "frame.h"
|
||||
#include "stacking.h"
|
||||
#include "focus.h"
|
||||
#include <glib.h>
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'ClientWrap'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_CWRAP(v) ((v)->ob_type == &ClientWrapType)
|
||||
#define IS_VALID_CWRAP(v) ((v)->client != NULL)
|
||||
#define CHECK_CWRAP(self, funcname) { \
|
||||
if (!IS_CWRAP(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires a 'Client' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
if (!IS_VALID_CWRAP(self)) { \
|
||||
PyErr_SetString(PyExc_ValueError, \
|
||||
"This 'Client' is wrapping a client which no longer "\
|
||||
"exists."); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
staticforward PyTypeObject ClientWrapType;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Attribute methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *cwrap_window(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "window");
|
||||
if (!PyArg_ParseTuple(args, ":window"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->window);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_group(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "group");
|
||||
if (!PyArg_ParseTuple(args, ":group"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->group);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_parent(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "parent");
|
||||
if (!PyArg_ParseTuple(args, ":parent"))
|
||||
return NULL;
|
||||
if (self->client->transient_for != NULL)
|
||||
return clientwrap_new(self->client->transient_for);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_children(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *list;
|
||||
GSList *it;
|
||||
guint i, s;
|
||||
|
||||
CHECK_CWRAP(self, "children");
|
||||
if (!PyArg_ParseTuple(args, ":children"))
|
||||
return NULL;
|
||||
s = g_slist_length(self->client->transients);
|
||||
list = PyList_New(s);
|
||||
for (i = 0, it = self->client->transients; i < s; ++i, it = it->next)
|
||||
PyList_SET_ITEM(list, i, clientwrap_new(it->data));
|
||||
return list;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_desktop(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "desktop");
|
||||
if (!PyArg_ParseTuple(args, ":desktop"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->desktop);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_title(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "title");
|
||||
if (!PyArg_ParseTuple(args, ":title"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->client->title);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_iconTitle(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "iconTitle");
|
||||
if (!PyArg_ParseTuple(args, ":iconTitle"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->client->icon_title);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_resName(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "resName");
|
||||
if (!PyArg_ParseTuple(args, ":resName"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->client->res_name);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_resClass(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "resClass");
|
||||
if (!PyArg_ParseTuple(args, ":resClass"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->client->res_class);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_role(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "role");
|
||||
if (!PyArg_ParseTuple(args, ":role"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->client->role);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_type(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "type");
|
||||
if (!PyArg_ParseTuple(args, ":type"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->type);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_area(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "area");
|
||||
if (!PyArg_ParseTuple(args, ":area"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->area.x));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->area.y));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(self->client->area.width));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(self->client->area.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_screenArea(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "screenArea");
|
||||
if (!PyArg_ParseTuple(args, ":screenArea"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->frame->area.x));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->frame->area.y));
|
||||
PyTuple_SET_ITEM(tuple, 2,
|
||||
PyInt_FromLong(self->client->frame->area.width));
|
||||
PyTuple_SET_ITEM(tuple, 3,
|
||||
PyInt_FromLong(self->client->frame->area.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_strut(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "strut");
|
||||
if (!PyArg_ParseTuple(args, ":strut"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->strut.left));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->strut.top));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(self->client->strut.right));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(self->client->strut.bottom));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_logicalSize(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "logicalSize");
|
||||
if (!PyArg_ParseTuple(args, ":logicalSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0,
|
||||
PyInt_FromLong(self->client->logical_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1,
|
||||
PyInt_FromLong(self->client->logical_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_minRatio(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "minRatio");
|
||||
if (!PyArg_ParseTuple(args, ":minRatio"))
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(self->client->min_ratio);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_maxRatio(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "maxRatio");
|
||||
if (!PyArg_ParseTuple(args, ":maxRatio"))
|
||||
return NULL;
|
||||
return PyFloat_FromDouble(self->client->max_ratio);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_minSize(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "minSize");
|
||||
if (!PyArg_ParseTuple(args, ":minSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->min_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->min_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_maxSize(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "maxSize");
|
||||
if (!PyArg_ParseTuple(args, ":maxSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->max_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->max_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_sizeIncrement(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "sizeIncrement");
|
||||
if (!PyArg_ParseTuple(args, ":sizeIncrement"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->size_inc.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->size_inc.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_baseSize(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "baseSize");
|
||||
if (!PyArg_ParseTuple(args, ":baseSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->base_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->base_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_gravity(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "gravity");
|
||||
if (!PyArg_ParseTuple(args, ":gravity"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->gravity);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_canClose(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "canClose");
|
||||
if (!PyArg_ParseTuple(args, ":canClose"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->delete_window ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_positionRequested(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "positionRequested");
|
||||
if (!PyArg_ParseTuple(args, ":positionRequested"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->positioned ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_canFocus(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "canFocus");
|
||||
if (!PyArg_ParseTuple(args, ":canFocus"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->can_focus ||
|
||||
self->client->focus_notify);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_urgent(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "urgent");
|
||||
if (!PyArg_ParseTuple(args, ":urgent"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->urgent ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_focused(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "focused");
|
||||
if (!PyArg_ParseTuple(args, ":focused"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->focused ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_modal(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "modal");
|
||||
if (!PyArg_ParseTuple(args, ":modal"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->modal ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_shaded(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "shaded");
|
||||
if (!PyArg_ParseTuple(args, ":shaded"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->shaded ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_iconic(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "iconic");
|
||||
if (!PyArg_ParseTuple(args, ":iconc"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->iconic ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_maximizedVertical(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "maximizedVertical");
|
||||
if (!PyArg_ParseTuple(args, ":maximizedVertical"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->max_vert ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_maximizedHorizontal(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "maximizedHorizontal");
|
||||
if (!PyArg_ParseTuple(args, ":maximizedHorizontal"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->max_horz ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_skipPager(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "skipPager");
|
||||
if (!PyArg_ParseTuple(args, ":skipPager"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->skip_pager ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_skipTaskbar(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "skipTaskbar");
|
||||
if (!PyArg_ParseTuple(args, ":skipTaskbar"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->skip_taskbar ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_fullscreen(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "fullscreen");
|
||||
if (!PyArg_ParseTuple(args, ":fullscreen"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->fullscreen ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_above(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "above");
|
||||
if (!PyArg_ParseTuple(args, ":above"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->above ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_below(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "below");
|
||||
if (!PyArg_ParseTuple(args, ":below"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->below ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_layer(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "layer");
|
||||
if (!PyArg_ParseTuple(args, ":layer"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->layer);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_decorations(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "decorations");
|
||||
if (!PyArg_ParseTuple(args, ":decorations"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->decorations);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_disabledDecorations(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "disabledDecorations");
|
||||
if (!PyArg_ParseTuple(args, ":disabledDecorations"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->disabled_decorations);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_functions(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "functions");
|
||||
if (!PyArg_ParseTuple(args, ":functions"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->functions);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_visible(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "visible");
|
||||
if (!PyArg_ParseTuple(args, ":visible"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->client->frame->visible ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_decorationSize(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_CWRAP(self, "decorationSize");
|
||||
if (!PyArg_ParseTuple(args, ":decorationSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->frame->size.left));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->frame->size.top));
|
||||
PyTuple_SET_ITEM(tuple, 2,
|
||||
PyInt_FromLong(self->client->frame->size.right));
|
||||
PyTuple_SET_ITEM(tuple, 3,
|
||||
PyInt_FromLong(self->client->frame->size.bottom));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_normal(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "normal");
|
||||
if (!PyArg_ParseTuple(args, ":normal"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(client_normal(self->client) ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_setVisible(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
int i;
|
||||
|
||||
CHECK_CWRAP(self, "setVisible");
|
||||
if (!PyArg_ParseTuple(args, "i:setVisible", &i))
|
||||
return NULL;
|
||||
if (i)
|
||||
frame_show(self->client->frame);
|
||||
else
|
||||
frame_hide(self->client->frame);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_raiseWindow(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "raiseWindow");
|
||||
if (!PyArg_ParseTuple(args, ":raiseWindow"))
|
||||
return NULL;
|
||||
stacking_raise(self->client);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_lowerWindow(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "lowerWindow");
|
||||
if (!PyArg_ParseTuple(args, ":lowerWindow"))
|
||||
return NULL;
|
||||
stacking_lower(self->client);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_focus(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "focus");
|
||||
if (!PyArg_ParseTuple(args, ":focus"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(client_focus(self->client) ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_unfocus(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_CWRAP(self, "unfocus");
|
||||
if (!PyArg_ParseTuple(args, ":unfocus"))
|
||||
return NULL;
|
||||
client_unfocus(self->client);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *cwrap_move(ClientWrap *self, PyObject *args)
|
||||
{
|
||||
int x, y;
|
||||
int final = TRUE;
|
||||
CHECK_CWRAP(self, "move");
|
||||
if (!PyArg_ParseTuple(args, "ii|i:unfocus", &x, &y, &final))
|
||||
return NULL;
|
||||
/* get the client's position based on x,y for the frame */
|
||||
frame_frame_gravity(self->client->frame, &x, &y);
|
||||
|
||||
client_configure(self->client, Corner_TopLeft, x, y,
|
||||
self->client->area.width, self->client->area.height,
|
||||
TRUE, final);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#define ATTRMETH(n, d) {#n, (PyCFunction)cwrap_##n, METH_VARARGS, #d}
|
||||
|
||||
static PyMethodDef ClientWrapMethods[] = {
|
||||
ATTRMETH(window,
|
||||
"c.window() -- Returns the window id for the Client."),
|
||||
ATTRMETH(group,
|
||||
"c.group() -- Returns the group id for the Client."),
|
||||
ATTRMETH(parent,
|
||||
"c.parent() -- Returns the parent Client for the Client, or the "
|
||||
"Client for which this Client is a transient. Returns None if it "
|
||||
"is not a transient."),
|
||||
ATTRMETH(children,
|
||||
"c.parent() -- Returns a list of child Clients for the Client, "
|
||||
"or the Clients transients."),
|
||||
ATTRMETH(desktop,
|
||||
"c.desktop() -- Returns the desktop on which the Client resides, "
|
||||
"or 0xffffffff for 'all desktops'."),
|
||||
ATTRMETH(title,
|
||||
"c.title() -- Returns the Client's title string. This is in "
|
||||
"UTF-8 encoding."),
|
||||
ATTRMETH(iconTitle,
|
||||
"c.iconTitle() -- Returns the Client's icon title string. This "
|
||||
"is in UTF-8 encoding."),
|
||||
ATTRMETH(resName,
|
||||
"c.resName() -- Returns the application's specified resource "
|
||||
"name."),
|
||||
ATTRMETH(resClass,
|
||||
"c.resClass() -- Returns the application's specified resource "
|
||||
"class."),
|
||||
ATTRMETH(role,
|
||||
"c.role() -- Returns the window's role, which should be unique "
|
||||
"for every window of an application, if it is not empty."),
|
||||
ATTRMETH(type,
|
||||
"c.type() -- Returns the window's type, one of the ob.Type_ "
|
||||
"constants. This is the logical type of the window."),
|
||||
ATTRMETH(area,
|
||||
"c.area() -- Returns the area rectangle for the Client in a "
|
||||
"tuple. The tuple's format is (x, y, width, height). This is "
|
||||
"not the area on-screen that the Client and frame occupies, but "
|
||||
"rather, the position and size that the Client has requested, "
|
||||
"before its gravity() and decorations have been applied. You "
|
||||
"should use the c.screenArea() to get the actual on-screen area "
|
||||
"for the Client."),
|
||||
ATTRMETH(screenArea,
|
||||
"c.screenArea() -- Returns the on-screen area rectangle for the "
|
||||
"Client in a tuple. The tuple's format is (x, y, width, height). "
|
||||
"This is the actual position and size of the Client plus its "
|
||||
"decorations."),
|
||||
ATTRMETH(strut,
|
||||
"c.strut() -- Returns the strut requested by the Client in a "
|
||||
"tuple. The format of the tuple is (left, top, right, bottom)."),
|
||||
ATTRMETH(logicalSize,
|
||||
"c.logicalSize() -- Returns the logical size of the Client. This "
|
||||
"is the 'user friendly' size for the Client, such as for an "
|
||||
"xterm, it will be the number of characters in the xterm "
|
||||
"instead of the number of pixels it takes up."),
|
||||
ATTRMETH(minRatio,
|
||||
"c.minRatio() -- Returns the minimum width:height ratio for "
|
||||
"the Client. A value of 0 implies no ratio enforcement."),
|
||||
ATTRMETH(maxRatio,
|
||||
"c.maxRatio() -- Returns the maximum width:height ratio for "
|
||||
"the Client. A value of 0 implies no ratio enforcement."),
|
||||
ATTRMETH(minSize,
|
||||
"c.minSize() -- Returns the minimum size of the Client."),
|
||||
ATTRMETH(maxSize,
|
||||
"c.maxSize() -- Returns the maximum size of the Client."),
|
||||
ATTRMETH(sizeIncrement,
|
||||
"c.sizeIncrement() -- Returns the size increments in which the "
|
||||
"Client must be resized."),
|
||||
ATTRMETH(baseSize,
|
||||
"c.baseSize() -- Returns the base size of the Client, which is "
|
||||
"subtracted from the Client's size before comparing to its "
|
||||
"various sizing constraints."),
|
||||
ATTRMETH(gravity,
|
||||
"c.gravity() -- Returns the gravity for the Client. One of the "
|
||||
"ob.Gravity_ constants."),
|
||||
ATTRMETH(canClose,
|
||||
"c.canClose() -- Returns whether or not the Client provides a "
|
||||
"means for Openbox to request that it close."),
|
||||
ATTRMETH(positionRequested,
|
||||
"c.positionRequested() -- Returns whether or not the Client has "
|
||||
"requested a specified position on screen. When it has it should "
|
||||
"probably not be placed using an algorithm when it is managed."),
|
||||
ATTRMETH(canFocus,
|
||||
"c.canFocus() -- Returns whether or not the Client can be "
|
||||
"given input focus."),
|
||||
ATTRMETH(urgent,
|
||||
"c.urgent() -- Returns the urgent state of the window (on/off)."),
|
||||
ATTRMETH(focused,
|
||||
"c.focused() -- Returns whether or not the Client has the input "
|
||||
"focus."),
|
||||
ATTRMETH(modal,
|
||||
"c.modal() -- Returns whether or not the Client is modal. A "
|
||||
"modal Client implies that it needs to be closed before its "
|
||||
"parent() can be used (focsed) again."),
|
||||
ATTRMETH(shaded,
|
||||
"c.shaded() -- Returns whether or not the Client is shaded. "
|
||||
"Shaded clients are hidden except for their titlebar."),
|
||||
ATTRMETH(iconic,
|
||||
"c.iconic() -- Returns whether or not the Client is iconic. "
|
||||
"Iconic windows are represented only by icons, or possibly "
|
||||
"hidden entirely."),
|
||||
ATTRMETH(maximizedVertical,
|
||||
"c.maximizedVertical() -- Returns whether or not the Client is "
|
||||
"maxized vertically. When a Client is maximized it will expand "
|
||||
"to fill as much of the screen as it can in that direction."),
|
||||
ATTRMETH(maximizedHorizontal,
|
||||
"c.maximizedHorizontal() -- Returns whether or not the Client is "
|
||||
"maxized horizontally. When a Client is maximized it will expand "
|
||||
"to fill as much of the screen as it can in that direction."),
|
||||
ATTRMETH(skipPager,
|
||||
"c.skipPager() -- Returns whether the Client as requested to be "
|
||||
"skipped by pagers."),
|
||||
ATTRMETH(skipTaskbar,
|
||||
"c.skipTaskbar() -- Returns whether the Client as requested to "
|
||||
"be skipped by taskbars."),
|
||||
ATTRMETH(fullscreen,
|
||||
"c.fullscreen() -- Returns whether the Client is in fullscreen "
|
||||
"mode."),
|
||||
ATTRMETH(above,
|
||||
"c.above() -- Returns whether the Client should be stacked above "
|
||||
"other windows of the same type."),
|
||||
ATTRMETH(below,
|
||||
"c.below() -- Returns whether the Client should be stacked below "
|
||||
"other windows of the same type."),
|
||||
ATTRMETH(layer,
|
||||
"c.layer() -- Returns the layer in which the window should be "
|
||||
"stacked. This is one of the ob.Layer_ constants. Windows in "
|
||||
"layers with higher values should be kept above windows in lower "
|
||||
"valued layers."),
|
||||
ATTRMETH(decorations,
|
||||
"c.decorations() -- Returns a mask of decorations which the "
|
||||
"Client will be given. It is made up of the ob.Decor_ constants. "
|
||||
"These can be turned off with the "
|
||||
" disabledDecorations()."),
|
||||
ATTRMETH(disabledDecorations,
|
||||
"c.disabledDecorations() -- returns a mask of decorations which "
|
||||
"are disabled on the Client. This is made up of the ob.Decor_ "
|
||||
"constants."),
|
||||
ATTRMETH(functions,
|
||||
"ob.functions() -- Returns the list of functionality for the "
|
||||
"Client, in a mask made up of the ob.Func_ constants."),
|
||||
ATTRMETH(visible,
|
||||
"ob.visible() -- Returns if the client is currently visible "
|
||||
"or hidden."),
|
||||
ATTRMETH(decorationSize,
|
||||
"c.decorationSize() -- Returns the size of the Client's "
|
||||
"decorations around the Client window, in a tuple. The format of "
|
||||
"the tuple is (left, top, right, bottom)."),
|
||||
ATTRMETH(normal,
|
||||
"c.normal() -- Returns if the window should be treated as a "
|
||||
"normal window. Some windows (desktops, docks, splash screens) "
|
||||
"should have special rules applied to them in a number of "
|
||||
"places regarding focus or user interaction."),
|
||||
ATTRMETH(setVisible,
|
||||
"c.setVisible(show) -- Shows or hides the Client."),
|
||||
ATTRMETH(raiseWindow,
|
||||
"c.raiseWindow() -- Raises the Client to the top of its layer."),
|
||||
ATTRMETH(lowerWindow,
|
||||
"c.lowerWindow() -- Lowers the Client to the bottom of its "
|
||||
"layer."),
|
||||
ATTRMETH(focus,
|
||||
"c.focus() -- Focuses the Client. Returns 1 if the Client will "
|
||||
"be focused, or 0 if it will not."),
|
||||
ATTRMETH(unfocus,
|
||||
"c.unfocus() -- Unfocuses the Client, leaving nothing focused."),
|
||||
ATTRMETH(move,
|
||||
"c.move(x, y) -- Moves the Client to the specified position. The "
|
||||
"top left corner of the Client's decorations is positioned at "
|
||||
"the given x, y."),
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/*static PyObject *cwrap_getattr(ClientWrap *self, char *name)
|
||||
{
|
||||
CHECK_CWRAP(self, "getattr");
|
||||
return Py_FindMethod(ClientWrapAttributeMethods, (PyObject*)self, name);
|
||||
}*/
|
||||
|
||||
static void cwrap_dealloc(ClientWrap *self)
|
||||
{
|
||||
if (self->client != NULL)
|
||||
self->client->wrap = NULL;
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyObject *cwrap_repr(ClientWrap *self)
|
||||
{
|
||||
CHECK_CWRAP(self, "repr");
|
||||
return PyString_FromFormat("0x%x", (guint)self->client->window);
|
||||
}
|
||||
|
||||
static int cwrap_compare(ClientWrap *self, ClientWrap *other)
|
||||
{
|
||||
Window w1, w2;
|
||||
if (!IS_VALID_CWRAP(self)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"This 'Client' is wrapping a client which no longer "
|
||||
"exists.");
|
||||
}
|
||||
|
||||
w1 = self->client->window;
|
||||
w2 = self->client->window;
|
||||
return w1 > w2 ? 1 : w1 < w2 ? -1 : 0;
|
||||
}
|
||||
|
||||
static PyTypeObject ClientWrapType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Client",
|
||||
sizeof(ClientWrap),
|
||||
0,
|
||||
(destructor) cwrap_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
(cmpfunc) cwrap_compare, /*tp_compare*/
|
||||
(reprfunc) cwrap_repr, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
External methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
void clientwrap_startup()
|
||||
{
|
||||
ClientWrapType.ob_type = &PyType_Type;
|
||||
ClientWrapType.tp_methods = ClientWrapMethods;
|
||||
PyType_Ready(&ClientWrapType);
|
||||
}
|
||||
|
||||
void clientwrap_shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
PyObject *clientwrap_new(Client *client)
|
||||
{
|
||||
g_assert(client != NULL);
|
||||
|
||||
if (client->wrap != NULL) {
|
||||
/* already has a wrapper! */
|
||||
Py_INCREF((PyObject*) client->wrap);
|
||||
} else {
|
||||
client->wrap = PyObject_New(ClientWrap, &ClientWrapType);
|
||||
client->wrap->client = client;
|
||||
}
|
||||
return (PyObject*) client->wrap;
|
||||
}
|
19
c/clientwrap.h
Normal file
19
c/clientwrap.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __clientwrap_h
|
||||
#define __clientwrap_h
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
/* ClientWrap is a PyObject */
|
||||
typedef struct ClientWrap {
|
||||
PyObject_HEAD
|
||||
struct Client *client;
|
||||
} ClientWrap;
|
||||
|
||||
void clientwrap_startup();
|
||||
void clientwrap_shutdown();
|
||||
|
||||
PyObject *clientwrap_new(struct Client *client);
|
||||
|
||||
#endif
|
593
c/event.c
Normal file
593
c/event.c
Normal file
|
@ -0,0 +1,593 @@
|
|||
#include "openbox.h"
|
||||
#include "client.h"
|
||||
#include "xerror.h"
|
||||
#include "prop.h"
|
||||
#include "screen.h"
|
||||
#include "frame.h"
|
||||
#include "focus.h"
|
||||
#include "hooks.h"
|
||||
#include "stacking.h"
|
||||
#include "kbind.h"
|
||||
#include "mbind.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static void event_process(XEvent *e);
|
||||
static void event_handle_root(XEvent *e);
|
||||
static void event_handle_client(Client *c, XEvent *e);
|
||||
|
||||
Time event_lasttime = 0;
|
||||
|
||||
/*! A list of all possible combinations of keyboard lock masks */
|
||||
static unsigned int mask_list[8];
|
||||
/*! The value of the mask for the NumLock modifier */
|
||||
static unsigned int NumLockMask;
|
||||
/*! The value of the mask for the ScrollLock modifier */
|
||||
static unsigned int ScrollLockMask;
|
||||
/*! The key codes for the modifier keys */
|
||||
static XModifierKeymap *modmap;
|
||||
/*! Table of the constant modifier masks */
|
||||
static const int mask_table[] = {
|
||||
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
};
|
||||
static int mask_table_size;
|
||||
|
||||
void event_startup()
|
||||
{
|
||||
mask_table_size = sizeof(mask_table) / sizeof(mask_table[0]);
|
||||
|
||||
/* get lock masks that are defined by the display (not constant) */
|
||||
modmap = XGetModifierMapping(ob_display);
|
||||
g_assert(modmap);
|
||||
if (modmap && modmap->max_keypermod > 0) {
|
||||
size_t cnt;
|
||||
const size_t size = mask_table_size * 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 = XKeysymToKeycode(ob_display, XK_Num_Lock);
|
||||
const KeyCode scroll_lock = XKeysymToKeycode(ob_display,
|
||||
XK_Scroll_Lock);
|
||||
|
||||
for (cnt = 0; cnt < size; ++cnt) {
|
||||
if (! modmap->modifiermap[cnt]) continue;
|
||||
|
||||
if (num_lock == modmap->modifiermap[cnt])
|
||||
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
if (scroll_lock == modmap->modifiermap[cnt])
|
||||
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
|
||||
mask_list[0] = 0;
|
||||
mask_list[1] = LockMask;
|
||||
mask_list[2] = NumLockMask;
|
||||
mask_list[3] = LockMask | NumLockMask;
|
||||
mask_list[4] = ScrollLockMask;
|
||||
mask_list[5] = ScrollLockMask | LockMask;
|
||||
mask_list[6] = ScrollLockMask | NumLockMask;
|
||||
mask_list[7] = ScrollLockMask | LockMask | NumLockMask;
|
||||
}
|
||||
|
||||
void event_shutdown()
|
||||
{
|
||||
XFreeModifiermap(modmap);
|
||||
}
|
||||
|
||||
void event_loop()
|
||||
{
|
||||
fd_set selset;
|
||||
XEvent e;
|
||||
int x_fd;
|
||||
|
||||
while (TRUE) {
|
||||
/*
|
||||
There are slightly different event retrieval semantics here for
|
||||
local (or high bandwidth) versus remote (or low bandwidth)
|
||||
connections to the display/Xserver.
|
||||
*/
|
||||
if (ob_remote) {
|
||||
if (!XPending(ob_display))
|
||||
break;
|
||||
} else {
|
||||
/*
|
||||
This XSync allows for far more compression of events, which
|
||||
makes things like Motion events perform far far better. Since
|
||||
it also means network traffic for every event instead of every
|
||||
X events (where X is the number retrieved at a time), it
|
||||
probably should not be used for setups where Openbox is
|
||||
running on a remote/low bandwidth display/Xserver.
|
||||
*/
|
||||
XSync(ob_display, FALSE);
|
||||
if (!XEventsQueued(ob_display, QueuedAlready))
|
||||
break;
|
||||
}
|
||||
XNextEvent(ob_display, &e);
|
||||
|
||||
event_process(&e);
|
||||
}
|
||||
|
||||
x_fd = ConnectionNumber(ob_display);
|
||||
FD_ZERO(&selset);
|
||||
FD_SET(x_fd, &selset);
|
||||
select(x_fd + 1, &selset, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void event_process(XEvent *e)
|
||||
{
|
||||
XEvent ce;
|
||||
KeyCode *kp;
|
||||
Window window;
|
||||
int i, k;
|
||||
Client *client;
|
||||
GQuark context;
|
||||
static guint motion_button = 0;
|
||||
|
||||
/* pick a window */
|
||||
switch (e->type) {
|
||||
case UnmapNotify:
|
||||
window = e->xunmap.window;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
window = e->xdestroywindow.window;
|
||||
break;
|
||||
case ConfigureRequest:
|
||||
window = e->xconfigurerequest.window;
|
||||
break;
|
||||
default:
|
||||
window = e->xany.window;
|
||||
}
|
||||
|
||||
/* grab the lasttime and hack up the state */
|
||||
switch (e->type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
event_lasttime = e->xbutton.time;
|
||||
e->xbutton.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xbutton.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
break;
|
||||
case KeyPress:
|
||||
event_lasttime = e->xkey.time;
|
||||
e->xkey.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xkey.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* add to the state the mask of the modifier being pressed, if it is
|
||||
a modifier key being pressed (this is a little ugly..) */
|
||||
/* I'm commenting this out cuz i don't want "C-Control_L" being returned. */
|
||||
/* kp = modmap->modifiermap;*/
|
||||
/* for (i = 0; i < mask_table_size; ++i) {*/
|
||||
/* for (k = 0; k < modmap->max_keypermod; ++k) {*/
|
||||
/* if (*kp == e->xkey.keycode) {*/ /* found the keycode */
|
||||
/* add the mask for it */
|
||||
/* e->xkey.state |= mask_table[i];*/
|
||||
/* cause the first loop to break; */
|
||||
/* i = mask_table_size;*/
|
||||
/* break;*/ /* get outta here! */
|
||||
/* }*/
|
||||
/* ++kp;*/
|
||||
/* }*/
|
||||
/* }*/
|
||||
|
||||
break;
|
||||
case KeyRelease:
|
||||
event_lasttime = e->xkey.time;
|
||||
e->xkey.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xkey.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* remove from the state the mask of the modifier being released, if
|
||||
it is a modifier key being released (this is a little ugly..) */
|
||||
kp = modmap->modifiermap;
|
||||
for (i = 0; i < mask_table_size; ++i) {
|
||||
for (k = 0; k < modmap->max_keypermod; ++k) {
|
||||
if (*kp == e->xkey.keycode) { /* found the keycode */
|
||||
/* remove the mask for it */
|
||||
e->xkey.state &= ~mask_table[i];
|
||||
/* cause the first loop to break; */
|
||||
i = mask_table_size;
|
||||
break; /* get outta here! */
|
||||
}
|
||||
++kp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
event_lasttime = e->xmotion.time;
|
||||
e->xmotion.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xmotion.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* compress events */
|
||||
while (XCheckTypedWindowEvent(ob_display, window, e->type, &ce)) {
|
||||
e->xmotion.x_root = ce.xmotion.x_root;
|
||||
e->xmotion.y_root = ce.xmotion.y_root;
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
event_lasttime = e->xproperty.time;
|
||||
break;
|
||||
case FocusIn:
|
||||
case FocusOut:
|
||||
if (e->xfocus.mode == NotifyGrab)
|
||||
/*|| e.xfocus.mode == NotifyUngrab ||*/
|
||||
|
||||
/* From Metacity, from WindowMaker, ignore all funky pointer
|
||||
root events. Its commented out cuz I don't think we need this
|
||||
at all. If problems arise we can look into it */
|
||||
/*e.xfocus.detail > NotifyNonlinearVirtual) */
|
||||
return; /* skip me! */
|
||||
if (e->type == FocusOut) {
|
||||
/* FocusOut events just make us look for FocusIn events. They
|
||||
are mostly ignored otherwise. */
|
||||
XEvent fi;
|
||||
if (XCheckTypedEvent(ob_display, FocusIn, &fi)) {
|
||||
event_process(&fi);
|
||||
/* dont unfocus the window we just focused! */
|
||||
if (fi.xfocus.window == e->xfocus.window)
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
event_lasttime = e->xcrossing.time;
|
||||
if (e->xcrossing.mode != NotifyNormal)
|
||||
return; /* skip me! */
|
||||
break;
|
||||
}
|
||||
|
||||
client = g_hash_table_lookup(client_map, (gpointer)window);
|
||||
if (client) {
|
||||
event_handle_client(client, e);
|
||||
} else if (window == ob_root)
|
||||
event_handle_root(e);
|
||||
else if (e->type == ConfigureRequest) {
|
||||
/* unhandled configure requests must be used to configure the
|
||||
window directly */
|
||||
XWindowChanges xwc;
|
||||
|
||||
xwc.x = e->xconfigurerequest.x;
|
||||
xwc.y = e->xconfigurerequest.y;
|
||||
xwc.width = e->xconfigurerequest.width;
|
||||
xwc.height = e->xconfigurerequest.height;
|
||||
xwc.border_width = e->xconfigurerequest.border_width;
|
||||
xwc.sibling = e->xconfigurerequest.above;
|
||||
xwc.stack_mode = e->xconfigurerequest.detail;
|
||||
|
||||
g_message("Proxying configure event for 0x%lx\n", window);
|
||||
|
||||
/* we are not to be held responsible if someone sends us an
|
||||
invalid request! */
|
||||
xerror_set_ignore(TRUE);
|
||||
XConfigureWindow(ob_display, window,
|
||||
e->xconfigurerequest.value_mask, &xwc);
|
||||
xerror_set_ignore(FALSE);
|
||||
}
|
||||
|
||||
/* dispatch Crossing, Pointer and Key events to the hooks */
|
||||
switch(e->type) {
|
||||
case EnterNotify:
|
||||
context = frame_get_context(client, window);
|
||||
LOGICALHOOK(EnterWindow, context, client);
|
||||
break;
|
||||
case LeaveNotify:
|
||||
context = frame_get_context(client, window);
|
||||
LOGICALHOOK(LeaveWindow, context, client);
|
||||
break;
|
||||
case ButtonPress:
|
||||
if (!motion_button) motion_button = e->xbutton.button;
|
||||
context = frame_get_context(client, window);
|
||||
mbind_fire(e->xbutton.state, e->xbutton.button, context,
|
||||
Pointer_Press, client, e->xbutton.x_root,
|
||||
e->xbutton.y_root);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (motion_button == e->xbutton.button) motion_button = 0;
|
||||
context = frame_get_context(client, window);
|
||||
mbind_fire(e->xbutton.state, e->xbutton.button, context,
|
||||
Pointer_Release, client, e->xbutton.x_root,
|
||||
e->xbutton.y_root);
|
||||
break;
|
||||
case MotionNotify:
|
||||
context = frame_get_context(client, window);
|
||||
mbind_fire(e->xkey.state, motion_button, context, Pointer_Motion,
|
||||
client, e->xmotion.x_root, e->xmotion.y_root);
|
||||
break;
|
||||
case KeyPress:
|
||||
kbind_fire(e->xkey.state, e->xkey.keycode, TRUE);
|
||||
break;
|
||||
case KeyRelease:
|
||||
kbind_fire(e->xkey.state, e->xkey.keycode, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handle_root(XEvent *e)
|
||||
{
|
||||
Atom msgtype;
|
||||
|
||||
switch(e->type) {
|
||||
case MapRequest:
|
||||
g_message("MapRequest on root");
|
||||
client_manage(e->xmap.window);
|
||||
break;
|
||||
case ClientMessage:
|
||||
if (e->xclient.format != 32) break;
|
||||
|
||||
msgtype = e->xclient.message_type;
|
||||
if (msgtype == prop_atoms.net_current_desktop) {
|
||||
unsigned int d = e->xclient.data.l[0];
|
||||
if (d <= screen_num_desktops)
|
||||
screen_set_desktop(d);
|
||||
} else if (msgtype == prop_atoms.net_number_of_desktops) {
|
||||
unsigned int d = e->xclient.data.l[0];
|
||||
if (d > 0)
|
||||
screen_set_num_desktops(d);
|
||||
} else if (msgtype == prop_atoms.net_showing_desktop) {
|
||||
screen_show_desktop(e->xclient.data.l[0] != 0);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
if (e->xproperty.atom == prop_atoms.net_desktop_names)
|
||||
screen_update_desktop_names();
|
||||
else if (e->xproperty.atom == prop_atoms.net_desktop_layout)
|
||||
screen_update_layout();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handle_client(Client *client, XEvent *e)
|
||||
{
|
||||
XEvent ce;
|
||||
Atom msgtype;
|
||||
|
||||
switch (e->type) {
|
||||
case FocusIn:
|
||||
client->focused = TRUE;
|
||||
frame_adjust_focus(client->frame);
|
||||
|
||||
/* focus state can affect the stacking layer */
|
||||
client_calc_layer(client);
|
||||
|
||||
focus_set_client(client);
|
||||
break;
|
||||
case FocusOut:
|
||||
client->focused = FALSE;
|
||||
frame_adjust_focus(client->frame);
|
||||
|
||||
/* focus state can affect the stacking layer */
|
||||
client_calc_layer(client);
|
||||
|
||||
if (focus_client == client)
|
||||
focus_set_client(NULL);
|
||||
break;
|
||||
case ConfigureRequest:
|
||||
g_message("ConfigureRequest for window %lx", client->window);
|
||||
/* compress these */
|
||||
while (XCheckTypedWindowEvent(ob_display, client->window,
|
||||
ConfigureRequest, &ce)) {
|
||||
/* XXX if this causes bad things.. we can compress config req's
|
||||
with the same mask. */
|
||||
e->xconfigurerequest.value_mask |=
|
||||
ce.xconfigurerequest.value_mask;
|
||||
if (ce.xconfigurerequest.value_mask & CWX)
|
||||
e->xconfigurerequest.x = ce.xconfigurerequest.x;
|
||||
if (ce.xconfigurerequest.value_mask & CWY)
|
||||
e->xconfigurerequest.y = ce.xconfigurerequest.y;
|
||||
if (ce.xconfigurerequest.value_mask & CWWidth)
|
||||
e->xconfigurerequest.width = ce.xconfigurerequest.width;
|
||||
if (ce.xconfigurerequest.value_mask & CWHeight)
|
||||
e->xconfigurerequest.height = ce.xconfigurerequest.height;
|
||||
if (ce.xconfigurerequest.value_mask & CWBorderWidth)
|
||||
e->xconfigurerequest.border_width =
|
||||
ce.xconfigurerequest.border_width;
|
||||
if (ce.xconfigurerequest.value_mask & CWStackMode)
|
||||
e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
|
||||
}
|
||||
|
||||
/* if we are iconic (or shaded (fvwm does this)) ignore the event */
|
||||
if (client->iconic || client->shaded) return;
|
||||
|
||||
if (e->xconfigurerequest.value_mask & CWBorderWidth)
|
||||
client->border_width = e->xconfigurerequest.border_width;
|
||||
|
||||
/* resize, then move, as specified in the EWMH section 7.7 */
|
||||
if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
|
||||
CWX | CWY)) {
|
||||
int x, y, w, h;
|
||||
Corner corner;
|
||||
|
||||
x = (e->xconfigurerequest.value_mask & CWX) ?
|
||||
e->xconfigurerequest.x : client->area.x;
|
||||
y = (e->xconfigurerequest.value_mask & CWY) ?
|
||||
e->xconfigurerequest.y : client->area.y;
|
||||
w = (e->xconfigurerequest.value_mask & CWWidth) ?
|
||||
e->xconfigurerequest.width : client->area.width;
|
||||
h = (e->xconfigurerequest.value_mask & CWHeight) ?
|
||||
e->xconfigurerequest.height : client->area.height;
|
||||
|
||||
switch (client->gravity) {
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
corner = Corner_TopRight;
|
||||
break;
|
||||
case SouthWestGravity:
|
||||
case SouthGravity:
|
||||
corner = Corner_BottomLeft;
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
corner = Corner_BottomRight;
|
||||
break;
|
||||
default: /* NorthWest, Static, etc */
|
||||
corner = Corner_TopLeft;
|
||||
}
|
||||
|
||||
client_configure(client, corner, x, y, w, h, FALSE, FALSE);
|
||||
}
|
||||
|
||||
if (e->xconfigurerequest.value_mask & CWStackMode) {
|
||||
switch (e->xconfigurerequest.detail) {
|
||||
case Below:
|
||||
case BottomIf:
|
||||
stacking_lower(client);
|
||||
break;
|
||||
|
||||
case Above:
|
||||
case TopIf:
|
||||
default:
|
||||
stacking_raise(client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UnmapNotify:
|
||||
if (client->ignore_unmaps) {
|
||||
client->ignore_unmaps--;
|
||||
break;
|
||||
}
|
||||
g_message("UnmapNotify for %lx", client->window);
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
g_message("DestroyNotify for %lx", client->window);
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case ReparentNotify:
|
||||
/* this is when the client is first taken captive in the frame */
|
||||
if (e->xreparent.parent == client->frame->plate) break;
|
||||
|
||||
/*
|
||||
This event is quite rare and is usually handled in unmapHandler.
|
||||
However, if the window is unmapped when the reparent event occurs,
|
||||
the window manager never sees it because an unmap event is not sent
|
||||
to an already unmapped window.
|
||||
*/
|
||||
|
||||
/* we don't want the reparent event, put it back on the stack for the
|
||||
X server to deal with after we unmanage the window */
|
||||
XPutBackEvent(ob_display, e);
|
||||
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case MapRequest:
|
||||
/* we shouldn't be able to get this unless we're iconic */
|
||||
g_assert(client->iconic);
|
||||
|
||||
LOGICALHOOK(RequestActivate, g_quark_try_string("client"), client);
|
||||
break;
|
||||
case ClientMessage:
|
||||
/* validate cuz we query stuff off the client here */
|
||||
if (!client_validate(client)) break;
|
||||
|
||||
if (e->xclient.format != 32) return;
|
||||
|
||||
msgtype = e->xclient.message_type;
|
||||
if (msgtype == prop_atoms.wm_change_state) {
|
||||
/* compress changes into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL messages of a
|
||||
type, not just messages in a row without other
|
||||
message types between. */
|
||||
if (ce.xclient.message_type != msgtype) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
e->xclient = ce.xclient;
|
||||
}
|
||||
client_set_wm_state(client, e->xclient.data.l[0]);
|
||||
} else if (msgtype == prop_atoms.net_wm_desktop) {
|
||||
/* compress changes into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL messages of a
|
||||
type, not just messages in a row without other
|
||||
message types between. */
|
||||
if (ce.xclient.message_type != msgtype) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
e->xclient = ce.xclient;
|
||||
}
|
||||
client_set_desktop(client, e->xclient.data.l[0]);
|
||||
} else if (msgtype == prop_atoms.net_wm_state) {
|
||||
/* can't compress these */
|
||||
g_message("net_wm_state %s %ld %ld for 0x%lx\n",
|
||||
(e->xclient.data.l[0] == 0 ? "Remove" :
|
||||
e->xclient.data.l[0] == 1 ? "Add" :
|
||||
e->xclient.data.l[0] == 2 ? "Toggle" : "INVALID"),
|
||||
e->xclient.data.l[1], e->xclient.data.l[2],
|
||||
client->window);
|
||||
client_set_state(client, e->xclient.data.l[0],
|
||||
e->xclient.data.l[1], e->xclient.data.l[2]);
|
||||
} else if (msgtype == prop_atoms.net_close_window) {
|
||||
g_message("net_close_window for 0x%lx\n", client->window);
|
||||
client_close(client);
|
||||
} else if (msgtype == prop_atoms.net_active_window) {
|
||||
g_message("net_active_window for 0x%lx\n", client->window);
|
||||
if (screen_showing_desktop)
|
||||
screen_show_desktop(FALSE);
|
||||
if (client->iconic)
|
||||
client_iconify(client, FALSE, TRUE);
|
||||
else if (!client->frame->visible)
|
||||
/* if its not visible for other reasons, then don't mess
|
||||
with it */
|
||||
return;
|
||||
LOGICALHOOK(RequestActivate, g_quark_try_string("client"), client);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
/* validate cuz we query stuff off the client here */
|
||||
if (!client_validate(client)) break;
|
||||
|
||||
/* compress changes to a single property into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL changes to a property,
|
||||
not just changes in a row without other props between. */
|
||||
if (ce.xproperty.atom != e->xproperty.atom) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
msgtype = e->xproperty.atom;
|
||||
if (msgtype == XA_WM_NORMAL_HINTS) {
|
||||
client_update_normal_hints(client);
|
||||
/* normal hints can make a window non-resizable */
|
||||
client_setup_decor_and_functions(client);
|
||||
} else if (msgtype == XA_WM_HINTS)
|
||||
client_update_wmhints(client);
|
||||
else if (msgtype == XA_WM_TRANSIENT_FOR) {
|
||||
client_update_transient_for(client);
|
||||
client_get_type(client);
|
||||
/* type may have changed, so update the layer */
|
||||
client_calc_layer(client);
|
||||
client_setup_decor_and_functions(client);
|
||||
}
|
||||
else if (msgtype == prop_atoms.net_wm_name ||
|
||||
msgtype == prop_atoms.wm_name)
|
||||
client_update_title(client);
|
||||
else if (msgtype == prop_atoms.net_wm_icon_name ||
|
||||
msgtype == prop_atoms.wm_icon_name)
|
||||
client_update_icon_title(client);
|
||||
else if (msgtype == prop_atoms.wm_class)
|
||||
client_update_class(client);
|
||||
else if (msgtype == prop_atoms.wm_protocols) {
|
||||
client_update_protocols(client);
|
||||
client_setup_decor_and_functions(client);
|
||||
}
|
||||
else if (msgtype == prop_atoms.net_wm_strut)
|
||||
client_update_strut(client);
|
||||
else if (msgtype == prop_atoms.net_wm_icon)
|
||||
client_update_icons(client);
|
||||
else if (msgtype == prop_atoms.kwm_win_icon)
|
||||
client_update_kwm_icon(client);
|
||||
}
|
||||
}
|
12
c/event.h
Normal file
12
c/event.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef __events_h
|
||||
#define __events_h
|
||||
|
||||
/*! Time at which the last event with a timestamp occured. */
|
||||
extern Time event_lasttime;
|
||||
|
||||
void event_startup();
|
||||
void event_shutdown();
|
||||
|
||||
void event_loop();
|
||||
|
||||
#endif
|
433
c/eventdata.c
Normal file
433
c/eventdata.c
Normal file
|
@ -0,0 +1,433 @@
|
|||
#include "eventdata.h"
|
||||
#include "openbox.h"
|
||||
#include "event.h"
|
||||
#include "clientwrap.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/*
|
||||
*
|
||||
* Define the type 'EventData'
|
||||
*
|
||||
*/
|
||||
|
||||
#define IS_EVENTDATA(v) ((v)->ob_type == &EventDataType)
|
||||
#define CHECK_EVENTDATA(self, funcname) { \
|
||||
if (!IS_EVENTDATA(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires an 'EventData' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
staticforward PyTypeObject EventDataType;
|
||||
|
||||
static PyObject *eventdata_type(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "type");
|
||||
if (!PyArg_ParseTuple(args, ":type"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(self->type);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_time(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "time");
|
||||
if (!PyArg_ParseTuple(args, ":time"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(event_lasttime);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_context(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "context");
|
||||
if (!PyArg_ParseTuple(args, ":context"))
|
||||
return NULL;
|
||||
return PyString_FromString(self->context);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_client(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "client");
|
||||
if (!PyArg_ParseTuple(args, ":client"))
|
||||
return NULL;
|
||||
if (self->client == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
} else {
|
||||
return clientwrap_new(self->client);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *eventdata_keycode(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "keycode");
|
||||
if (!PyArg_ParseTuple(args, ":keycode"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Key_Press:
|
||||
case Key_Release:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Key event");
|
||||
return NULL;
|
||||
}
|
||||
return PyInt_FromLong(self->details.key->keycode);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_modifiers(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "key");
|
||||
if (!PyArg_ParseTuple(args, ":key"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Key_Press:
|
||||
case Key_Release:
|
||||
case Pointer_Press:
|
||||
case Pointer_Release:
|
||||
case Pointer_Motion:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Key or Pointer event");
|
||||
return NULL;
|
||||
}
|
||||
return PyInt_FromLong(self->details.key->modifiers);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_keyName(EventData *self, PyObject *args)
|
||||
{
|
||||
GList *it;
|
||||
PyObject *tuple;
|
||||
int i;
|
||||
|
||||
CHECK_EVENTDATA(self, "keyName");
|
||||
if (!PyArg_ParseTuple(args, ":keyName"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Key_Press:
|
||||
case Key_Release:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Key event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (self->details.key->keylist != NULL) {
|
||||
tuple = PyTuple_New(g_list_length(self->details.key->keylist));
|
||||
for (i = 0, it = self->details.key->keylist; it != NULL;
|
||||
it = it->next, ++i)
|
||||
PyTuple_SET_ITEM(tuple, i, PyString_FromString(it->data));
|
||||
return tuple;
|
||||
} else {
|
||||
GString *str = g_string_sized_new(0);
|
||||
KeySym sym;
|
||||
|
||||
if (self->details.key->modifiers & ControlMask)
|
||||
g_string_append(str, "C-");
|
||||
if (self->details.key->modifiers & ShiftMask)
|
||||
g_string_append(str, "S-");
|
||||
if (self->details.key->modifiers & Mod1Mask)
|
||||
g_string_append(str, "Mod1-");
|
||||
if (self->details.key->modifiers & Mod2Mask)
|
||||
g_string_append(str, "Mod2-");
|
||||
if (self->details.key->modifiers & Mod3Mask)
|
||||
g_string_append(str, "Mod3-");
|
||||
if (self->details.key->modifiers & Mod4Mask)
|
||||
g_string_append(str, "Mod4-");
|
||||
if (self->details.key->modifiers & Mod5Mask)
|
||||
g_string_append(str, "Mod5-");
|
||||
|
||||
sym = XKeycodeToKeysym(ob_display, self->details.key->keycode, 0);
|
||||
if (sym == NoSymbol)
|
||||
g_string_append(str, "NoSymbol");
|
||||
else {
|
||||
char *name = XKeysymToString(sym);
|
||||
if (name == NULL)
|
||||
name = "Undefined";
|
||||
g_string_append(str, name);
|
||||
}
|
||||
|
||||
tuple = PyTuple_New(1);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyString_FromString(str->str));
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
return tuple;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *eventdata_button(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "button");
|
||||
if (!PyArg_ParseTuple(args, ":button"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Pointer_Press:
|
||||
case Pointer_Release:
|
||||
case Pointer_Motion:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Pointer event");
|
||||
return NULL;
|
||||
}
|
||||
return PyInt_FromLong(self->details.pointer->button);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_buttonName(EventData *self, PyObject *args)
|
||||
{
|
||||
CHECK_EVENTDATA(self, "buttonName");
|
||||
if (!PyArg_ParseTuple(args, ":buttonName"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Pointer_Press:
|
||||
case Pointer_Release:
|
||||
case Pointer_Motion:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Pointer event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (self->details.pointer->name != NULL) {
|
||||
return PyString_FromString(self->details.pointer->name);
|
||||
} else {
|
||||
PyObject *pystr;
|
||||
GString *str = g_string_sized_new(0);
|
||||
|
||||
if (self->details.pointer->modifiers & ControlMask)
|
||||
g_string_append(str, "C-");
|
||||
if (self->details.pointer->modifiers & ShiftMask)
|
||||
g_string_append(str, "S-");
|
||||
if (self->details.pointer->modifiers & Mod1Mask)
|
||||
g_string_append(str, "Mod1-");
|
||||
if (self->details.pointer->modifiers & Mod2Mask)
|
||||
g_string_append(str, "Mod2-");
|
||||
if (self->details.pointer->modifiers & Mod3Mask)
|
||||
g_string_append(str, "Mod3-");
|
||||
if (self->details.pointer->modifiers & Mod4Mask)
|
||||
g_string_append(str, "Mod4-");
|
||||
if (self->details.pointer->modifiers & Mod5Mask)
|
||||
g_string_append(str, "Mod5-");
|
||||
|
||||
g_string_append_printf(str, "%d", self->details.pointer->button);
|
||||
|
||||
pystr = PyString_FromString(str->str);
|
||||
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
return pystr;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *eventdata_position(EventData *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_EVENTDATA(self, "position");
|
||||
if (!PyArg_ParseTuple(args, ":position"))
|
||||
return NULL;
|
||||
switch (self->type) {
|
||||
case Pointer_Press:
|
||||
case Pointer_Release:
|
||||
case Pointer_Motion:
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"The EventData object is not a Pointer event");
|
||||
return NULL;
|
||||
}
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->details.pointer->xroot));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->details.pointer->yroot));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyMethodDef EventDataAttributeMethods[] = {
|
||||
{"type", (PyCFunction)eventdata_type, METH_VARARGS,
|
||||
"data.type() -- Return the event type"},
|
||||
{"context", (PyCFunction)eventdata_context, METH_VARARGS,
|
||||
"data.context() -- Return the context for the event. If it is "
|
||||
"\"client\", then data.client() can be used to find out the "
|
||||
"client."},
|
||||
{"client", (PyCFunction)eventdata_client, METH_VARARGS,
|
||||
"data.client() -- Return the client for the event. This may be None if "
|
||||
"there is no client, even if data.context() gives Context_Client."},
|
||||
{"time", (PyCFunction)eventdata_time, METH_VARARGS,
|
||||
"data.time() -- Return the time at which the last X event occured with "
|
||||
"a timestamp. Should be the time at which this event, or the event that "
|
||||
"caused this event to occur happened."},
|
||||
{"modifiers", (PyCFunction)eventdata_modifiers, METH_VARARGS,
|
||||
"data.modifiers() -- Return the modifier keymask that was pressed "
|
||||
"when the event occured. A bitmask of ShiftMask, LockMask, ControlMask, "
|
||||
"Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask. Cannot be used "
|
||||
"when the data.type() is not a Key_* or Pointer_* event type."},
|
||||
{"keycode", (PyCFunction)eventdata_keycode, METH_VARARGS,
|
||||
"data.keycode() -- Return the keycode for the key which generated the "
|
||||
"event. Cannot be used when the data.type() is not a Key_* event type."},
|
||||
{"keyName", (PyCFunction)eventdata_keyName, METH_VARARGS,
|
||||
"data.keyName() -- Return a tuple of the string names of the key which "
|
||||
"generated the event. Cannot be used when the data.type() is not a Key_* "
|
||||
"event "
|
||||
"type."},
|
||||
{"button", (PyCFunction)eventdata_button, METH_VARARGS,
|
||||
"data.button() -- Return the pointer button which generated the event. "
|
||||
"Cannot be used when the data.type() is not a Pointer_* event type."},
|
||||
{"buttonName", (PyCFunction)eventdata_keyName, METH_VARARGS,
|
||||
"data.buttonName() -- Return the name of the button which generated the "
|
||||
"event. Cannot be used when the data.type() is not a Pointer_* event "
|
||||
"type."},
|
||||
{"position", (PyCFunction)eventdata_position, METH_VARARGS,
|
||||
"data.position() -- Returns the current position of the pointer on the "
|
||||
"root window when the event was generated. Gives the position in a tuple "
|
||||
"with a format of (x, y). Cannot be used when the data.type() is not a "
|
||||
"Pointer_* event type."},
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static void data_dealloc(EventData *self)
|
||||
{
|
||||
GList *it;
|
||||
|
||||
switch(self->type) {
|
||||
case Logical_EnterWindow:
|
||||
case Logical_LeaveWindow:
|
||||
case Logical_NewWindow:
|
||||
case Logical_CloseWindow:
|
||||
case Logical_Startup:
|
||||
case Logical_Shutdown:
|
||||
case Logical_RequestActivate:
|
||||
case Logical_WindowShow:
|
||||
case Logical_WindowHide:
|
||||
case Logical_Focus:
|
||||
case Logical_Bell:
|
||||
case Logical_UrgentWindow:
|
||||
g_free(self->details.logical);
|
||||
break;
|
||||
case Pointer_Press:
|
||||
case Pointer_Release:
|
||||
case Pointer_Motion:
|
||||
if (self->details.pointer->name != NULL)
|
||||
g_free(self->details.pointer->name);
|
||||
g_free(self->details.pointer);
|
||||
break;
|
||||
case Key_Press:
|
||||
case Key_Release:
|
||||
for (it = self->details.key->keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(self->details.key->keylist);
|
||||
g_free(self->details.key);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyObject *eventdata_getattr(EventData *self, char *name)
|
||||
{
|
||||
return Py_FindMethod(EventDataAttributeMethods, (PyObject*)self, name);
|
||||
}
|
||||
|
||||
static PyTypeObject EventDataType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"EventData",
|
||||
sizeof(EventData),
|
||||
0,
|
||||
(destructor) data_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) eventdata_getattr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
|
||||
|
||||
void eventdata_startup()
|
||||
{
|
||||
EventDataType.ob_type = &PyType_Type;
|
||||
PyType_Ready(&EventDataType);
|
||||
}
|
||||
|
||||
void eventdata_shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
void eventdata_free(EventData *data)
|
||||
{
|
||||
Py_DECREF(data);
|
||||
}
|
||||
|
||||
EventData *eventdata_new_logical(EventType type, GQuark context,
|
||||
struct Client *client)
|
||||
{
|
||||
EventData *data;
|
||||
|
||||
g_assert(type < Pointer_Press);
|
||||
|
||||
data = PyObject_New(EventData, &EventDataType);
|
||||
data->type = type;
|
||||
data->context = g_quark_to_string(context);
|
||||
data->client = client;
|
||||
data->details.logical = g_new(LogicalEvent, 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
EventData *eventdata_new_pointer(EventType type, GQuark context,
|
||||
struct Client *client, guint modifiers,
|
||||
guint button, char *name,
|
||||
int xroot, int yroot)
|
||||
{
|
||||
EventData *data;
|
||||
|
||||
g_assert(type >= Pointer_Press && type < Key_Press);
|
||||
|
||||
data = PyObject_New(EventData, &EventDataType);
|
||||
data->type = type;
|
||||
data->context = g_quark_to_string(context);
|
||||
data->client = client;
|
||||
data->details.pointer = g_new(PointerEvent, 1);
|
||||
data->details.pointer->modifiers = modifiers;
|
||||
data->details.pointer->button = button;
|
||||
data->details.pointer->name = name == NULL ? name : g_strdup(name);
|
||||
data->details.pointer->xroot = xroot;
|
||||
data->details.pointer->yroot = yroot;
|
||||
return data;
|
||||
}
|
||||
|
||||
EventData *eventdata_new_key(EventType type, GQuark context,
|
||||
struct Client *client, guint modifiers,
|
||||
guint keycode, GList *keylist)
|
||||
{
|
||||
EventData *data;
|
||||
GList *mykeylist, *it;
|
||||
|
||||
g_assert(type >= Key_Press);
|
||||
|
||||
data = PyObject_New(EventData, &EventDataType);
|
||||
data->type = type;
|
||||
data->context = g_quark_to_string(context);
|
||||
data->client = client;
|
||||
data->details.key = g_new(KeyEvent, 1);
|
||||
|
||||
/* make a copy of the keylist.
|
||||
If the user were to clear the key bindings, then the keylist given here
|
||||
would no longer point at valid memory.*/
|
||||
mykeylist = g_list_copy(keylist); /* shallow copy */
|
||||
for (it = mykeylist; it != NULL; it = it->next) /* deep copy */
|
||||
it->data = g_strdup(it->data);
|
||||
|
||||
data->details.key->keylist = mykeylist;
|
||||
data->details.key->keycode = keycode;
|
||||
data->details.key->modifiers = modifiers;
|
||||
return data;
|
||||
}
|
74
c/eventdata.h
Normal file
74
c/eventdata.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
#ifndef __eventdata_h
|
||||
#define __eventdata_h
|
||||
|
||||
#include "obexport.h"
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
typedef struct {
|
||||
int temp:1; /* just a placeholder to kill warnings for now.. */
|
||||
} LogicalEvent;
|
||||
|
||||
typedef struct {
|
||||
/*! The button which generated the event */
|
||||
guint button;
|
||||
/*! The pointer's x position on the root window when the event occured */
|
||||
int xroot;
|
||||
/*! The pointer's y position on the root window when the event occured */
|
||||
int yroot;
|
||||
/*! The modifiers that were pressed when the event occured. A bitmask of:
|
||||
ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
|
||||
Mod4Mask, Mod5Mask */
|
||||
guint modifiers;
|
||||
/*! The name of the button/modifier combination being pressed,
|
||||
eg "Mod1-1" */
|
||||
char *name;
|
||||
} PointerEvent;
|
||||
|
||||
typedef struct {
|
||||
/*! The keycode of the key which generated the event */
|
||||
guint keycode;
|
||||
/*! The modifiers that were pressed when the event occured. A bitmask of:
|
||||
ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
|
||||
Mod4Mask, Mod5Mask */
|
||||
guint modifiers;
|
||||
/* The list of strings which make up the chain that fired,
|
||||
eg ("Mod1-a", "a") */
|
||||
GList *keylist;
|
||||
} KeyEvent;
|
||||
|
||||
/* EventData is a PyObject */
|
||||
typedef struct EventData {
|
||||
PyObject_HEAD
|
||||
/* The type of event which occured */
|
||||
EventType type;
|
||||
/*! The context in which the event occured, the type of window it occured
|
||||
for. */
|
||||
const char *context;
|
||||
/* The Client on which the event occured, or NULL */
|
||||
struct Client *client;
|
||||
|
||||
union EventDetails {
|
||||
LogicalEvent *logical;
|
||||
PointerEvent *pointer;
|
||||
KeyEvent *key;
|
||||
} details;
|
||||
} EventData;
|
||||
|
||||
void eventdata_startup();
|
||||
void eventdata_shutdown();
|
||||
|
||||
EventData *eventdata_new_logical(EventType type, GQuark context,
|
||||
struct Client *client);
|
||||
EventData *eventdata_new_pointer(EventType type, GQuark context,
|
||||
struct Client *client, guint modifiers,
|
||||
guint button, char *name,
|
||||
int xroot, int yroot);
|
||||
EventData *eventdata_new_key(EventType type, GQuark context,
|
||||
struct Client *client, guint modifiers,
|
||||
guint keycode, GList *keylist);
|
||||
void eventdata_free(EventData *data);
|
||||
|
||||
#endif
|
34
c/extensions.c
Normal file
34
c/extensions.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "openbox.h"
|
||||
#include "extensions.h"
|
||||
|
||||
gboolean extensions_xkb = FALSE;
|
||||
int extensions_xkb_event_basep;
|
||||
gboolean extensions_shape = FALSE;
|
||||
int extensions_shape_event_basep;
|
||||
gboolean extensions_xinerama = FALSE;
|
||||
int extensions_xinerama_event_basep;
|
||||
|
||||
|
||||
void extensions_query_all()
|
||||
{
|
||||
int junk;
|
||||
(void)junk;
|
||||
|
||||
#ifdef XKB
|
||||
extensions_xkb =
|
||||
XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
|
||||
&junk, NULL, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef SHAPE
|
||||
extensions_shape =
|
||||
XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
|
||||
&junk);
|
||||
#endif
|
||||
|
||||
#ifdef XINERAMA
|
||||
extensions_xinerama =
|
||||
XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
|
||||
&junk);
|
||||
#endif
|
||||
}
|
33
c/extensions.h
Normal file
33
c/extensions.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef __extensions_h
|
||||
#define __extensions_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#ifdef XKB
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
#ifdef SHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#include <glib.h>
|
||||
|
||||
/*! Does the display have the XKB extension? */
|
||||
extern gboolean extensions_xkb;
|
||||
/*! Base for events for the XKB extension */
|
||||
extern int extensions_xkb_event_basep;
|
||||
|
||||
/*! Does the display have the Shape extension? */
|
||||
extern gboolean extensions_shape;
|
||||
/*! Base for events for the Shape extension */
|
||||
extern int extensions_shape_event_basep;
|
||||
|
||||
/*! Does the display have the Xinerama extension? */
|
||||
extern gboolean extensions_xinerama;
|
||||
/*! Base for events for the Xinerama extension */
|
||||
extern int extensions_xinerama_event_basep;
|
||||
|
||||
void extensions_query_all();
|
||||
|
||||
#endif
|
56
c/focus.c
Normal file
56
c/focus.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "openbox.h"
|
||||
#include "client.h"
|
||||
#include "screen.h"
|
||||
#include "prop.h"
|
||||
#include "hooks.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
Client *focus_client = NULL;
|
||||
|
||||
Window focus_backup = None;
|
||||
|
||||
void focus_set_client(Client *client);
|
||||
|
||||
void focus_startup()
|
||||
{
|
||||
/* create the window which gets focus when no clients get it. Have to
|
||||
make it override-redirect so we don't try manage it, since it is
|
||||
mapped. */
|
||||
XSetWindowAttributes attrib;
|
||||
|
||||
attrib.override_redirect = TRUE;
|
||||
focus_backup = XCreateWindow(ob_display, ob_root,
|
||||
-100, -100, 1, 1, 0, 0, InputOnly,
|
||||
CopyFromParent, CWOverrideRedirect, &attrib);
|
||||
XMapRaised(ob_display, focus_backup);
|
||||
|
||||
/* start with nothing focused */
|
||||
focus_set_client(NULL);
|
||||
}
|
||||
|
||||
void focus_set_client(Client *client)
|
||||
{
|
||||
Window active;
|
||||
|
||||
/* sometimes this is called with the already-focused window, this is
|
||||
important for the python scripts to work (eg, c = 0 twice). don't just
|
||||
return if _focused_client == c */
|
||||
|
||||
/* uninstall the old colormap, and install the new one */
|
||||
screen_install_colormap(focus_client, FALSE);
|
||||
screen_install_colormap(client, TRUE);
|
||||
|
||||
|
||||
if (client == NULL) {
|
||||
/* when nothing will be focused, send focus to the backup target */
|
||||
XSetInputFocus(ob_display, focus_backup, RevertToNone, CurrentTime);
|
||||
}
|
||||
|
||||
focus_client = client;
|
||||
|
||||
/* set the NET_ACTIVE_WINDOW hint */
|
||||
active = client ? client->window : None;
|
||||
PROP_SET32(ob_root, net_active_window, window, active);
|
||||
|
||||
LOGICALHOOK(Focus, g_quark_try_string("client"), client);
|
||||
}
|
20
c/focus.h
Normal file
20
c/focus.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __focus_h
|
||||
#define __focus_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
/*! The window which gets focus when nothing else will be focused */
|
||||
extern Window focus_backup;
|
||||
|
||||
/*! The client which is currently focused */
|
||||
extern struct Client *focus_client;
|
||||
|
||||
void focus_startup();
|
||||
|
||||
/*! Specify which client is currently focused, this doesn't actually
|
||||
send focus anywhere, its called by the Focus event handlers */
|
||||
void focus_set_client(struct Client *client);
|
||||
|
||||
#endif
|
533
c/frame.c
Normal file
533
c/frame.c
Normal file
|
@ -0,0 +1,533 @@
|
|||
#include "openbox.h"
|
||||
#include "frame.h"
|
||||
#include "extensions.h"
|
||||
#include "hooks.h"
|
||||
|
||||
#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
|
||||
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
|
||||
|
||||
static Window createWindow(Window parent, unsigned long mask,
|
||||
XSetWindowAttributes *attrib)
|
||||
{
|
||||
/* XXX DONT USE THE DEFAULT SHIT */
|
||||
return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
|
||||
DefaultDepth(ob_display, ob_screen), InputOutput,
|
||||
DefaultVisual(ob_display, ob_screen),
|
||||
mask, attrib);
|
||||
|
||||
}
|
||||
|
||||
Frame *frame_new(Client *client)
|
||||
{
|
||||
XSetWindowAttributes attrib;
|
||||
unsigned long mask;
|
||||
Frame *self;
|
||||
|
||||
self = g_new(Frame, 1);
|
||||
|
||||
self->client = client;
|
||||
self->visible = FALSE;
|
||||
|
||||
/* create all of the decor windows */
|
||||
mask = CWOverrideRedirect | CWEventMask;
|
||||
attrib.event_mask = FRAME_EVENTMASK;
|
||||
attrib.override_redirect = TRUE;
|
||||
self->window = createWindow(ob_root, mask, &attrib);
|
||||
|
||||
mask = 0;
|
||||
self->plate = createWindow(self->window, mask, &attrib);
|
||||
mask = CWEventMask;
|
||||
attrib.event_mask = (ButtonPressMask | ButtonReleaseMask |
|
||||
ButtonMotionMask | ExposureMask);
|
||||
self->title = createWindow(self->window, mask, &attrib);
|
||||
self->label = createWindow(self->title, mask, &attrib);
|
||||
self->max = createWindow(self->title, mask, &attrib);
|
||||
self->close = createWindow(self->title, mask, &attrib);
|
||||
self->desk = createWindow(self->title, mask, &attrib);
|
||||
self->icon = createWindow(self->title, mask, &attrib);
|
||||
self->iconify = createWindow(self->title, mask, &attrib);
|
||||
self->handle = createWindow(self->window, mask, &attrib);
|
||||
mask |= CWCursor;
|
||||
attrib.cursor = ob_cursors.ll_angle;
|
||||
self->lgrip = createWindow(self->handle, mask, &attrib);
|
||||
attrib.cursor = ob_cursors.lr_angle;
|
||||
self->rgrip = createWindow(self->handle, mask, &attrib);
|
||||
|
||||
/* the other stuff is shown based on decor settings */
|
||||
XMapWindow(ob_display, self->plate);
|
||||
XMapWindow(ob_display, self->lgrip);
|
||||
XMapWindow(ob_display, self->rgrip);
|
||||
XMapWindow(ob_display, self->label);
|
||||
|
||||
|
||||
/* XXX TEMPORARY OF COURSE!@&*(@! */
|
||||
|
||||
XSetWindowBackground(ob_display, self->title, 0x3333aa);
|
||||
XSetWindowBackground(ob_display, self->handle, 0x3333aa);
|
||||
XSetWindowBackground(ob_display, self->lgrip, 0x2233aa);
|
||||
XSetWindowBackground(ob_display, self->rgrip, 0x2233aa);
|
||||
|
||||
XSetWindowBorder(ob_display, self->window, 0);
|
||||
XSetWindowBorder(ob_display, self->label, 0);
|
||||
XSetWindowBorder(ob_display, self->rgrip, 0);
|
||||
XSetWindowBorder(ob_display, self->lgrip, 0);
|
||||
XSetWindowBorder(ob_display, self->plate, 0x771122);
|
||||
|
||||
/* XXX /TEMPORARY OF COURSE!@&*(@! */
|
||||
|
||||
/* set all the windows for the frame in the client_map */
|
||||
g_hash_table_insert(client_map, (gpointer)self->window, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->plate, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->title, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->label, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->max, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->close, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->desk, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->icon, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->iconify, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->handle, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->lgrip, self->client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->rgrip, self->client);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void frame_free(Frame *self)
|
||||
{
|
||||
/* remove all the windows for the frame from the client_map */
|
||||
g_hash_table_remove(client_map, (gpointer)self->window);
|
||||
g_hash_table_remove(client_map, (gpointer)self->plate);
|
||||
g_hash_table_remove(client_map, (gpointer)self->title);
|
||||
g_hash_table_remove(client_map, (gpointer)self->label);
|
||||
g_hash_table_remove(client_map, (gpointer)self->max);
|
||||
g_hash_table_remove(client_map, (gpointer)self->close);
|
||||
g_hash_table_remove(client_map, (gpointer)self->desk);
|
||||
g_hash_table_remove(client_map, (gpointer)self->icon);
|
||||
g_hash_table_remove(client_map, (gpointer)self->iconify);
|
||||
g_hash_table_remove(client_map, (gpointer)self->handle);
|
||||
g_hash_table_remove(client_map, (gpointer)self->lgrip);
|
||||
g_hash_table_remove(client_map, (gpointer)self->rgrip);
|
||||
|
||||
XDestroyWindow(ob_display, self->window);
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
void frame_grab_client(Frame *self)
|
||||
{
|
||||
/* reparent the client to the frame */
|
||||
XReparentWindow(ob_display, self->client->window, self->plate, 0, 0);
|
||||
/*
|
||||
When reparenting the client window, it is usually not mapped yet, since
|
||||
this occurs from a MapRequest. However, in the case where Openbox is
|
||||
starting up, the window is already mapped, so we'll see unmap events for
|
||||
it. There are 2 unmap events generated that we see, one with the 'event'
|
||||
member set the root window, and one set to the client, but both get
|
||||
handled and need to be ignored.
|
||||
*/
|
||||
if (ob_state == State_Starting)
|
||||
self->client->ignore_unmaps += 2;
|
||||
|
||||
/* select the event mask on the client's parent (to receive config/map
|
||||
req's) the ButtonPress is to catch clicks on the client border */
|
||||
XSelectInput(ob_display, self->plate, PLATE_EVENTMASK);
|
||||
|
||||
/* map the client so it maps when the frame does */
|
||||
XMapWindow(ob_display, self->client->window);
|
||||
|
||||
frame_adjust_size(self);
|
||||
frame_adjust_position(self);
|
||||
}
|
||||
|
||||
void frame_release_client(Frame *self)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
/* check if the app has already reparented its window away */
|
||||
if (XCheckTypedWindowEvent(ob_display, self->client->window,
|
||||
ReparentNotify, &ev)) {
|
||||
XPutBackEvent(ob_display, &ev);
|
||||
/* re-map the window since the unmanaging process unmaps it */
|
||||
XMapWindow(ob_display, self->client->window);
|
||||
} else {
|
||||
/* according to the ICCCM - if the client doesn't reparent itself,
|
||||
then we will reparent the window to root for them */
|
||||
XReparentWindow(ob_display, self->client->window, ob_root,
|
||||
self->client->area.x, self->client->area.y);
|
||||
}
|
||||
}
|
||||
|
||||
void frame_show(Frame *self)
|
||||
{
|
||||
if (!self->visible) {
|
||||
self->visible = TRUE;
|
||||
XMapWindow(ob_display, self->window);
|
||||
LOGICALHOOK(WindowShow, g_quark_try_string("client"), self->client);
|
||||
}
|
||||
}
|
||||
|
||||
void frame_hide(Frame *self)
|
||||
{
|
||||
if (self->visible) {
|
||||
self->visible = FALSE;
|
||||
self->client->ignore_unmaps++;
|
||||
XUnmapWindow(ob_display, self->window);
|
||||
LOGICALHOOK(WindowHide, g_quark_try_string("client"), self->client);
|
||||
}
|
||||
}
|
||||
|
||||
void frame_adjust_size(Frame *self)
|
||||
{
|
||||
self->decorations = self->client->decorations;
|
||||
|
||||
/* XXX set shit from the style */
|
||||
self->geom.font_height = 10;
|
||||
self->geom.bevel = 1;
|
||||
self->geom.button_size = self->geom.font_height - 2;
|
||||
self->geom.handle_height = 2;
|
||||
self->geom.grip_width = self->geom.button_size * 2;
|
||||
XResizeWindow(ob_display, self->lgrip, self->geom.grip_width,
|
||||
self->geom.handle_height);
|
||||
XResizeWindow(ob_display, self->rgrip, self->geom.grip_width,
|
||||
self->geom.handle_height);
|
||||
|
||||
|
||||
|
||||
|
||||
if (self->decorations & Decor_Border) {
|
||||
self->geom.bwidth = 1;/*XXX style->frameBorderWidth(); */
|
||||
self->geom.cbwidth = 1; /*XXX style->clientBorderWidth(); */
|
||||
} else {
|
||||
self->geom.bwidth = self->geom.cbwidth = 0;
|
||||
}
|
||||
STRUT_SET(self->innersize, self->geom.cbwidth, self->geom.cbwidth,
|
||||
self->geom.cbwidth, self->geom.cbwidth);
|
||||
self->geom.width = self->client->area.width + self->geom.cbwidth * 2;
|
||||
g_assert(self->geom.width > 0);
|
||||
|
||||
/* set border widths */
|
||||
XSetWindowBorderWidth(ob_display, self->plate, self->geom.cbwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->window, self->geom.bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->title, self->geom.bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->handle, self->geom.bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->lgrip, self->geom.bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->rgrip, self->geom.bwidth);
|
||||
|
||||
/* position/size and map/unmap all the windows */
|
||||
|
||||
if (self->decorations & Decor_Titlebar) {
|
||||
self->geom.title_height = self->geom.font_height +
|
||||
self->geom.bevel * 2;
|
||||
XMoveResizeWindow(ob_display, self->title,
|
||||
-self->geom.bwidth, -self->geom.bwidth,
|
||||
self->geom.width, self->geom.title_height);
|
||||
self->innersize.top += self->geom.title_height + self->geom.bwidth;
|
||||
XMapWindow(ob_display, self->title);
|
||||
|
||||
/* layout the title bar elements */
|
||||
/*XXX layoutTitle(); */
|
||||
} else {
|
||||
XUnmapWindow(ob_display, self->title);
|
||||
/* make all the titlebar stuff not render */
|
||||
self->decorations &= ~(Decor_Icon | Decor_Iconify |
|
||||
Decor_Maximize | Decor_Close |
|
||||
Decor_AllDesktops);
|
||||
}
|
||||
|
||||
if (self->decorations & Decor_Handle) {
|
||||
self->geom.handle_y = self->innersize.top +
|
||||
self->client->area.height + self->geom.cbwidth;
|
||||
XMoveResizeWindow(ob_display, self->handle,
|
||||
-self->geom.bwidth, self->geom.handle_y,
|
||||
self->geom.width, self->geom.handle_height);
|
||||
XMoveWindow(ob_display, self->lgrip,
|
||||
-self->geom.bwidth, -self->geom.bwidth);
|
||||
XMoveWindow(ob_display, self->rgrip,
|
||||
-self->geom.bwidth + self->geom.width -
|
||||
self->geom.grip_width, -self->geom.bwidth);
|
||||
self->innersize.bottom += self->geom.handle_height +
|
||||
self->geom.bwidth;
|
||||
XMapWindow(ob_display, self->handle);
|
||||
} else
|
||||
XUnmapWindow(ob_display, self->handle);
|
||||
|
||||
XResizeWindow(ob_display, self->window, self->geom.width,
|
||||
(self->client->shaded ? self->geom.title_height :
|
||||
self->innersize.top + self->innersize.bottom +
|
||||
self->client->area.height));
|
||||
|
||||
/* do this in two steps because clients whose gravity is set to
|
||||
'Static' don't end up getting moved at all with an XMoveResizeWindow */
|
||||
XMoveWindow(ob_display, self->plate,
|
||||
self->innersize.left - self->geom.cbwidth,
|
||||
self->innersize.top - self->geom.cbwidth);
|
||||
XResizeWindow(ob_display, self->plate, self->client->area.width,
|
||||
self->client->area.height);
|
||||
|
||||
STRUT_SET(self->size,
|
||||
self->innersize.left + self->geom.bwidth,
|
||||
self->innersize.right + self->geom.bwidth,
|
||||
self->innersize.top + self->geom.bwidth,
|
||||
self->innersize.bottom + self->geom.bwidth);
|
||||
|
||||
RECT_SET_SIZE(self->area,
|
||||
self->client->area.width +
|
||||
self->size.left + self->size.right,
|
||||
self->client->area.height +
|
||||
self->size.top + self->size.bottom);
|
||||
|
||||
/*
|
||||
// render all the elements
|
||||
int screen = _client->screen();
|
||||
bool focus = _client->focused();
|
||||
if (_decorations & Client::Decor_Titlebar) {
|
||||
render(screen, otk::Size(geom.width, geom.title_height()), _title,
|
||||
&_title_sur, *(focus ? style->titlebarFocusBackground() :
|
||||
style->titlebarUnfocusBackground()), false);
|
||||
|
||||
renderLabel();
|
||||
renderMax();
|
||||
renderDesk();
|
||||
renderIconify();
|
||||
renderIcon();
|
||||
renderClose();
|
||||
}
|
||||
|
||||
if (_decorations & Client::Decor_Handle) {
|
||||
render(screen, otk::Size(geom.width, geom.handle_height), _handle,
|
||||
&_handle_sur, *(focus ? style->handleFocusBackground() :
|
||||
style->handleUnfocusBackground()));
|
||||
render(screen, otk::Size(geom.grip_width(), geom.handle_height), _lgrip,
|
||||
&_grip_sur, *(focus ? style->gripFocusBackground() :
|
||||
style->gripUnfocusBackground()));
|
||||
if ((focus ? style->gripFocusBackground() :
|
||||
style->gripUnfocusBackground())->parentRelative())
|
||||
XSetWindowBackgroundPixmap(**otk::display, _rgrip, ParentRelative);
|
||||
else {
|
||||
XSetWindowBackgroundPixmap(**otk::display, _rgrip, _grip_sur->pixmap());
|
||||
}
|
||||
XClearWindow(**otk::display, _rgrip);
|
||||
}
|
||||
|
||||
XSetWindowBorder(**otk::display, _plate,
|
||||
focus ? style->clientBorderFocusColor()->pixel() :
|
||||
style->clientBorderUnfocusColor()->pixel());
|
||||
|
||||
*/
|
||||
|
||||
frame_adjust_shape(self);
|
||||
}
|
||||
|
||||
void frame_adjust_position(Frame *self)
|
||||
{
|
||||
self->area.x = self->client->area.x;
|
||||
self->area.y = self->client->area.y;
|
||||
frame_client_gravity(self, &self->area.x, &self->area.y);
|
||||
XMoveWindow(ob_display, self->window, self->area.x, self->area.y);
|
||||
}
|
||||
|
||||
void frame_adjust_shape(Frame *self)
|
||||
{
|
||||
#ifdef SHAPE
|
||||
int num;
|
||||
XRectangle xrect[2];
|
||||
|
||||
if (!self->client->shaped) {
|
||||
/* clear the shape on the frame window */
|
||||
XShapeCombineMask(ob_display, self->window, ShapeBounding,
|
||||
self->innersize.left,
|
||||
self->innersize.top,
|
||||
None, ShapeSet);
|
||||
} else {
|
||||
/* make the frame's shape match the clients */
|
||||
XShapeCombineShape(ob_display, self->window, ShapeBounding,
|
||||
self->innersize.left,
|
||||
self->innersize.top,
|
||||
self->client->window, ShapeBounding, ShapeSet);
|
||||
|
||||
num = 0;
|
||||
if (self->decorations & Decor_Titlebar) {
|
||||
xrect[0].x = -self->geom.bevel;
|
||||
xrect[0].y = -self->geom.bevel;
|
||||
xrect[0].width = self->geom.width + self->geom.bwidth * 2;
|
||||
xrect[0].height = self->geom.title_height +
|
||||
self->geom.bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
if (self->decorations & Decor_Handle) {
|
||||
xrect[1].x = -self->geom.bevel;
|
||||
xrect[1].y = self->geom.handle_y;
|
||||
xrect[1].width = self->geom.width + self->geom.bwidth * 2;
|
||||
xrect[1].height = self->geom.handle_height +
|
||||
self->geom.bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
XShapeCombineRectangles(ob_display, self->window,
|
||||
ShapeBounding, 0, 0, xrect, num,
|
||||
ShapeUnion, Unsorted);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void frame_client_gravity(Frame *self, int *x, int *y)
|
||||
{
|
||||
/* horizontal */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case SouthWestGravity:
|
||||
case WestGravity:
|
||||
break;
|
||||
|
||||
case NorthGravity:
|
||||
case SouthGravity:
|
||||
case CenterGravity:
|
||||
*x -= (self->size.left + self->size.right) / 2;
|
||||
break;
|
||||
|
||||
case NorthEastGravity:
|
||||
case SouthEastGravity:
|
||||
case EastGravity:
|
||||
*x -= self->size.left + self->size.right;
|
||||
break;
|
||||
|
||||
case ForgetGravity:
|
||||
case StaticGravity:
|
||||
*x -= self->size.left;
|
||||
break;
|
||||
}
|
||||
|
||||
/* vertical */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case NorthEastGravity:
|
||||
case NorthGravity:
|
||||
break;
|
||||
|
||||
case CenterGravity:
|
||||
case EastGravity:
|
||||
case WestGravity:
|
||||
*y -= (self->size.top + self->size.bottom) / 2;
|
||||
break;
|
||||
|
||||
case SouthWestGravity:
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
*y -= self->size.top + self->size.bottom;
|
||||
break;
|
||||
|
||||
case ForgetGravity:
|
||||
case StaticGravity:
|
||||
*y -= self->size.top;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void frame_frame_gravity(Frame *self, int *x, int *y)
|
||||
{
|
||||
/* horizontal */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
*x += (self->size.left + self->size.right) / 2;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
*x += self->size.left + self->size.right;
|
||||
break;
|
||||
case StaticGravity:
|
||||
case ForgetGravity:
|
||||
x += self->size.left;
|
||||
break;
|
||||
}
|
||||
|
||||
/* vertical */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
*y += (self->size.top + self->size.bottom) / 2;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
*y += self->size.top + self->size.bottom;
|
||||
break;
|
||||
case StaticGravity:
|
||||
case ForgetGravity:
|
||||
*y += self->size.top;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void frame_adjust_state(Frame *self)
|
||||
{
|
||||
/* XXX do shit.. buttons? */
|
||||
}
|
||||
|
||||
void frame_adjust_focus(Frame *self)
|
||||
{
|
||||
/* XXX optimizations later... */
|
||||
frame_adjust_size(self);
|
||||
}
|
||||
|
||||
void frame_adjust_title(Frame *self)
|
||||
{
|
||||
/* XXX optimizations later... */
|
||||
frame_adjust_size(self);
|
||||
}
|
||||
|
||||
void frame_adjust_icon(Frame *self)
|
||||
{
|
||||
/* XXX render icon */
|
||||
}
|
||||
|
||||
GQuark frame_get_context(Client *client, Window win)
|
||||
{
|
||||
Frame *self;
|
||||
|
||||
if (win == ob_root) return g_quark_try_string("root");
|
||||
if (client == NULL) return g_quark_try_string("none");
|
||||
if (win == client->window) return g_quark_try_string("client");
|
||||
|
||||
self = client->frame;
|
||||
if (win == self->window) return g_quark_try_string("frame");
|
||||
if (win == self->plate) return g_quark_try_string("frame");
|
||||
if (win == self->title) return g_quark_try_string("titlebar");
|
||||
if (win == self->label) return g_quark_try_string("titlebar");
|
||||
if (win == self->handle) return g_quark_try_string("handle");
|
||||
if (win == self->lgrip) return g_quark_try_string("blcorner");
|
||||
if (win == self->rgrip) return g_quark_try_string("brcorner");
|
||||
|
||||
return g_quark_try_string("none");
|
||||
}
|
||||
|
||||
void frame_startup(void)
|
||||
{
|
||||
g_quark_from_string("none");
|
||||
g_quark_from_string("root");
|
||||
g_quark_from_string("client");
|
||||
g_quark_from_string("titlebar");
|
||||
g_quark_from_string("handle");
|
||||
g_quark_from_string("frame");
|
||||
g_quark_from_string("blcorner");
|
||||
g_quark_from_string("brcorner");
|
||||
g_quark_from_string("tlcorner");
|
||||
g_quark_from_string("trcorner");
|
||||
g_quark_from_string("foo");
|
||||
}
|
101
c/frame.h
Normal file
101
c/frame.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
#ifndef __frame_h
|
||||
#define __frame_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include "geom.h"
|
||||
#include "client.h"
|
||||
|
||||
/*! Varius geometry settings in the frame decorations */
|
||||
typedef struct {
|
||||
int width; /* title and handle */
|
||||
int font_height;
|
||||
/* int title_height() { return font_height + bevel*2; } */
|
||||
int title_height;
|
||||
int label_width;
|
||||
/* int label_height() { return font_height; } */
|
||||
int handle_height; /* static, from the style */
|
||||
int icon_x; /* x-position of the window icon button */
|
||||
int title_x; /* x-position of the window title */
|
||||
int iconify_x; /* x-position of the window iconify button */
|
||||
int desktop_x; /* x-position of the window all-desktops button */
|
||||
int max_x; /* x-position of the window maximize button */
|
||||
int close_x; /* x-position of the window close button */
|
||||
int handle_y;
|
||||
int button_size; /* static, from the style */
|
||||
/* int grip_width() { return button_size * 2; } */
|
||||
int grip_width;
|
||||
int bevel; /* static, from the style */
|
||||
int bwidth; /* frame elements' border width */
|
||||
int cbwidth; /* client border width */
|
||||
} FrameGeometry;
|
||||
|
||||
typedef struct Frame {
|
||||
Window window;
|
||||
Window plate;
|
||||
Window title;
|
||||
Window label;
|
||||
Window max;
|
||||
Window close;
|
||||
Window desk;
|
||||
Window icon;
|
||||
Window iconify;
|
||||
Window handle;
|
||||
Window lgrip;
|
||||
Window rgrip;
|
||||
|
||||
Strut size;
|
||||
Strut innersize;
|
||||
Rect area;
|
||||
FrameGeometry geom;
|
||||
|
||||
Client *client;
|
||||
int decorations;
|
||||
|
||||
gboolean visible;
|
||||
} Frame;
|
||||
|
||||
Frame *frame_new(struct Client *client);
|
||||
void frame_free(Frame *self);
|
||||
|
||||
void frame_grab_client(Frame *self);
|
||||
void frame_release_client(Frame *self);
|
||||
|
||||
/*! Update the frame's size to match the client */
|
||||
void frame_adjust_size(Frame *self);
|
||||
/*! Update the frame's position to match the client */
|
||||
void frame_adjust_position(Frame *self);
|
||||
/*! Shape the frame window to the client window */
|
||||
void frame_adjust_shape(Frame *self);
|
||||
/*! Update the frame to match the client's new state (for things like toggle
|
||||
buttons, focus, and the title) XXX break this up */
|
||||
void frame_adjust_state(Frame *self);
|
||||
/*! Update the frame to match the client's focused state */
|
||||
void frame_adjust_focus(Frame *self);
|
||||
/*! Update the frame to display the client's current title */
|
||||
void frame_adjust_title(Frame *self);
|
||||
/*! Update the frame to display the client's current icon */
|
||||
void frame_adjust_icon(Frame *self);
|
||||
|
||||
/*! Applies gravity to the client's position to find where the frame should
|
||||
be positioned.
|
||||
@return The proper coordinates for the frame, based on the client.
|
||||
*/
|
||||
void frame_client_gravity(Frame *self, int *x, int *y);
|
||||
|
||||
/*! Reversly applies gravity to the frame's position to find where the client
|
||||
should be positioned.
|
||||
@return The proper coordinates for the client, based on the frame.
|
||||
*/
|
||||
void frame_frame_gravity(Frame *self, int *x, int *y);
|
||||
|
||||
/*! Shows the frame */
|
||||
void frame_show(Frame *self);
|
||||
/*! Hides the frame */
|
||||
void frame_hide(Frame *self);
|
||||
|
||||
/*! inits quarks - this will go in engines later */
|
||||
void frame_startup(void);
|
||||
|
||||
GQuark frame_get_context(Client *client, Window win);
|
||||
|
||||
#endif
|
53
c/geom.h
Normal file
53
c/geom.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef __geom_h
|
||||
#define __geom_h
|
||||
|
||||
#ifdef HAVE_ASSERT_H
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
typedef struct Point {
|
||||
int x;
|
||||
int y;
|
||||
} Point;
|
||||
|
||||
#define POINT_SET(pt, nx, ny) {pt.x = nx; pt.y = ny;}
|
||||
|
||||
typedef struct Size {
|
||||
int width;
|
||||
int height;
|
||||
} Size;
|
||||
|
||||
#define SIZE_SET(sz, w, h) {sz.width = w; sz.height = h;}
|
||||
|
||||
typedef struct Rect {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} Rect;
|
||||
|
||||
#define RECT_SET_POINT(r, nx, ny) \
|
||||
{r.x = ny; r.y = ny;}
|
||||
#define RECT_SET_SIZE(r, w, h) \
|
||||
{r.width = w; r.height = h;}
|
||||
#define RECT_SET(r, nx, ny, w, h) \
|
||||
{r.x = nx; r.y = ny; r.width = w; r.height = h;}
|
||||
|
||||
#define RECT_EQUAL(r1, r2) (r1.x == r2.x && r1.y == r2.y && \
|
||||
r1.width == r2.width && r1.height == r2.height)
|
||||
|
||||
typedef struct Strut {
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} Strut;
|
||||
|
||||
#define STRUT_SET(s, l, t, r, b) \
|
||||
{s.left = l; s.top = t; s.right = r; s.bottom = b; }
|
||||
|
||||
#define STRUT_ADD(s1, s2) \
|
||||
{s1.left = MAX(s1.left, s2.left); s1.right = MAX(s1.right, s2.right); \
|
||||
s1.top = MAX(s1.top, s2.top); s1.bottom = MAX(s1.bottom, s2.bottom); }
|
||||
|
||||
#endif
|
73
c/gettext.h
Normal file
73
c/gettext.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
/* Custom macro to make life easier */
|
||||
#define _(str) gettext(str)
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
285
c/hooks.c
Normal file
285
c/hooks.c
Normal file
|
@ -0,0 +1,285 @@
|
|||
#include "hooks.h"
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
|
||||
/* the 'hooks' module and its dictionary */
|
||||
static PyObject *hooks = NULL, *hooksdict = NULL;
|
||||
|
||||
/*
|
||||
*
|
||||
* Define the type 'Hook'
|
||||
*
|
||||
*/
|
||||
#define IS_HOOK(v) ((v)->ob_type == &HookType)
|
||||
|
||||
staticforward PyTypeObject HookType;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
GSList *funcs;
|
||||
} HookObject;
|
||||
|
||||
static PyObject *create_Hook(PyObject *self, PyObject *args)
|
||||
{
|
||||
HookObject *hook;
|
||||
char *name;
|
||||
int ret;
|
||||
|
||||
(void) self;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:Hook", &name))
|
||||
return NULL;
|
||||
|
||||
hook = PyObject_New(HookObject, &HookType);
|
||||
hook->funcs = NULL;
|
||||
|
||||
/* add it to the hooks module */
|
||||
ret = PyDict_SetItemString(hooksdict, name, (PyObject*) hook);
|
||||
Py_DECREF(hook);
|
||||
|
||||
if (ret == -1) {
|
||||
char *s = g_strdup_printf(
|
||||
"Failed to add the hook '%s' to the 'hooks' module", name);
|
||||
PyErr_SetString(PyExc_RuntimeError, s);
|
||||
g_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static void hook_dealloc(HookObject *self)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
for (it = self->funcs; it != NULL; it = it->next)
|
||||
Py_DECREF((PyObject*) it->data);
|
||||
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyObject *hook_fire(HookObject *self, PyObject *args)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'fire' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (it = self->funcs; it != NULL; it = it->next) {
|
||||
PyObject *ret = PyObject_CallObject(it->data, args);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *hook_add(HookObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'add' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "O:add", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'add' requires a callable argument");
|
||||
return NULL;
|
||||
}
|
||||
self->funcs = g_slist_append(self->funcs, func);
|
||||
Py_INCREF(func);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *hook_remove(HookObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
GSList *it;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'remove' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "O:remove", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'remove' requires a callable argument");
|
||||
return NULL;
|
||||
}
|
||||
it = g_slist_find(self->funcs, func);
|
||||
if (it != NULL) {
|
||||
self->funcs = g_slist_delete_link(self->funcs, it);
|
||||
Py_DECREF(func);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"given callable object was not found in Hook");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *hook_count(HookObject *self, PyObject *args)
|
||||
{
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'fire' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, ":count"))
|
||||
return NULL;
|
||||
|
||||
return PyInt_FromLong(g_slist_length(self->funcs));
|
||||
}
|
||||
|
||||
static PyTypeObject HookType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Hook",
|
||||
sizeof(HookObject),
|
||||
0,
|
||||
(destructor) hook_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
static PyMethodDef HookMethods[] = {
|
||||
{"fire", (PyCFunction)hook_fire, METH_VARARGS,
|
||||
"hook.fire() -- Fire the added hook functions for the Hook."},
|
||||
{"add", (PyCFunction)hook_add, METH_VARARGS,
|
||||
"hook.add(func) -- Add a function to the hook." },
|
||||
{"remove", (PyCFunction)hook_remove, METH_VARARGS,
|
||||
"hook.remove(func) -- Remove a function from the hook." },
|
||||
{"count", (PyCFunction)hook_count, METH_VARARGS,
|
||||
"hook.count() -- Return the number of functions in the hook." },
|
||||
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Module initialization/finalization
|
||||
*
|
||||
*/
|
||||
|
||||
/* the "events" hook */
|
||||
static HookObject *events_hook = NULL, *keyboard_hook = NULL,
|
||||
*pointer_hook = NULL;
|
||||
|
||||
static PyMethodDef HooksMethods[] = {
|
||||
{"create", create_Hook, METH_VARARGS,
|
||||
"hooks.create('name') -- Add a hook called 'name' to the hooks module."},
|
||||
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
void hooks_startup()
|
||||
{
|
||||
int ret;
|
||||
|
||||
HookType.ob_type = &PyType_Type;
|
||||
HookType.tp_methods = HookMethods;
|
||||
PyType_Ready(&HookType);
|
||||
|
||||
Py_InitModule("hooks", HooksMethods);
|
||||
|
||||
/* get the hooks module/dict */
|
||||
hooks = PyImport_ImportModule("hooks"); /* new */
|
||||
g_assert(hooks != NULL);
|
||||
hooksdict = PyModule_GetDict(hooks); /* borrowed */
|
||||
g_assert(hooksdict != NULL);
|
||||
|
||||
/* create the "events" hook */
|
||||
events_hook = PyObject_New(HookObject, &HookType);
|
||||
events_hook->funcs = NULL;
|
||||
|
||||
/* add it to the hooks module */
|
||||
ret = PyDict_SetItemString(hooksdict, "events", (PyObject*) events_hook);
|
||||
g_assert(ret == 0);
|
||||
|
||||
/* create the "keyboard" hook */
|
||||
keyboard_hook = PyObject_New(HookObject, &HookType);
|
||||
keyboard_hook->funcs = NULL;
|
||||
|
||||
/* add it to the hooks module */
|
||||
ret = PyDict_SetItemString(hooksdict, "keyboard",
|
||||
(PyObject*) keyboard_hook);
|
||||
g_assert(ret == 0);
|
||||
|
||||
/* create the "pointer" hook */
|
||||
pointer_hook = PyObject_New(HookObject, &HookType);
|
||||
pointer_hook->funcs = NULL;
|
||||
|
||||
/* add it to the hooks module */
|
||||
ret = PyDict_SetItemString(hooksdict, "pointer", (PyObject*) pointer_hook);
|
||||
g_assert(ret == 0);
|
||||
}
|
||||
|
||||
void hooks_shutdown()
|
||||
{
|
||||
Py_DECREF(pointer_hook);
|
||||
Py_DECREF(keyboard_hook);
|
||||
Py_DECREF(events_hook);
|
||||
Py_DECREF(hooks);
|
||||
}
|
||||
|
||||
void hooks_fire(EventData *data)
|
||||
{
|
||||
PyObject *ret, *args;
|
||||
|
||||
g_assert(events_hook != NULL);
|
||||
|
||||
args = Py_BuildValue("(O)", data);
|
||||
ret = hook_fire(events_hook, args);
|
||||
Py_DECREF(args);
|
||||
if (ret == NULL)
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
void hooks_fire_keyboard(EventData *data)
|
||||
{
|
||||
PyObject *ret, *args;
|
||||
|
||||
g_assert(events_hook != NULL);
|
||||
|
||||
args = Py_BuildValue("(O)", data);
|
||||
ret = hook_fire(keyboard_hook, args);
|
||||
Py_DECREF(args);
|
||||
if (ret == NULL)
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
void hooks_fire_pointer(EventData *data)
|
||||
{
|
||||
PyObject *ret, *args;
|
||||
|
||||
g_assert(events_hook != NULL);
|
||||
|
||||
args = Py_BuildValue("(O)", data);
|
||||
ret = hook_fire(pointer_hook, args);
|
||||
Py_DECREF(args);
|
||||
if (ret == NULL)
|
||||
PyErr_Print();
|
||||
}
|
23
c/hooks.h
Normal file
23
c/hooks.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef __hooks_h
|
||||
#define __hooks_h
|
||||
|
||||
#include "eventdata.h"
|
||||
|
||||
void hooks_startup();
|
||||
void hooks_shutdown();
|
||||
|
||||
void hooks_fire(EventData *data);
|
||||
|
||||
void hooks_fire_keyboard(EventData *data);
|
||||
|
||||
void hooks_fire_pointer(EventData *data);
|
||||
|
||||
#define LOGICALHOOK(type, context, client) \
|
||||
{ EventData *data = eventdata_new_logical(Logical_##type, \
|
||||
context, client); \
|
||||
g_assert(data != NULL); \
|
||||
hooks_fire(data); \
|
||||
eventdata_free(data); \
|
||||
}
|
||||
|
||||
#endif
|
354
c/kbind.c
Normal file
354
c/kbind.c
Normal file
|
@ -0,0 +1,354 @@
|
|||
#include "focus.h"
|
||||
#include "openbox.h"
|
||||
#include "hooks.h"
|
||||
#include "kbind.h"
|
||||
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
typedef struct KeyBindingTree {
|
||||
guint state;
|
||||
guint key;
|
||||
GList *keylist;
|
||||
|
||||
/* the next binding in the tree at the same level */
|
||||
struct KeyBindingTree *next_sibling;
|
||||
/* the first child of this binding (next binding in a chained sequence).*/
|
||||
struct KeyBindingTree *first_child;
|
||||
} KeyBindingTree;
|
||||
|
||||
|
||||
static KeyBindingTree *firstnode, *curpos;
|
||||
static guint reset_key, reset_state;
|
||||
static gboolean grabbed, user_grabbed;
|
||||
|
||||
guint kbind_translate_modifier(char *str)
|
||||
{
|
||||
if (!strcmp("Mod1", str)) return Mod1Mask;
|
||||
else if (!strcmp("Mod2", str)) return Mod2Mask;
|
||||
else if (!strcmp("Mod3", str)) return Mod3Mask;
|
||||
else if (!strcmp("Mod4", str)) return Mod4Mask;
|
||||
else if (!strcmp("Mod5", str)) return Mod5Mask;
|
||||
else if (!strcmp("C", str)) return ControlMask;
|
||||
else if (!strcmp("S", str)) return ShiftMask;
|
||||
g_warning("Invalid modifier '%s' in binding.", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean translate(char *str, guint *state, guint *keycode)
|
||||
{
|
||||
char **parsed;
|
||||
char *l;
|
||||
int i;
|
||||
gboolean ret = FALSE;
|
||||
KeySym sym;
|
||||
|
||||
parsed = g_strsplit(str, "-", -1);
|
||||
|
||||
/* first, find the key (last token) */
|
||||
l = NULL;
|
||||
for (i = 0; parsed[i] != NULL; ++i)
|
||||
l = parsed[i];
|
||||
if (l == NULL)
|
||||
goto translation_fail;
|
||||
|
||||
/* figure out the mod mask */
|
||||
*state = 0;
|
||||
for (i = 0; parsed[i] != l; ++i) {
|
||||
guint m = kbind_translate_modifier(parsed[i]);
|
||||
if (!m) goto translation_fail;
|
||||
*state |= m;
|
||||
}
|
||||
|
||||
/* figure out the keycode */
|
||||
sym = XStringToKeysym(l);
|
||||
if (sym == NoSymbol) {
|
||||
g_warning("Invalid key name '%s' in key binding.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
*keycode = XKeysymToKeycode(ob_display, sym);
|
||||
if (!keycode) {
|
||||
g_warning("Key '%s' does not exist on the display.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
translation_fail:
|
||||
g_strfreev(parsed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void destroytree(KeyBindingTree *tree)
|
||||
{
|
||||
KeyBindingTree *c;
|
||||
|
||||
while (tree) {
|
||||
destroytree(tree->next_sibling);
|
||||
c = tree->first_child;
|
||||
if (c == NULL) {
|
||||
GList *it;
|
||||
for (it = tree->keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(tree->keylist);
|
||||
}
|
||||
g_free(tree);
|
||||
tree = c;
|
||||
}
|
||||
}
|
||||
|
||||
static KeyBindingTree *buildtree(GList *keylist)
|
||||
{
|
||||
GList *it;
|
||||
KeyBindingTree *ret = NULL, *p;
|
||||
|
||||
if (g_list_length(keylist) <= 0)
|
||||
return NULL; /* nothing in the list.. */
|
||||
|
||||
for (it = g_list_last(keylist); it != NULL; it = it->prev) {
|
||||
p = ret;
|
||||
ret = g_new(KeyBindingTree, 1);
|
||||
ret->next_sibling = NULL;
|
||||
if (p == NULL) {
|
||||
GList *it;
|
||||
|
||||
/* this is the first built node, the bottom node of the tree */
|
||||
ret->keylist = g_list_copy(keylist); /* shallow copy */
|
||||
for (it = ret->keylist; it != NULL; it = it->next) /* deep copy */
|
||||
it->data = g_strdup(it->data);
|
||||
}
|
||||
ret->first_child = p;
|
||||
if (!translate(it->data, &ret->state, &ret->key)) {
|
||||
destroytree(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void assimilate(KeyBindingTree *node)
|
||||
{
|
||||
KeyBindingTree *a, *b, *tmp, *last;
|
||||
|
||||
if (firstnode == NULL) {
|
||||
/* there are no nodes at this level yet */
|
||||
firstnode = node;
|
||||
} else {
|
||||
a = firstnode;
|
||||
last = a;
|
||||
b = node;
|
||||
while (a) {
|
||||
last = a;
|
||||
if (!(a->state == b->state && a->key == b->key)) {
|
||||
a = a->next_sibling;
|
||||
} else {
|
||||
tmp = b;
|
||||
b = b->first_child;
|
||||
g_free(tmp);
|
||||
a = a->first_child;
|
||||
}
|
||||
}
|
||||
if (!(last->state == b->state && last->key == a->key))
|
||||
last->next_sibling = b;
|
||||
else {
|
||||
last->first_child = b->first_child;
|
||||
g_free(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeyBindingTree *find(KeyBindingTree *search, gboolean *conflict)
|
||||
{
|
||||
KeyBindingTree *a, *b;
|
||||
|
||||
*conflict = FALSE;
|
||||
|
||||
a = firstnode;
|
||||
b = search;
|
||||
while (a && b) {
|
||||
if (!(a->state == b->state && a->key == b->key)) {
|
||||
a = a->next_sibling;
|
||||
} else {
|
||||
if ((a->first_child == NULL) == (b->first_child == NULL)) {
|
||||
if (a->first_child == NULL) {
|
||||
/* found it! (return the actual node, not the search's) */
|
||||
return a;
|
||||
}
|
||||
} else {
|
||||
*conflict = TRUE;
|
||||
return NULL; /* the chain status' don't match (conflict!) */
|
||||
}
|
||||
b = b->first_child;
|
||||
a = a->first_child;
|
||||
}
|
||||
}
|
||||
return NULL; // it just isn't in here
|
||||
}
|
||||
|
||||
static void grab_keys(gboolean grab)
|
||||
{
|
||||
if (!grab) {
|
||||
XUngrabKey(ob_display, AnyKey, AnyModifier, ob_root);
|
||||
} else {
|
||||
KeyBindingTree *p = firstnode;
|
||||
while (p) {
|
||||
XGrabKey(ob_display, p->key, p->state, ob_root, FALSE,
|
||||
GrabModeAsync, GrabModeSync);
|
||||
p = p->next_sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reset_chains()
|
||||
{
|
||||
/* XXX kill timer */
|
||||
curpos = NULL;
|
||||
if (grabbed) {
|
||||
grabbed = FALSE;
|
||||
g_message("reset chains. user: %d", user_grabbed);
|
||||
if (!user_grabbed)
|
||||
XUngrabKeyboard(ob_display, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
void kbind_fire(guint state, guint key, gboolean press)
|
||||
{
|
||||
EventData *data;
|
||||
struct Client *c = focus_client;
|
||||
GQuark context = c != NULL ? g_quark_try_string("client")
|
||||
: g_quark_try_string("root");
|
||||
|
||||
if (user_grabbed) {
|
||||
data = eventdata_new_key(press ? Key_Press : Key_Release,
|
||||
context, c, state, key, NULL);
|
||||
g_assert(data != NULL);
|
||||
hooks_fire_keyboard(data);
|
||||
eventdata_free(data);
|
||||
}
|
||||
|
||||
if (key == reset_key && state == reset_state) {
|
||||
reset_chains();
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
} else {
|
||||
KeyBindingTree *p;
|
||||
if (curpos == NULL)
|
||||
p = firstnode;
|
||||
else
|
||||
p = curpos->first_child;
|
||||
while (p) {
|
||||
if (p->key == key && p->state == state) {
|
||||
if (p->first_child != NULL) { /* part of a chain */
|
||||
/* XXX TIMER */
|
||||
if (!grabbed && !user_grabbed) {
|
||||
/*grab should never fail because we should have a sync
|
||||
grab at this point */
|
||||
XGrabKeyboard(ob_display, ob_root, 0, GrabModeAsync,
|
||||
GrabModeSync, CurrentTime);
|
||||
}
|
||||
grabbed = TRUE;
|
||||
curpos = p;
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
} else {
|
||||
data = eventdata_new_key(press ? Key_Press : Key_Release,
|
||||
context, c, state, key,
|
||||
p->keylist);
|
||||
g_assert(data != NULL);
|
||||
hooks_fire(data);
|
||||
eventdata_free(data);
|
||||
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
reset_chains();
|
||||
}
|
||||
break;
|
||||
}
|
||||
p = p->next_sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean kbind_add(GList *keylist)
|
||||
{
|
||||
KeyBindingTree *tree, *t;
|
||||
gboolean conflict;
|
||||
|
||||
if (!(tree = buildtree(keylist)))
|
||||
return FALSE; /* invalid binding requested */
|
||||
|
||||
t = find(tree, &conflict);
|
||||
if (conflict) {
|
||||
/* conflicts with another binding */
|
||||
destroytree(tree);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (t != NULL) {
|
||||
/* already bound to something */
|
||||
destroytree(tree);
|
||||
} else {
|
||||
/* grab the server here to make sure no key pressed go missed */
|
||||
XGrabServer(ob_display);
|
||||
XSync(ob_display, FALSE);
|
||||
|
||||
grab_keys(FALSE);
|
||||
|
||||
/* assimilate this built tree into the main tree */
|
||||
assimilate(tree); // assimilation destroys/uses the tree
|
||||
|
||||
grab_keys(TRUE);
|
||||
|
||||
XUngrabServer(ob_display);
|
||||
XFlush(ob_display);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void kbind_clearall()
|
||||
{
|
||||
grab_keys(FALSE);
|
||||
destroytree(firstnode);
|
||||
firstnode = NULL;
|
||||
grab_keys(TRUE);
|
||||
}
|
||||
|
||||
void kbind_startup()
|
||||
{
|
||||
gboolean b;
|
||||
|
||||
curpos = firstnode = NULL;
|
||||
grabbed = user_grabbed = FALSE;
|
||||
|
||||
b = translate("C-G", &reset_state, &reset_key);
|
||||
g_assert(b);
|
||||
}
|
||||
|
||||
void kbind_shutdown()
|
||||
{
|
||||
if (grabbed || user_grabbed) {
|
||||
grabbed = FALSE;
|
||||
kbind_grab_keyboard(FALSE);
|
||||
}
|
||||
grab_keys(FALSE);
|
||||
destroytree(firstnode);
|
||||
firstnode = NULL;
|
||||
}
|
||||
|
||||
gboolean kbind_grab_keyboard(gboolean grab)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
if (!grab)
|
||||
g_message("grab_keyboard(false). grabbed: %d", grabbed);
|
||||
|
||||
user_grabbed = grab;
|
||||
if (!grabbed) {
|
||||
if (grab)
|
||||
ret = XGrabKeyboard(ob_display, ob_root, 0, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) == GrabSuccess;
|
||||
else
|
||||
XUngrabKeyboard(ob_display, CurrentTime);
|
||||
}
|
||||
return ret;
|
||||
}
|
23
c/kbind.h
Normal file
23
c/kbind.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef __kbind_h
|
||||
#define __kbind_h
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
void kbind_startup();
|
||||
void kbind_shutdown();
|
||||
|
||||
/*! Adds a new key binding
|
||||
A binding will fail to be added if the binding already exists (as part of
|
||||
a chain or not), or if any of the strings in the keylist are invalid.
|
||||
@return TRUE if the binding could be added; FALSE if it could not.
|
||||
*/
|
||||
gboolean kbind_add(GList *keylist);
|
||||
void kbind_clearall();
|
||||
|
||||
guint kbind_translate_modifier(char *str);
|
||||
|
||||
void kbind_fire(guint state, guint key, gboolean press);
|
||||
|
||||
gboolean kbind_grab_keyboard(gboolean grab);
|
||||
|
||||
#endif
|
220
c/mbind.c
Normal file
220
c/mbind.c
Normal file
|
@ -0,0 +1,220 @@
|
|||
#include "mbind.h"
|
||||
#include "kbind.h"
|
||||
#include "frame.h"
|
||||
#include "openbox.h"
|
||||
#include "eventdata.h"
|
||||
#include "hooks.h"
|
||||
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* GData of GSList*'s of PointerBinding*'s. */
|
||||
static GData *bound_contexts;
|
||||
|
||||
static gboolean grabbed;
|
||||
|
||||
struct mbind_foreach_grab_temp {
|
||||
Client *client;
|
||||
gboolean grab;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
guint state;
|
||||
guint button;
|
||||
char *name;
|
||||
} PointerBinding;
|
||||
|
||||
static gboolean translate(char *str, guint *state, guint *button)
|
||||
{
|
||||
char **parsed;
|
||||
char *l;
|
||||
int i;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
parsed = g_strsplit(str, "-", -1);
|
||||
|
||||
/* first, find the button (last token) */
|
||||
l = NULL;
|
||||
for (i = 0; parsed[i] != NULL; ++i)
|
||||
l = parsed[i];
|
||||
if (l == NULL)
|
||||
goto translation_fail;
|
||||
|
||||
/* figure out the mod mask */
|
||||
*state = 0;
|
||||
for (i = 0; parsed[i] != l; ++i) {
|
||||
guint m = kbind_translate_modifier(parsed[i]);
|
||||
if (!m) goto translation_fail;
|
||||
*state |= m;
|
||||
}
|
||||
|
||||
/* figure out the button */
|
||||
*button = atoi(l);
|
||||
if (!*button) {
|
||||
g_warning("Invalid button '%s' in pointer binding.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
translation_fail:
|
||||
g_strfreev(parsed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void grab_button(Client *client, guint state, guint button, GQuark context,
|
||||
gboolean grab)
|
||||
{
|
||||
Window win;
|
||||
int mode = GrabModeAsync;
|
||||
unsigned int mask;
|
||||
|
||||
if (context == g_quark_try_string("frame")) {
|
||||
win = client->frame->window;
|
||||
mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
|
||||
} else if (context == g_quark_try_string("client")) {
|
||||
win = client->frame->plate;
|
||||
mode = GrabModeSync; /* this is handled in mbind_fire */
|
||||
mask = ButtonPressMask; /* can't catch more than this with Sync mode
|
||||
the release event is manufactured in
|
||||
mbind_fire */
|
||||
} else return;
|
||||
|
||||
if (grab)
|
||||
XGrabButton(ob_display, button, state, win, FALSE, mask, mode,
|
||||
GrabModeAsync, None, None);
|
||||
else
|
||||
XUngrabButton(ob_display, button, state, win);
|
||||
}
|
||||
|
||||
static void mbind_foreach_grab(GQuark key, gpointer data, gpointer user_data)
|
||||
{
|
||||
struct mbind_foreach_grab_temp *d = user_data;
|
||||
PointerBinding *b = ((GSList *)data)->data;
|
||||
if (b != NULL)
|
||||
grab_button(d->client, b->state, b->button, key, d->grab);
|
||||
}
|
||||
|
||||
void mbind_grab_all(Client *client, gboolean grab)
|
||||
{
|
||||
struct mbind_foreach_grab_temp bt;
|
||||
bt.client = client;
|
||||
bt.grab = grab;
|
||||
g_datalist_foreach(&bound_contexts, mbind_foreach_grab, &bt);
|
||||
}
|
||||
|
||||
void grab_all_clients(gboolean grab)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
for (it = client_list; it != NULL; it = it->next)
|
||||
mbind_grab_all(it->data, grab);
|
||||
}
|
||||
|
||||
void mbind_startup()
|
||||
{
|
||||
grabbed = FALSE;
|
||||
g_datalist_init(&bound_contexts);
|
||||
}
|
||||
|
||||
void mbind_shutdown()
|
||||
{
|
||||
if (grabbed)
|
||||
mbind_grab_pointer(FALSE);
|
||||
mbind_clearall();
|
||||
g_datalist_clear(&bound_contexts);
|
||||
}
|
||||
|
||||
gboolean mbind_add(char *name, GQuark context)
|
||||
{
|
||||
guint state, button;
|
||||
PointerBinding *b;
|
||||
GSList *it;
|
||||
|
||||
if (!translate(name, &state, &button))
|
||||
return FALSE;
|
||||
|
||||
for (it = g_datalist_id_get_data(&bound_contexts, context);
|
||||
it != NULL; it = it->next){
|
||||
b = it->data;
|
||||
if (b->state == state && b->button == button)
|
||||
return TRUE; /* already bound */
|
||||
}
|
||||
|
||||
grab_all_clients(FALSE);
|
||||
|
||||
/* add the binding */
|
||||
b = g_new(PointerBinding, 1);
|
||||
b->state = state;
|
||||
b->button = button;
|
||||
b->name = g_strdup(name);
|
||||
g_datalist_id_set_data(&bound_contexts, context,
|
||||
g_slist_append(g_datalist_id_get_data(&bound_contexts, context), b));
|
||||
grab_all_clients(TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void mbind_foreach_clear(GQuark key, gpointer data, gpointer user_data)
|
||||
{
|
||||
GSList *it;
|
||||
user_data = user_data;
|
||||
for (it = data; it != NULL; it = it->next) {
|
||||
PointerBinding *b = it->data;
|
||||
g_free(b->name);
|
||||
g_free(b);
|
||||
}
|
||||
g_slist_free(data);
|
||||
}
|
||||
void mbind_clearall()
|
||||
{
|
||||
grab_all_clients(FALSE);
|
||||
g_datalist_foreach(&bound_contexts, mbind_foreach_clear, NULL);
|
||||
}
|
||||
|
||||
void mbind_fire(guint state, guint button, GQuark context, EventType type,
|
||||
Client *client, int xroot, int yroot)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
if (grabbed) {
|
||||
EventData *data;
|
||||
data = eventdata_new_pointer(type, context, client, state, button,
|
||||
NULL, xroot, yroot);
|
||||
g_assert(data != NULL);
|
||||
hooks_fire_pointer(data);
|
||||
eventdata_free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
for (it = g_datalist_id_get_data(&bound_contexts, context);
|
||||
it != NULL; it = it->next){
|
||||
PointerBinding *b = it->data;
|
||||
if (b->state == state && b->button == button) {
|
||||
EventData *data;
|
||||
data = eventdata_new_pointer(type, context, client, state, button,
|
||||
b->name, xroot, yroot);
|
||||
g_assert(data != NULL);
|
||||
hooks_fire(data);
|
||||
eventdata_free(data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean mbind_grab_pointer(gboolean grab)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
if (grab)
|
||||
ret = XGrabPointer(ob_display, ob_root, FALSE, (ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
ButtonMotionMask |
|
||||
PointerMotionMask),
|
||||
GrabModeAsync, GrabModeAsync, None, None,
|
||||
CurrentTime) == GrabSuccess;
|
||||
else
|
||||
XUngrabPointer(ob_display, CurrentTime);
|
||||
return ret;
|
||||
}
|
21
c/mbind.h
Normal file
21
c/mbind.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef __mbind_h
|
||||
#define __mbind_h
|
||||
|
||||
#include "obexport.h"
|
||||
#include "client.h"
|
||||
#include <glib.h>
|
||||
|
||||
void mbind_startup();
|
||||
void mbind_shutdown();
|
||||
|
||||
/*! Adds a new pointer binding */
|
||||
gboolean mbind_add(char *name, GQuark context);
|
||||
void mbind_clearall();
|
||||
|
||||
void mbind_fire(guint state, guint button, GQuark context, EventType type,
|
||||
Client *client, int xroot, int yroot);
|
||||
|
||||
void mbind_grab_all(Client *client, gboolean grab);
|
||||
gboolean mbind_grab_pointer(gboolean grab);
|
||||
|
||||
#endif
|
116
c/obexport.c
Normal file
116
c/obexport.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
#include "obexport.h"
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
|
||||
static PyMethodDef obMethods[] = {
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
#define ADD_INT_CONST(n) (PyModule_AddIntConstant(ob, #n, n))
|
||||
|
||||
void obexport_startup()
|
||||
{
|
||||
PyObject *ob, *obdict;
|
||||
|
||||
Py_InitModule("ob", obMethods);
|
||||
|
||||
/* get the ob module/dict */
|
||||
ob = PyImport_ImportModule("ob"); /* new */
|
||||
g_assert(ob != NULL);
|
||||
obdict = PyModule_GetDict(ob); /* borrowed */
|
||||
g_assert(obdict != NULL);
|
||||
|
||||
/* define all the constants! */
|
||||
|
||||
/* State */
|
||||
ADD_INT_CONST(State_Starting);
|
||||
ADD_INT_CONST(State_Exiting);
|
||||
ADD_INT_CONST(State_Running);
|
||||
|
||||
/* Corner */
|
||||
ADD_INT_CONST(Corner_TopLeft);
|
||||
ADD_INT_CONST(Corner_TopRight);
|
||||
ADD_INT_CONST(Corner_BottomLeft);
|
||||
ADD_INT_CONST(Corner_BottomRight);
|
||||
|
||||
/* Orientation */
|
||||
ADD_INT_CONST(Orientation_Horz);
|
||||
ADD_INT_CONST(Orientation_Vert);
|
||||
|
||||
/* Gravity */
|
||||
ADD_INT_CONST(Gravity_Forget);
|
||||
ADD_INT_CONST(Gravity_NE);
|
||||
ADD_INT_CONST(Gravity_N);
|
||||
ADD_INT_CONST(Gravity_NW);
|
||||
ADD_INT_CONST(Gravity_W);
|
||||
ADD_INT_CONST(Gravity_SW);
|
||||
ADD_INT_CONST(Gravity_S);
|
||||
ADD_INT_CONST(Gravity_SE);
|
||||
ADD_INT_CONST(Gravity_E);
|
||||
ADD_INT_CONST(Gravity_Center);
|
||||
ADD_INT_CONST(Gravity_Static);
|
||||
|
||||
/* WindowType */
|
||||
ADD_INT_CONST(Type_Desktop);
|
||||
ADD_INT_CONST(Type_Dock);
|
||||
ADD_INT_CONST(Type_Toolbar);
|
||||
ADD_INT_CONST(Type_Menu);
|
||||
ADD_INT_CONST(Type_Utility);
|
||||
ADD_INT_CONST(Type_Splash);
|
||||
ADD_INT_CONST(Type_Dialog);
|
||||
ADD_INT_CONST(Type_Normal);
|
||||
|
||||
/* Function */
|
||||
ADD_INT_CONST(Func_Resize);
|
||||
ADD_INT_CONST(Func_Move);
|
||||
ADD_INT_CONST(Func_Iconify);
|
||||
ADD_INT_CONST(Func_Maximize);
|
||||
ADD_INT_CONST(Func_Shade);
|
||||
ADD_INT_CONST(Func_Fullscreen);
|
||||
ADD_INT_CONST(Func_Close);
|
||||
|
||||
/* Decoration */
|
||||
ADD_INT_CONST(Decor_Titlebar);
|
||||
ADD_INT_CONST(Decor_Handle);
|
||||
ADD_INT_CONST(Decor_Border);
|
||||
ADD_INT_CONST(Decor_Icon);
|
||||
ADD_INT_CONST(Decor_Iconify);
|
||||
ADD_INT_CONST(Decor_Maximize);
|
||||
ADD_INT_CONST(Decor_AllDesktops);
|
||||
ADD_INT_CONST(Decor_Close);
|
||||
|
||||
/* StackLayer */
|
||||
ADD_INT_CONST(Layer_Icon);
|
||||
ADD_INT_CONST(Layer_Desktop);
|
||||
ADD_INT_CONST(Layer_Below);
|
||||
ADD_INT_CONST(Layer_Normal);
|
||||
ADD_INT_CONST(Layer_Above);
|
||||
ADD_INT_CONST(Layer_Top);
|
||||
ADD_INT_CONST(Layer_Fullscreen);
|
||||
ADD_INT_CONST(Layer_Internal);
|
||||
|
||||
/* EventType */
|
||||
ADD_INT_CONST(Logical_EnterWindow);
|
||||
ADD_INT_CONST(Logical_LeaveWindow);
|
||||
ADD_INT_CONST(Logical_NewWindow);
|
||||
ADD_INT_CONST(Logical_CloseWindow);
|
||||
ADD_INT_CONST(Logical_Startup);
|
||||
ADD_INT_CONST(Logical_Shutdown);
|
||||
ADD_INT_CONST(Logical_RequestActivate);
|
||||
ADD_INT_CONST(Logical_Focus);
|
||||
ADD_INT_CONST(Logical_Bell);
|
||||
ADD_INT_CONST(Logical_UrgentWindow);
|
||||
ADD_INT_CONST(Logical_WindowShow);
|
||||
ADD_INT_CONST(Logical_WindowHide);
|
||||
ADD_INT_CONST(Pointer_Press);
|
||||
ADD_INT_CONST(Pointer_Release);
|
||||
ADD_INT_CONST(Pointer_Motion);
|
||||
ADD_INT_CONST(Key_Press);
|
||||
ADD_INT_CONST(Key_Release);
|
||||
|
||||
Py_DECREF(ob);
|
||||
}
|
||||
|
||||
void obexport_shutdown()
|
||||
{
|
||||
}
|
74
c/obexport.h
Normal file
74
c/obexport.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
#ifndef __obexport_h
|
||||
#define __obexport_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/* Define values which will be exported in the 'ob' module. */
|
||||
|
||||
typedef enum {
|
||||
/*! Occurs when the mouse enters a window */
|
||||
Logical_EnterWindow,
|
||||
/*! Occurs when the mouse enters a window */
|
||||
Logical_LeaveWindow,
|
||||
/*! Occurs when a window is finished being managed, just before it is
|
||||
(possibly) displayed.
|
||||
The python scripts are reponsible for showing the window when this is
|
||||
called if they want it to be shown.
|
||||
*/
|
||||
Logical_NewWindow,
|
||||
/*! Occurs when a window is being unmanaged */
|
||||
Logical_CloseWindow,
|
||||
/*! Occurs when the window manager starts up */
|
||||
Logical_Startup,
|
||||
/*! Occurs when the window manager is shutting down */
|
||||
Logical_Shutdown,
|
||||
/*! Occurs when a client is requesting/requested to be activated (i.e.
|
||||
focused, raised, unshaded) */
|
||||
Logical_RequestActivate,
|
||||
/*! Occurs when the input focus target changes
|
||||
The data.client will be NULL of no client is focused. */
|
||||
Logical_Focus,
|
||||
/*! Occurs when the system is fired through X.
|
||||
The data.client will hold the client associated with the bell if
|
||||
one has been specified, or NULL. */
|
||||
Logical_Bell,
|
||||
/*! Occurs when a client toggles its urgent status.
|
||||
The client.urgent member can be used to get the status. */
|
||||
Logical_UrgentWindow,
|
||||
/*! Occurs when a client becomes visible */
|
||||
Logical_WindowShow,
|
||||
/*! Occurs when a client becomes non-visible */
|
||||
Logical_WindowHide,
|
||||
/*! Occurs when a pointer button is pressed on a client or its
|
||||
decorations.
|
||||
Note: to get the event for the client's window or for the entire
|
||||
window+decorations, you need to do an mgrab for the window. */
|
||||
Pointer_Press,
|
||||
/*! Occurs when a pointer button is released on a client or its
|
||||
decorations.
|
||||
Note: to get the event for the client's window or for the entire
|
||||
window+decorations, you need to do an mgrab for the window. */
|
||||
Pointer_Release,
|
||||
/*! Occurs when a pointer button is held and the pointer is dragged on a
|
||||
client or its decorations.
|
||||
Note: to get the event for the client's window or for the entire
|
||||
window+decorations, you need to do an mgrab for the window, or an
|
||||
mgrab_pointer (in which case it may not be a drag). */
|
||||
Pointer_Motion,
|
||||
/*! Occurs when a key is pressed.
|
||||
Note: in order to recieve a key event, a kgrab must be done for the
|
||||
key combination, or a kgrab_keyboard.
|
||||
*/
|
||||
Key_Press,
|
||||
/*! Occurs when a key is released.
|
||||
Note: in order to recieve a key event, a kgrab must be done for the
|
||||
key combination, or a kgrab_keyboard.
|
||||
*/
|
||||
Key_Release
|
||||
} EventType;
|
||||
|
||||
/* create the 'ob' module */
|
||||
void obexport_startup();
|
||||
void obexport_shutdown();
|
||||
|
||||
#endif
|
203
c/openbox.c
Normal file
203
c/openbox.c
Normal file
|
@ -0,0 +1,203 @@
|
|||
#include "openbox.h"
|
||||
#include "event.h"
|
||||
#include "client.h"
|
||||
#include "xerror.h"
|
||||
#include "prop.h"
|
||||
#include "screen.h"
|
||||
#include "focus.h"
|
||||
#include "extensions.h"
|
||||
#include "python.h"
|
||||
#include "hooks.h"
|
||||
#include "eventdata.h"
|
||||
#include "gettext.h"
|
||||
#include "clientwrap.h"
|
||||
#include "screenwrap.h"
|
||||
#include "kbind.h"
|
||||
#include "mbind.h"
|
||||
#include "frame.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
Display *ob_display = NULL;
|
||||
int ob_screen;
|
||||
Window ob_root;
|
||||
State ob_state;
|
||||
gboolean ob_shutdown = FALSE;
|
||||
gboolean ob_restart = FALSE;
|
||||
gboolean ob_remote = FALSE;
|
||||
gboolean ob_sync = TRUE;
|
||||
Cursors ob_cursors;
|
||||
|
||||
void signal_handler(int signal);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct sigaction action;
|
||||
sigset_t sigset;
|
||||
|
||||
ob_state = State_Starting;
|
||||
|
||||
/* initialize the locale */
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
g_warning("Couldn't set locale from environment.\n");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
||||
textdomain(PACKAGE);
|
||||
|
||||
/* set up signal handler */
|
||||
sigemptyset(&sigset);
|
||||
action.sa_handler = signal_handler;
|
||||
action.sa_mask = sigset;
|
||||
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
|
||||
sigaction(SIGUSR1, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGPIPE, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGSEGV, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGFPE, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGTERM, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGINT, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGHUP, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGCHLD, &action, (struct sigaction *) NULL);
|
||||
|
||||
/* anything that died while we were restarting won't give us a SIGCHLD */
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
|
||||
/* XXX parse out command line args */
|
||||
(void)argc;(void)argv;
|
||||
|
||||
/* critical warnings will exit the program */
|
||||
g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
|
||||
|
||||
ob_display = XOpenDisplay(NULL);
|
||||
if (ob_display == NULL)
|
||||
/* print a message and exit */
|
||||
g_critical("Failed to open the display.");
|
||||
if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
|
||||
/* print a message and exit */
|
||||
g_critical("Failed to set display as close-on-exec.");
|
||||
|
||||
ob_screen = DefaultScreen(ob_display);
|
||||
ob_root = RootWindow(ob_display, ob_screen);
|
||||
|
||||
/* XXX fork self onto other screens */
|
||||
|
||||
XSynchronize(ob_display, ob_sync);
|
||||
|
||||
/* check for locale support */
|
||||
if (!XSupportsLocale())
|
||||
g_warning("X server does not support locale.");
|
||||
if (!XSetLocaleModifiers(""))
|
||||
g_warning("Cannot set locale modifiers for the X server.");
|
||||
|
||||
/* set our error handler */
|
||||
XSetErrorHandler(xerror_handler);
|
||||
|
||||
/* set the DISPLAY environment variable for any lauched children, to the
|
||||
display we're using, so they open in the right place. */
|
||||
putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display)));
|
||||
|
||||
ob_cursors.left_ptr = XCreateFontCursor(ob_display, XC_left_ptr);
|
||||
ob_cursors.ll_angle = XCreateFontCursor(ob_display, XC_ll_angle);
|
||||
ob_cursors.lr_angle = XCreateFontCursor(ob_display, XC_lr_angle);
|
||||
|
||||
prop_init(); /* get atoms values for the display */
|
||||
extensions_query_all(); /* find which extensions are present */
|
||||
|
||||
if (screen_annex()) { /* it will be ours! */
|
||||
frame_startup();
|
||||
python_startup();
|
||||
obexport_startup();
|
||||
hooks_startup();
|
||||
screenwrap_startup();
|
||||
clientwrap_startup();
|
||||
eventdata_startup();
|
||||
event_startup();
|
||||
screen_startup();
|
||||
focus_startup();
|
||||
client_startup();
|
||||
kbind_startup();
|
||||
mbind_startup();
|
||||
|
||||
/* load the user's settings */
|
||||
if (!python_import("rc"))
|
||||
g_warning("ERROR LOADING RC FILE");
|
||||
|
||||
LOGICALHOOK(Startup, g_quark_try_string("none"), NULL);
|
||||
|
||||
/* get all the existing windows */
|
||||
client_manage_all();
|
||||
|
||||
ob_state = State_Running;
|
||||
while (!ob_shutdown) {
|
||||
event_loop();
|
||||
}
|
||||
ob_state = State_Exiting;
|
||||
|
||||
client_unmanage_all();
|
||||
|
||||
LOGICALHOOK(Shutdown, g_quark_try_string("none"), NULL);
|
||||
|
||||
mbind_shutdown();
|
||||
kbind_shutdown();
|
||||
client_shutdown();
|
||||
screen_shutdown();
|
||||
event_shutdown();
|
||||
eventdata_shutdown();
|
||||
clientwrap_shutdown();
|
||||
screenwrap_shutdown();
|
||||
hooks_shutdown();
|
||||
obexport_shutdown();
|
||||
python_shutdown();
|
||||
}
|
||||
|
||||
XCloseDisplay(ob_display);
|
||||
|
||||
/* XXX if (ob_restart) */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void signal_handler(int signal)
|
||||
{
|
||||
switch (signal) {
|
||||
case SIGUSR1:
|
||||
g_message("Caught SIGUSR1 signal. Restarting.");
|
||||
ob_shutdown = ob_restart = TRUE;
|
||||
break;
|
||||
|
||||
case SIGCHLD:
|
||||
wait(NULL);
|
||||
break;
|
||||
|
||||
case SIGHUP:
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
case SIGPIPE:
|
||||
g_message("Caught signal %d. Exiting.", signal);
|
||||
ob_shutdown = TRUE;
|
||||
break;
|
||||
|
||||
case SIGFPE:
|
||||
case SIGSEGV:
|
||||
g_error("Caught signal %d. Aborting and dumping core.", signal);
|
||||
}
|
||||
}
|
35
c/openbox.h
Normal file
35
c/openbox.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef __openbox_h
|
||||
#define __openbox_h
|
||||
|
||||
#include "obexport.h"
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/*! The X display */
|
||||
extern Display *ob_display;
|
||||
/*! The number of the screen on which we're running */
|
||||
extern int ob_screen;
|
||||
/*! The root window */
|
||||
extern Window ob_root;
|
||||
|
||||
/* The state of execution of the window manager */
|
||||
State ob_state;
|
||||
|
||||
/*! When set to true, Openbox will exit */
|
||||
extern gboolean ob_shutdown;
|
||||
/*! When set to true, Openbox will restart instead of shutting down */
|
||||
extern gboolean ob_restart;
|
||||
|
||||
/*! Runtime option to specify running on a remote display */
|
||||
extern gboolean ob_remote;
|
||||
/*! Runtime option to run in synchronous mode */
|
||||
extern gboolean ob_sync;
|
||||
|
||||
typedef struct Cursors {
|
||||
Cursor left_ptr;
|
||||
Cursor ll_angle;
|
||||
Cursor lr_angle;
|
||||
} Cursors;
|
||||
Cursors ob_cursors;
|
||||
|
||||
#endif
|
271
c/prop.c
Normal file
271
c/prop.c
Normal file
|
@ -0,0 +1,271 @@
|
|||
#include "prop.h"
|
||||
#include "openbox.h"
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
Atoms prop_atoms;
|
||||
|
||||
#define CREATE(var, name) (prop_atoms.var = \
|
||||
XInternAtom(ob_display, name, FALSE))
|
||||
|
||||
void prop_init()
|
||||
{
|
||||
g_assert(ob_display != NULL);
|
||||
|
||||
CREATE(cardinal, "CARDINAL");
|
||||
CREATE(window, "WINDOW");
|
||||
CREATE(pixmap, "PIXMAP");
|
||||
CREATE(atom, "ATOM");
|
||||
CREATE(string, "STRING");
|
||||
CREATE(utf8, "UTF8_STRING");
|
||||
|
||||
CREATE(wm_colormap_windows, "WM_COLORMAP_WINDOWS");
|
||||
CREATE(wm_protocols, "WM_PROTOCOLS");
|
||||
CREATE(wm_state, "WM_STATE");
|
||||
CREATE(wm_change_state, "WM_CHANGE_STATE");
|
||||
CREATE(wm_delete_window, "WM_DELETE_WINDOW");
|
||||
CREATE(wm_take_focus, "WM_TAKE_FOCUS");
|
||||
CREATE(wm_name, "WM_NAME");
|
||||
CREATE(wm_icon_name, "WM_ICON_NAME");
|
||||
CREATE(wm_class, "WM_CLASS");
|
||||
CREATE(wm_window_role, "WM_WINDOW_ROLE");
|
||||
CREATE(motif_wm_hints, "_MOTIF_WM_HINTS");
|
||||
|
||||
CREATE(net_supported, "_NET_SUPPORTED");
|
||||
CREATE(net_client_list, "_NET_CLIENT_LIST");
|
||||
CREATE(net_client_list_stacking, "_NET_CLIENT_LIST_STACKING");
|
||||
CREATE(net_number_of_desktops, "_NET_NUMBER_OF_DESKTOPS");
|
||||
CREATE(net_desktop_geometry, "_NET_DESKTOP_GEOMETRY");
|
||||
CREATE(net_desktop_viewport, "_NET_DESKTOP_VIEWPORT");
|
||||
CREATE(net_current_desktop, "_NET_CURRENT_DESKTOP");
|
||||
CREATE(net_desktop_names, "_NET_DESKTOP_NAMES");
|
||||
CREATE(net_active_window, "_NET_ACTIVE_WINDOW");
|
||||
CREATE(net_workarea, "_NET_WORKAREA");
|
||||
CREATE(net_supporting_wm_check, "_NET_SUPPORTING_WM_CHECK");
|
||||
/* CREATE(net_virtual_roots, "_NET_VIRTUAL_ROOTS"); */
|
||||
CREATE(net_desktop_layout, "_NET_DESKTOP_LAYOUT");
|
||||
CREATE(net_showing_desktop, "_NET_SHOWING_DESKTOP");
|
||||
|
||||
CREATE(net_close_window, "_NET_CLOSE_WINDOW");
|
||||
CREATE(net_wm_moveresize, "_NET_WM_MOVERESIZE");
|
||||
|
||||
/* CREATE(net_properties, "_NET_PROPERTIES"); */
|
||||
CREATE(net_wm_name, "_NET_WM_NAME");
|
||||
CREATE(net_wm_visible_name, "_NET_WM_VISIBLE_NAME");
|
||||
CREATE(net_wm_icon_name, "_NET_WM_ICON_NAME");
|
||||
CREATE(net_wm_visible_icon_name, "_NET_WM_VISIBLE_ICON_NAME");
|
||||
CREATE(net_wm_desktop, "_NET_WM_DESKTOP");
|
||||
CREATE(net_wm_window_type, "_NET_WM_WINDOW_TYPE");
|
||||
CREATE(net_wm_state, "_NET_WM_STATE");
|
||||
CREATE(net_wm_strut, "_NET_WM_STRUT");
|
||||
/* CREATE(net_wm_icon_geometry, "_NET_WM_ICON_GEOMETRY"); */
|
||||
CREATE(net_wm_icon, "_NET_WM_ICON");
|
||||
/* CREATE(net_wm_pid, "_NET_WM_PID"); */
|
||||
/* CREATE(net_wm_handled_icons, "_NET_WM_HANDLED_ICONS"); */
|
||||
CREATE(net_wm_allowed_actions, "_NET_WM_ALLOWED_ACTIONS");
|
||||
|
||||
/* CREATE(net_wm_ping, "_NET_WM_PING"); */
|
||||
|
||||
CREATE(net_wm_window_type_desktop, "_NET_WM_WINDOW_TYPE_DESKTOP");
|
||||
CREATE(net_wm_window_type_dock, "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
CREATE(net_wm_window_type_toolbar, "_NET_WM_WINDOW_TYPE_TOOLBAR");
|
||||
CREATE(net_wm_window_type_menu, "_NET_WM_WINDOW_TYPE_MENU");
|
||||
CREATE(net_wm_window_type_utility, "_NET_WM_WINDOW_TYPE_UTILITY");
|
||||
CREATE(net_wm_window_type_splash, "_NET_WM_WINDOW_TYPE_SPLASH");
|
||||
CREATE(net_wm_window_type_dialog, "_NET_WM_WINDOW_TYPE_DIALOG");
|
||||
CREATE(net_wm_window_type_normal, "_NET_WM_WINDOW_TYPE_NORMAL");
|
||||
|
||||
CREATE(net_wm_moveresize_size_topleft, "_NET_WM_MOVERESIZE_SIZE_TOPLEFT");
|
||||
CREATE(net_wm_moveresize_size_topright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_TOPRIGHT");
|
||||
CREATE(net_wm_moveresize_size_bottomleft,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT");
|
||||
CREATE(net_wm_moveresize_size_bottomright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT");
|
||||
CREATE(net_wm_moveresize_move, "_NET_WM_MOVERESIZE_MOVE");
|
||||
|
||||
CREATE(net_wm_action_move, "_NET_WM_ACTION_MOVE");
|
||||
CREATE(net_wm_action_resize, "_NET_WM_ACTION_RESIZE");
|
||||
CREATE(net_wm_action_minimize, "_NET_WM_ACTION_MINIMIZE");
|
||||
CREATE(net_wm_action_shade, "_NET_WM_ACTION_SHADE");
|
||||
CREATE(net_wm_action_stick, "_NET_WM_ACTION_STICK");
|
||||
CREATE(net_wm_action_maximize_horz, "_NET_WM_ACTION_MAXIMIZE_HORZ");
|
||||
CREATE(net_wm_action_maximize_vert, "_NET_WM_ACTION_MAXIMIZE_VERT");
|
||||
CREATE(net_wm_action_fullscreen, "_NET_WM_ACTION_FULLSCREEN");
|
||||
CREATE(net_wm_action_change_desktop, "_NET_WM_ACTION_CHANGE_DESKTOP");
|
||||
CREATE(net_wm_action_close, "_NET_WM_ACTION_CLOSE");
|
||||
CREATE(net_wm_state_modal, "_NET_WM_STATE_MODAL");
|
||||
CREATE(net_wm_state_sticky, "_NET_WM_STATE_STICKY");
|
||||
CREATE(net_wm_state_maximized_vert, "_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
CREATE(net_wm_state_maximized_horz, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
CREATE(net_wm_state_shaded, "_NET_WM_STATE_SHADED");
|
||||
CREATE(net_wm_state_skip_taskbar, "_NET_WM_STATE_SKIP_TASKBAR");
|
||||
CREATE(net_wm_state_skip_pager, "_NET_WM_STATE_SKIP_PAGER");
|
||||
CREATE(net_wm_state_hidden, "_NET_WM_STATE_HIDDEN");
|
||||
CREATE(net_wm_state_fullscreen, "_NET_WM_STATE_FULLSCREEN");
|
||||
CREATE(net_wm_state_above, "_NET_WM_STATE_ABOVE");
|
||||
CREATE(net_wm_state_below, "_NET_WM_STATE_BELOW");
|
||||
|
||||
prop_atoms.net_wm_state_add = 1;
|
||||
prop_atoms.net_wm_state_remove = 0;
|
||||
prop_atoms.net_wm_state_toggle = 2;
|
||||
|
||||
prop_atoms.net_wm_orientation_horz = 0;
|
||||
prop_atoms.net_wm_orientation_vert = 1;
|
||||
prop_atoms.net_wm_topleft = 0;
|
||||
prop_atoms.net_wm_topright = 1;
|
||||
prop_atoms.net_wm_bottomright = 2;
|
||||
prop_atoms.net_wm_bottomleft = 3;
|
||||
|
||||
CREATE(kde_net_system_tray_windows, "_KDE_NET_SYSTEM_TRAY_WINDOWS");
|
||||
CREATE(kde_net_wm_system_tray_window_for,
|
||||
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");
|
||||
CREATE(kde_net_wm_window_type_override,
|
||||
"_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
|
||||
|
||||
CREATE(kwm_win_icon, "KWM_WIN_ICON");
|
||||
|
||||
CREATE(rootpmapid, "_XROOTPMAP_ID");
|
||||
CREATE(esetrootid, "ESETROOT_PMAP_ID");
|
||||
|
||||
CREATE(openbox_pid, "_OPENBOX_PID");
|
||||
CREATE(openbox_premax, "_OPENBOX_PREMAX");
|
||||
}
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
*data = g_memdup(xdata, num * (size / 8));
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
gulong i;
|
||||
for (i = 0; i < num; ++i)
|
||||
switch (size) {
|
||||
case 8:
|
||||
data[i] = xdata[i];
|
||||
break;
|
||||
case 16:
|
||||
((guint16*)data)[i] = ((guint16*)xdata)[i];
|
||||
break;
|
||||
case 32:
|
||||
((guint32*)data)[i] = ((guint32*)xdata)[i];
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached(); /* unhandled size */
|
||||
}
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, G_MAXLONG,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success) {
|
||||
if (ret_size == size && ret_items > 0) {
|
||||
*data = g_memdup(xdata, ret_items * (size / 8));
|
||||
*num = ret_items;
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((char*)raw, num);
|
||||
g_assert(str->str[num] == '\0');
|
||||
|
||||
g_free(raw);
|
||||
|
||||
*data = (guchar*)g_string_free(str, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str, *str2;
|
||||
guint i, start;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((gchar*)raw, num);
|
||||
g_assert(str->str[num] == '\0'); /* assuming this is always true.. */
|
||||
|
||||
g_free(raw);
|
||||
|
||||
/* split it into the list */
|
||||
for (start = 0, i = 0; i < str->len; ++i) {
|
||||
if (str->str[i] == '\0') {
|
||||
str2 = g_string_new_len(&str->str[start], i - start);
|
||||
g_ptr_array_add(data, g_string_free(str2, FALSE));
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
if (data->len > 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void prop_erase(Window win, Atom prop)
|
||||
{
|
||||
XDeleteProperty(ob_display, win, prop);
|
||||
}
|
202
c/prop.h
Normal file
202
c/prop.h
Normal file
|
@ -0,0 +1,202 @@
|
|||
#ifndef __atoms_h
|
||||
#define __atoms_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "openbox.h"
|
||||
|
||||
/*! The atoms on the X server which this class will cache */
|
||||
typedef struct Atoms {
|
||||
/* types */
|
||||
Atom cardinal; /*!< The atom which represents the Cardinal data type */
|
||||
Atom window; /*!< The atom which represents window ids */
|
||||
Atom pixmap; /*!< The atom which represents pixmap ids */
|
||||
Atom atom; /*!< The atom which represents atom values */
|
||||
Atom string; /*!< The atom which represents ascii strings */
|
||||
Atom utf8; /*!< The atom which represents utf8-encoded strings */
|
||||
|
||||
/* window hints */
|
||||
Atom wm_colormap_windows;
|
||||
Atom wm_protocols;
|
||||
Atom wm_state;
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom wm_name;
|
||||
Atom wm_icon_name;
|
||||
Atom wm_class;
|
||||
Atom wm_window_role;
|
||||
Atom motif_wm_hints;
|
||||
|
||||
/* NETWM atoms */
|
||||
|
||||
/* root window properties */
|
||||
Atom net_supported;
|
||||
Atom net_client_list;
|
||||
Atom net_client_list_stacking;
|
||||
Atom net_number_of_desktops;
|
||||
Atom net_desktop_geometry;
|
||||
Atom net_desktop_viewport;
|
||||
Atom net_current_desktop;
|
||||
Atom net_desktop_names;
|
||||
Atom net_active_window;
|
||||
Atom net_workarea;
|
||||
Atom net_supporting_wm_check;
|
||||
/* Atom net_virtual_roots; */
|
||||
Atom net_desktop_layout;
|
||||
Atom net_showing_desktop;
|
||||
/* root window messages */
|
||||
Atom net_close_window;
|
||||
Atom net_wm_moveresize;
|
||||
/* application window properties */
|
||||
/* Atom net_properties; */
|
||||
Atom net_wm_name;
|
||||
Atom net_wm_visible_name;
|
||||
Atom net_wm_icon_name;
|
||||
Atom net_wm_visible_icon_name;
|
||||
Atom net_wm_desktop;
|
||||
Atom net_wm_window_type;
|
||||
Atom net_wm_state;
|
||||
Atom net_wm_strut;
|
||||
/* Atom net_wm_icon_geometry; */
|
||||
Atom net_wm_icon;
|
||||
/* Atom net_wm_pid; */
|
||||
/* Atom net_wm_handled_icons; */
|
||||
Atom net_wm_allowed_actions;
|
||||
/* application protocols */
|
||||
/* Atom Atom net_wm_ping; */
|
||||
|
||||
Atom net_wm_window_type_desktop;
|
||||
Atom net_wm_window_type_dock;
|
||||
Atom net_wm_window_type_toolbar;
|
||||
Atom net_wm_window_type_menu;
|
||||
Atom net_wm_window_type_utility;
|
||||
Atom net_wm_window_type_splash;
|
||||
Atom net_wm_window_type_dialog;
|
||||
Atom net_wm_window_type_normal;
|
||||
|
||||
Atom net_wm_moveresize_size_topleft;
|
||||
Atom net_wm_moveresize_size_topright;
|
||||
Atom net_wm_moveresize_size_bottomleft;
|
||||
Atom net_wm_moveresize_size_bottomright;
|
||||
Atom net_wm_moveresize_move;
|
||||
|
||||
Atom net_wm_action_move;
|
||||
Atom net_wm_action_resize;
|
||||
Atom net_wm_action_minimize;
|
||||
Atom net_wm_action_shade;
|
||||
Atom net_wm_action_stick;
|
||||
Atom net_wm_action_maximize_horz;
|
||||
Atom net_wm_action_maximize_vert;
|
||||
Atom net_wm_action_fullscreen;
|
||||
Atom net_wm_action_change_desktop;
|
||||
Atom net_wm_action_close;
|
||||
|
||||
Atom net_wm_state_modal;
|
||||
Atom net_wm_state_sticky;
|
||||
Atom net_wm_state_maximized_vert;
|
||||
Atom net_wm_state_maximized_horz;
|
||||
Atom net_wm_state_shaded;
|
||||
Atom net_wm_state_skip_taskbar;
|
||||
Atom net_wm_state_skip_pager;
|
||||
Atom net_wm_state_hidden;
|
||||
Atom net_wm_state_fullscreen;
|
||||
Atom net_wm_state_above;
|
||||
Atom net_wm_state_below;
|
||||
|
||||
Atom net_wm_state_add;
|
||||
Atom net_wm_state_remove;
|
||||
Atom net_wm_state_toggle;
|
||||
|
||||
Atom net_wm_orientation_horz;
|
||||
Atom net_wm_orientation_vert;
|
||||
Atom net_wm_topleft;
|
||||
Atom net_wm_topright;
|
||||
Atom net_wm_bottomright;
|
||||
Atom net_wm_bottomleft;
|
||||
|
||||
/* Extra atoms */
|
||||
|
||||
Atom kde_net_system_tray_windows;
|
||||
Atom kde_net_wm_system_tray_window_for;
|
||||
Atom kde_net_wm_window_type_override;
|
||||
|
||||
Atom kwm_win_icon;
|
||||
|
||||
Atom rootpmapid;
|
||||
Atom esetrootid;
|
||||
|
||||
/* Openbox specific atoms */
|
||||
|
||||
Atom openbox_pid;
|
||||
Atom openbox_premax;
|
||||
} Atoms;
|
||||
Atoms prop_atoms;
|
||||
|
||||
void prop_init();
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num);
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num);
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num);
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data);
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data);
|
||||
|
||||
void prop_erase(Window win, Atom prop);
|
||||
|
||||
/* Set an 8-bit property from a string */
|
||||
#define PROP_SETS(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
PropModeReplace, (guchar*)value, strlen(value)))
|
||||
/* Set a 32-bit property from a single value */
|
||||
#define PROP_SET32(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)&value, 1))
|
||||
/* Set a 32-bit property from an array */
|
||||
#define PROP_SET32A(win, prop, type, value, num) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)value, num))
|
||||
|
||||
/* Get an 8-bit property into a string */
|
||||
#define PROP_GETS(win, prop, type, value) \
|
||||
(prop_get_string(win, prop_atoms.prop, prop_atoms.type, \
|
||||
(guchar**)&value))
|
||||
/* Get an 8-bit property into a GPtrArray of strings
|
||||
(The strings must be freed, the GPtrArray must already be created.) */
|
||||
#define PROP_GETSA(win, prop, type, value) \
|
||||
(prop_get_strings(win, prop_atoms.prop, prop_atoms.type, \
|
||||
value))
|
||||
|
||||
/* Get an entire 8-bit property into an array (which must be freed) */
|
||||
#define PROP_GET8U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
/* Get 1 element of a 32-bit property into a given variable */
|
||||
#define PROP_GET32(win, prop, type, value) \
|
||||
(prop_get_prealloc(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar*)&value, 1))
|
||||
|
||||
/* Get an amount of a 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32A(win, prop, type, value, num) \
|
||||
(prop_get(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, num))
|
||||
|
||||
/* Get an entire 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
#define PROP_ERASE(win, prop) (prop_erase(win, prop_atoms.prop))
|
||||
|
||||
#endif
|
55
c/python.c
Normal file
55
c/python.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
void python_startup()
|
||||
{
|
||||
PyObject *sys, *sysdict, *syspath, *path1, *path2;
|
||||
char *home, *homescriptdir;
|
||||
|
||||
Py_Initialize();
|
||||
|
||||
/* fix up the system path */
|
||||
|
||||
sys = PyImport_ImportModule((char*)"sys"); /* new */
|
||||
sysdict = PyModule_GetDict(sys); /* borrowed */
|
||||
syspath = PyDict_GetItemString(sysdict, (char*)"path"); /* borrowed */
|
||||
|
||||
path1 = PyString_FromString(SCRIPTDIR); /* new */
|
||||
PyList_Insert(syspath, 0, path1);
|
||||
Py_DECREF(path1);
|
||||
|
||||
home = getenv("HOME");
|
||||
if (home != NULL) {
|
||||
homescriptdir = g_strdup_printf("%s/.openbox", home);
|
||||
path2 = PyString_FromString(homescriptdir); /* new */
|
||||
g_free(homescriptdir);
|
||||
|
||||
PyList_Insert(syspath, 0, path2);
|
||||
Py_DECREF(path2);
|
||||
} else
|
||||
g_warning("Failed to read the $HOME environment variable");
|
||||
|
||||
Py_DECREF(sys);
|
||||
}
|
||||
|
||||
void python_shutdown()
|
||||
{
|
||||
Py_Finalize();
|
||||
}
|
||||
|
||||
gboolean python_import(char *module)
|
||||
{
|
||||
PyObject *mod;
|
||||
|
||||
mod = PyImport_ImportModule(module); /* new */
|
||||
if (mod == NULL) {
|
||||
PyErr_Print();
|
||||
return FALSE;
|
||||
}
|
||||
Py_DECREF(mod);
|
||||
return TRUE;
|
||||
}
|
10
c/python.h
Normal file
10
c/python.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef __python_h
|
||||
#define __python_h
|
||||
|
||||
void python_startup();
|
||||
void python_shutdown();
|
||||
|
||||
/*! Import a python module */
|
||||
gboolean python_import(char *module);
|
||||
|
||||
#endif
|
516
c/screen.c
Normal file
516
c/screen.c
Normal file
|
@ -0,0 +1,516 @@
|
|||
#include "openbox.h"
|
||||
#include "prop.h"
|
||||
#include "screen.h"
|
||||
#include "client.h"
|
||||
#include "focus.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/*! The event mask to grab on the root window */
|
||||
#define ROOT_EVENTMASK (/*ColormapChangeMask |*/ PropertyChangeMask | \
|
||||
EnterWindowMask | LeaveWindowMask | \
|
||||
SubstructureNotifyMask | SubstructureRedirectMask | \
|
||||
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
|
||||
|
||||
guint screen_num_desktops = 1;
|
||||
guint screen_desktop = 0;
|
||||
Size screen_physical_size;
|
||||
gboolean screen_showing_desktop;
|
||||
DesktopLayout screen_desktop_layout;
|
||||
GPtrArray *screen_desktop_names;
|
||||
|
||||
static Rect *area = NULL;
|
||||
static Strut *strut = NULL;
|
||||
|
||||
static void screen_update_area();
|
||||
|
||||
static gboolean running;
|
||||
static int another_running(Display *d, XErrorEvent *e)
|
||||
{
|
||||
(void)d;(void)e;
|
||||
g_message("A window manager is already running on screen %d",
|
||||
ob_screen);
|
||||
running = TRUE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
gboolean screen_annex()
|
||||
{
|
||||
XErrorHandler old;
|
||||
Window support;
|
||||
pid_t pid;
|
||||
int i, num_support;
|
||||
Atom *supported;
|
||||
|
||||
running = FALSE;
|
||||
old = XSetErrorHandler(another_running);
|
||||
XSelectInput(ob_display, ob_root, ROOT_EVENTMASK);
|
||||
XSync(ob_display, FALSE);
|
||||
XSetErrorHandler(old);
|
||||
if (running)
|
||||
return FALSE;
|
||||
|
||||
g_message("Managing screen %d", ob_screen);
|
||||
|
||||
/* set the mouse cursor for the root window (the default cursor) */
|
||||
XDefineCursor(ob_display, ob_root, ob_cursors.left_ptr);
|
||||
|
||||
/* set the OPENBOX_PID hint */
|
||||
pid = getpid();
|
||||
PROP_SET32(ob_root, openbox_pid, cardinal, pid);
|
||||
|
||||
/* create the netwm support window */
|
||||
support = XCreateSimpleWindow(ob_display, ob_root, 0, 0, 1, 1, 0, 0, 0);
|
||||
|
||||
/* set supporting window */
|
||||
PROP_SET32(ob_root, net_supporting_wm_check, window, support);
|
||||
|
||||
/* set properties on the supporting window */
|
||||
PROP_SETS(support, net_wm_name, utf8, "Openbox");
|
||||
PROP_SET32(support, net_supporting_wm_check, window, support);
|
||||
|
||||
/* set the _NET_SUPPORTED_ATOMS hint */
|
||||
num_support = 48;
|
||||
i = 0;
|
||||
supported = g_new(Atom, num_support);
|
||||
supported[i++] = prop_atoms.net_current_desktop;
|
||||
supported[i++] = prop_atoms.net_number_of_desktops;
|
||||
supported[i++] = prop_atoms.net_desktop_geometry;
|
||||
supported[i++] = prop_atoms.net_desktop_viewport;
|
||||
supported[i++] = prop_atoms.net_active_window;
|
||||
supported[i++] = prop_atoms.net_workarea;
|
||||
supported[i++] = prop_atoms.net_client_list;
|
||||
supported[i++] = prop_atoms.net_client_list_stacking;
|
||||
supported[i++] = prop_atoms.net_desktop_names;
|
||||
supported[i++] = prop_atoms.net_close_window;
|
||||
supported[i++] = prop_atoms.net_desktop_layout;
|
||||
supported[i++] = prop_atoms.net_showing_desktop;
|
||||
supported[i++] = prop_atoms.net_wm_name;
|
||||
supported[i++] = prop_atoms.net_wm_visible_name;
|
||||
supported[i++] = prop_atoms.net_wm_icon_name;
|
||||
supported[i++] = prop_atoms.net_wm_visible_icon_name;
|
||||
supported[i++] = prop_atoms.net_wm_desktop;
|
||||
supported[i++] = prop_atoms.net_wm_strut;
|
||||
supported[i++] = prop_atoms.net_wm_window_type;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_desktop;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_dock;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_toolbar;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_menu;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_utility;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_splash;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_dialog;
|
||||
supported[i++] = prop_atoms.net_wm_window_type_normal;
|
||||
supported[i++] = prop_atoms.net_wm_allowed_actions;
|
||||
supported[i++] = prop_atoms.net_wm_action_move;
|
||||
supported[i++] = prop_atoms.net_wm_action_resize;
|
||||
supported[i++] = prop_atoms.net_wm_action_minimize;
|
||||
supported[i++] = prop_atoms.net_wm_action_shade;
|
||||
supported[i++] = prop_atoms.net_wm_action_maximize_horz;
|
||||
supported[i++] = prop_atoms.net_wm_action_maximize_vert;
|
||||
supported[i++] = prop_atoms.net_wm_action_fullscreen;
|
||||
supported[i++] = prop_atoms.net_wm_action_change_desktop;
|
||||
supported[i++] = prop_atoms.net_wm_action_close;
|
||||
supported[i++] = prop_atoms.net_wm_state;
|
||||
supported[i++] = prop_atoms.net_wm_state_modal;
|
||||
supported[i++] = prop_atoms.net_wm_state_maximized_vert;
|
||||
supported[i++] = prop_atoms.net_wm_state_maximized_horz;
|
||||
supported[i++] = prop_atoms.net_wm_state_shaded;
|
||||
supported[i++] = prop_atoms.net_wm_state_skip_taskbar;
|
||||
supported[i++] = prop_atoms.net_wm_state_skip_pager;
|
||||
supported[i++] = prop_atoms.net_wm_state_hidden;
|
||||
supported[i++] = prop_atoms.net_wm_state_fullscreen;
|
||||
supported[i++] = prop_atoms.net_wm_state_above;
|
||||
supported[i++] = prop_atoms.net_wm_state_below;
|
||||
g_assert(i == num_support);
|
||||
/*
|
||||
supported[] = prop_atoms.net_wm_moveresize;
|
||||
supported[] = prop_atoms.net_wm_moveresize_size_topleft;
|
||||
supported[] = prop_atoms.net_wm_moveresize_size_topright;
|
||||
supported[] = prop_atoms.net_wm_moveresize_size_bottomleft;
|
||||
supported[] = prop_atoms.net_wm_moveresize_size_bottomright;
|
||||
supported[] = prop_atoms.net_wm_moveresize_move;
|
||||
supported[] = prop_atoms.net_wm_action_stick;
|
||||
*/
|
||||
|
||||
PROP_SET32A(ob_root, net_supported, atom, supported, num_support);
|
||||
g_free(supported);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void screen_startup()
|
||||
{
|
||||
screen_desktop_names = g_ptr_array_new();
|
||||
|
||||
/* get the initial size */
|
||||
screen_resize();
|
||||
|
||||
screen_set_num_desktops(4);
|
||||
screen_set_desktop(0);
|
||||
|
||||
/* don't start in showing-desktop mode */
|
||||
screen_showing_desktop = FALSE;
|
||||
PROP_SET32(ob_root, net_showing_desktop, cardinal, screen_showing_desktop);
|
||||
|
||||
screen_update_layout();
|
||||
}
|
||||
|
||||
void screen_shutdown()
|
||||
{
|
||||
guint i;
|
||||
for (i = 0; i < screen_desktop_names->len; ++i)
|
||||
g_free(g_ptr_array_index(screen_desktop_names, i));
|
||||
g_ptr_array_free(screen_desktop_names, TRUE);
|
||||
g_free(strut);
|
||||
g_free(area);
|
||||
}
|
||||
|
||||
void screen_resize()
|
||||
{
|
||||
/* Set the _NET_DESKTOP_GEOMETRY hint */
|
||||
/* XXX RandR support here? */
|
||||
int geometry[2];
|
||||
|
||||
geometry[0] = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen));
|
||||
geometry[1] = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen));
|
||||
PROP_SET32A(ob_root, net_desktop_geometry, cardinal, geometry, 2);
|
||||
screen_physical_size.width = geometry[0];
|
||||
screen_physical_size.height = geometry[1];
|
||||
|
||||
if (ob_state == State_Starting)
|
||||
return;
|
||||
|
||||
screen_update_struts();
|
||||
|
||||
/* XXX adjust more stuff ? */
|
||||
}
|
||||
|
||||
void screen_set_num_desktops(guint num)
|
||||
{
|
||||
unsigned long *viewport;
|
||||
|
||||
g_assert(num > 0);
|
||||
|
||||
/* move windows on desktops that will no longer exist! */
|
||||
/* XXX
|
||||
std::list<Client*>::iterator it, end = clients.end();
|
||||
for (it = clients.begin(); it != end; ++it) {
|
||||
unsigned int d = (*it)->desktop();
|
||||
if (d >= num && d != 0xffffffff) {
|
||||
XEvent ce;
|
||||
ce.xclient.type = ClientMessage;
|
||||
ce.xclient.message_type = otk::Property::atoms.net_wm_desktop;
|
||||
ce.xclient.display = **otk::display;
|
||||
ce.xclient.window = (*it)->window();
|
||||
ce.xclient.format = 32;
|
||||
ce.xclient.data.l[0] = num - 1;
|
||||
XSendEvent(**otk::display, _info->rootWindow(), false,
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, &ce);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
screen_num_desktops = num;
|
||||
PROP_SET32(ob_root, net_number_of_desktops, cardinal, num);
|
||||
|
||||
/* set the viewport hint */
|
||||
viewport = g_new0(unsigned long, num * 2);
|
||||
PROP_SET32A(ob_root, net_desktop_viewport, cardinal, viewport, num * 2);
|
||||
g_free(viewport);
|
||||
|
||||
/* change our struts/area to match */
|
||||
screen_update_struts();
|
||||
|
||||
/* the number of rows/columns will differ */
|
||||
screen_update_layout();
|
||||
|
||||
/* may be some unnamed desktops that we need to fill in with names */
|
||||
screen_update_desktop_names();
|
||||
|
||||
/* change our desktop if we're on one that no longer exists! */
|
||||
if (screen_desktop >= screen_num_desktops)
|
||||
screen_set_desktop(num - 1);
|
||||
}
|
||||
|
||||
void screen_set_desktop(guint num)
|
||||
{
|
||||
guint old = screen_desktop;
|
||||
|
||||
g_assert(num < screen_num_desktops);
|
||||
|
||||
g_message("Moving to desktop %u", num);
|
||||
|
||||
screen_desktop = num;
|
||||
PROP_SET32(ob_root, net_current_desktop, cardinal, num);
|
||||
|
||||
if (old == num) return;
|
||||
|
||||
/* XXX show/hide all the clients
|
||||
std::list<Client*>::iterator it, end = clients.end();
|
||||
for (it = clients.begin(); it != end; ++it)
|
||||
(*it)->showhide(); */
|
||||
|
||||
/* XXX force the callbacks to fire
|
||||
if (!openbox->focusedClient())
|
||||
openbox->setFocusedClient(0); */
|
||||
}
|
||||
|
||||
void screen_update_layout()
|
||||
{
|
||||
unsigned long *data = NULL;
|
||||
|
||||
/* defaults */
|
||||
screen_desktop_layout.orientation = prop_atoms.net_wm_orientation_horz;
|
||||
screen_desktop_layout.start_corner = prop_atoms.net_wm_topleft;
|
||||
screen_desktop_layout.rows = 1;
|
||||
screen_desktop_layout.columns = screen_num_desktops;
|
||||
|
||||
if (PROP_GET32A(ob_root, net_desktop_layout, cardinal, data, 4)) {
|
||||
if (data[0] == prop_atoms.net_wm_orientation_vert)
|
||||
screen_desktop_layout.orientation = data[0];
|
||||
if (data[3] == prop_atoms.net_wm_topright)
|
||||
screen_desktop_layout.start_corner = data[3];
|
||||
else if (data[3] == prop_atoms.net_wm_bottomright)
|
||||
screen_desktop_layout.start_corner = data[3];
|
||||
else if (data[3] == prop_atoms.net_wm_bottomleft)
|
||||
screen_desktop_layout.start_corner = data[3];
|
||||
|
||||
/* fill in a zero rows/columns */
|
||||
if (!(data[1] == 0 && data[2] == 0)) { /* both 0's is bad data.. */
|
||||
if (data[1] == 0) {
|
||||
data[1] = (screen_num_desktops +
|
||||
screen_num_desktops % data[2]) / data[2];
|
||||
} else if (data[2] == 0) {
|
||||
data[2] = (screen_num_desktops +
|
||||
screen_num_desktops % data[1]) / data[1];
|
||||
}
|
||||
screen_desktop_layout.columns = data[1];
|
||||
screen_desktop_layout.rows = data[2];
|
||||
}
|
||||
|
||||
/* bounds checking */
|
||||
if (screen_desktop_layout.orientation ==
|
||||
prop_atoms.net_wm_orientation_horz) {
|
||||
if (screen_desktop_layout.rows > screen_num_desktops)
|
||||
screen_desktop_layout.rows = screen_num_desktops;
|
||||
if (screen_desktop_layout.columns > ((screen_num_desktops +
|
||||
screen_num_desktops %
|
||||
screen_desktop_layout.rows) /
|
||||
screen_desktop_layout.rows))
|
||||
screen_desktop_layout.columns =
|
||||
(screen_num_desktops + screen_num_desktops %
|
||||
screen_desktop_layout.rows) /
|
||||
screen_desktop_layout.rows;
|
||||
} else {
|
||||
if (screen_desktop_layout.columns > screen_num_desktops)
|
||||
screen_desktop_layout.columns = screen_num_desktops;
|
||||
if (screen_desktop_layout.rows > ((screen_num_desktops +
|
||||
screen_num_desktops %
|
||||
screen_desktop_layout.columns) /
|
||||
screen_desktop_layout.columns))
|
||||
screen_desktop_layout.rows =
|
||||
(screen_num_desktops + screen_num_desktops %
|
||||
screen_desktop_layout.columns) /
|
||||
screen_desktop_layout.columns;
|
||||
}
|
||||
g_free(data);
|
||||
}
|
||||
}
|
||||
|
||||
void screen_update_desktop_names()
|
||||
{
|
||||
guint i;
|
||||
|
||||
/* empty the array */
|
||||
for (i = 0; i < screen_desktop_names->len; ++i)
|
||||
g_free(g_ptr_array_index(screen_desktop_names, i));
|
||||
g_ptr_array_set_size(screen_desktop_names, 0);
|
||||
|
||||
PROP_GETSA(ob_root, net_desktop_names, utf8, screen_desktop_names);
|
||||
|
||||
while (screen_desktop_names->len < screen_num_desktops)
|
||||
g_ptr_array_add(screen_desktop_names, g_strdup("Unnamed Desktop"));
|
||||
}
|
||||
|
||||
void screen_show_desktop(gboolean show)
|
||||
{
|
||||
GSList *it;
|
||||
static Window saved_focus = 0;
|
||||
|
||||
if (show == screen_showing_desktop) return; /* no change */
|
||||
|
||||
/* save the window focus, and restore it when leaving the show-desktop
|
||||
mode */
|
||||
if (show && focus_client)
|
||||
saved_focus = focus_client->window;
|
||||
|
||||
screen_showing_desktop = show;
|
||||
|
||||
for (it = client_list; it; it = g_slist_next(it)) {
|
||||
Client *client = it->data;
|
||||
if (client->type == Type_Desktop) {
|
||||
if (show) client_focus(client);
|
||||
} else
|
||||
client_showhide(client);
|
||||
}
|
||||
|
||||
if (!show) {
|
||||
Client *f = focus_client;
|
||||
if (!f || f->type == Type_Desktop) {
|
||||
Client *c = g_hash_table_lookup(client_map,
|
||||
(gpointer)saved_focus);
|
||||
if (c) client_focus(c);
|
||||
}
|
||||
}
|
||||
|
||||
show = show ? 1 : 0; /* make it boolean */
|
||||
PROP_SET32(ob_root, net_showing_desktop, cardinal, show);
|
||||
}
|
||||
|
||||
void screen_install_colormap(Client *client, gboolean install)
|
||||
{
|
||||
if (client == NULL) {
|
||||
/* XXX DONT USE THE DEFAULT SHIT HERE */
|
||||
if (install)
|
||||
XInstallColormap(ob_display,
|
||||
DefaultColormap(ob_display, ob_screen));
|
||||
else
|
||||
XUninstallColormap(ob_display,
|
||||
DefaultColormap(ob_display, ob_screen));
|
||||
} else {
|
||||
XWindowAttributes wa;
|
||||
if (XGetWindowAttributes(ob_display, client->window, &wa)) {
|
||||
if (install)
|
||||
XInstallColormap(ob_display, wa.colormap);
|
||||
else
|
||||
XUninstallColormap(ob_display, wa.colormap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void screen_update_struts()
|
||||
{
|
||||
GSList *it;
|
||||
guint i;
|
||||
|
||||
if (strut != NULL)
|
||||
g_free(strut);
|
||||
strut = g_new0(Strut, screen_num_desktops + 1);
|
||||
|
||||
for (it = client_list; it; it = it->next) {
|
||||
Client *c = it->data;
|
||||
if (c->iconic) continue; /* these dont count in the strut */
|
||||
|
||||
if (c->desktop == 0xffffffff) {
|
||||
for (i = 0; i < screen_num_desktops; ++i)
|
||||
STRUT_ADD(strut[i], c->strut);
|
||||
} else {
|
||||
g_assert(c->desktop < screen_num_desktops);
|
||||
STRUT_ADD(strut[c->desktop], c->strut);
|
||||
}
|
||||
/* apply to the 'all desktops' strut */
|
||||
STRUT_ADD(strut[screen_num_desktops], c->strut);
|
||||
}
|
||||
screen_update_area();
|
||||
}
|
||||
|
||||
static void screen_update_area()
|
||||
{
|
||||
guint i;
|
||||
gulong *dims;
|
||||
|
||||
if (area != NULL)
|
||||
g_free(area);
|
||||
area = g_new0(Rect, screen_num_desktops + 1);
|
||||
|
||||
dims = g_new(unsigned long, 4 * screen_num_desktops);
|
||||
for (i = 0; i < screen_num_desktops + 1; ++i) {
|
||||
Rect old_area = area[i];
|
||||
/*
|
||||
#ifdef XINERAMA
|
||||
// reset to the full areas
|
||||
if (isXineramaActive())
|
||||
xineramaUsableArea = getXineramaAreas();
|
||||
#endif // XINERAMA
|
||||
*/
|
||||
|
||||
RECT_SET(area[i], strut[i].left, strut[i].top,
|
||||
screen_physical_size.width - (strut[i].left +
|
||||
strut[i].right),
|
||||
screen_physical_size.height - (strut[i].top +
|
||||
strut[i].bottom));
|
||||
|
||||
/*
|
||||
#ifdef XINERAMA
|
||||
if (isXineramaActive()) {
|
||||
// keep each of the ximerama-defined areas inside the strut
|
||||
RectList::iterator xit, xend = xineramaUsableArea.end();
|
||||
for (xit = xineramaUsableArea.begin(); xit != xend; ++xit) {
|
||||
if (xit->x() < usableArea.x()) {
|
||||
xit->setX(usableArea.x());
|
||||
xit->setWidth(xit->width() - usableArea.x());
|
||||
}
|
||||
if (xit->y() < usableArea.y()) {
|
||||
xit->setY(usableArea.y());
|
||||
xit->setHeight(xit->height() - usableArea.y());
|
||||
}
|
||||
if (xit->x() + xit->width() > usableArea.width())
|
||||
xit->setWidth(usableArea.width() - xit->x());
|
||||
if (xit->y() + xit->height() > usableArea.height())
|
||||
xit->setHeight(usableArea.height() - xit->y());
|
||||
}
|
||||
}
|
||||
#endif // XINERAMA
|
||||
*/
|
||||
if (!RECT_EQUAL(old_area, area[i])) {
|
||||
/* the area has changed, adjust all the maximized windows */
|
||||
GSList *it;
|
||||
for (it = client_list; it; it = it->next) {
|
||||
Client *c = it->data;
|
||||
if (i < screen_num_desktops) {
|
||||
if (c->desktop == i)
|
||||
client_remaximize(c);
|
||||
} else {
|
||||
/* the 'all desktops' size */
|
||||
if (c->desktop == DESKTOP_ALL)
|
||||
client_remaximize(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* don't set these for the 'all desktops' area */
|
||||
if (i < screen_num_desktops) {
|
||||
dims[(i * 4) + 0] = area[i].x;
|
||||
dims[(i * 4) + 1] = area[i].y;
|
||||
dims[(i * 4) + 2] = area[i].width;
|
||||
dims[(i * 4) + 3] = area[i].height;
|
||||
}
|
||||
}
|
||||
PROP_SET32A(ob_root, net_workarea, cardinal,
|
||||
dims, 4 * screen_num_desktops);
|
||||
g_free(dims);
|
||||
}
|
||||
|
||||
Rect *screen_area(guint desktop)
|
||||
{
|
||||
if (desktop >= screen_num_desktops) {
|
||||
if (desktop == DESKTOP_ALL)
|
||||
return &area[screen_num_desktops];
|
||||
return NULL;
|
||||
}
|
||||
return &area[desktop];
|
||||
}
|
||||
|
||||
Strut *screen_strut(guint desktop)
|
||||
{
|
||||
if (desktop >= screen_num_desktops) {
|
||||
if (desktop == DESKTOP_ALL)
|
||||
return &strut[screen_num_desktops];
|
||||
return NULL;
|
||||
}
|
||||
return &strut[desktop];
|
||||
}
|
66
c/screen.h
Normal file
66
c/screen.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifndef __screen_h
|
||||
#define __screen_h
|
||||
|
||||
#include "geom.h"
|
||||
|
||||
struct Client;
|
||||
|
||||
#define DESKTOP_ALL (0xffffffff)
|
||||
|
||||
/*! The number of available desktops */
|
||||
extern guint screen_num_desktops;
|
||||
/*! The current desktop */
|
||||
extern guint screen_desktop;
|
||||
/*! The size of the screen */
|
||||
extern Size screen_physical_size;
|
||||
/*! Are we in showing-desktop mode? */
|
||||
extern gboolean screen_showing_desktop;
|
||||
|
||||
typedef struct DesktopLayout {
|
||||
guint orientation;
|
||||
guint start_corner;
|
||||
guint rows;
|
||||
guint columns;
|
||||
} DesktopLayout;
|
||||
extern DesktopLayout screen_desktop_layout;
|
||||
|
||||
/*! An array of gchar*'s which are desktop names in UTF-8 format */
|
||||
extern GPtrArray *screen_desktop_names;
|
||||
|
||||
/*! Take over the screen, set the basic hints on it claming it as ours */
|
||||
gboolean screen_annex();
|
||||
|
||||
/*! Once the screen is ours, set up its initial state */
|
||||
void screen_startup();
|
||||
/*! Free resources */
|
||||
void screen_shutdown();
|
||||
|
||||
/*! Figure out the new size of the screen and adjust stuff for it */
|
||||
void screen_resize();
|
||||
|
||||
/*! Change the number of available desktops */
|
||||
void screen_set_num_desktops(guint num);
|
||||
/*! Change the current desktop */
|
||||
void screen_set_desktop(guint num);
|
||||
|
||||
/*! Shows and focuses the desktop and hides all the client windows, or
|
||||
returns to the normal state, showing client windows. */
|
||||
void screen_show_desktop(gboolean show);
|
||||
|
||||
/*! Updates the desktop layout from the root property if available */
|
||||
void screen_update_layout();
|
||||
|
||||
/*! Get desktop names from the root window property */
|
||||
void screen_update_desktop_names();
|
||||
|
||||
/*! Installs or uninstalls a colormap for a client. If client is NULL, then
|
||||
it handles the root colormap. */
|
||||
void screen_install_colormap(struct Client *client, gboolean install);
|
||||
|
||||
void screen_update_struts();
|
||||
|
||||
Rect *screen_area(guint desktop);
|
||||
|
||||
Strut *screen_strut(guint desktop);
|
||||
|
||||
#endif
|
433
c/screenwrap.c
Normal file
433
c/screenwrap.c
Normal file
|
@ -0,0 +1,433 @@
|
|||
#include "screenwrap.h"
|
||||
#include "openbox.h"
|
||||
#include "screen.h"
|
||||
#include "kbind.h"
|
||||
#include "mbind.h"
|
||||
|
||||
ScreenWrap *screenwrap_instance;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'ScreenWrap'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_SWRAP(v) ((v)->ob_type == &ScreenWrapType)
|
||||
#define CHECK_SWRAP(self, funcname) { \
|
||||
if (!IS_SWRAP(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' a 'Screen' object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
staticforward PyTypeObject ScreenWrapType;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Attribute methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *swrap_number(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "number");
|
||||
if (!PyArg_ParseTuple(args, ":number"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_screen);
|
||||
}
|
||||
|
||||
static PyObject *swrap_rootWindow(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "rootWindow");
|
||||
if (!PyArg_ParseTuple(args, ":rootWindow"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_root);
|
||||
}
|
||||
|
||||
static PyObject *swrap_state(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "state");
|
||||
if (!PyArg_ParseTuple(args, ":state"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_state);
|
||||
}
|
||||
|
||||
static PyObject *swrap_numDesktops(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "numDesktops");
|
||||
if (!PyArg_ParseTuple(args, ":numDesktops"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(screen_num_desktops);
|
||||
}
|
||||
|
||||
static PyObject *swrap_desktop(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "desktop");
|
||||
if (!PyArg_ParseTuple(args, ":desktop"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(screen_desktop);
|
||||
}
|
||||
|
||||
static PyObject *swrap_physicalSize(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_SWRAP(self, "physicalSize");
|
||||
if (!PyArg_ParseTuple(args, ":physicalSize"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(screen_physical_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(screen_physical_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *swrap_showingDesktop(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "showingDesktop");
|
||||
if (!PyArg_ParseTuple(args, ":showingDesktop"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(screen_showing_desktop ? 1 : 0);
|
||||
}
|
||||
|
||||
static PyObject *swrap_desktopLayout(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_SWRAP(self, "desktopLayout");
|
||||
if (!PyArg_ParseTuple(args, ":desktopLayout"))
|
||||
return NULL;
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0,
|
||||
PyInt_FromLong(screen_desktop_layout.orientation));
|
||||
PyTuple_SET_ITEM(tuple, 1,
|
||||
PyInt_FromLong(screen_desktop_layout.start_corner));
|
||||
PyTuple_SET_ITEM(tuple, 2,
|
||||
PyInt_FromLong(screen_desktop_layout.rows));
|
||||
PyTuple_SET_ITEM(tuple, 3,
|
||||
PyInt_FromLong(screen_desktop_layout.columns));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *swrap_desktopNames(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *list;
|
||||
guint s, i;
|
||||
|
||||
CHECK_SWRAP(self, "desktopNames");
|
||||
if (!PyArg_ParseTuple(args, ":desktopNames"))
|
||||
return NULL;
|
||||
s = screen_desktop_names->len;
|
||||
list = PyList_New(s);
|
||||
for (i = 0; i < s; ++i)
|
||||
PyList_SET_ITEM(list, i, PyString_FromString
|
||||
(g_ptr_array_index(screen_desktop_names, i)));
|
||||
return list;
|
||||
}
|
||||
|
||||
static PyObject *swrap_area(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject * tuple;
|
||||
Rect *r;
|
||||
guint i;
|
||||
|
||||
CHECK_SWRAP(self, "area");
|
||||
if (!PyArg_ParseTuple(args, "i:area", &i))
|
||||
return NULL;
|
||||
r = screen_area(i);
|
||||
if (r == NULL) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"the requested desktop was not valid");
|
||||
return NULL;
|
||||
}
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(r->x));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(r->y));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(r->width));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(r->height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *swrap_strut(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
Strut *s;
|
||||
guint i;
|
||||
|
||||
CHECK_SWRAP(self, "strut");
|
||||
if (!PyArg_ParseTuple(args, "i:strut", &i))
|
||||
return NULL;
|
||||
s = screen_strut(i);
|
||||
if (s == NULL) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"the requested desktop was not valid");
|
||||
return NULL;
|
||||
}
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(s->left));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(s->top));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(s->right));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(s->bottom));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *swrap_grabKey(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *item, *tuple;
|
||||
GList *keylist = NULL, *it;
|
||||
int i, s;
|
||||
gboolean grab = FALSE;
|
||||
|
||||
CHECK_SWRAP(self, "grabKey");
|
||||
if (!PyArg_ParseTuple(args, "O:grabKey", &tuple))
|
||||
return NULL;
|
||||
|
||||
if (PyTuple_Check(tuple)) {
|
||||
s = PyTuple_GET_SIZE(tuple);
|
||||
if (s > 0) {
|
||||
for (i = 0; i < s; ++i) {
|
||||
item = PyTuple_GET_ITEM(tuple, i);
|
||||
if (!PyString_Check(item))
|
||||
break;
|
||||
keylist = g_list_append(keylist,
|
||||
g_strdup(PyString_AsString(item)));
|
||||
}
|
||||
if (i == s)
|
||||
grab = kbind_add(keylist);
|
||||
|
||||
for (it = keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(it);
|
||||
|
||||
if (grab) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"the key could not be grabbed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_TypeError, "expected a tuple of strings");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *swrap_clearKeyGrabs(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "clearKeyGrabs");
|
||||
if (!PyArg_ParseTuple(args, ":clearKeyGrabs"))
|
||||
return NULL;
|
||||
kbind_clearall();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *swrap_grabKeyboard(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
int grab;
|
||||
|
||||
CHECK_SWRAP(self, "grabKeyboard");
|
||||
if (!PyArg_ParseTuple(args, "i:grabKeyboard", &grab))
|
||||
return NULL;
|
||||
if (!kbind_grab_keyboard(grab)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "failed to grab keyboard");
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *swrap_grabButton(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
char *name;
|
||||
char *context_str;
|
||||
GQuark context;
|
||||
|
||||
CHECK_SWRAP(self, "grabButton");
|
||||
if (!PyArg_ParseTuple(args, "ss:grabKey", &name, &context_str))
|
||||
return NULL;
|
||||
|
||||
context = g_quark_try_string(context_str);
|
||||
|
||||
if (!context) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mbind_add(name, context)) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"the button could not be grabbed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *swrap_clearButtonGrabs(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_SWRAP(self, "clearButtonGrabs");
|
||||
if (!PyArg_ParseTuple(args, ":clearButtonGrabs"))
|
||||
return NULL;
|
||||
mbind_clearall();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *swrap_grabPointer(ScreenWrap *self, PyObject *args)
|
||||
{
|
||||
int grab;
|
||||
|
||||
CHECK_SWRAP(self, "grabPointer");
|
||||
if (!PyArg_ParseTuple(args, "i:grabPointer", &grab))
|
||||
return NULL;
|
||||
if (!mbind_grab_pointer(grab)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "failed to grab pointer");
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyMethodDef ScreenWrapAttributeMethods[] = {
|
||||
{"number", (PyCFunction)swrap_number, METH_VARARGS,
|
||||
"Screen.number() -- Returns the number of the screen on the X server on "
|
||||
"which this Openbox instance is running."},
|
||||
{"rootWindow", (PyCFunction)swrap_rootWindow, METH_VARARGS,
|
||||
"Screen.rootWindow() -- Returns the window id of the root window."},
|
||||
{"state", (PyCFunction)swrap_state, METH_VARARGS,
|
||||
"Screen.state() -- Returns the running state of Openbox. One of the "
|
||||
"ob.State_ constants."},
|
||||
{"numDesktops", (PyCFunction)swrap_numDesktops, METH_VARARGS,
|
||||
"Screen.numDesktops() -- Returns the number of desktops available."},
|
||||
{"desktop", (PyCFunction)swrap_desktop, METH_VARARGS,
|
||||
"Screen.desktop() -- Returns the currently visible desktop."},
|
||||
{"physicalSize", (PyCFunction)swrap_physicalSize, METH_VARARGS,
|
||||
"Screen.physicalSize() -- Returns the physical size (in pixels) of the "
|
||||
"display in a tuple. The tuple is formatted as (width, height)."},
|
||||
{"showingDesktop", (PyCFunction)swrap_showingDesktop, METH_VARARGS,
|
||||
"Screen.showingDesktop() -- Returns if in showing-the-desktop mode or "
|
||||
"not."},
|
||||
{"desktopNames", (PyCFunction)swrap_desktopNames, METH_VARARGS,
|
||||
"Screen.desktopNames() -- Returns a list of the names of all the "
|
||||
"desktops, and possibly for desktops beyond those. The names are encoded "
|
||||
"as UTF-8."},
|
||||
{"desktopLayout", (PyCFunction)swrap_desktopLayout, METH_VARARGS,
|
||||
"Screen.desktopLayout() -- Returns the layout of the desktops, as "
|
||||
"specified by a compliant pager, in a tuple. The format of the tuple is "
|
||||
"(orientation, corner, rows, columns). Where, orientation is one of the "
|
||||
"ob.Orientation_ constants, corner is one of the ob.Corner_ constants, "
|
||||
"and rows and columns specify the size of the layout. The rows and "
|
||||
"columns will always include all the desktops."},
|
||||
{"area", (PyCFunction)swrap_area, METH_VARARGS,
|
||||
"Screen.area(d) -- Returns the usuable area on the Screen for a desktop, "
|
||||
"in the form of a tuple. The tuples format is (x, y, width, height). The "
|
||||
"desktop must be in the range of desktops on the screen, or 0xffffffff "
|
||||
"to get a combined area for 'all desktops'."},
|
||||
{"strut", (PyCFunction)swrap_area, METH_VARARGS,
|
||||
"Screen.strut(d) -- Returns the combined strut of all clients on a "
|
||||
"desktop, in the form of a tuple. The tuples format is "
|
||||
"(left, top, right, bottom). The desktop must be in the range of "
|
||||
"desktops on the screen, or 0xffffffff to get a combined strut for "
|
||||
"'all desktops'."},
|
||||
{"grabKey", (PyCFunction)swrap_grabKey, METH_VARARGS,
|
||||
"Screen.grabKey(('Mod1-C-a', 'd')) -- Grabs a key chain so that key "
|
||||
"events for it will occur. The argument must be a tuple of one or "
|
||||
"more elements. Each key element is made up of "
|
||||
"Modifier-Modifier-...-Key, where Modifier is one of Mod1, Mod2, "
|
||||
"Mod3, Mod4, Mod5, S (for Shift), or C (for Control)."},
|
||||
{"clearKeyGrabs", (PyCFunction)swrap_clearKeyGrabs, METH_VARARGS,
|
||||
"Screen.clearKeyGrabs() -- Removes all key grabs that have been done "
|
||||
"with grabKey()."},
|
||||
{"grabKeyboard", (PyCFunction)swrap_grabKeyboard, METH_VARARGS,
|
||||
"Screen.grabKeyboard(grab) -- Grabs or ungrabs the entire keyboard. When "
|
||||
"the keyboard is grabbed, all key presses will be sent to the "
|
||||
"hooks.keyboard hook. (grabbed keys will go to the hooks.events hook "
|
||||
"too. "},
|
||||
{"grabButton", (PyCFunction)swrap_grabButton, METH_VARARGS,
|
||||
"Screen.grabButton('C-1', \"frame\") -- Grabs a pointer button "
|
||||
"for the given context. The context must be one of the ob.Context_* "
|
||||
"constants. The button definition is made up of "
|
||||
"Modifier-Modifier-...-Button, where Modifier is one of Mod1, Mod2, "
|
||||
"Mod3, Mod4, Mod5, S (for Shift), or C (for Control)."},
|
||||
{"clearButtonGrabs", (PyCFunction)swrap_clearButtonGrabs, METH_VARARGS,
|
||||
"Screen.clearButtonGrabs() -- Removes all button grabs that have been "
|
||||
"done with grabButton()."},
|
||||
{"grabPointer", (PyCFunction)swrap_grabPointer, METH_VARARGS,
|
||||
"grabPointer(grab) -- Grabs or ungrabs the pointer device. When the "
|
||||
"pointer is grabbed, all pointer events will be sent to the "
|
||||
"hooks.pointer hook. (grabbed buttons will NOT go to the hooks.events "
|
||||
"hook while the pointer is grabbed)."},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *swrap_getattr(ScreenWrap *self, char *name)
|
||||
{
|
||||
CHECK_SWRAP(self, "getattr");
|
||||
return Py_FindMethod(ScreenWrapAttributeMethods, (PyObject*)self, name);
|
||||
}
|
||||
|
||||
static void swrap_dealloc(ScreenWrap *self)
|
||||
{
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyTypeObject ScreenWrapType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Screen",
|
||||
sizeof(ScreenWrap),
|
||||
0,
|
||||
(destructor) swrap_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) swrap_getattr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
External methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
void screenwrap_startup()
|
||||
{
|
||||
PyObject *ob, *obdict;
|
||||
ScreenWrap *swrap;
|
||||
|
||||
ScreenWrapType.ob_type = &PyType_Type;
|
||||
ScreenWrapType.tp_doc = "Wraps information and functionality global to an "
|
||||
"instance of Openbox.";
|
||||
PyType_Ready(&ScreenWrapType);
|
||||
swrap = PyObject_New(ScreenWrap, &ScreenWrapType);
|
||||
|
||||
/* get the ob module/dict */
|
||||
ob = PyImport_ImportModule("ob"); /* new */
|
||||
g_assert(ob != NULL);
|
||||
obdict = PyModule_GetDict(ob); /* borrowed */
|
||||
g_assert(obdict != NULL);
|
||||
|
||||
PyDict_SetItemString(obdict, "Screen", (PyObject*)swrap);
|
||||
Py_DECREF(swrap);
|
||||
Py_DECREF(ob);
|
||||
}
|
||||
|
||||
void screenwrap_shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
|
14
c/screenwrap.h
Normal file
14
c/screenwrap.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef __screenwrap_h
|
||||
#define __screenwrap_h
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/* ScreenWrap is a PyObject */
|
||||
typedef struct ScreenWrap {
|
||||
PyObject_HEAD
|
||||
} ScreenWrap;
|
||||
|
||||
void screenwrap_startup();
|
||||
void screenwrap_shutdown();
|
||||
|
||||
#endif
|
116
c/stacking.c
Normal file
116
c/stacking.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
#include "openbox.h"
|
||||
#include "prop.h"
|
||||
#include "focus.h"
|
||||
#include "client.h"
|
||||
#include "frame.h"
|
||||
#include <glib.h>
|
||||
|
||||
GList *stacking_list = NULL;
|
||||
|
||||
void stacking_set_list()
|
||||
{
|
||||
Window *windows, *win_it;
|
||||
GList *it;
|
||||
guint size = g_list_length(stacking_list);
|
||||
|
||||
/* create an array of the window ids (from bottom to top,
|
||||
reverse order!) */
|
||||
if (size > 0) {
|
||||
windows = g_new(Window, size);
|
||||
win_it = windows;
|
||||
for (it = g_list_last(stacking_list); it; it = it->prev, ++win_it)
|
||||
*win_it = ((Client*)it->data)->window;
|
||||
} else
|
||||
windows = NULL;
|
||||
|
||||
PROP_SET32A(ob_root, net_client_list_stacking, window, windows, size);
|
||||
|
||||
if (windows)
|
||||
g_free(windows);
|
||||
}
|
||||
|
||||
void stacking_raise(Client *client)
|
||||
{
|
||||
Window wins[2]; /* only ever restack 2 windows. */
|
||||
GList *it;
|
||||
Client *m;
|
||||
|
||||
g_assert(stacking_list != NULL); /* this would be bad */
|
||||
|
||||
m = client_find_modal_child(client);
|
||||
/* if we have a modal child, raise it instead, we'll go along tho later */
|
||||
if (m) stacking_raise(m);
|
||||
|
||||
/* remove the client before looking so we can't run into ourselves */
|
||||
stacking_list = g_list_remove(stacking_list, client);
|
||||
|
||||
/* the stacking list is from highest to lowest */
|
||||
it = stacking_list;
|
||||
while (it) {
|
||||
Client *c = it->data;
|
||||
if (client->layer >= c->layer && m != c)
|
||||
break;
|
||||
it = it->next;
|
||||
}
|
||||
|
||||
/*
|
||||
if our new position is the top, we want to stack under the focus_backup.
|
||||
otherwise, we want to stack under the previous window in the stack.
|
||||
*/
|
||||
if (it == stacking_list)
|
||||
wins[0] = focus_backup;
|
||||
else if (it != NULL)
|
||||
wins[0] = ((Client*)it->prev->data)->frame->window;
|
||||
else
|
||||
wins[0] = ((Client*)g_list_last(stacking_list)->data)->frame->window;
|
||||
wins[1] = client->frame->window;
|
||||
|
||||
stacking_list = g_list_insert_before(stacking_list, it, client);
|
||||
|
||||
XRestackWindows(ob_display, wins, 2);
|
||||
|
||||
stacking_set_list();
|
||||
}
|
||||
|
||||
void stacking_lower(Client *client)
|
||||
{
|
||||
Window wins[2]; /* only ever restack 2 windows. */
|
||||
GList *it;
|
||||
|
||||
g_assert(stacking_list != NULL); /* this would be bad */
|
||||
|
||||
it = g_list_last(stacking_list);
|
||||
|
||||
if (client->modal && client->transient_for) {
|
||||
/* don't let a modal window lower below its transient_for */
|
||||
it = g_list_find(stacking_list, client->transient_for);
|
||||
g_assert(it != NULL);
|
||||
|
||||
wins[0] = (it == stacking_list ? focus_backup :
|
||||
((Client*)it->prev->data)->frame->window);
|
||||
wins[1] = client->frame->window;
|
||||
if (wins[0] == wins[1]) return; /* already right above the window */
|
||||
|
||||
stacking_list = g_list_remove(stacking_list, client);
|
||||
stacking_list = g_list_insert_before(stacking_list, it, client);
|
||||
} else {
|
||||
while (it != stacking_list) {
|
||||
Client *c = it->data;
|
||||
if (client->layer >= c->layer)
|
||||
break;
|
||||
it = it->prev;
|
||||
}
|
||||
if (it->data == client) return; /* already the bottom, return */
|
||||
|
||||
wins[0] = ((Client*)it->data)->frame->window;
|
||||
wins[1] = client->frame->window;
|
||||
|
||||
stacking_list = g_list_remove(stacking_list, client);
|
||||
stacking_list = g_list_insert_before(stacking_list,
|
||||
it->next, client);
|
||||
}
|
||||
|
||||
XRestackWindows(ob_display, wins, 2);
|
||||
stacking_set_list();
|
||||
}
|
||||
|
26
c/stacking.h
Normal file
26
c/stacking.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef __stacking_h
|
||||
#define __stacking_h
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
extern GList *stacking_list;
|
||||
|
||||
/*! Sets the client stacking list on the root window from the
|
||||
stacking_clientlist */
|
||||
void stacking_set_list();
|
||||
|
||||
/*! Raises a client window above all others in its stacking layer
|
||||
raiseWindow has a couple of constraints that lowerWindow does not.<br>
|
||||
1) raiseWindow can be called after changing a Client's stack layer, and
|
||||
the list will be reorganized properly.<br>
|
||||
2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
|
||||
called for the specified client.
|
||||
*/
|
||||
void stacking_raise(struct Client *client);
|
||||
|
||||
/*! Lowers a client window below all others in its stacking layer */
|
||||
void stacking_lower(struct Client *client);
|
||||
|
||||
#endif
|
32
c/xerror.c
Normal file
32
c/xerror.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "openbox.h"
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
static gboolean xerror_ignore = FALSE;
|
||||
|
||||
int xerror_handler(Display *d, XErrorEvent *e)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (!xerror_ignore) {
|
||||
char errtxt[128];
|
||||
|
||||
/*if (e->error_code != BadWindow) */
|
||||
{
|
||||
XGetErrorText(d, e->error_code, errtxt, 127);
|
||||
if (e->error_code == BadWindow)
|
||||
g_warning("X Error: %s", errtxt);
|
||||
else
|
||||
g_error("X Error: %s", errtxt);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)d; (void)e;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xerror_set_ignore(gboolean ignore)
|
||||
{
|
||||
XSync(ob_display, FALSE);
|
||||
xerror_ignore = ignore;
|
||||
}
|
11
c/xerror.h
Normal file
11
c/xerror.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#ifndef __xerror_h
|
||||
#define __xerror_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
int xerror_handler(Display *, XErrorEvent *);
|
||||
|
||||
void xerror_set_ignore(gboolean ignore);
|
||||
|
||||
#endif
|
51
configure.ac
51
configure.ac
|
@ -1,7 +1,7 @@
|
|||
AC_PREREQ([2.50])
|
||||
AC_INIT([src/main.cc])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_LANG([C++])
|
||||
#AC_CONFIG_HEADERS(config.h)
|
||||
AC_LANG([C])
|
||||
AC_ENABLE_STATIC([no])
|
||||
AC_ENABLE_SHARED([yes])
|
||||
|
||||
|
@ -13,23 +13,27 @@ fi
|
|||
|
||||
AM_INIT_AUTOMAKE([openbox], [2.90.0cvs])
|
||||
|
||||
AC_PATH_PROG([awk_cmd], [awk]) # used by swig.m4
|
||||
test "$awk_cmd" || AC_MSG_ERROR([awk not found])
|
||||
##AC_PATH_PROG([awk_cmd], [awk]) # used by swig.m4
|
||||
##test "$awk_cmd" || AC_MSG_ERROR([awk not found])
|
||||
AC_PATH_PROG([regex_cmd], [sed])
|
||||
test "$regex_cmd" || AC_MSG_ERROR([sed not found])
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
# Determine build target
|
||||
OB_DEBUG
|
||||
# Pick compiler specific/build target flags
|
||||
# Pick compiler specific/build target flags, and set $CVS
|
||||
OB_COMPILER_FLAGS
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
SWIG_PROG(1.3.14)
|
||||
SWIG_ENABLE_CXX
|
||||
SWIG_MULTI_MODULE_SUPPORT
|
||||
SWIG_PYTHON
|
||||
PKG_CHECK_MODULES(GLIB, glib-2.0)
|
||||
AC_SUBST(GLIB_CFLAGS)
|
||||
AC_SUBST(GLIB_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(GMODULE, gmodule-2.0)
|
||||
AC_SUBST(GMODULE_CFLAGS)
|
||||
AC_SUBST(GMODULE_LIBS)
|
||||
|
||||
PYTHON_DEVEL
|
||||
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_LIBTOOL
|
||||
LIBTOOL="$LIBTOOL --silent"
|
||||
|
@ -39,12 +43,14 @@ ALL_LINGUAS=""
|
|||
AM_GNU_GETTEXT_VERSION(0.11.5)
|
||||
AM_GNU_GETTEXT([external])
|
||||
|
||||
AC_CHECK_HEADERS(fcntl.h signal.h stdarg.h stdint.h unistd.h sys/select.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/wait.h)
|
||||
AC_CHECK_HEADERS(ctype.h fcntl.h locale.h signal.h string.h stdlib.h unistd.h)
|
||||
AC_CHECK_HEADERS(sys/select.h sys/time.h sys/wait.h)
|
||||
# AC_HEADER_TIME
|
||||
# AC_TYPE_SIGNAL
|
||||
|
||||
# Check for Xft2
|
||||
XFT_DEVEL(2.0.0)
|
||||
PKG_CHECK_MODULES(XFT, xft)
|
||||
AC_SUBST(XFT_CFLAGS)
|
||||
AC_SUBST(XFT_LIBS)
|
||||
|
||||
# Check for X11 extensions
|
||||
X11_EXT_XKB
|
||||
|
@ -52,16 +58,18 @@ X11_EXT_SHAPE
|
|||
X11_EXT_XINERAMA
|
||||
|
||||
AC_CONFIG_FILES([Makefile po/Makefile.in
|
||||
otk/Makefile
|
||||
src/Makefile
|
||||
tools/Makefile
|
||||
wrap/Makefile
|
||||
scripts/Makefile
|
||||
c/Makefile
|
||||
kernel/Makefile
|
||||
render/Makefile
|
||||
engines/Makefile
|
||||
engines/openbox/Makefile
|
||||
python/Makefile
|
||||
doc/Makefile
|
||||
doc/doxygen/Makefile
|
||||
data/Makefile
|
||||
data/buttons/Makefile
|
||||
data/styles/Makefile
|
||||
themes/Makefile
|
||||
themes/openbox/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
|
@ -74,10 +82,5 @@ if test "$DEBUG" = "yes"; then
|
|||
else
|
||||
AC_MSG_RESULT([Creating a RELEASE build.])
|
||||
fi
|
||||
AC_MSG_RESULT([Using '$prefix' for installation.])
|
||||
AC_MSG_RESULT([Using '$CXX' for C++ compiler.])
|
||||
AC_MSG_RESULT([Building with '$CPPFLAGS' for C++ preprocessor flags.])
|
||||
AC_MSG_RESULT([Building with '$CXXFLAGS' for C++ compiler flags.])
|
||||
AC_MSG_RESULT([Building with '$LIBS' for linker flags.])
|
||||
AC_MSG_RESULT
|
||||
AC_MSG_RESULT([configure complete, now type \"make\"])
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#styledir = $(pkgdatadir)/styles
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
#style_DATA =
|
||||
#artwiz bbs bluebox cthulhain deep fieron fieron2 flux frobozz \
|
||||
#frobust mbdtex miklos nyz nyzclone ob20 operation outcomes paper \
|
||||
#purplehaaze shade steelblue steelblue2 the_orange trisb twice \
|
||||
#warp-xp
|
||||
#EXTRA_DIST = $(style_DATA)
|
||||
|
||||
distclean-local:
|
||||
$(RM) *\~ .\#*
|
||||
#uninstall-am:
|
||||
# -rmdir -p $(DESTDIR)$(styledir)
|
|
@ -1,9 +1,9 @@
|
|||
CLEANFILES = openbox.1
|
||||
#CLEANFILES = openbox.1
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
man_MANS = openbox.1
|
||||
#man_MANS = openbox.1
|
||||
SUBDIRS = doxygen
|
||||
|
||||
EXTRA_DIST = openbox.1.in
|
||||
#EXTRA_DIST = openbox.1.in
|
||||
|
||||
DEFAULT_MENU=$(pkgdatadir)/menu
|
||||
|
||||
|
|
142
doc/bsetbg.1
142
doc/bsetbg.1
|
@ -1,142 +0,0 @@
|
|||
.TH bsetbg 1 "February 2002" "bsetbg" "v2.0"
|
||||
.SH NAME
|
||||
bsetbg \- utility to manipulate the appearance of the X11 desktop's root window.
|
||||
.SH SYNOPSIS
|
||||
\fBbsetbg\fR [options] \fIimage\fR
|
||||
.SH DESCRIPTION
|
||||
\fBbsetbg\fR is intended to provide a standard method for the \fIBlackbox\fR
|
||||
window manager to alter the background of the root window
|
||||
(although it will work with any other window manager as well). \fBbsetbg\fR
|
||||
acts as a wrapper both to \fIbsetroot\fR
|
||||
and to a flexible variety of third-party applications that it uses when handling images files.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-full\fR \fIimage\fR
|
||||
\fIimage\fR is stretched to fill the entire desktop.
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-tile\fR \fIimage\fR
|
||||
\fIimage\fR is tiled on the desktop.
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-center\fR \fIimage\fR
|
||||
\fIimage\fR is centered on the desktop.
|
||||
.TP
|
||||
\fB\-e\fR, \fB\-exec\fR \fIprogram\fR \fIoptions\fR \fIfallback\-\fIarg\fR \fIimage\fR
|
||||
This option tells \fBbsetbg\fR to run a separate command by executing \fIprogram\fR with
|
||||
\fIoptions\fR, where \fIoptions\fR are arguments to \fIprogram\fR.
|
||||
|
||||
If a \fIfallback\-arg\fR is supplied (\fB\-full\fR, \fB\-tile\fR, or \fB\-center\fR
|
||||
as described above),
|
||||
\fBbsetbg\fR will assume that the last argument is a filename. In the case that
|
||||
\fIprogram\fR exits non-zero or isn't available on the target system, \fBbsetbg\fR
|
||||
will try to handle the file with the fallback argument.
|
||||
|
||||
See the \fBEXAMPLES\fR section for more information on \fB\-exec\fR.
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-post\fR \fIlist\fR
|
||||
Specifies a list of arguments to pass to the $POST_COMMAND.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-debug\fR
|
||||
Debugging mode. \fBbsetbg\fR will print commands without executing them.
|
||||
.TP
|
||||
\fB\-g\fR, \fB\-generate\fR \fIlist\fR
|
||||
Output a list of default configuration values, suitable for redirecting into
|
||||
\fI~/.bsetbgrc\fR. Any arguments that are supplied will be considered applications
|
||||
to search for in the system path, overriding \fBbsetbg\fR's internal defaults.
|
||||
.TP
|
||||
\fB\-app\fR \fIimageApp\fR
|
||||
Use this flag to specify which image application to use. This
|
||||
application may be one of the pre-defined list or any application
|
||||
capable of displaying an image on the root window. This flag may be
|
||||
used in conjunction with passing application specific parameters to
|
||||
the application, in which
|
||||
case they should be enclosed in double quotes.
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-version\fR
|
||||
Output version number.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-help\fR
|
||||
Output a brief usage message.
|
||||
|
||||
.SH OTHER OPTIONS
|
||||
\fBbsetbg\fR will also accept all of the arguments for \fIbsetroot\fR.
|
||||
Consult the \fIbsetroot\fR(1) man page for further information.
|
||||
|
||||
.SH CONFIGURATION
|
||||
\fBbsetbg\fR will read its configuration values from the file \fI~/.bsetbgrc\fR
|
||||
if it exists. Otherwise, it will scan the
|
||||
system path for a pre-defined list of image applications to use
|
||||
(currently this list consists of qiv, xli, xv, wmsetbg, Esetroot,
|
||||
display, and xsetbg).
|
||||
\fP
|
||||
\fI~/.bsetbgrc\fR should contain the following variables:
|
||||
.TP
|
||||
\fB CENTER=\fR\fI"string"\fR
|
||||
Application and arguments to be used to center an image on the root window
|
||||
when the \fB-center\fR argument is specified.
|
||||
|
||||
.TP
|
||||
\fB FULL=\fR\fI"string"\fR
|
||||
Application and arguments to be used to stretch an image to fill the root window
|
||||
when the \fB-full\fR argument is specified.
|
||||
|
||||
.TP
|
||||
\fB TILE=\fR\fI"string"\fR
|
||||
Application and arguments to be used to tile an image on the root window
|
||||
when the \fB-tile\fR argument is specified.
|
||||
|
||||
.TP
|
||||
\fB DEFAULT=\fR\fI"string"\fR
|
||||
Action to take place by default if none of the above have been specified.
|
||||
|
||||
.TP
|
||||
The following variables are optional:
|
||||
|
||||
.TP
|
||||
\fB NO_EXEC=\fR\fI"boolean"\fR
|
||||
If this variable is set, bsetbg will never modify the root window.
|
||||
|
||||
.TP
|
||||
\fB POST_COMMAND=\fR\fI"string"\fR
|
||||
This variable specifies a command that \fBbsetbg\fR will run after every
|
||||
successful modification of the root window.
|
||||
|
||||
.TP
|
||||
\fB LOG_LAST_CMD=\fR\fI"boolean"\fR
|
||||
If this variable is set, \fBbsetbg\fR will keep a logfile of the last two
|
||||
successful commands.
|
||||
|
||||
.TP
|
||||
\fB LOGFILE=\fR\fI"string"\fR
|
||||
This variable can specify the logfile to be used when $LOG_LAST_CMD is defined.
|
||||
The default is ~/.bsetbg_last_cmd .
|
||||
|
||||
.TP
|
||||
As mentioned above, \fBbsetbg\fR will function perfectly for the majority of users without having a configuration file. Power users who want more control over \fBbsetbg\fR's behavior should run \fBbsetbg -g\fR and use the output to create a \fI~/.bsetbgrc\fR which may then be tweaked by hand.
|
||||
|
||||
.SH EXAMPLES
|
||||
In this example, bsetbg will set the image in centered mode:
|
||||
|
||||
bsetbg -center foo.png
|
||||
|
||||
An example of the \fB-exec\fR argument:
|
||||
|
||||
bsetbg -exec xv -root -quit -rmode 5 -rbg rgb:2/2/2 \\
|
||||
-center foo.png
|
||||
|
||||
An example in which bsetbg creates a configuration file using xv and qiv:
|
||||
|
||||
bsetbg -g xv qiv > ~/.bsetbgrc
|
||||
|
||||
An example of the use of the \fB-app\fR argument:
|
||||
|
||||
bsetbg -app qiv "-o rgb:d6/c5/a2 -x" -c foo.png
|
||||
|
||||
.SH AUTHOR
|
||||
The author of
|
||||
.B bsetbg
|
||||
may be reached at \fItmk@lordzork.com\fR.
|
||||
|
||||
.SH SEE ALSO
|
||||
\fIblackbox\fR(1), \fIbsetroot\fR(1), \fIqiv\fR(1), \fIxli\fR(1), \fIxv\fR(1), \fIdisplay\fR(1),
|
||||
\fIwmsetbg\fR(1)
|
|
@ -1,89 +0,0 @@
|
|||
.\"
|
||||
.\" Man page for Bsetroot
|
||||
.\"
|
||||
.\" Copyright (c) 2000 by Wilbert Berendsen <wbsoft@xs4all.nl>
|
||||
.\"
|
||||
.TH bsetroot 1 "June 16th, 2000" "0.60.3"
|
||||
.SH NAME
|
||||
bsetroot \- Openbox utility to change root window appearance
|
||||
.SH SYNOPSIS
|
||||
.BR bsetroot " \-help"
|
||||
.br
|
||||
.B bsetroot
|
||||
.RI "[ \-display " display " ] \-solid " color
|
||||
.br
|
||||
.B bsetroot
|
||||
.RI "[ \-display " display " ] \-mod " "x y" " \-fg " color " \-bg " color
|
||||
.br
|
||||
.B bsetroot
|
||||
.RI "[ \-display " display " ] \-gradient " texture " \-from " color " \-to " color
|
||||
.SH DESCRIPTION
|
||||
Bsetroot is a utility that can control the appearance of the root window in
|
||||
three ways: Either give it a solid color, or write a two color modula pattern
|
||||
to it, or render a gradient texture, based on two different colors.
|
||||
.PP
|
||||
Bsetroot resembles
|
||||
.IR xsetroot (1)
|
||||
in this functionality but it supports multiple screen displays, and gradient
|
||||
textures the same way as Openbox does.
|
||||
It doesn't handle cursors etc.
|
||||
Bsetroot is part of the Openbox package.
|
||||
.SH OPTIONS
|
||||
Bsetroot operates in three ways, you must choose one of the first 3 options:
|
||||
.TP
|
||||
.BI \-solid " color"
|
||||
Sets the root window to specified color.
|
||||
.TP
|
||||
.BI \-mod " x y"
|
||||
Creates a modula pattern. You must specify
|
||||
.BR \-bg " and " \-fg
|
||||
colors.
|
||||
.TP
|
||||
.BI \-gradient " texturestring"
|
||||
Renders the specified texture string to the root window.
|
||||
For possible texture strings, please refer to
|
||||
.IR openbox (1).
|
||||
You must also specify both a
|
||||
.BR \-from " and a " \-to
|
||||
color.
|
||||
.TP
|
||||
.BI \-display " display"
|
||||
Tells Bsetroot to connect to the specified display.
|
||||
.TP
|
||||
.BI "\-bg, \-background " color
|
||||
Background color.
|
||||
Needed for
|
||||
.B \-mod
|
||||
patterns.
|
||||
.TP
|
||||
.BI "\-fg, \-foreground " color
|
||||
Foreground color.
|
||||
Needed for
|
||||
.B \-mod
|
||||
patterns.
|
||||
.TP
|
||||
.BI \-from " color"
|
||||
Start color for rendering textures.
|
||||
Needed for
|
||||
.B \-gradient
|
||||
operation mode.
|
||||
.TP
|
||||
.BI \-to " color"
|
||||
Ending color for rendering textures.
|
||||
Needed for
|
||||
.B \-gradient
|
||||
operation mode.
|
||||
.TP
|
||||
.B \-help
|
||||
Prints version info and short help text.
|
||||
.SH AUTHOR
|
||||
Bsetroot was written and maintained by Brad Hughes
|
||||
.nh \" hyphenation off
|
||||
(blackbox@alug.org)
|
||||
.hy \" on again
|
||||
and Jeff Raven
|
||||
.nh
|
||||
(jraven@psu.edu).
|
||||
.hy
|
||||
.SH SEE ALSO
|
||||
.IR openbox (1)
|
859
doc/openbox.1.in
859
doc/openbox.1.in
|
@ -1,859 +0,0 @@
|
|||
.\"
|
||||
.\" Man page for Openbox
|
||||
.\"
|
||||
.\" Copyright (c) 2000 by Wilbert Berendsen <wbsoft@xs4all.nl>
|
||||
.\"
|
||||
.\" This manual page may be freely distributed and modified.
|
||||
.\" Parts of the text are taken from website and several README's
|
||||
.\" by His Great Hughesness himself. Why reinvent wheels?
|
||||
.\"
|
||||
.\" Created with NEdit, tested with ``man'' and ``tkman.''
|
||||
.\" This manpage uses only standard groff and tmac.an macros.
|
||||
.\" To all translators who didn't do manpages earlier (like me ;-):
|
||||
.\" Read the Man-Page-Mini-HOWTO and the LDP manpage ``man 7 man''
|
||||
.\" There's all I needed to know about these macros.
|
||||
.\"
|
||||
.\" Updated for bb 0.61 at Sat Sep 9 06:56:04 CEST 2000
|
||||
.\"
|
||||
.\" ..define sort of <blockquote><pre> macro
|
||||
.de EX
|
||||
.ne 5
|
||||
.if n .sp 1
|
||||
.if t .sp .5
|
||||
.nf
|
||||
.in +.5i
|
||||
..
|
||||
.de EE
|
||||
.fi
|
||||
.in -.5i
|
||||
.if n .sp 1
|
||||
.if t .sp .5
|
||||
..
|
||||
.TH openbox 1 "April 8th, 2002" "@VERSION@"
|
||||
.SH NAME
|
||||
openbox \- a window manager for X11
|
||||
.SH SYNOPSIS
|
||||
.BR openbox " \-help | \-version"
|
||||
.br
|
||||
.B openbox
|
||||
.RI "[ \-rc" " rcfile " "] [ \-display" " display " ]
|
||||
.SH DESCRIPTION
|
||||
.\"
|
||||
.\" First few Paragraphs taken from FILLMEINNOW
|
||||
.\"
|
||||
.\"Openbox is yet another addition to the list of window managers for the Open
|
||||
.\"Group's X Window System, Version 11 Release 6 and above.
|
||||
.\"Openbox is built with C++, sharing no common code with any other window
|
||||
.\"manager (even though the graphics implementation is similar to that of Window
|
||||
.\"Maker).
|
||||
.\".PP
|
||||
.\"From the time the first line of code was written, Openbox has evolved around
|
||||
.\"one premise, minimalism.
|
||||
.\"It's not meant to be Eye Candy, nor the most Featureful, nor the most Adorned
|
||||
.\"for modelling the Widely acclaimed NeXT interface.
|
||||
.\"It is just meant to be
|
||||
.\".BR fast .
|
||||
.\".PP
|
||||
.\"Openbox provides configurable window decorations, a root menu to launch
|
||||
.\"applications, and a toolbar that shows the current workspace name, the focused
|
||||
.\"application name, and the current time.
|
||||
.\"There is also a workspace menu to add or remove workspaces. The `slit' can be
|
||||
.\"used to dock small applications, e.g. most of the bbtools can use the slit.
|
||||
.\".PP
|
||||
.\"Openbox features a special kind of icon handling: When you minimize a window,
|
||||
.\"no icon appears; instead, you can view all minimized applications in the `Icons'
|
||||
.\"submenu of the workspace menu.
|
||||
.\"Your desktop will never get cluttered with icons. As an alternative to icons,
|
||||
.\"shaded windows are provided: A double click on the titlebar of a window will
|
||||
.\"shade it (i.e. the window will disappear; only the titlebar stays visible).
|
||||
.\".PP
|
||||
.\"Openbox uses its own graphics class to render its images on the fly.
|
||||
.\"By using style files, you can determine at a great level how your desktop looks.
|
||||
.\"Openbox currently uses the Blackbox protocol to communicate with other clients
|
||||
.\"such as the pager. Work is underway to support the new window manager
|
||||
.\"specification that both GNOME and KDE use.
|
||||
.SH OPTIONS
|
||||
Openbox supports the following command line options:
|
||||
.TP
|
||||
.B \-help
|
||||
Display command line options and compiled-in features, then exit.
|
||||
.TP
|
||||
.B \-version
|
||||
Display version info and exit.
|
||||
.TP
|
||||
.BI \-rc \ rcfile
|
||||
Use another rcfile than the default
|
||||
.IR "~/.openbox/rc" .
|
||||
.TP
|
||||
.BI \-display \ display
|
||||
Start Openbox on the specified display.
|
||||
Programs started by Openbox will have the
|
||||
.B DISPLAY
|
||||
environment variable set to this value, too.
|
||||
.SH RUNNING OPENBOX
|
||||
This program is usually started by the user's startup script, most times called
|
||||
.IR ~/.xinitrc .
|
||||
To run openbox, modify the script by adding
|
||||
.EX 0
|
||||
exec openbox
|
||||
.EE
|
||||
as the last executed command of the script.
|
||||
When Openbox terminates, the X session will terminate too.
|
||||
.PP
|
||||
When started, Openbox will try to find a default menu file in
|
||||
.IR @defaultmenu@ .
|
||||
You can provide a system-wide menu for your users here.
|
||||
.PP
|
||||
On exit or restart, Openbox will save user defaults in the file
|
||||
.I ~/.openbox/rc
|
||||
in the user's home directory.
|
||||
Some resources in this file can be edited by hand.
|
||||
.SH USING OPENBOX
|
||||
Openbox does no keyboard handling by itself; instead, it relies on an external
|
||||
program
|
||||
.IR epist (1)
|
||||
or
|
||||
.IR bbkeys (1)
|
||||
for this.
|
||||
So, in this section, we will discuss all mouse commands.
|
||||
.SS Root window (background):
|
||||
A right click (button 3) will pop up the root menu.
|
||||
With this, you can launch your applications.
|
||||
You can also customize this menu for your needs. See above for its location.
|
||||
A middle click (button 2) will pop up the workspace menu.
|
||||
You can add or remove a workspace, view
|
||||
applications running on all workspace, inspect your iconified applications,
|
||||
and jump directly to any workspace or application.
|
||||
.PP
|
||||
Left clicking (button 1) on an application in the Workspaces menu will bring
|
||||
you to that workspace and raise/focus that application;
|
||||
middle clicking (button 2) will warp the application to the current workspace.
|
||||
.SS Toolbar:
|
||||
The toolbar consists of three fields: a workspace name, the name of the
|
||||
window that currently has focus, and a clock.
|
||||
A left click on the toolbar will bring it to the foreground, a
|
||||
middle click will hide it behind other windows (if AlwaysOnTop is not set), and
|
||||
the right button will bring up a little menu.
|
||||
.PP
|
||||
Using this menu, you can enter a name for the current workspace (when finished,
|
||||
press Enter).
|
||||
Also, you can choose the toolbar's position, whether or not it
|
||||
should be always on top (i.e. it cannot be obscured by other windows),
|
||||
and whether it should hide itself when the mouse moves away.
|
||||
.PP
|
||||
Note: In Openbox versions below 0.60.0, a right click on the toolbar
|
||||
immediately entered workspace name edit mode.
|
||||
.SS Window Titlebar and Borders:
|
||||
A left click on any part of the window's border will raise it.
|
||||
Dragging then moves the window.
|
||||
Dragging the resize grips at the bottom left and bottom right
|
||||
corners resizes the window.
|
||||
Middle clicking will immediately lower the window.
|
||||
Right clicking on the border or titlebar pops up the window menu,
|
||||
containing these commands:
|
||||
.TP
|
||||
.B Send To...
|
||||
Send window to another workspace.
|
||||
When you select the workspace with the middle button, Openbox will
|
||||
send you, along with the application, to the selected workspace.
|
||||
.TP
|
||||
.B Shade
|
||||
Shade window (display titlebar only).
|
||||
.TP
|
||||
.B Iconify
|
||||
Iconify window.
|
||||
The `icon' can be found in the `Icons' submenu of the workspace menu. It will
|
||||
*NOT* appear on screen otherwise.
|
||||
.TP
|
||||
.B Maximize
|
||||
(Un)Maximize window.
|
||||
When you click the middle button on this item, the
|
||||
window will maximize only vertically.
|
||||
.TP
|
||||
.B Raise
|
||||
Raise window.
|
||||
.TP
|
||||
.B Lower
|
||||
Lower window.
|
||||
.TP
|
||||
.B Stick
|
||||
(Un)Stick window.
|
||||
A stuck window will always be displayed in the current workspace.
|
||||
.TP
|
||||
.B Kill Client
|
||||
Kill (-SIGKILL) owner of window. Only use this if the client refuses to close.
|
||||
.TP
|
||||
.B Close
|
||||
Close the application cleanly.
|
||||
.PP
|
||||
When you double click on the titlebar of a window, it will `shade', so
|
||||
that only the titlebar stays visible.
|
||||
Another double click will redisplay the window contents.
|
||||
.SS Window Buttons:
|
||||
The button at the left upper corner of a window is the Minimize button.
|
||||
Clicking with any button causes the window to be iconified.
|
||||
The rightmost button (with the X) closes the application.
|
||||
The other button on the right (if present) maximizes the window in three ways:
|
||||
Button 1 causes full screen maximization, button 2 maximizes the window only
|
||||
vertically, and button 3 only horizontally.
|
||||
.SS Any menu:
|
||||
Clicking button 3 in a menu will popdown the menu.
|
||||
Clicking button 1 on the titlebar of any (sub)menu and then dragging it somewhere
|
||||
else will cause the menu to stay visible, and not disappear when you click on
|
||||
a menu item.
|
||||
.SS Miscellaneous:
|
||||
When you want to drag a window, but cannot see either the bottom handle or its
|
||||
titlebar, you can press Alt + button 1 anywhere in the window and then
|
||||
drag it around.
|
||||
You can also use Alt + button 1 to raise a partially visible window.
|
||||
Finally, Alt + button 2 lowers a window, and Alt + button 3 resizes the window.
|
||||
.SH MENU FILE
|
||||
A default menu file is installed in
|
||||
.IR @defaultmenu@ .
|
||||
Of course, this system-wide menu can be customized for all users at once.
|
||||
But it is also possible to create a personal menu.
|
||||
It is a convention to use the directory
|
||||
.IR "~/.openbox/"
|
||||
in your home directory, and to create a menu file, e.g.
|
||||
.I menu
|
||||
in this directory, or copy the system-wide menu file to this location.
|
||||
Next, we have to tell Openbox to load our menu file instead of the default.
|
||||
This is accomplished by adding (or changing) a resource value in the
|
||||
.I ~/.openbox/rc
|
||||
file, e.g.:
|
||||
.EX
|
||||
session.menuFile: ~/.openbox/menu
|
||||
.EE
|
||||
For this change to take effect, Openbox has to be restarted.
|
||||
Be sure that your menu is usable, then choose `Restart' from the default
|
||||
Openbox root menu.
|
||||
.SS Menu syntax
|
||||
The menu syntax is very simple and very effective.
|
||||
There are up to three fields in a menu line.
|
||||
They are of the form:
|
||||
.EX
|
||||
[tag] (label or filename) {command or filename}
|
||||
.EE
|
||||
The supported tags are as follows:
|
||||
.TP
|
||||
.B [begin] (label for root menu)
|
||||
This tells Openbox to start parsing the menu file.
|
||||
This tag is required for Openbox to parse your menu file.
|
||||
If it cannot find it, the system default menu is used instead.
|
||||
.TP
|
||||
.B [end]
|
||||
This tells Openbox that it is at the end of a menu.
|
||||
This can either be a submenu or the main root menu.
|
||||
There must be at least one of these tags in your menu to correspond to the
|
||||
required [begin] tag.
|
||||
.TP
|
||||
.B [exec] (label for command) {shell command}
|
||||
Inserts a command item into the menu.
|
||||
When you select the menu item from the menu, Openbox runs `shell command.'
|
||||
.TP
|
||||
.B [exit] (label for exit)
|
||||
Inserts an item that shuts down and exits Openbox.
|
||||
Any running programs are not closed.
|
||||
.TP
|
||||
.B [include] (filename)
|
||||
Parses the file specified by
|
||||
.I filename
|
||||
and includes it with the current menu. The filename can be the full path to a
|
||||
file, or it can begin with
|
||||
.IR ~/ ,
|
||||
which will be expanded into your home directory (e.g.
|
||||
.EX
|
||||
[include] (~/.openbox/stylesmenu)
|
||||
.EE
|
||||
will include
|
||||
.I /home/bhughes/.openbox/stylesmenu
|
||||
in my menu).
|
||||
.TP
|
||||
.B [nop] (label - optional)
|
||||
Insert a non-operational item into the current menu.
|
||||
This can be used to help format the menu into blocks or sections
|
||||
if so desired.
|
||||
.B [nop]
|
||||
does accept a label, but it is not required, and a blank item will be used
|
||||
if none is supplied.
|
||||
.TP
|
||||
.B [style] (label) {filename}
|
||||
This tells Openbox to insert an item that, when selected, reads the style file
|
||||
named
|
||||
.I filename
|
||||
and applies the new textures, colors, and fonts to the current
|
||||
running session.
|
||||
.TP
|
||||
.B [stylesdir] (directory name)
|
||||
Reads all filenames (directories are ignored) from the specified directory and
|
||||
creates menu items in the current menu for every filename. Openbox assumes
|
||||
that each file is a valid style file. When selected by the user, Openbox
|
||||
applies the selected style file to the current session.
|
||||
The labels that are created in the menu are the filenames of the style files.
|
||||
.TP
|
||||
.B [stylesmenu] (label) {directory name}
|
||||
Creates a submenu entry with
|
||||
.I label
|
||||
(that is also the title of the new submenu), and inserts in that submenu all
|
||||
filenames in the specified directory, in the same way as the
|
||||
.B [stylesdir]
|
||||
command does.
|
||||
.IP
|
||||
.RB Both\ [stylesdir] \ and\ [stylesmenu]
|
||||
commands make it possible to install style files without editing your menu file.
|
||||
.TP
|
||||
.B [submenu] (label) {title for menu - optional}
|
||||
This tells Openbox to create and parse a new menu.
|
||||
This menu is inserted as a submenu into the parent menu.
|
||||
These menus are parsed recursively, so there is no limit to the number of levels
|
||||
or nested submenus you can have.
|
||||
The title for the new menu is optional; if none is supplied,
|
||||
the new menu's title is the same as the item label.
|
||||
An
|
||||
.B [end]
|
||||
tag is required to end the submenu.
|
||||
.TP
|
||||
.B [reconfig] (label)
|
||||
When selected, this item rereads the current style, menu files and rc file,
|
||||
and applies any changes.
|
||||
This is useful for creating a new style or theme, as you don't have to
|
||||
constantly restart Openbox every time you save your style.
|
||||
However, Openbox automagically rereads the menu whenever it changes.
|
||||
.TP
|
||||
.B [restart] (label) {shell command - optional}
|
||||
This tells Openbox to restart.
|
||||
If `shell command' is supplied, it shuts down and runs the command (which is
|
||||
commonly the name of another window manager).
|
||||
If the command is omitted, Openbox restarts itself.
|
||||
.TP
|
||||
.B [config] (label)
|
||||
Inserts a Openbox generated submenu item containing numerous configuration
|
||||
options concerning window placement, focus style, window moving style, etc.
|
||||
.TP
|
||||
.B [workspaces] (label)
|
||||
This tells Openbox to insert a link to the workspaces menu directly
|
||||
into your menu.
|
||||
This is handy for those users who can't access the
|
||||
workspace menu directly (e.g. if you don't have a 3 button mouse).
|
||||
.PP
|
||||
Any line that starts with a `#' is considered a comment and ignored by Openbox.
|
||||
Also, in the labels/commands/filenames fields,
|
||||
you can escape any character like so:
|
||||
.EX
|
||||
[exec] (\\(my cool\\) \\{XTERM\\}) {xterm -T \\"cool XTERM\\"}
|
||||
.EE
|
||||
Using `\\\\' inserts a literal back-slash into the label/command/filename field.
|
||||
.SS Menu example
|
||||
Now let's put together some things.
|
||||
Here is a short example of a menu file:
|
||||
.PP
|
||||
.nf
|
||||
# Openbox menu file
|
||||
[begin] (Openbox @version@)
|
||||
[exec] (rxvt) {rxvt -ls}
|
||||
[exec] (Mozilla) {mozilla}
|
||||
[exec] (The GIMP) {gimp}
|
||||
[submenu] (Window Manager)
|
||||
[exec] (Edit Menus) {nedit .openbox/Menu}
|
||||
[submenu] (Style) {Which Style?}
|
||||
[stylesdir] (~/.openbox/styles)
|
||||
[stylesmenu] (Openbox Styles) {@pkgdatadir@/styles}
|
||||
[end]
|
||||
[config] (Config Options)
|
||||
[reconfig] (Reconfigure)
|
||||
[restart] (Restart)
|
||||
[end]
|
||||
[exit] (Log Out)
|
||||
[end]
|
||||
# end of menu file
|
||||
.fi
|
||||
.SH STYLES
|
||||
Openbox enables you to use specialized files that contain
|
||||
.IR X (1)
|
||||
resources to specify colors, textures, and fonts and therefore
|
||||
the overall look of your window borders, menus, and the toolbar.
|
||||
.PP
|
||||
The default installation of Openbox provides some of these style files.
|
||||
Usually they are put in
|
||||
.IR @pkgdatadir@/styles .
|
||||
You can study or edit these files to grasp how the Openbox style mechanism
|
||||
works.
|
||||
You can use the
|
||||
.BR [style] ", " [stylesdir] " and " [stylesmenu]
|
||||
menu commands in your menu file to be able to select and change between styles
|
||||
on the fly.
|
||||
.PP
|
||||
You can also create a directory in your home directory (usually named
|
||||
.I ~/.openbox/styles)
|
||||
and put your own style files there.
|
||||
Of course, you may choose any name for this directory, but many downloadable
|
||||
themes will rely on the name
|
||||
.I styles
|
||||
(following the bb.themes.org naming scheme).
|
||||
.PP
|
||||
To understand how the style mechanism works, you should have a little knowledge
|
||||
of how X resources work.
|
||||
.PP
|
||||
X resources consist of a key and a value.
|
||||
The key is constructed of several smaller keys (sometimes referred to as
|
||||
children), delimited by a period (`.').
|
||||
Keys may also contain a star (`*') to serve as a wildcard, which means that one
|
||||
line of typed text will match several keys.
|
||||
This is useful for styles that are based on one or two colors.
|
||||
.PP
|
||||
Openbox allows you to configure its four main components: the toolbar, the
|
||||
slit, the menus, and the window decorations.
|
||||
.PP
|
||||
The little window that shows the x-y position while dragging windows borrows
|
||||
its style from the window's titlebar.
|
||||
.PP
|
||||
Here are some quick examples:
|
||||
.EX
|
||||
toolbar.clock.color: green
|
||||
.EE
|
||||
This sets the color resource of the toolbar clock to `green'. Another example:
|
||||
.EX
|
||||
menu*color: rgb:3/4/5
|
||||
.EE
|
||||
This sets the color resource of the menu
|
||||
.I and all of its `children'
|
||||
to `rgb:3/4/5'.
|
||||
(For a description of color names, see
|
||||
.IR X (1).)
|
||||
So this one also applies to
|
||||
.IR menu.title.color " and " menu.frame.color .
|
||||
And with
|
||||
.EX
|
||||
*font: -b&h-lucida-medium-r-normal-*-*-140-*
|
||||
.EE
|
||||
you set the font resource for all keys to this font name all at once.
|
||||
(For information about the fonts installed on your system, you can use a program like
|
||||
.IR xfontsel "(1), " gtkfontsel ", or " xlsfonts "(1).)"
|
||||
.PP
|
||||
Now what makes Openbox just so spectacular is its ability to render textures
|
||||
on the fly.
|
||||
Texture descriptions are specified in a similar way to the colors shown above
|
||||
e.g.:
|
||||
.ta \w'toolbar.clock.colorTo:\ 'u
|
||||
.EX
|
||||
toolbar.clock: Raised Gradient Diagonal Bevel1
|
||||
toolbar.clock.color: rgb:8/6/4
|
||||
toolbar.clock.colorTo: rgb:4/3/2
|
||||
.EE
|
||||
Don't worry; we will explain right now!
|
||||
A texture description consists of up to five fields, which are as follows:
|
||||
.TP
|
||||
.B Flat / Raised / Sunken
|
||||
gives the component either a flat, raised, or sunken appearance.
|
||||
.TP
|
||||
.B Gradient / Solid
|
||||
tells Openbox to draw either a solid color or a texture with gradient.
|
||||
.TP
|
||||
.B Horizontal / Vertical / Diagonal / Crossdiagonal / Pipecross / Elliptic / Rectangle / Pyramid
|
||||
Select one of these texture types. They only work when
|
||||
.B Gradient
|
||||
is also specified!
|
||||
.TP
|
||||
.B Interlaced
|
||||
tells Openbox to interlace the texture (darken every other line).
|
||||
This option is most commonly used with gradiented textures, but, from Openbox
|
||||
version 0.60.3 on, it also works in solid textures.
|
||||
.TP
|
||||
.B Bevel1 / Bevel2
|
||||
tells Openbox which type of bevel to use.
|
||||
Bevel1 is the default bevel.
|
||||
The shading is placed on the edge of the image.
|
||||
Bevel2 is an alternative.
|
||||
The shading is placed one pixel in from the edge of the image.
|
||||
.PP
|
||||
Instead of a texture description, the option
|
||||
.B ParentRelative
|
||||
is also available, which makes the component appear as a part of its parent, i.e.
|
||||
totally transparent.
|
||||
.PP
|
||||
All gradient textures are composed of two color values: the
|
||||
.IR color " and " colorTo " resources."
|
||||
color represents the initial color, colorTo represents the final color of the
|
||||
gradient.
|
||||
When
|
||||
.B Interlaced
|
||||
is used in
|
||||
.B Solid
|
||||
mode, the
|
||||
.I colorTo
|
||||
resource is used to specify the interlacing color.
|
||||
.PP
|
||||
Well, here is the complete component list; also, all components together with
|
||||
which kind of value they can contain.
|
||||
Comments are preceded with an exclamation sign (!), which is also used for
|
||||
comments in Openbox style c.q. X resource files.
|
||||
.PP
|
||||
.ta \w'window.button.unfocus.picColor: \ 'u
|
||||
.nf
|
||||
.\"
|
||||
.\" The comments also to be translated!
|
||||
.\"
|
||||
! The toolbar itself.
|
||||
toolbar: Texture
|
||||
toolbar.color: Color
|
||||
toolbar.colorTo: Color
|
||||
|
||||
! The buttons on the toolbar.
|
||||
toolbar.button: Texture or \fIParentRelative\fR
|
||||
toolbar.button.color: Color
|
||||
toolbar.button.colorTo: Color
|
||||
|
||||
! Color of the button arrows.
|
||||
toolbar.button.picColor: Color
|
||||
|
||||
! Buttons in pressed state.
|
||||
toolbar.button.pressed: Texture \fI(e.g. Sunken)\fR or \fIParentRelative\fR
|
||||
toolbar.button.pressed.color: Color
|
||||
toolbar.button.pressed.colorTo: Color
|
||||
|
||||
! Color of pressed button arrows.
|
||||
toolbar.button.pressed.picColor: Color
|
||||
|
||||
! The toolbar workspace label.
|
||||
toolbar.label: Texture or \fIParentRelative\fR
|
||||
toolbar.label.color: Color
|
||||
toolbar.label.colorTo: Color
|
||||
toolbar.label.textColor: Color
|
||||
|
||||
! The toolbar window label.
|
||||
toolbar.windowLabel: Texture or \fIParentRelative\fR
|
||||
toolbar.windowLabel.color: Color
|
||||
toolbar.windowLabel.colorTo: Color
|
||||
toolbar.windowLabel.textColor: Color
|
||||
|
||||
! The toolbar clock.
|
||||
toolbar.clock: Texture or \fIParentRelative\fR
|
||||
toolbar.clock.color: Color
|
||||
toolbar.clock.colorTo: Color
|
||||
toolbar.clock.textColor: Color
|
||||
|
||||
! How the toolbar's text should be justified.
|
||||
toolbar.justify: \fIcenter\fR, \fIleft\fR, or \fIright\fR
|
||||
|
||||
.ta \w'toolbar.font:\ 'u
|
||||
! Font to be used for all toolbar components.
|
||||
toolbar.font: Font \fI(e.g. -*-helvetica-medium-r-normal-*-*-100-*)\fR
|
||||
|
||||
.ta \w'window.button.unfocus.picColor: \ 'u
|
||||
! The menu titlebar.
|
||||
menu.title: Texture
|
||||
menu.title.color: Color
|
||||
menu.title.colorTo: Color
|
||||
menu.title.textColor: Color
|
||||
menu.title.font: Font
|
||||
menu.title.justify: \fIcenter\fR, \fIleft\fR, or \fIright\fR
|
||||
|
||||
! The menu frame.
|
||||
menu.frame: Texture
|
||||
menu.frame.color: Color
|
||||
menu.frame.colorTo: Color
|
||||
menu.frame.textColor: Color
|
||||
menu.frame.disableColor: Color
|
||||
menu.frame.font: Font
|
||||
menu.frame.justify: \fIcenter\fR, \fIleft\fR, or \fIright\fR
|
||||
|
||||
! Bullets for submenu items.
|
||||
menu.bullet: \fIempty\fR, \fItriangle\fR, \fIsquare\fR, or \fIdiamond\fR
|
||||
menu.bullet.position: \fIright\fR or \fIleft\fR
|
||||
|
||||
! The highlighted menu item.
|
||||
menu.hilite: Texture (e.g. \fIRaised\fR)
|
||||
menu.hilite.color: Color
|
||||
menu.hilite.colorTo: Color
|
||||
menu.hilite.textColor: Color
|
||||
|
||||
! A focused window.
|
||||
window.title.focus: Texture
|
||||
window.title.focus.color: Color
|
||||
window.title.focus.colorTo: Color
|
||||
|
||||
! An unfocused window.
|
||||
window.title.unfocus: Texture
|
||||
window.title.unfocus.color: Color
|
||||
window.title.unfocus.colorTo: Color
|
||||
|
||||
! Window label.
|
||||
window.label.focus: Texture or \fIParentRelative\fR
|
||||
window.label.focus.color: Color
|
||||
window.label.focus.colorTo: Color
|
||||
window.label.focus.textColor: Color
|
||||
|
||||
window.label.unfocus: Texture or \fIParentRelative\fR
|
||||
window.label.unfocus.color: Color
|
||||
window.label.unfocus.colorTo: Color
|
||||
window.label.unfocus.textColor: Color
|
||||
|
||||
! Handlebar.
|
||||
window.handle.focus: Texture
|
||||
window.handle.focus.color: Color
|
||||
window.handle.focus.colorTo: Color
|
||||
|
||||
window.handle.unfocus: Texture
|
||||
window.handle.unfocus.color: Color
|
||||
window.handle.unfocus.colorTo: Color
|
||||
|
||||
! Resize grips.
|
||||
window.grip.focus: Texture
|
||||
window.grip.focus.color: Color
|
||||
window.grip.focus.colorTo: Color
|
||||
|
||||
window.grip.unfocus: Texture
|
||||
window.grip.unfocus.color: Color
|
||||
window.grip.unfocus.colorTo: Color
|
||||
|
||||
! Window buttons.
|
||||
window.button.focus: Texture or \fIParentRelative\fR
|
||||
window.button.focus.color: Color
|
||||
window.button.focus.colorTo: Color
|
||||
window.button.focus.picColor: Color
|
||||
|
||||
window.button.unfocus: Texture or \fIParentRelative\fR
|
||||
window.button.unfocus.color: Color
|
||||
window.button.unfocus.colorTo: Color
|
||||
window.button.unfocus.picColor: Color
|
||||
|
||||
window.button.pressed: Texture (e.g. \fISunken\fR)
|
||||
window.button.pressed.color: Color
|
||||
window.button.pressed.colorTo: Color
|
||||
|
||||
.ta \w'window.button.pressed.unfocus.colorTo:\ 'u
|
||||
! If either the focused, or unfocused pressed button isn't
|
||||
! defined, it will use the normal pressed: resource
|
||||
window.button.pressed.focus: Texture (eg. \fISunken\fR)
|
||||
window.button.pressed.focus.color: Color
|
||||
window.button.pressed.focus.colorTo: Color
|
||||
window.button.pressed.unfocus: Texture (eg. \fISunken\fR)
|
||||
window.button.pressed.unfocus.color: Color
|
||||
window.button.pressed.unfocus.colorTo: Color
|
||||
|
||||
.ta \w'window.button.unfocus.picColor:\ 'u
|
||||
! Frame around window.
|
||||
window.frame.focusColor: Color
|
||||
window.frame.unfocusColor: Color
|
||||
|
||||
! Font and justification for window labels.
|
||||
window.font: Font
|
||||
window.justify: \fIcenter\fR, \fIleft\fR, or \fIright\fR
|
||||
|
||||
! Miscellaneous resources.
|
||||
|
||||
! A border can be drawn around all components.
|
||||
borderWidth: a number of pixels, e.g. \fI1\fR
|
||||
borderColor: Color
|
||||
|
||||
bevelWidth: a number of pixels > 0
|
||||
handleWidth: a number of pixels > 0
|
||||
|
||||
! Width of the window frame (from version 0.61 on).
|
||||
! When not specified, frameWidth defaults to the value of bevelWidth.
|
||||
frameWidth: a number of pixels >= 0
|
||||
|
||||
! This command is executed whenever this style is selected.
|
||||
! Typically it sets the root window to a nice picture.
|
||||
rootCommand: Shell command, e.g. \fIbsetroot -mod 4 4 -fg rgb: 5/6/6 -bg grey20\fR
|
||||
|
||||
! Some of the bbtools read these old 0.51 resources.
|
||||
menuFont: Font
|
||||
titleFont: Font
|
||||
.fi
|
||||
.PP
|
||||
Now, this seems a long list, but, remember, when you create your own style, you
|
||||
can easily set lots of keys with a single command, e.g.
|
||||
.EX
|
||||
.ta \w'*unfocus.textColor:\ 'u
|
||||
*color: slategrey
|
||||
*colorTo: darkslategrey
|
||||
*unfocus.color: darkslategrey
|
||||
*unfocus.colorTo: black
|
||||
*textColor: white
|
||||
*unfocus.textColor: lightgrey
|
||||
*font: lucidasans-10
|
||||
.EE
|
||||
This sets already nice defaults for many components.
|
||||
.PP
|
||||
Openbox also lets you pick what the small graphics in the buttons and in the manu look like. It uses the X Bitmap file format (.xbm extension). The style resources are as follows:
|
||||
.EX
|
||||
! Close, maximize, sticky and iconify
|
||||
! buttons on a window.
|
||||
window.button.close.mask: xbm file
|
||||
window.button.max.mask: xbm file
|
||||
window.button.stick.mask: xbm file
|
||||
window.button.icon.mask: xbm file
|
||||
|
||||
! The icon for submenus in a menu.
|
||||
menu.arrow.mask: xbm file
|
||||
|
||||
! The icon for a selected option or workspace
|
||||
! in the menus.
|
||||
menu.selected.mask: xbm file
|
||||
|
||||
! The left and right buttons in the toolbar
|
||||
toolbar.button.left.mask: xbm file
|
||||
toolbar.button.right.mask: xbm file
|
||||
.EE
|
||||
If the xbm file value is the path to a .xbm image. If the value is absolute, it uses that file. If the file is just a file name, e.g. `close.xbm', it uses ~/.openbox/buttons/close.xbm.
|
||||
.SH THE SLIT
|
||||
The slit is a special Openbox window frame that can contain dockable
|
||||
applications, e.g. the `bbtools' or WindowMaker's dockapps.
|
||||
When applications are run in the slit, they have no window borders of their own;
|
||||
instead, they are framed in the slit, and they are always visible in the current
|
||||
workspace.
|
||||
You can click button 3 on the edge of the slit window to get a menu to
|
||||
determine its position, whether its contained applications should be grouped
|
||||
horizontally or vertically and whether it should hide itself when the
|
||||
mouse moves away.
|
||||
.PP
|
||||
Most dockable applications use the
|
||||
.B -w
|
||||
option to run in the slit.
|
||||
For example, you could put in your
|
||||
.IR ~/.xinitrc :
|
||||
.EX
|
||||
bbmail -w &
|
||||
bbpager -w &
|
||||
exec openbox
|
||||
.EE
|
||||
Of course, to use the slit, you must have slit support compiled in (this is
|
||||
the default).
|
||||
.SH RESOURCE FILE
|
||||
Usually the
|
||||
.I ~/.openbox/rc
|
||||
resource file is created and maintained by Openbox itself.
|
||||
All options from the
|
||||
.B [config]
|
||||
menu (from 0.60.x on), the last selected style file, your workspace names and
|
||||
so on are saved automatically in this file.
|
||||
However, there are some resources in it you might want to edit yourself:
|
||||
.TP
|
||||
.B session.menuFile:
|
||||
This tells Openbox where to look for its menu file.
|
||||
.TP
|
||||
.B session.screen0.toolbar.widthPercent:
|
||||
This determines the amount (in %) of space the toolbar will take.
|
||||
Default value is:
|
||||
.IR 66 .
|
||||
.TP
|
||||
.B session.screen0.strftimeFormat:
|
||||
This adjusts the way the current time is displayed in the toolbar.
|
||||
The
|
||||
.IR strftime (3)
|
||||
format is used.
|
||||
Default value is:
|
||||
.IR "%I:%M %p" .
|
||||
.TP
|
||||
.B session.autoRaiseDelay:
|
||||
This adjusts the delay (in ms) before focused windows will raise when using the
|
||||
Auto Raise option.
|
||||
Default value is:
|
||||
.IR 250 .
|
||||
.TP
|
||||
.B session.doubleClickInterval:
|
||||
This adjusts the delay (in ms) between mouse clicks for Openbox to consider a double click.
|
||||
Default value is:
|
||||
.IR 250 .
|
||||
.TP
|
||||
.B session.screen0.edgeSnapThreshold:
|
||||
When moving a window across your screen, Openbox is able to have it `snap' to
|
||||
the edges of the screen for easy placement.
|
||||
This variable tells Openbox the distance (in pixels) at which the window will
|
||||
jump to the edge.
|
||||
Default value is:
|
||||
.IR 0 .
|
||||
.TP
|
||||
.B session.cacheMax:
|
||||
This tells Openbox how much memory (in Kb) it may use to store cached pixmaps on
|
||||
the X server.
|
||||
If your machine runs short of memory, you may lower this value.
|
||||
Default value is:
|
||||
.IR 200 .
|
||||
.TP
|
||||
.B session.cacheLife:
|
||||
This tells Openbox how long (in minutes) unused pixmaps may stay in the X
|
||||
server's memory.
|
||||
Default value is:
|
||||
.IR 5 .
|
||||
.TP
|
||||
.B session.titleBarLayout:
|
||||
The order of the elements of window titlebars. This is a string built
|
||||
of the following characters:
|
||||
.IP
|
||||
.nf I: Iconify button
|
||||
L: Label (window title)
|
||||
M: Maximize button
|
||||
S: Sticky button
|
||||
C: Close button
|
||||
.fi
|
||||
.IP
|
||||
The order in which these character appear in the string is the order they will appear in window titlebars. You can also omit an item to not have it appear in the titlebar at all, except for the label which will always appear.
|
||||
Default value is:
|
||||
.IR ILMC
|
||||
.TP
|
||||
.B session.colorsPerChannel:
|
||||
This tells Openbox how many colors to take from the X server on pseudocolor
|
||||
displays. A channel would be red, green, or blue.
|
||||
Openbox will allocate this variable ^ 3 colors and make them always available.
|
||||
This value must be between 2 and 6.
|
||||
When you run Openbox on an 8-bit display, you must set this resource to 4.
|
||||
Default value is:
|
||||
.IR 4.
|
||||
.PP
|
||||
When running Openbox in a multiple desktop environment, the
|
||||
.B screen0
|
||||
key can also be
|
||||
.B screen1, 2
|
||||
etc. for any appropriate desktop.
|
||||
.SH ENVIRONMENT
|
||||
.TP
|
||||
.B HOME
|
||||
Openbox uses
|
||||
.RB $ HOME
|
||||
to find its
|
||||
.I .openbox/rc
|
||||
file, and to resolve style file and directory names.
|
||||
.TP
|
||||
.B DISPLAY
|
||||
When no other display was given on the command line, Openbox will start on the
|
||||
display specified by this variable.
|
||||
.SH AUTHOR and CREDITS
|
||||
All of the code was initially written and maintained as Blackbox by Brad Hughes
|
||||
.nh \" hyphenation off
|
||||
(blackbox@alug.org)
|
||||
.hy \" on again
|
||||
and then Jeff Raven
|
||||
.nh
|
||||
(jraven@psu.edu),
|
||||
.hy
|
||||
and then Sean 'Shaleh' Perry
|
||||
.nh
|
||||
(shaleh@debian.org)
|
||||
.hy
|
||||
.hy
|
||||
and is now maintained as Openbox by Ben Jansens
|
||||
.nh
|
||||
(ben@orodu.net)
|
||||
.hy
|
||||
with contributions and patches merged from
|
||||
many individuals around the world.
|
||||
.PP
|
||||
The official Openbox website:
|
||||
.nh
|
||||
.B http://openbox.sunsite.dk/
|
||||
.hy
|
||||
.br
|
||||
Many themes and other contributions:
|
||||
.nh
|
||||
.B http://themes.freshmeat.net/
|
||||
.hy
|
||||
.PP
|
||||
This manpage was put together by Wilbert Berendsen
|
||||
.nh
|
||||
(wbsoft@xs4all.nl).
|
||||
.hy
|
||||
Numerous other languages will be available.
|
||||
.SH SEE ALSO
|
||||
.IR bsetroot (1), \ bbkeys (1), \ xftlsfonts (1), \ epist (1)
|
553
doc/python/client.txt
Normal file
553
doc/python/client.txt
Normal file
|
@ -0,0 +1,553 @@
|
|||
ob.Client
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'ob.Client' class, exposed by Openbox to its python
|
||||
scripts. The 'Client' class cannot be instantiated, and can only be
|
||||
retrieved by catching events from Openbox, or from the ob.Openbox.clientList()
|
||||
method.
|
||||
|
||||
A Client instance is associated with a single client window which Openbox is
|
||||
managing. When the client window is closed/destroyed/released, the Client
|
||||
instance will be marked as invalid (see valid()). Any methods of Client, with
|
||||
the exception of valid(), will raise a ReferenceError exception if they are
|
||||
called on a non-valid Client instance. For this reason, it is not encouraged to
|
||||
keep references to Client instances between events, unless you are tracking the
|
||||
hooks.closed hook or check valid() before attempting to reuse a Client
|
||||
instance.
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
valid()
|
||||
|
||||
Returns if the Client instance is still valid. Client instances are marked as
|
||||
invalid when the Client they are associated is closed/destroyed/released.
|
||||
|
||||
Returns: True or False for if the Client instance is valid.
|
||||
|
||||
----
|
||||
|
||||
title()
|
||||
|
||||
Returns the client's title.
|
||||
|
||||
Returns: A string containing the client's title.
|
||||
|
||||
----
|
||||
|
||||
setTitle(title)
|
||||
|
||||
Change the client's title to the given string. This change will be overwritten
|
||||
if/when the client changes its title.
|
||||
|
||||
title: A string containing the new title for the client.
|
||||
|
||||
----
|
||||
|
||||
iconTitle()
|
||||
|
||||
Returns's the client's icon title. The icon title is the title to be displayed
|
||||
when the client is iconified.
|
||||
|
||||
Returns: A string containing the client's icon title.
|
||||
|
||||
----
|
||||
|
||||
setIconTitle(title)
|
||||
|
||||
Change the client's icon title to the given string. This change will be
|
||||
overwritten if/when the client changes its icon title.
|
||||
|
||||
title: A string containing the new icon title for the client.
|
||||
|
||||
----
|
||||
|
||||
desktop()
|
||||
|
||||
Returns the desktop on which the client is visible. This value will always be
|
||||
in the range [0, ob.Openbox.numDesktops()), unless it is 0xffffffff. A value of
|
||||
0xffffffff indicates the client is visible on all desktops.
|
||||
|
||||
Returns: An integer containing the client's desktop,
|
||||
|
||||
----
|
||||
|
||||
setDesktop(desktop)
|
||||
|
||||
Moves the client to the specified desktop. The desktop must be in the range
|
||||
[0, ob.Openbox.numDesktops()), unless it is 0xffffffff. A value of 0xffffffff
|
||||
indicates the client is visible on all desktops.
|
||||
|
||||
desktop: The desktop on which to place the client.
|
||||
|
||||
----
|
||||
|
||||
resName()
|
||||
|
||||
Returns the resouce name of the client. The resource name is meant to provide
|
||||
an instance name for the client.
|
||||
|
||||
Returns: A string containing the client's resource name.
|
||||
|
||||
----
|
||||
resClass()
|
||||
|
||||
Returns the resouce class of the client. The resource class is meant to provide
|
||||
the genereal class of the application. e.g. 'Emacs', 'Xterm', 'XClock',
|
||||
'XLoad', and so on.
|
||||
|
||||
Returns: A string containing the client's resource class.
|
||||
|
||||
----
|
||||
|
||||
role()
|
||||
|
||||
Returns the client's role. The role is meant to distinguish between different
|
||||
windows of an application. Each window should have a unique role.
|
||||
|
||||
Returns: A string containing the client window's role.
|
||||
|
||||
----
|
||||
|
||||
transient()
|
||||
|
||||
Returns True or False describing if the client is a transient window. Transient
|
||||
windows are 'temporary' windows, such as preference dialogs, and usually have
|
||||
a parent window, which can be found from transientFor().
|
||||
|
||||
Returns: True or False for if the client is a transient window.
|
||||
|
||||
----
|
||||
|
||||
transientFor()
|
||||
|
||||
Returns the client for which this client is a transient. See transient() for
|
||||
a description of transience.
|
||||
|
||||
Returns: A Client containing the client which this client is transient
|
||||
for. None if such a client does not exist.
|
||||
|
||||
----
|
||||
|
||||
transients()
|
||||
|
||||
Returns a tuple containing all the Clients which are transients of this window.
|
||||
See transient() for a description of transience.
|
||||
|
||||
Returns: A tuple containing Clients which are transients for this
|
||||
client. The tuple may be empty.
|
||||
|
||||
----
|
||||
|
||||
type()
|
||||
|
||||
Returns the logical type of the window. This is one of the ClientType
|
||||
constants. See also normal().
|
||||
|
||||
Returns: The type of the window.
|
||||
|
||||
----
|
||||
|
||||
normal()
|
||||
|
||||
Returns True or False for if the client is a 'normal' window. Normal windows
|
||||
make up most applications. Non-normal windows have special rules applied to
|
||||
them at times such as for focus handling. An example of a non-normal window
|
||||
is 'gnome-panel'. This value is determined from the client's type(), but does
|
||||
not imply that the window is ClientType.Normal. Rather this is a more generic
|
||||
definition of 'normal' windows, and includes dialogs and others.
|
||||
|
||||
Returns: True or False declaring the client as 'normal' or not.
|
||||
|
||||
----
|
||||
|
||||
area()
|
||||
|
||||
Returns the area of the screen which the client occupies. It may be important
|
||||
to note that this is the position and size of the client *with* its
|
||||
decorations. If you want the underlying position and size of the client
|
||||
itself, you should use clientArea(). See also logicalSize().
|
||||
|
||||
Returns: A tuple containing the area of the client and decorations on
|
||||
the screen. The tuple is in the format (x, y, width, height).
|
||||
|
||||
----
|
||||
|
||||
setArea(area, [final])
|
||||
|
||||
Sets the client's area, moving and resizing it as specified (or as close as can
|
||||
be accomidated).
|
||||
|
||||
area: The new area for the client, in a tuple. The tuple should be of
|
||||
the format (x, y, width, height).
|
||||
|
||||
final: Optional True or False for if this is a final change. This
|
||||
should be set to False if the change is only part of a
|
||||
move/resize. Otherwise, it should be set to True. If it is not
|
||||
specified, it will default to True.
|
||||
|
||||
----
|
||||
|
||||
clientArea()
|
||||
|
||||
Returns the area of the screen which the client considers itself to be
|
||||
occupying. This value is not what you see and should not be used for most
|
||||
things (it should, for example, be used for persisting a client's dimentions
|
||||
across sessions). See also area().
|
||||
|
||||
Returns: A tuple containing the area the client considers itself to be
|
||||
occupying. The tuple is in the format (x, y, width, height).
|
||||
|
||||
----
|
||||
|
||||
setClientArea(area)
|
||||
|
||||
Sets the area of the screen which the client considers itself to be occupying.
|
||||
This is not the on-screen visible position and size, and should be used with
|
||||
care. You probably want to use setArea() to adjust the client. This should be
|
||||
used if you want the client window (inside the decorations) to be a specific
|
||||
size. Adjusting the client's position with this function is probably always a
|
||||
bad idea, because of window gravity.
|
||||
|
||||
area: The new area for the client. in a tuple. The tuple should be of
|
||||
the format (x, y, width, height).
|
||||
|
||||
----
|
||||
|
||||
frameSize()
|
||||
|
||||
Returns the size of the decorations around the client window.
|
||||
|
||||
Returns: A tuple containing the size of the decorations on each side
|
||||
of the client window. The tuple has the format
|
||||
(left, top, right, bottom).
|
||||
|
||||
----
|
||||
|
||||
strut()
|
||||
|
||||
Returns the application's specified strut. The strut is the amount of space
|
||||
that should be reserved for the application on each side of the screen.
|
||||
|
||||
|
||||
Returns: A tuple containing the application's strut. The tuple has the
|
||||
format (left, top, right, bottom).
|
||||
|
||||
----
|
||||
|
||||
logicalSize()
|
||||
|
||||
Returns the client's logical size. The logical size is the client's size in
|
||||
more user friendly terms. For many apps this is simply the size of the client
|
||||
in pixels, however for some apps this will differ (e.g. terminal emulators).
|
||||
This value should be used when displaying an applications size to the user.
|
||||
|
||||
Returns: A tuple containing the client's logical size. The tuple has
|
||||
the format (width, height).
|
||||
|
||||
----
|
||||
|
||||
canFocus()
|
||||
|
||||
Returns True or False for if the client can be focused.
|
||||
|
||||
Returns: True or False for if the client can recieve input focus.
|
||||
|
||||
----
|
||||
|
||||
focus([focus])
|
||||
|
||||
Focuses (or unfocuses) the client window. Windows which return False for
|
||||
canFocus() or visible() cannot be focused. When this function returns, the
|
||||
client's focused() state will not be changed yet. This only sends the request
|
||||
through the X server. You should wait for the hooks.focused hook to fire, and
|
||||
not assume the client has been focused.
|
||||
|
||||
focus: Optional. If True, the window will be focused. If False, and
|
||||
focused() is True, it will lose its focus. If the argument is
|
||||
not passed, it will default to True.
|
||||
|
||||
Returns: True if the client could be focused, and focus has been sent
|
||||
to the window. False if the client could not be focused.
|
||||
|
||||
----
|
||||
|
||||
focused()
|
||||
|
||||
Returns True or False for if the client has the input focus.
|
||||
|
||||
Returns: True or False for if the client has the input focus.
|
||||
|
||||
----
|
||||
|
||||
visible()
|
||||
|
||||
Returns True or False for if the client is visible. A client is not visible if
|
||||
it is iconic() or if its desktop() is not visible.
|
||||
|
||||
Returns: True or False for if the client is visible.
|
||||
|
||||
----
|
||||
|
||||
setVisible(show)
|
||||
|
||||
Shows or hides the client. This has no effect if its current visible() state
|
||||
is requested.
|
||||
|
||||
show: True or False specifying if the client should be hidden or shown.
|
||||
|
||||
----
|
||||
|
||||
modal()
|
||||
|
||||
Returns True or False for if the client is a modal window. Modal windows
|
||||
indicate that they must be dealt with before the program can continue. When
|
||||
a modal window is a transient(), its transientFor() client cannot be focused or
|
||||
raised above it.
|
||||
|
||||
Returns: True or False for if the client is a modal window.
|
||||
|
||||
----
|
||||
|
||||
setModal(modal)
|
||||
|
||||
Make the client window modal or non-modal.
|
||||
|
||||
mdal: True or False to make the client modal or not respectively.
|
||||
|
||||
----
|
||||
|
||||
shaded()
|
||||
|
||||
Returns True or False for if the client is shaded. Shaded windows have only
|
||||
their titlebar decorations showing.
|
||||
|
||||
----
|
||||
|
||||
setShaded(shade)
|
||||
|
||||
Shade or unshade the client. Shaded windows have only their titlebar
|
||||
decorations showing. Windows which do not have a titlebar cannot be shaded.
|
||||
|
||||
shade: True or False to make the client shaded or not respectively.
|
||||
|
||||
----
|
||||
|
||||
iconic()
|
||||
|
||||
Returns True or False for if the window is iconified. Iconified windows are not
|
||||
visible on any desktops.
|
||||
|
||||
Returns: True or False for if the client is iconified.
|
||||
|
||||
----
|
||||
|
||||
setIconic(iconify, [current])
|
||||
|
||||
Iconifies or restores the client window. Iconified windows are not visible on
|
||||
any desktops. Iconified windows can be restored to the currently visible
|
||||
desktop or to their original (native) desktop.
|
||||
|
||||
iconify: True or False to iconify or deiconify the client repectively.
|
||||
|
||||
current: Optional True or False to specify if the client should be
|
||||
restored to the currently visible desktop or to the desktop
|
||||
from which it was iconified. This does not apply to windows
|
||||
who's desktop() is 0xffffffff. If this is not specified, it
|
||||
defaults to True (the current desktop).
|
||||
|
||||
----
|
||||
|
||||
maximizedHorz()
|
||||
|
||||
Returns whether the client is maximized in the horizontal direction.
|
||||
|
||||
Returns: True if the client is maximized horizontally; False if it is
|
||||
not.
|
||||
|
||||
----
|
||||
|
||||
setMaximizedHorz(max)
|
||||
|
||||
Maximizes or restores a client horizontally.
|
||||
|
||||
max: True or False for if the client should be maximized or
|
||||
unmaximized in the horizontal direction.
|
||||
|
||||
----
|
||||
|
||||
maximizedVert()
|
||||
|
||||
Returns whether the client is maximized in the vertical direction.
|
||||
|
||||
Returns: True if the client is maximized vertically; False if it is
|
||||
not.
|
||||
|
||||
----
|
||||
|
||||
setMaximizedVert(max)
|
||||
|
||||
Maximizes or restores a client vertically.
|
||||
|
||||
max: True or False for if the client should be maximized or
|
||||
unmaximized in the vertical direction.
|
||||
|
||||
----
|
||||
|
||||
maximized()
|
||||
|
||||
Returns whether the client is maximized in the horizontal or vertical
|
||||
direction.
|
||||
|
||||
Returns: True if the client is maximized horizontally or vertically;
|
||||
False if it is not.
|
||||
|
||||
----
|
||||
|
||||
setMaximized(max)
|
||||
|
||||
Maximizes or restores a client vertically and horzontally.
|
||||
|
||||
max: True or False for if the client should be maximized or
|
||||
unmaximized in the vertical and horizontal direction.
|
||||
-
|
||||
---
|
||||
|
||||
fullscreen()
|
||||
|
||||
Returns if the client is in fullscreen mode. Fullscreen windows are kept above
|
||||
all other windows and are stretched to fill the entire physical display.
|
||||
|
||||
Returns: True or False for if the client is fullscreen.
|
||||
|
||||
----
|
||||
|
||||
setFullscreen(full)
|
||||
|
||||
Set a client into or out of fullscreen mode. Fullscreen windows are kept above
|
||||
all other windows and are stretched to fill the entire physical display.
|
||||
|
||||
full: True or False to set the client into or out of fullscreen mode
|
||||
respectively.
|
||||
|
||||
----
|
||||
|
||||
stacking()
|
||||
|
||||
Returns if the client will be stacked above/below other clients in the same
|
||||
layer.
|
||||
|
||||
Returns: An integer > 0 if the client will be stacked above other
|
||||
clients in its layer. An integer < 0 if it will be stacked
|
||||
below other clients. 0 will be returned if the client is
|
||||
stacked as normal amongst other clients in its layer.
|
||||
|
||||
----
|
||||
|
||||
setStacking(stack)
|
||||
|
||||
Set how the client will be stacked according to other clients in its layer.
|
||||
|
||||
stack: An integer > 0 if the client should be stacked above other
|
||||
clients in its layer. An integer < 0 if it should be stacked
|
||||
below other clients. Exactly 0 if the client should be stacked
|
||||
as normal amongst other clients in its layer.
|
||||
|
||||
----
|
||||
|
||||
raiseWindow()
|
||||
|
||||
Raises the window to the top of its stacking layer.
|
||||
|
||||
----
|
||||
|
||||
lowerWindow()
|
||||
|
||||
Lowers the window to the bottom of its stacking layer.
|
||||
|
||||
----
|
||||
|
||||
skipPager()
|
||||
|
||||
Returns if the client has requested to be skipped (not displayed) by pagers.
|
||||
|
||||
Returns: True or False for if the client has requested to be skiped by
|
||||
pagers.
|
||||
|
||||
----
|
||||
|
||||
setSkipPager(skip)
|
||||
|
||||
Set whether the client should be skipped (not displayed) by pagers.
|
||||
|
||||
skip: True or False to make the client be skipped or not skipped by
|
||||
pagers.
|
||||
|
||||
----
|
||||
|
||||
skipTaskbar()
|
||||
|
||||
Returns if the client has requested to be skipped (not displayed) by taskbars.
|
||||
|
||||
Returns: True or False for if the client has requested to be skiped by
|
||||
taskbars.
|
||||
|
||||
----
|
||||
|
||||
setSkipTaskbar(skip)
|
||||
|
||||
Set whether the client should be skipped (not displayed) by taskbars.
|
||||
|
||||
skip: True or False to make the client be skipped or not skipped by
|
||||
taskbars.
|
||||
|
||||
----
|
||||
|
||||
disableDecorations(titlebar, handle, border)
|
||||
|
||||
Choose which decorations to disable on the client. Note that decorations can
|
||||
only be disabled, and decorations that would normally not be shown cannot be
|
||||
added. These values may have slightly different meanings in different theme
|
||||
engines.
|
||||
|
||||
titlebar: True to disable, or False to enable (if possible) the
|
||||
client's titlebar.
|
||||
|
||||
handle: True to disable, or False to enable (if possible) the
|
||||
client's handle.
|
||||
|
||||
border: True to disable, or False to enable (if possible) the
|
||||
client's border.
|
||||
|
||||
----
|
||||
|
||||
close()
|
||||
|
||||
Requests the client to close its window.
|
||||
|
||||
----
|
||||
|
||||
window()
|
||||
|
||||
Returns the client's window id. This is the id by which the X server knows the
|
||||
client.
|
||||
|
||||
Returns: An integer containing the client's window id.
|
||||
|
||||
----
|
||||
|
||||
ob.ClientType
|
||||
|
||||
ClientType.Normal: a normal application window.
|
||||
ClientType.Dialog: a dialog window (usually a transient()).
|
||||
ClientType.Desktop: a desktop (bottom-most) window.
|
||||
ClientType.Dock: a dock or panel window.
|
||||
ClientType.Toolbar: a toolbar "torn off" from an application.
|
||||
ClientType.Menu: a pinnable menu "torn off" from an application.
|
||||
ClientType.Utility: a small persistent utility window such as a
|
||||
palette or toolbox.
|
||||
ClientType.Splash: a splash screen window.
|
13
doc/python/config.txt
Normal file
13
doc/python/config.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
config.Config
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'Config' class, exposed by Openbox's 'config'
|
||||
module to its python scripts.
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
25
doc/python/helpers.txt
Normal file
25
doc/python/helpers.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
helpers
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'helpers' module. The 'helpers' module provides
|
||||
methods to make writing python scripts easier.
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
execute(path)
|
||||
|
||||
Forks and executes a process.
|
||||
|
||||
path: The executable to execute. The $PATH is searched so the full
|
||||
path to the executable is not generally needed.
|
||||
|
||||
Example:
|
||||
execute("xterm")
|
||||
|
||||
----
|
||||
|
255
doc/python/hooks.txt
Normal file
255
doc/python/hooks.txt
Normal file
|
@ -0,0 +1,255 @@
|
|||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
** CAUTION: changing any value in the hook for that value changing is **
|
||||
** dangerous, as this can easily lead to an infinate loop of updating! **
|
||||
*******************************************************************************
|
||||
*******************************************************************************
|
||||
|
||||
hooks
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'Hook' class, exposed by Openbox's 'hooks' module
|
||||
to its python scripts, and the standard hooks exposed in the 'hooks' module.
|
||||
|
||||
----
|
||||
|
||||
hooks.Hook
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
__call__(args)
|
||||
|
||||
Fires the hook, passing the given arguments on to all functions registered with
|
||||
the hook. Functions are called in the order in which they were added. If any
|
||||
function defined as a hook returns any value other than None, the hook will
|
||||
not fire any more functions.
|
||||
|
||||
args: Any number of function arguments, which are passed on to the
|
||||
hook's registered functions.
|
||||
|
||||
----
|
||||
|
||||
append(func)
|
||||
|
||||
Appends a function to the hook.
|
||||
|
||||
func: The function to add to the hook.
|
||||
|
||||
----
|
||||
|
||||
remove(func)
|
||||
|
||||
Removes the function from the hook.
|
||||
|
||||
func: The function to remove from the hook.
|
||||
|
||||
----
|
||||
|
||||
hooks
|
||||
|
||||
----
|
||||
|
||||
Hooks
|
||||
|
||||
The following standard hooks are defined by Openbox. After each name comes the
|
||||
expected format of a function added to the hook. Adding a function of another
|
||||
format will lead to an exception when the hook is fired.
|
||||
|
||||
----
|
||||
|
||||
startup - function()
|
||||
|
||||
When Openbox is starting, just before it begins managing clients.
|
||||
|
||||
----
|
||||
|
||||
shutdown - function()
|
||||
|
||||
When Openbox is shutting down, after releasing all clients.
|
||||
|
||||
----
|
||||
|
||||
visibledesktop - function(new, old)
|
||||
|
||||
When the current desktop changes.
|
||||
|
||||
new: An integer containing the new desktop.
|
||||
|
||||
old: An integer containing the old desktop.
|
||||
|
||||
----
|
||||
|
||||
numdesktops - function(desktops)
|
||||
|
||||
When the number of desktops changes.
|
||||
|
||||
desktops: An integer containing the number of available desktops.
|
||||
|
||||
----
|
||||
|
||||
desktopnames - function()
|
||||
|
||||
When the desktops' names have been changed.
|
||||
|
||||
----
|
||||
|
||||
showdesktop - function(showing)
|
||||
|
||||
When Openbox enters or leaves 'showing the desktop' mode. Called after the
|
||||
desktop is shown/hidden.
|
||||
|
||||
showing: True if entering 'showing the desktop' mode, False if leaving.
|
||||
|
||||
----
|
||||
|
||||
screenconfiguration - function(size)
|
||||
|
||||
When the screen's size (ob.Openbox.physicalSize()) has changed.
|
||||
|
||||
size: The new size of the screen, as returned by
|
||||
ob.Openbox.physicalSize().
|
||||
|
||||
----
|
||||
|
||||
screenarea - function()
|
||||
|
||||
When the screen's area (ob.Openbox.screenArea()) has changed.
|
||||
|
||||
----
|
||||
|
||||
managed - function(client)
|
||||
|
||||
When a client is managed.
|
||||
|
||||
client: The Client being managed.
|
||||
|
||||
----
|
||||
|
||||
closed - function(client)
|
||||
|
||||
When a client is being closed/destroyed/released.
|
||||
|
||||
client: The Client which has been closed.
|
||||
|
||||
----
|
||||
|
||||
bell - function(client)
|
||||
|
||||
When the system bell is fired.
|
||||
|
||||
client: The Client the bell is associated with, or None. Clients can
|
||||
only be associated with bells through the XKB extension.
|
||||
|
||||
----
|
||||
|
||||
urgent - function(client)
|
||||
|
||||
When a window enters/leaves urgent status.
|
||||
|
||||
client: The client which has become/stopped being urgent.
|
||||
|
||||
----
|
||||
|
||||
pointerenter - function(client)
|
||||
|
||||
When the pointer moves above a client.
|
||||
|
||||
client: The Client that the pointer has move above.
|
||||
|
||||
----
|
||||
|
||||
pointerleave - function(client)
|
||||
|
||||
When the pointer moves off of a client.
|
||||
|
||||
client: The Client that the pointer has moved off of.
|
||||
|
||||
----
|
||||
|
||||
focused - function(client)
|
||||
|
||||
When focus changes.
|
||||
|
||||
client: The Client which has recieved input focus, or None if no client
|
||||
is focused.
|
||||
|
||||
----
|
||||
|
||||
requestactivate - function(client)
|
||||
|
||||
When a request is made to activate a client.
|
||||
|
||||
client: The Client who has been requested to be made active.
|
||||
|
||||
----
|
||||
|
||||
title - function(client)
|
||||
|
||||
When a client's title or icon title changes.
|
||||
|
||||
client: The Client whose title changed.
|
||||
|
||||
----
|
||||
|
||||
desktop - function(client, new, old)
|
||||
|
||||
When a client's desktop changes.
|
||||
|
||||
client: The Client that changed desktops.
|
||||
|
||||
new: An integer containing the client's new desktop.
|
||||
|
||||
old: An integer containing the client's old desktop.
|
||||
|
||||
----
|
||||
|
||||
iconic - function(client)
|
||||
|
||||
When a client's iconic status changes.
|
||||
|
||||
client: The Client that has been (un)iconified.
|
||||
|
||||
----
|
||||
|
||||
shaded - function(client)
|
||||
|
||||
When a client's shaded status changes.
|
||||
|
||||
client: The Client that has been (un)shaded.
|
||||
|
||||
----
|
||||
|
||||
maximized - function(client)
|
||||
|
||||
When a client's maximized status changes.
|
||||
|
||||
client: The Client that has been (un)maximized.
|
||||
|
||||
----
|
||||
|
||||
fullscreen - function(client)
|
||||
|
||||
When a client's fullscreen status changes.
|
||||
|
||||
client: The Client which as been (un)fullscreened.
|
||||
|
||||
----
|
||||
|
||||
visible - function(client)
|
||||
|
||||
When a client becomes visible or hidden, but not for desktop changes.
|
||||
|
||||
client: The Client which has been shown/hidden.
|
||||
|
||||
----
|
||||
|
||||
configuration - function(client)
|
||||
|
||||
When a client's configuration (area/position/size) changes.
|
||||
|
||||
client: The Client which has moved or resized.
|
59
doc/python/keyboard.txt
Normal file
59
doc/python/keyboard.txt
Normal file
|
@ -0,0 +1,59 @@
|
|||
input.Keyboard
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'Keyboard' class, exposed by Openbox's 'input'
|
||||
module to its python scripts.
|
||||
|
||||
All keyboard events which will be generated because of the Keyboard class can
|
||||
be caught from the hooks.keyboard hook.
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
bind(keychain, func)
|
||||
|
||||
Binds a key-chain to a function. The keychain is a tuple of strings which
|
||||
define a chain of key presses. Each member of the tuple has the format
|
||||
[Modifier-]...[Key]. Modifiers can be 'mod1', 'mod2', 'mod3', 'mod4', 'mod5',
|
||||
'control', and 'shift'. The keys on your keyboard that are bound to each of
|
||||
these modifiers can be found by running 'xmodmap'. The Key can be any valid
|
||||
key definition. Key definitions can be found by running 'xev', pressing the
|
||||
key while its window is focused, and watching its output. Here are some
|
||||
examples of valid keychains: ('a'), ('F7'), ('control-a', 'd'),
|
||||
('control-mod1-x', 'control-mod4-g'), ('F1', 'space').
|
||||
The func must have a definition similar to 'def func(keydata, client)'. The
|
||||
arguments passed to the function are a KeyboardData object and a Client object.
|
||||
A keychain cannot be bound to more than one function.
|
||||
|
||||
keychain: A tuple containing strings defining a chain of key presses.
|
||||
|
||||
func: A function to bind to the keychain.
|
||||
|
||||
----
|
||||
|
||||
clearBinds()
|
||||
|
||||
Removes all bindings that were previously made by bind().
|
||||
|
||||
----
|
||||
|
||||
grab(func)
|
||||
|
||||
Grabs the entire keyboard, causing all possible keyboard events to be passed
|
||||
to the given function. CAUTION: Be sure when you grab() that you also have an
|
||||
ungrab() that will execute, or you will not be able to type until you restart
|
||||
Openbox. The func must have a definition similar to 'def func(keydata)'. The
|
||||
argument passed to the function is a KeyboardData object. The keyboard cannot
|
||||
be grabbed if it is already grabbed.
|
||||
|
||||
func: A function to receive all the grabbed keyboard events.
|
||||
|
||||
----
|
||||
|
||||
ungrab()
|
||||
|
||||
Ungrabs the keyboard. The keyboard cannot be ungrabbed if it is not grabbed.
|
35
doc/python/keyboarddata.txt
Normal file
35
doc/python/keyboarddata.txt
Normal file
|
@ -0,0 +1,35 @@
|
|||
KeyboardData
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'KeyboardData' class, passed to functions bound to
|
||||
keyboard events.
|
||||
|
||||
----
|
||||
|
||||
Attributes
|
||||
|
||||
----
|
||||
|
||||
keychain
|
||||
|
||||
The keychain (in the format that input.Keyboard.bind() expects them) that
|
||||
was pressed.
|
||||
|
||||
----
|
||||
|
||||
state
|
||||
|
||||
An integer bitmask of the modifiers pressed down when the key was pressed.
|
||||
|
||||
----
|
||||
|
||||
keycode
|
||||
|
||||
An integer containing the keycode for the key that was pressed.
|
||||
|
||||
----
|
||||
|
||||
press
|
||||
|
||||
True or False for if the event was a key press or a key release
|
208
doc/python/openbox.txt
Normal file
208
doc/python/openbox.txt
Normal file
|
@ -0,0 +1,208 @@
|
|||
ob.Openbox
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'Openbox' class, exposed by Openbox's 'ob' module
|
||||
to its python scripts.
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
shutdown()
|
||||
|
||||
Causes Openbox to shutdown and exit.
|
||||
|
||||
|
||||
----
|
||||
|
||||
restart([path])
|
||||
|
||||
Causes Openbox to shutdown and restart. If path is specified, Openbox will
|
||||
shutdown and attempt to run the specified executable instead of restarting
|
||||
itself. If that fails, however, it will restart itself.
|
||||
|
||||
path: Optional path to replacement executable.
|
||||
|
||||
----
|
||||
|
||||
state()
|
||||
|
||||
Returns Openbox's current state, this will be one of the State constants.
|
||||
|
||||
Returns: One of the State values representing the internal state
|
||||
of Openbox.
|
||||
|
||||
----
|
||||
|
||||
desktop()
|
||||
|
||||
Returns the number of the currently visible desktop. This will be in the range
|
||||
of [0, numDesktops()).
|
||||
|
||||
Returns: The currently visible desktop.
|
||||
|
||||
----
|
||||
|
||||
setDesktop(desktop)
|
||||
|
||||
Sets the specified desktop as the visible desktop.
|
||||
|
||||
desktop: The desktop to make visible. Must be in the range of
|
||||
[0, numDesktops()) or a ValueError exception will be raised.
|
||||
|
||||
----
|
||||
|
||||
setNextDesktop([wrap])
|
||||
|
||||
Sets the visible desktop to the next desktop, optionally wrapping around when
|
||||
reaching the last.
|
||||
|
||||
wrap: An optional argument which, when True will cause the function to
|
||||
wrap to the first desktop when going past the last. If it is not
|
||||
specified, it defaults to true.
|
||||
|
||||
----
|
||||
|
||||
setPreviousDesktop([wrap])
|
||||
|
||||
Sets the visible desktop to the previous desktop, optionally wrapping around
|
||||
when reaching the first.
|
||||
|
||||
wrap: An optional argument which, when True will cause the function to
|
||||
wrap to the last desktop when going past the first. If it is not
|
||||
specified, it defaults to true.
|
||||
|
||||
----
|
||||
|
||||
numDesktops()
|
||||
|
||||
Returns the number of desktops available.
|
||||
|
||||
Returns: The number of available desktops.
|
||||
|
||||
----
|
||||
|
||||
setNumDesktops(num)
|
||||
|
||||
Sets the number of desktops available.
|
||||
|
||||
num: The new number of available desktops. This must be greater than 0.
|
||||
|
||||
----
|
||||
|
||||
desktopNames()
|
||||
|
||||
Returns a tuple of names, containing a name for each desktop. The tuple may
|
||||
have a length greater than numDesktops() if more names have been specified.
|
||||
|
||||
Returns: A tuple of names.
|
||||
|
||||
----
|
||||
|
||||
setDesktopNames(names)
|
||||
|
||||
Sets the names for the desktops.
|
||||
|
||||
names: An iterable list of names to apply to the desktops. Can contain
|
||||
more or less names than numDesktops(). If it contains fewer
|
||||
names, then Openbox will give the remaining desktops a
|
||||
placeholder name.
|
||||
|
||||
----
|
||||
|
||||
showingDesktop()
|
||||
|
||||
Returns True or False, depicting if Openbox is in 'showing the desktop' mode.
|
||||
In 'showing the desktop' mode, all normal clients are hidden and the desktop
|
||||
is given focus if possible.
|
||||
|
||||
Returns: True or False describing if Openbox is in 'showing the
|
||||
desktop' mode.
|
||||
|
||||
----
|
||||
|
||||
setShowingDesktop(show)
|
||||
|
||||
Enters or leaves 'showing the desktop' mode. See showingDesktop() for a
|
||||
description of this mode.
|
||||
|
||||
show: True or False to enter or leave 'showing the desktop' mode
|
||||
respectively.
|
||||
|
||||
----
|
||||
|
||||
screenArea(desktop)
|
||||
|
||||
Returns the on-screen available area. This is the area not reserved by
|
||||
applications' struts. Windows should be placed within this area, not within
|
||||
the physicalSize().
|
||||
|
||||
desktop: The desktop for which to get the available area. 0xffffffff to
|
||||
get the combined area for all desktops (combined
|
||||
subtractively).
|
||||
|
||||
Returns: A tuple of form (x, y, width, height) containing the
|
||||
dimensions of the available on-screen area for the desktop.
|
||||
|
||||
|
||||
----
|
||||
|
||||
screenStrut(desktop)
|
||||
|
||||
Returns the combined strut which has been reserved by all applications on the
|
||||
desktops.
|
||||
|
||||
desktop: The desktop for which to get the strut. 0xffffffff to get the
|
||||
combined strut for all desktops (combined additively).
|
||||
|
||||
Returns: A tuple of form (left, top, right, bottom) containing the
|
||||
size of the reserved strut space for the desktop.
|
||||
|
||||
----
|
||||
|
||||
physicalSize()
|
||||
|
||||
Returns the physical size of the display device (in pixels).
|
||||
|
||||
Returns: A tuple of the form (width, height) containing the size of
|
||||
the display device's area.
|
||||
|
||||
----
|
||||
|
||||
screenNumber()
|
||||
|
||||
Returns the number of the screen on which Openbox is running.
|
||||
|
||||
Returns: An integer specifying the screen on which this instance of
|
||||
Openbox is running.
|
||||
|
||||
----
|
||||
|
||||
rootWindow()
|
||||
|
||||
Return the window id of the root window.
|
||||
|
||||
Returns: An integer containing the window id of the root window.
|
||||
|
||||
----
|
||||
|
||||
clientList()
|
||||
|
||||
Returns a all clients currently being managed by Openbox. This list is updated
|
||||
as clients are managed and closed/destroyed/released.
|
||||
|
||||
Returns: A list of Clients containing all the clients managed by
|
||||
Openbox.
|
||||
|
||||
----
|
||||
|
||||
ob.State
|
||||
|
||||
State.Starting: Openbox is starting up and has not yet reached its
|
||||
main event loop.
|
||||
State.Running: Openbox is running normally.
|
||||
State.Exiting: Openbox has left its main event loop and is shutting
|
||||
down.
|
130
doc/python/pointer.txt
Normal file
130
doc/python/pointer.txt
Normal file
|
@ -0,0 +1,130 @@
|
|||
input.Pointer
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'Pointer' class, exposed by Openbox's 'input'
|
||||
module to its python scripts.
|
||||
|
||||
All pointer events which will be generated because of the Pointer class can
|
||||
be caught from the hooks.pointer hook.
|
||||
|
||||
----
|
||||
|
||||
Terminology
|
||||
|
||||
----
|
||||
|
||||
Context -- A context is a string describing a part of a window or screen in
|
||||
which an event can occur. Contexts are used for grabbing and
|
||||
tracking pointer events. A list of possible contexts are exposed by
|
||||
the engine through the contexts() method. The standard list of
|
||||
contexts are:
|
||||
* "none" - no context associated.
|
||||
* "root" - the root window.
|
||||
* "frame" - the client's entire frame. Note: when a button is
|
||||
grabbed in the "frame" context, it will not get passed
|
||||
through to the client.
|
||||
* "client" - client's window.
|
||||
* "titlebar" - a client's titlebar.
|
||||
* "handle" - a client's handle.
|
||||
* "tlcorner" - the top-left corner of a client's decorations.
|
||||
* "trcorner" - the top-right corner of a client's decorations.
|
||||
* "blcorner" - the bottom-left corner of a client's decorations.
|
||||
* "brcorner" - the bottom-right corner of a client's decorations.
|
||||
* "maximize" - the maximize button in the titlebar.
|
||||
* "close" - the close button in the titlebar.
|
||||
* "iconify" - the iconify button in the titlebar.
|
||||
* "alldesktops" - the all-desktops button in the titlebar.
|
||||
* "icon" - the window icon in the titlebar.
|
||||
|
||||
An engine may add to this list as it sees fit (most engines will
|
||||
include "close", "maximize", etc. contexts for titlebar buttons).
|
||||
|
||||
----
|
||||
|
||||
Methods
|
||||
|
||||
----
|
||||
|
||||
bind(button, context, action, func)
|
||||
|
||||
Binds a pointer button for a context and action to a function. See the
|
||||
Terminology section for a decription and list of common contexts. The button is
|
||||
a string which defines a modifier and button combination with the format
|
||||
[Modifier-]...[Button]. Modifiers can be 'mod1', 'mod2', 'mod3', 'mod4',
|
||||
'mod5', 'control', and 'shift'. The keys on your keyboard that are bound to
|
||||
each of these modifiers can be found by running 'xmodmap'. The button is the
|
||||
number of the button. Button numbers can be found by running 'xev', pressing
|
||||
the button with the pointer over its window, and watching its output. Here
|
||||
are some examples of valid buttons: 'control-1', '2', 'mod1-shift-5'. The
|
||||
action is one of the Action_* constants. The func must have a definition
|
||||
similar to 'def func(ptrdata, client)'. The arguments passed to the function
|
||||
are a PointerData object and a Client object (or None). A button and context
|
||||
may be bound to more than one function.
|
||||
|
||||
button: A string defining the modifiers and button to for which events
|
||||
should be generated.
|
||||
|
||||
context: The context in which the button events should be generated.
|
||||
|
||||
action: One of the Action_* constants specifying the action to bind
|
||||
the function to.
|
||||
|
||||
func: A function to bind to the button/context.
|
||||
|
||||
----
|
||||
|
||||
clearBinds()
|
||||
|
||||
Removes all bindings that were previously made by bind().
|
||||
|
||||
----
|
||||
|
||||
grab(func)
|
||||
|
||||
Grabs the pointer device, causing all possible pointer events to be sent to
|
||||
the given function. CAUTION: Be sure when you grab() that you also have an
|
||||
ungrab() that will execute, or you will not be able to use the pointer device
|
||||
until you restart Openbox. The func must have a definition similar to
|
||||
'def func(data)'. The argument passed to the function is a PointerData object.
|
||||
The pointer cannot be grabbed if it is already grabbed. When a grab is active,
|
||||
no pointer bindings will fire, everything is sent only to the specified func.
|
||||
|
||||
func: A function to receive all the grabbed pointer events.
|
||||
|
||||
----
|
||||
|
||||
ungrab()
|
||||
|
||||
Ungrabs the pointer. The pointer cannot be ungrabbed if it is not grabbed.
|
||||
|
||||
----
|
||||
|
||||
Constants
|
||||
|
||||
----
|
||||
|
||||
Action_Press a pointer button press
|
||||
Action_Release a pointer button release
|
||||
Action_Click a pointer button click (press-release)
|
||||
Action_DoubleClick a pointer button double-click
|
||||
Action_Motion a pointer drag
|
||||
|
||||
----
|
||||
|
||||
Configuration options (through the config module)
|
||||
|
||||
----
|
||||
|
||||
double_click_rate
|
||||
|
||||
An integer containing the number of milliseconds in which 2 clicks must be
|
||||
received to cause a double-click event.
|
||||
|
||||
----
|
||||
|
||||
drag_threshold
|
||||
|
||||
An integer containing the number of pixels a drag must go before motion events
|
||||
start getting generated. Once a drag has begun, the button release will not
|
||||
count as a click event.
|
67
doc/python/pointerdata.txt
Normal file
67
doc/python/pointerdata.txt
Normal file
|
@ -0,0 +1,67 @@
|
|||
PointerData
|
||||
|
||||
----
|
||||
|
||||
This document describes the 'PointerData' class, passed to functions bound to
|
||||
pointer events.
|
||||
|
||||
----
|
||||
|
||||
Attributes
|
||||
|
||||
----
|
||||
|
||||
action
|
||||
|
||||
The type of event. One of the input.Pointer.Action_* constants.
|
||||
|
||||
----
|
||||
|
||||
button
|
||||
|
||||
The button (in the format that input.Pointer.bind() expects them) that caused
|
||||
the event. This will be 'None' if there was no button associated with the
|
||||
event. (This can only happen during a pointer grab.)
|
||||
|
||||
----
|
||||
|
||||
context
|
||||
|
||||
A string containing the context of the event. See the Terminology section in
|
||||
the Pointer documentation for a decription and list of common contexts.
|
||||
|
||||
----
|
||||
|
||||
state
|
||||
|
||||
An integer bitmask of the modifiers pressed down when the event occured.
|
||||
|
||||
----
|
||||
|
||||
buttonnum
|
||||
|
||||
An integer containing the number of the pointer button associated with the
|
||||
event.
|
||||
|
||||
----
|
||||
|
||||
pos
|
||||
|
||||
A tuple containing the current position of the cursor. The tuple has the format
|
||||
(x, y). This is only valid when 'action' is 'Action_Motion'.
|
||||
|
||||
-----
|
||||
|
||||
presspos
|
||||
|
||||
A tuple containing the position of the cursor when the drag started. The tuple
|
||||
has the format (x, y). This is only valid when 'action' is 'Action_Motion'.
|
||||
|
||||
----
|
||||
|
||||
pressclientarea
|
||||
|
||||
A tuple containing the area of the client when the drag started. The tuple has
|
||||
the format (x, y, width, height). This will be None if there is no client
|
||||
associated with the event (during a pointer grab, or a drag on the root
|
||||
window). This is only valid when 'action' is 'Action_Motion'.
|
54
doc/themerc.txt
Normal file
54
doc/themerc.txt
Normal file
|
@ -0,0 +1,54 @@
|
|||
The themerc file dictates which engine and theme openbox will use, as well as
|
||||
parameters for the engine.
|
||||
|
||||
----
|
||||
|
||||
Options for the themerc file are specified as:
|
||||
option = value
|
||||
|
||||
Lines that begin with # are considered comments.
|
||||
|
||||
----
|
||||
|
||||
These are the valid options:
|
||||
|
||||
engine
|
||||
String value, containing the name of the engine to load.
|
||||
example: 'openbox'
|
||||
default: 'openbox'
|
||||
|
||||
theme
|
||||
String value containing the theme to load in the engine. This can be
|
||||
an absolute path to the theme, or simply the theme's name in which case
|
||||
the appropriate paths will be searched for the theme.
|
||||
example: 'mytheme'
|
||||
default: engine-dependant
|
||||
|
||||
font
|
||||
String value containing the font to use in the window titlebars. The
|
||||
format of this string is described in:
|
||||
http://keithp.com/~keithp/render/Xft.tutorial
|
||||
example: 'times-12:bold:slant=italic,oblique'
|
||||
default: 'sans-8'
|
||||
|
||||
titlebarlayout
|
||||
The layout of the titlebar of windows. This is a string that can
|
||||
consist of only valid characters. The characters are:
|
||||
I - iconify button
|
||||
M - maximize button
|
||||
C - close button
|
||||
D - all-desktops button
|
||||
N - window icon
|
||||
L - text label (window title)
|
||||
example: 'ILMC'
|
||||
default: 'NDLIMC'
|
||||
|
||||
----
|
||||
|
||||
example themerc:
|
||||
|
||||
# My themerc file!
|
||||
engine='openbox'
|
||||
theme='nyz'
|
||||
titlebarlayout='ILMC'
|
||||
font='arial,sans-9:bold'
|
1
engines/Makefile.am
Normal file
1
engines/Makefile.am
Normal file
|
@ -0,0 +1 @@
|
|||
SUBDIRS = openbox
|
53
engines/engineinterface.h
Normal file
53
engines/engineinterface.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef __engineinterface_h
|
||||
#define __engineinterface_h
|
||||
|
||||
#include "../kernel/frame.h"
|
||||
#include <glib.h>
|
||||
|
||||
/* startup */
|
||||
typedef gboolean EngineStartup();
|
||||
|
||||
/* shutdown */
|
||||
typedef void EngineShutdown();
|
||||
|
||||
/* frame_new */
|
||||
typedef Frame *EngineFrameNew();
|
||||
|
||||
/* frame_grab_client */
|
||||
typedef void EngineFrameGrabClient(Frame *self, Client *client);
|
||||
/* frame_release_client */
|
||||
typedef void EngineFrameReleaseClient(Frame *self, Client *client);
|
||||
|
||||
/* frame_adjust_size */
|
||||
/*! Update the frame's size to match the client */
|
||||
typedef void EngineFrameAdjustSize(Frame *self);
|
||||
/* frame_adjust_position */
|
||||
/*! Update the frame's position to match the client */
|
||||
typedef void EngineFrameAdjustPosition(Frame *self);
|
||||
/* frame_adjust_shape */
|
||||
/*! Shape the frame window to the client window */
|
||||
typedef void EngineFrameAdjustShape(Frame *self);
|
||||
/* frame_adjust_state */
|
||||
/*! Update the frame to match the client's new state (for things like toggle
|
||||
buttons, focus, and the title) XXX break this up */
|
||||
typedef void EngineFrameAdjustState(Frame *self);
|
||||
/* frame_adjust_focus */
|
||||
/*! Update the frame to match the client's focused state */
|
||||
typedef void EngineFrameAdjustFocus(Frame *self);
|
||||
/* frame_adjust_title */
|
||||
/*! Update the frame to display the client's current title */
|
||||
typedef void EngineFrameAdjustTitle(Frame *self);
|
||||
/* frame_adjust_icon */
|
||||
/*! Update the frame to display the client's current icon */
|
||||
typedef void EngineFrameAdjustIcon(Frame *self);
|
||||
|
||||
/* frame_show */
|
||||
/*! Shows the frame */
|
||||
typedef void EngineFrameShow(Frame *self);
|
||||
/*! Hides the frame */
|
||||
typedef void EngineFrameHide(Frame *self);
|
||||
|
||||
/* get_context */
|
||||
typedef GQuark EngineGetContext(Client *client, Window win);
|
||||
|
||||
#endif
|
7
engines/openbox/.cvsignore
Normal file
7
engines/openbox/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
.deps
|
||||
.libs
|
||||
openbox.la
|
||||
openbox.lo
|
||||
theme.lo
|
20
engines/openbox/Makefile.am
Normal file
20
engines/openbox/Makefile.am
Normal file
|
@ -0,0 +1,20 @@
|
|||
enginedir=$(libdir)/openbox/engines
|
||||
themedir=$(datadir)/openbox/themes/openbox
|
||||
|
||||
CPPFLAGS=$(XFT_CFLAGS) $(GLIB_CFLAGS) @CPPFLAGS@ \
|
||||
-DENGINEDIR=\"$(enginedir)\" \
|
||||
-DTHEMEDIR=\"$(themedir)\" \
|
||||
-DDEFAULT_THEME=\"nyz\" \
|
||||
-DG_LOG_DOMAIN=\"Openbox-Engine\"
|
||||
|
||||
engine_LTLIBRARIES=openbox.la
|
||||
|
||||
openbox_la_LDFLAGS=-module -avoid-version
|
||||
openbox_la_SOURCES=openbox.c theme.c
|
||||
|
||||
noinst_HEADERS=
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
distclean-local:
|
||||
$(RM) *\~ *.orig *.rej .\#*
|
829
engines/openbox/openbox.c
Normal file
829
engines/openbox/openbox.c
Normal file
|
@ -0,0 +1,829 @@
|
|||
#include "theme.h"
|
||||
#include "../../kernel/openbox.h"
|
||||
#include "../../kernel/screen.h"
|
||||
#include "../../kernel/extensions.h"
|
||||
#include "../../kernel/themerc.h"
|
||||
#include "../../kernel/frame.h"
|
||||
#include "../../render/render.h"
|
||||
#include "../../render/color.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define TITLE_HEIGHT (s_font_height + s_bevel * 2)
|
||||
#define LABEL_HEIGHT (s_font_height)
|
||||
#define HANDLE_Y(f) (f->innersize.top + f->frame.client->area.height + \
|
||||
f->cbwidth)
|
||||
#define BUTTON_SIZE (LABEL_HEIGHT - 2)
|
||||
#define GRIP_WIDTH (BUTTON_SIZE * 2)
|
||||
#define HANDLE_WIDTH(f) (f->width - (GRIP_WIDTH + f->bwidth) * 2)
|
||||
|
||||
#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
|
||||
#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
|
||||
|
||||
/* style settings - geometry */
|
||||
int s_font_height;
|
||||
int s_bevel;
|
||||
int s_handle_height;
|
||||
int s_bwidth;
|
||||
int s_cbwidth;
|
||||
/* style settings - colors */
|
||||
color_rgb *s_b_color;
|
||||
color_rgb *s_cb_focused_color;
|
||||
color_rgb *s_cb_unfocused_color;
|
||||
|
||||
/* global appearances */
|
||||
Appearance *a_focused_unpressed_max;
|
||||
Appearance *a_focused_pressed_max;
|
||||
Appearance *a_unfocused_unpressed_max;
|
||||
Appearance *a_unfocused_pressed_max;
|
||||
Appearance *a_focused_unpressed_close;
|
||||
Appearance *a_focused_pressed_close;
|
||||
Appearance *a_unfocused_unpressed_close;
|
||||
Appearance *a_unfocused_pressed_close;
|
||||
Appearance *a_focused_unpressed_desk;
|
||||
Appearance *a_focused_pressed_desk;
|
||||
Appearance *a_unfocused_unpressed_desk;
|
||||
Appearance *a_unfocused_pressed_desk;
|
||||
Appearance *a_focused_unpressed_iconify;
|
||||
Appearance *a_focused_pressed_iconify;
|
||||
Appearance *a_unfocused_unpressed_iconify;
|
||||
Appearance *a_unfocused_pressed_iconify;
|
||||
Appearance *a_focused_grip;
|
||||
Appearance *a_unfocused_grip;
|
||||
Appearance *a_focused_title;
|
||||
Appearance *a_unfocused_title;
|
||||
Appearance *a_focused_label;
|
||||
Appearance *a_unfocused_label;
|
||||
Appearance *a_icon; /* always parentrelative, so no focused/unfocused */
|
||||
Appearance *a_focused_handle;
|
||||
Appearance *a_unfocused_handle;
|
||||
|
||||
typedef struct ObFrame {
|
||||
Frame frame;
|
||||
|
||||
Window title;
|
||||
Window label;
|
||||
Window max;
|
||||
Window close;
|
||||
Window desk;
|
||||
Window icon;
|
||||
Window iconify;
|
||||
Window handle;
|
||||
Window lgrip;
|
||||
Window rgrip;
|
||||
|
||||
Appearance *a_unfocused_title;
|
||||
Appearance *a_focused_title;
|
||||
Appearance *a_unfocused_label;
|
||||
Appearance *a_focused_label;
|
||||
Appearance *a_icon;
|
||||
Appearance *a_unfocused_handle;
|
||||
Appearance *a_focused_handle;
|
||||
|
||||
Strut innersize;
|
||||
|
||||
GSList *clients;
|
||||
|
||||
int width; /* title and handle */
|
||||
int label_width;
|
||||
int icon_x; /* x-position of the window icon button */
|
||||
int label_x; /* x-position of the window title */
|
||||
int iconify_x; /* x-position of the window iconify button */
|
||||
int desk_x; /* x-position of the window all-desktops button */
|
||||
int max_x; /* x-position of the window maximize button */
|
||||
int close_x; /* x-position of the window close button */
|
||||
int bwidth; /* border width */
|
||||
int cbwidth; /* client border width */
|
||||
|
||||
gboolean max_press;
|
||||
gboolean close_press;
|
||||
gboolean desk_press;
|
||||
gboolean iconify_press;
|
||||
} ObFrame;
|
||||
|
||||
static void layout_title(ObFrame *self);
|
||||
static void render(ObFrame *self);
|
||||
static void render_label(ObFrame *self);
|
||||
static void render_max(ObFrame *self);
|
||||
static void render_icon(ObFrame *self);
|
||||
static void render_iconify(ObFrame *self);
|
||||
static void render_desk(ObFrame *self);
|
||||
static void render_close(ObFrame *self);
|
||||
|
||||
gboolean startup()
|
||||
{
|
||||
g_quark_from_string("none");
|
||||
g_quark_from_string("root");
|
||||
g_quark_from_string("client");
|
||||
g_quark_from_string("titlebar");
|
||||
g_quark_from_string("handle");
|
||||
g_quark_from_string("frame");
|
||||
g_quark_from_string("blcorner");
|
||||
g_quark_from_string("brcorner");
|
||||
g_quark_from_string("maximize");
|
||||
g_quark_from_string("alldesktops");
|
||||
g_quark_from_string("iconify");
|
||||
g_quark_from_string("icon");
|
||||
g_quark_from_string("close");
|
||||
|
||||
s_b_color = s_cb_unfocused_color = s_cb_focused_color = NULL;
|
||||
|
||||
a_focused_unpressed_max = appearance_new(Surface_Planar, 0);//1);
|
||||
a_focused_pressed_max = appearance_new(Surface_Planar, 0);//1);
|
||||
a_unfocused_unpressed_max = appearance_new(Surface_Planar, 0);//1);
|
||||
a_unfocused_pressed_max = appearance_new(Surface_Planar, 0);//1);
|
||||
a_focused_unpressed_close = NULL;
|
||||
a_focused_pressed_close = NULL;
|
||||
a_unfocused_unpressed_close = NULL;
|
||||
a_unfocused_pressed_close = NULL;
|
||||
a_focused_unpressed_desk = NULL;
|
||||
a_focused_pressed_desk = NULL;
|
||||
a_unfocused_unpressed_desk = NULL;
|
||||
a_unfocused_pressed_desk = NULL;
|
||||
a_focused_unpressed_iconify = NULL;
|
||||
a_focused_pressed_iconify = NULL;
|
||||
a_unfocused_unpressed_iconify = NULL;
|
||||
a_unfocused_pressed_iconify = NULL;
|
||||
a_focused_grip = appearance_new(Surface_Planar, 0);
|
||||
a_unfocused_grip = appearance_new(Surface_Planar, 0);
|
||||
a_focused_title = appearance_new(Surface_Planar, 0);
|
||||
a_unfocused_title = appearance_new(Surface_Planar, 0);
|
||||
a_focused_label = appearance_new(Surface_Planar, 0);//1);
|
||||
a_unfocused_label = appearance_new(Surface_Planar, 0);//1);
|
||||
a_icon = appearance_new(Surface_Planar, 0);//1);
|
||||
a_focused_handle = appearance_new(Surface_Planar, 0);
|
||||
a_unfocused_handle = appearance_new(Surface_Planar, 0);
|
||||
|
||||
return load();
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
if (s_b_color != NULL) color_free(s_b_color);
|
||||
if (s_cb_unfocused_color != NULL) color_free(s_cb_unfocused_color);
|
||||
if (s_cb_focused_color != NULL) color_free(s_cb_focused_color);
|
||||
|
||||
appearance_free(a_focused_unpressed_max);
|
||||
appearance_free(a_focused_pressed_max);
|
||||
appearance_free(a_unfocused_unpressed_max);
|
||||
appearance_free(a_unfocused_pressed_max);
|
||||
if (a_focused_unpressed_close != NULL)
|
||||
appearance_free(a_focused_unpressed_close);
|
||||
if (a_focused_pressed_close != NULL)
|
||||
appearance_free(a_focused_pressed_close);
|
||||
if (a_unfocused_unpressed_close != NULL)
|
||||
appearance_free(a_unfocused_unpressed_close);
|
||||
if (a_unfocused_pressed_close != NULL)
|
||||
appearance_free(a_unfocused_pressed_close);
|
||||
if (a_focused_unpressed_desk != NULL)
|
||||
appearance_free(a_focused_unpressed_desk);
|
||||
if (a_focused_pressed_desk != NULL)
|
||||
appearance_free(a_focused_pressed_desk);
|
||||
if (a_unfocused_unpressed_desk != NULL)
|
||||
appearance_free(a_unfocused_unpressed_desk);
|
||||
if (a_unfocused_pressed_desk != NULL)
|
||||
appearance_free(a_unfocused_pressed_desk);
|
||||
if (a_focused_unpressed_iconify != NULL)
|
||||
appearance_free(a_focused_unpressed_iconify);
|
||||
if (a_focused_pressed_iconify != NULL)
|
||||
appearance_free(a_focused_pressed_iconify);
|
||||
if (a_unfocused_unpressed_iconify != NULL)
|
||||
appearance_free(a_unfocused_unpressed_iconify);
|
||||
if (a_unfocused_pressed_iconify != NULL)
|
||||
appearance_free(a_unfocused_pressed_iconify);
|
||||
appearance_free(a_focused_grip);
|
||||
appearance_free(a_unfocused_grip);
|
||||
appearance_free(a_focused_title);
|
||||
appearance_free(a_unfocused_title);
|
||||
appearance_free(a_focused_label);
|
||||
appearance_free(a_unfocused_label);
|
||||
appearance_free(a_icon);
|
||||
appearance_free(a_focused_handle);
|
||||
appearance_free(a_unfocused_handle);
|
||||
}
|
||||
|
||||
static Window createWindow(Window parent, unsigned long mask,
|
||||
XSetWindowAttributes *attrib)
|
||||
{
|
||||
/* XXX DONT USE THE DEFAULT SHIT */
|
||||
return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
|
||||
DefaultDepth(ob_display, ob_screen), InputOutput,
|
||||
DefaultVisual(ob_display, ob_screen),
|
||||
mask, attrib);
|
||||
|
||||
}
|
||||
|
||||
Frame *frame_new()
|
||||
{
|
||||
XSetWindowAttributes attrib;
|
||||
unsigned long mask;
|
||||
ObFrame *self;
|
||||
|
||||
self = g_new(ObFrame, 1);
|
||||
|
||||
self->frame.visible = FALSE;
|
||||
|
||||
/* create all of the decor windows */
|
||||
mask = CWOverrideRedirect | CWEventMask;
|
||||
attrib.event_mask = FRAME_EVENTMASK;
|
||||
attrib.override_redirect = TRUE;
|
||||
self->frame.window = createWindow(ob_root, mask, &attrib);
|
||||
|
||||
mask = 0;
|
||||
self->frame.plate = createWindow(self->frame.window, mask, &attrib);
|
||||
|
||||
mask = CWEventMask;
|
||||
attrib.event_mask = (ButtonPressMask | ButtonReleaseMask |
|
||||
ButtonMotionMask | ExposureMask);
|
||||
self->title = createWindow(self->frame.window, mask, &attrib);
|
||||
self->label = createWindow(self->title, mask, &attrib);
|
||||
self->max = createWindow(self->title, mask, &attrib);
|
||||
self->close = createWindow(self->title, mask, &attrib);
|
||||
self->desk = createWindow(self->title, mask, &attrib);
|
||||
self->icon = createWindow(self->title, mask, &attrib);
|
||||
self->iconify = createWindow(self->title, mask, &attrib);
|
||||
self->handle = createWindow(self->frame.window, mask, &attrib);
|
||||
mask |= CWCursor;
|
||||
attrib.cursor = ob_cursors.ll_angle;
|
||||
self->lgrip = createWindow(self->handle, mask, &attrib);
|
||||
attrib.cursor = ob_cursors.lr_angle;
|
||||
self->rgrip = createWindow(self->handle, mask, &attrib);
|
||||
|
||||
/* the other stuff is shown based on decor settings */
|
||||
XMapWindow(ob_display, self->frame.plate);
|
||||
XMapWindow(ob_display, self->lgrip);
|
||||
XMapWindow(ob_display, self->rgrip);
|
||||
XMapWindow(ob_display, self->label);
|
||||
|
||||
/* set colors/appearance/sizes for stuff that doesn't change */
|
||||
XSetWindowBorder(ob_display, self->frame.window, s_b_color->pixel);
|
||||
XSetWindowBorder(ob_display, self->label, s_b_color->pixel);
|
||||
XSetWindowBorder(ob_display, self->rgrip, s_b_color->pixel);
|
||||
XSetWindowBorder(ob_display, self->lgrip, s_b_color->pixel);
|
||||
|
||||
XResizeWindow(ob_display, self->max, BUTTON_SIZE, BUTTON_SIZE);
|
||||
XResizeWindow(ob_display, self->iconify, BUTTON_SIZE, BUTTON_SIZE);
|
||||
XResizeWindow(ob_display, self->icon, BUTTON_SIZE, BUTTON_SIZE);
|
||||
XResizeWindow(ob_display, self->close, BUTTON_SIZE, BUTTON_SIZE);
|
||||
XResizeWindow(ob_display, self->desk, BUTTON_SIZE, BUTTON_SIZE);
|
||||
XResizeWindow(ob_display, self->lgrip, GRIP_WIDTH, s_handle_height);
|
||||
XResizeWindow(ob_display, self->rgrip, GRIP_WIDTH, s_handle_height);
|
||||
|
||||
/* set up the dynamic appearances */
|
||||
self->a_unfocused_title = appearance_copy(a_unfocused_title);
|
||||
self->a_focused_title = appearance_copy(a_focused_title);
|
||||
self->a_unfocused_label = appearance_copy(a_unfocused_label);
|
||||
self->a_focused_label = appearance_copy(a_focused_label);
|
||||
self->a_unfocused_handle = appearance_copy(a_unfocused_handle);
|
||||
self->a_focused_handle = appearance_copy(a_focused_handle);
|
||||
self->a_icon = appearance_copy(a_icon);
|
||||
|
||||
self->max_press = self->close_press = self->desk_press =
|
||||
self->iconify_press = FALSE;
|
||||
|
||||
return (Frame*)self;
|
||||
}
|
||||
|
||||
static void frame_free(ObFrame *self)
|
||||
{
|
||||
appearance_free(self->a_unfocused_title);
|
||||
appearance_free(self->a_focused_title);
|
||||
appearance_free(self->a_unfocused_label);
|
||||
appearance_free(self->a_focused_label);
|
||||
appearance_free(self->a_unfocused_handle);
|
||||
appearance_free(self->a_focused_handle);
|
||||
appearance_free(self->a_icon);
|
||||
|
||||
XDestroyWindow(ob_display, self->frame.window);
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
void frame_show(ObFrame *self)
|
||||
{
|
||||
if (!self->frame.visible) {
|
||||
self->frame.visible = TRUE;
|
||||
XMapWindow(ob_display, self->frame.window);
|
||||
}
|
||||
}
|
||||
|
||||
void frame_hide(ObFrame *self)
|
||||
{
|
||||
if (self->frame.visible) {
|
||||
self->frame.visible = FALSE;
|
||||
self->frame.client->ignore_unmaps++;
|
||||
XUnmapWindow(ob_display, self->frame.window);
|
||||
}
|
||||
}
|
||||
|
||||
void frame_adjust_shape(ObFrame *self)
|
||||
{
|
||||
#ifdef SHAPE
|
||||
int num;
|
||||
XRectangle xrect[2];
|
||||
|
||||
if (!self->frame.client->shaped) {
|
||||
/* clear the shape on the frame window */
|
||||
XShapeCombineMask(ob_display, self->frame.window, ShapeBounding,
|
||||
self->innersize.left,
|
||||
self->innersize.top,
|
||||
None, ShapeSet);
|
||||
} else {
|
||||
/* make the frame's shape match the clients */
|
||||
XShapeCombineShape(ob_display, self->frame.window, ShapeBounding,
|
||||
self->innersize.left,
|
||||
self->innersize.top,
|
||||
self->frame.client->window,
|
||||
ShapeBounding, ShapeSet);
|
||||
|
||||
num = 0;
|
||||
if (self->frame.client->decorations & Decor_Titlebar) {
|
||||
xrect[0].x = -s_bevel;
|
||||
xrect[0].y = -s_bevel;
|
||||
xrect[0].width = self->width + self->bwidth * 2;
|
||||
xrect[0].height = TITLE_HEIGHT +
|
||||
self->bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
if (self->frame.client->decorations & Decor_Handle) {
|
||||
xrect[1].x = -s_bevel;
|
||||
xrect[1].y = HANDLE_Y(self);
|
||||
xrect[1].width = self->width + self->bwidth * 2;
|
||||
xrect[1].height = s_handle_height +
|
||||
self->bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
XShapeCombineRectangles(ob_display, self->frame.window,
|
||||
ShapeBounding, 0, 0, xrect, num,
|
||||
ShapeUnion, Unsorted);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void frame_adjust_size(ObFrame *self)
|
||||
{
|
||||
if (self->frame.client->decorations & Decor_Border) {
|
||||
self->bwidth = s_bwidth;
|
||||
self->cbwidth = s_cbwidth;
|
||||
} else {
|
||||
self->bwidth = self->cbwidth = 0;
|
||||
}
|
||||
STRUT_SET(self->innersize, self->cbwidth, self->cbwidth,
|
||||
self->cbwidth, self->cbwidth);
|
||||
self->width = self->frame.client->area.width + self->cbwidth * 2;
|
||||
g_assert(self->width > 0);
|
||||
|
||||
/* set border widths */
|
||||
XSetWindowBorderWidth(ob_display, self->frame.plate, self->cbwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->frame.window, self->bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->title, self->bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->handle, self->bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->lgrip, self->bwidth);
|
||||
XSetWindowBorderWidth(ob_display, self->rgrip, self->bwidth);
|
||||
|
||||
/* position/size and map/unmap all the windows */
|
||||
|
||||
if (self->frame.client->decorations & Decor_Titlebar) {
|
||||
XMoveResizeWindow(ob_display, self->title,
|
||||
-self->bwidth, -self->bwidth,
|
||||
self->width, TITLE_HEIGHT);
|
||||
self->innersize.top += TITLE_HEIGHT + self->bwidth;
|
||||
XMapWindow(ob_display, self->title);
|
||||
|
||||
/* layout the title bar elements */
|
||||
layout_title(self);
|
||||
} else {
|
||||
XUnmapWindow(ob_display, self->title);
|
||||
/* make all the titlebar stuff not render */
|
||||
self->frame.client->decorations &= ~(Decor_Icon | Decor_Iconify |
|
||||
Decor_Maximize | Decor_Close |
|
||||
Decor_AllDesktops);
|
||||
}
|
||||
|
||||
if (self->frame.client->decorations & Decor_Handle) {
|
||||
XMoveResizeWindow(ob_display, self->handle,
|
||||
-self->bwidth, HANDLE_Y(self),
|
||||
self->width, s_handle_height);
|
||||
XMoveWindow(ob_display, self->lgrip,
|
||||
-self->bwidth, -self->bwidth);
|
||||
XMoveWindow(ob_display, self->rgrip,
|
||||
-self->bwidth + self->width -
|
||||
GRIP_WIDTH, -self->bwidth);
|
||||
self->innersize.bottom += s_handle_height +
|
||||
self->bwidth;
|
||||
XMapWindow(ob_display, self->handle);
|
||||
} else
|
||||
XUnmapWindow(ob_display, self->handle);
|
||||
|
||||
XResizeWindow(ob_display, self->frame.window, self->width,
|
||||
(self->frame.client->shaded ? TITLE_HEIGHT :
|
||||
self->innersize.top + self->innersize.bottom +
|
||||
self->frame.client->area.height));
|
||||
|
||||
/* do this in two steps because clients whose gravity is set to
|
||||
'Static' don't end up getting moved at all with an XMoveResizeWindow */
|
||||
XMoveWindow(ob_display, self->frame.plate,
|
||||
self->innersize.left - self->cbwidth,
|
||||
self->innersize.top - self->cbwidth);
|
||||
XResizeWindow(ob_display, self->frame.plate,
|
||||
self->frame.client->area.width,
|
||||
self->frame.client->area.height);
|
||||
|
||||
STRUT_SET(self->frame.size,
|
||||
self->innersize.left + self->bwidth,
|
||||
self->innersize.top + self->bwidth,
|
||||
self->innersize.right + self->bwidth,
|
||||
self->innersize.bottom + self->bwidth);
|
||||
|
||||
RECT_SET_SIZE(self->frame.area,
|
||||
self->frame.client->area.width +
|
||||
self->frame.size.left + self->frame.size.right,
|
||||
self->frame.client->area.height +
|
||||
self->frame.size.top + self->frame.size.bottom);
|
||||
|
||||
render(self);
|
||||
|
||||
frame_adjust_shape(self);
|
||||
}
|
||||
|
||||
void frame_adjust_position(ObFrame *self)
|
||||
{
|
||||
self->frame.area.x = self->frame.client->area.x;
|
||||
self->frame.area.y = self->frame.client->area.y;
|
||||
frame_client_gravity((Frame*)self,
|
||||
&self->frame.area.x, &self->frame.area.y);
|
||||
XMoveWindow(ob_display, self->frame.window,
|
||||
self->frame.area.x, self->frame.area.y);
|
||||
}
|
||||
|
||||
void frame_adjust_state(ObFrame *self)
|
||||
{
|
||||
render_max(self);
|
||||
render_desk(self);
|
||||
}
|
||||
|
||||
void frame_adjust_focus(ObFrame *self)
|
||||
{
|
||||
render(self);
|
||||
}
|
||||
|
||||
void frame_adjust_title(ObFrame *self)
|
||||
{
|
||||
render_label(self);
|
||||
}
|
||||
|
||||
void frame_adjust_icon(ObFrame *self)
|
||||
{
|
||||
render_icon(self);
|
||||
}
|
||||
|
||||
void frame_grab_client(ObFrame *self, Client *client)
|
||||
{
|
||||
self->frame.client = client;
|
||||
|
||||
/* reparent the client to the frame */
|
||||
XReparentWindow(ob_display, client->window, self->frame.plate, 0, 0);
|
||||
/*
|
||||
When reparenting the client window, it is usually not mapped yet, since
|
||||
this occurs from a MapRequest. However, in the case where Openbox is
|
||||
starting up, the window is already mapped, so we'll see unmap events for
|
||||
it. There are 2 unmap events generated that we see, one with the 'event'
|
||||
member set the root window, and one set to the client, but both get
|
||||
handled and need to be ignored.
|
||||
*/
|
||||
if (ob_state == State_Starting)
|
||||
client->ignore_unmaps += 2;
|
||||
|
||||
/* select the event mask on the client's parent (to receive config/map
|
||||
req's) the ButtonPress is to catch clicks on the client border */
|
||||
XSelectInput(ob_display, self->frame.plate, PLATE_EVENTMASK);
|
||||
|
||||
/* map the client so it maps when the frame does */
|
||||
XMapWindow(ob_display, client->window);
|
||||
|
||||
frame_adjust_size(self);
|
||||
frame_adjust_position(self);
|
||||
|
||||
/* set all the windows for the frame in the client_map */
|
||||
g_hash_table_insert(client_map, (gpointer)self->frame.window, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->frame.plate, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->title, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->label, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->max, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->close, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->desk, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->icon, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->iconify, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->handle, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->lgrip, client);
|
||||
g_hash_table_insert(client_map, (gpointer)self->rgrip, client);
|
||||
}
|
||||
|
||||
void frame_release_client(ObFrame *self, Client *client)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
g_assert(self->frame.client == client);
|
||||
|
||||
/* check if the app has already reparented its window away */
|
||||
if (XCheckTypedWindowEvent(ob_display, client->window,
|
||||
ReparentNotify, &ev)) {
|
||||
XPutBackEvent(ob_display, &ev);
|
||||
/* re-map the window since the unmanaging process unmaps it */
|
||||
XMapWindow(ob_display, client->window);
|
||||
} else {
|
||||
/* according to the ICCCM - if the client doesn't reparent itself,
|
||||
then we will reparent the window to root for them */
|
||||
XReparentWindow(ob_display, client->window, ob_root,
|
||||
client->area.x,
|
||||
client->area.y);
|
||||
}
|
||||
|
||||
/* remove all the windows for the frame from the client_map */
|
||||
g_hash_table_remove(client_map, (gpointer)self->frame.window);
|
||||
g_hash_table_remove(client_map, (gpointer)self->frame.plate);
|
||||
g_hash_table_remove(client_map, (gpointer)self->title);
|
||||
g_hash_table_remove(client_map, (gpointer)self->label);
|
||||
g_hash_table_remove(client_map, (gpointer)self->max);
|
||||
g_hash_table_remove(client_map, (gpointer)self->close);
|
||||
g_hash_table_remove(client_map, (gpointer)self->desk);
|
||||
g_hash_table_remove(client_map, (gpointer)self->icon);
|
||||
g_hash_table_remove(client_map, (gpointer)self->iconify);
|
||||
g_hash_table_remove(client_map, (gpointer)self->handle);
|
||||
g_hash_table_remove(client_map, (gpointer)self->lgrip);
|
||||
g_hash_table_remove(client_map, (gpointer)self->rgrip);
|
||||
|
||||
frame_free(self);
|
||||
}
|
||||
|
||||
static void layout_title(ObFrame *self)
|
||||
{
|
||||
const char *lc;
|
||||
int x;
|
||||
gboolean n, d, i, l, m ,c;
|
||||
n = d = i = l = m = c = FALSE;
|
||||
|
||||
/* figure out whats being shown, and the width of the label */
|
||||
self->label_width = self->width - s_bevel * 2;
|
||||
for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
|
||||
switch (*lc) {
|
||||
case 'N':
|
||||
if (!(self->frame.client->decorations & Decor_Icon)) break;
|
||||
n = TRUE;
|
||||
self->label_width -= BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'D':
|
||||
if (!(self->frame.client->decorations & Decor_AllDesktops)) break;
|
||||
d = TRUE;
|
||||
self->label_width -= BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'I':
|
||||
if (!(self->frame.client->decorations & Decor_Iconify)) break;
|
||||
i = TRUE;
|
||||
self->label_width -= BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'L':
|
||||
l = TRUE;
|
||||
break;
|
||||
case 'M':
|
||||
if (!(self->frame.client->decorations & Decor_Maximize)) break;
|
||||
m = TRUE;
|
||||
self->label_width -= BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'C':
|
||||
if (!(self->frame.client->decorations & Decor_Close)) break;
|
||||
c = TRUE;
|
||||
self->label_width -= BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (self->label_width < 1) self->label_width = 1;
|
||||
|
||||
XResizeWindow(ob_display, self->label, self->label_width, s_font_height);
|
||||
|
||||
if (!n) {
|
||||
self->frame.client->decorations &= ~Decor_Icon;
|
||||
XUnmapWindow(ob_display, self->icon);
|
||||
self->icon_x = -1;
|
||||
}
|
||||
if (!d) {
|
||||
self->frame.client->decorations &= ~Decor_AllDesktops;
|
||||
XUnmapWindow(ob_display, self->desk);
|
||||
self->desk_x = -1;
|
||||
}
|
||||
if (!i) {
|
||||
self->frame.client->decorations &= ~Decor_Iconify;
|
||||
XUnmapWindow(ob_display, self->iconify);
|
||||
self->icon_x = -1;
|
||||
}
|
||||
if (!l) {
|
||||
XUnmapWindow(ob_display, self->label);
|
||||
self->label_x = -1;
|
||||
}
|
||||
if (!m) {
|
||||
self->frame.client->decorations &= ~Decor_Maximize;
|
||||
XUnmapWindow(ob_display, self->max);
|
||||
self->max_x = -1;
|
||||
}
|
||||
if (!c) {
|
||||
self->frame.client->decorations &= ~Decor_Close;
|
||||
XUnmapWindow(ob_display, self->close);
|
||||
self->close_x = -1;
|
||||
}
|
||||
|
||||
x = s_bevel;
|
||||
for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
|
||||
switch (*lc) {
|
||||
case 'N':
|
||||
if (!n) break;
|
||||
self->icon_x = x;
|
||||
XMapWindow(ob_display, self->icon);
|
||||
XMoveWindow(ob_display, self->icon, x, s_bevel + 1);
|
||||
x += BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'D':
|
||||
if (!d) break;
|
||||
self->desk_x = x;
|
||||
XMapWindow(ob_display, self->desk);
|
||||
XMoveWindow(ob_display, self->desk, x, s_bevel + 1);
|
||||
x += BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'I':
|
||||
if (!i) break;
|
||||
self->iconify_x = x;
|
||||
XMapWindow(ob_display, self->iconify);
|
||||
XMoveWindow(ob_display, self->iconify, x, s_bevel + 1);
|
||||
x += BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'L':
|
||||
if (!l) break;
|
||||
self->label_x = x;
|
||||
XMapWindow(ob_display, self->label);
|
||||
XMoveWindow(ob_display, self->label, x, s_bevel);
|
||||
x += self->label_width + s_bevel;
|
||||
break;
|
||||
case 'M':
|
||||
if (!m) break;
|
||||
self->max_x = x;
|
||||
XMapWindow(ob_display, self->max);
|
||||
XMoveWindow(ob_display, self->max, x, s_bevel + 1);
|
||||
x += BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
case 'C':
|
||||
if (!c) break;
|
||||
self->close_x = x;
|
||||
XMapWindow(ob_display, self->close);
|
||||
XMoveWindow(ob_display, self->close, x, s_bevel + 1);
|
||||
x += BUTTON_SIZE + s_bevel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void render(ObFrame *self)
|
||||
{
|
||||
if (self->frame.client->focused) {
|
||||
XSetWindowBorder(ob_display, self->frame.plate,
|
||||
s_cb_focused_color->pixel);
|
||||
} else {
|
||||
XSetWindowBorder(ob_display, self->frame.plate,
|
||||
s_cb_unfocused_color->pixel);
|
||||
}
|
||||
|
||||
if (self->frame.client->decorations & Decor_Titlebar) {
|
||||
paint(self->title, (self->frame.client->focused ?
|
||||
self->a_focused_title :
|
||||
self->a_unfocused_title),
|
||||
self->width, TITLE_HEIGHT);
|
||||
render_label(self);
|
||||
render_max(self);
|
||||
render_icon(self);
|
||||
render_iconify(self);
|
||||
render_desk(self);
|
||||
render_close(self);
|
||||
}
|
||||
|
||||
if (self->frame.client->decorations & Decor_Handle) {
|
||||
paint(self->handle, (self->frame.client->focused ?
|
||||
self->a_focused_handle :
|
||||
self->a_unfocused_handle),
|
||||
HANDLE_WIDTH(self), s_handle_height);
|
||||
paint(self->lgrip, (self->frame.client->focused ?
|
||||
a_focused_grip :
|
||||
a_unfocused_grip),
|
||||
GRIP_WIDTH, s_handle_height);
|
||||
paint(self->rgrip, (self->frame.client->focused ?
|
||||
a_focused_grip :
|
||||
a_unfocused_grip),
|
||||
GRIP_WIDTH, s_handle_height);
|
||||
}
|
||||
}
|
||||
|
||||
static void render_label(ObFrame *self)
|
||||
{
|
||||
if (self->label_x < 0) return;
|
||||
|
||||
/* XXX set the texture's text! */
|
||||
paint(self->label, (self->frame.client->focused ?
|
||||
self->a_focused_label :
|
||||
self->a_unfocused_label),
|
||||
self->label_width, LABEL_HEIGHT);
|
||||
}
|
||||
|
||||
static void render_icon(ObFrame *self)
|
||||
{
|
||||
if (self->icon_x < 0) return;
|
||||
|
||||
/* XXX set the texture's icon picture! */
|
||||
paint(self->icon, self->a_icon, BUTTON_SIZE, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
static void render_max(ObFrame *self)
|
||||
{
|
||||
gboolean press = self->max_press ||
|
||||
self->frame.client->max_vert || self->frame.client->max_horz;
|
||||
|
||||
if (self->max_x < 0) return;
|
||||
|
||||
paint(self->max, (self->frame.client->focused ?
|
||||
(press ?
|
||||
a_focused_pressed_max :
|
||||
a_focused_unpressed_max) :
|
||||
(press ?
|
||||
a_unfocused_pressed_max :
|
||||
a_unfocused_unpressed_max)),
|
||||
BUTTON_SIZE, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
static void render_iconify(ObFrame *self)
|
||||
{
|
||||
if (self->iconify_x < 0) return;
|
||||
|
||||
paint(self->iconify, (self->frame.client->focused ?
|
||||
(self->iconify_press ?
|
||||
a_focused_pressed_iconify :
|
||||
a_focused_unpressed_iconify) :
|
||||
(self->iconify_press ?
|
||||
a_unfocused_pressed_iconify :
|
||||
a_unfocused_unpressed_iconify)),
|
||||
BUTTON_SIZE, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
static void render_desk(ObFrame *self)
|
||||
{
|
||||
gboolean press = self->desk_press ||
|
||||
self->frame.client->desktop == DESKTOP_ALL;
|
||||
|
||||
if (self->desk_x < 0) return;
|
||||
|
||||
paint(self->desk, (self->frame.client->focused ?
|
||||
(press ?
|
||||
a_focused_pressed_desk :
|
||||
a_focused_unpressed_desk) :
|
||||
(press ?
|
||||
a_unfocused_pressed_desk :
|
||||
a_unfocused_unpressed_desk)),
|
||||
BUTTON_SIZE, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
static void render_close(ObFrame *self)
|
||||
{
|
||||
if (self->close_x < 0) return;
|
||||
|
||||
paint(self->close, (self->frame.client->focused ?
|
||||
(self->close_press ?
|
||||
a_focused_pressed_close :
|
||||
a_focused_unpressed_close) :
|
||||
(self->close_press ?
|
||||
a_unfocused_pressed_close :
|
||||
a_unfocused_unpressed_close)),
|
||||
BUTTON_SIZE, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
GQuark get_context(Client *client, Window win)
|
||||
{
|
||||
ObFrame *self;
|
||||
|
||||
if (win == ob_root) return g_quark_try_string("root");
|
||||
if (client == NULL) return g_quark_try_string("none");
|
||||
if (win == client->window) return g_quark_try_string("client");
|
||||
|
||||
self = (ObFrame*) client->frame;
|
||||
if (win == self->frame.window) return g_quark_try_string("frame");
|
||||
if (win == self->frame.plate) return g_quark_try_string("client");
|
||||
if (win == self->title) return g_quark_try_string("titlebar");
|
||||
if (win == self->label) return g_quark_try_string("titlebar");
|
||||
if (win == self->handle) return g_quark_try_string("handle");
|
||||
if (win == self->lgrip) return g_quark_try_string("blcorner");
|
||||
if (win == self->rgrip) return g_quark_try_string("brcorner");
|
||||
if (win == self->max) return g_quark_try_string("maximize");
|
||||
if (win == self->iconify) return g_quark_try_string("iconify");
|
||||
if (win == self->close) return g_quark_try_string("close");
|
||||
if (win == self->icon) return g_quark_try_string("icon");
|
||||
if (win == self->desk) return g_quark_try_string("alldesktops");
|
||||
|
||||
return g_quark_try_string("none");
|
||||
}
|
43
engines/openbox/openbox.h
Normal file
43
engines/openbox/openbox.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef __engine_openbox_h
|
||||
#define __engine_openbox_h
|
||||
|
||||
#include "../../render/render.h"
|
||||
#include "../../render/color.h"
|
||||
|
||||
extern int s_font_height;
|
||||
extern int s_bevel;
|
||||
extern int s_handle_height;
|
||||
extern int s_bwidth;
|
||||
extern int s_cbwidth;
|
||||
|
||||
extern color_rgb *s_b_color;
|
||||
extern color_rgb *s_cb_focused_color;
|
||||
extern color_rgb *s_cb_unfocused_color;
|
||||
|
||||
extern Appearance *a_focused_unpressed_max;
|
||||
extern Appearance *a_focused_pressed_max;
|
||||
extern Appearance *a_unfocused_unpressed_max;
|
||||
extern Appearance *a_unfocused_pressed_max;
|
||||
extern Appearance *a_focused_unpressed_close;
|
||||
extern Appearance *a_focused_pressed_close;
|
||||
extern Appearance *a_unfocused_unpressed_close;
|
||||
extern Appearance *a_unfocused_pressed_close;
|
||||
extern Appearance *a_focused_unpressed_desk;
|
||||
extern Appearance *a_focused_pressed_desk;
|
||||
extern Appearance *a_unfocused_unpressed_desk;
|
||||
extern Appearance *a_unfocused_pressed_desk;
|
||||
extern Appearance *a_focused_unpressed_iconify;
|
||||
extern Appearance *a_focused_pressed_iconify;
|
||||
extern Appearance *a_unfocused_unpressed_iconify;
|
||||
extern Appearance *a_unfocused_pressed_iconify;
|
||||
extern Appearance *a_focused_grip;
|
||||
extern Appearance *a_unfocused_grip;
|
||||
extern Appearance *a_focused_title;
|
||||
extern Appearance *a_unfocused_title;
|
||||
extern Appearance *a_focused_label;
|
||||
extern Appearance *a_unfocused_label;
|
||||
extern Appearance *a_icon;
|
||||
extern Appearance *a_focused_handle;
|
||||
extern Appearance *a_unfocused_handle;
|
||||
|
||||
#endif
|
327
engines/openbox/theme.c
Normal file
327
engines/openbox/theme.c
Normal file
|
@ -0,0 +1,327 @@
|
|||
#include "openbox.h"
|
||||
#include "../../kernel/themerc.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
static XrmDatabase loaddb(char *theme)
|
||||
{
|
||||
XrmDatabase db;
|
||||
|
||||
db = XrmGetFileDatabase(theme);
|
||||
if (db == NULL) {
|
||||
char *s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
|
||||
"openbox", theme, NULL);
|
||||
db = XrmGetFileDatabase(s);
|
||||
g_free(s);
|
||||
}
|
||||
if (db == NULL) {
|
||||
char *s = g_build_filename(THEMEDIR, theme, NULL);
|
||||
db = XrmGetFileDatabase(s);
|
||||
g_free(s);
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
static char *create_class_name(char *rname)
|
||||
{
|
||||
char *rclass = g_strdup(rname);
|
||||
char *p = rclass;
|
||||
|
||||
while (TRUE) {
|
||||
*p = toupper(*p);
|
||||
p = strchr(p+1, '.');
|
||||
if (p == NULL) break;
|
||||
++p;
|
||||
if (*p == '\0') break;
|
||||
}
|
||||
return rclass;
|
||||
}
|
||||
|
||||
gboolean read_bool(XrmDatabase db, char *rname, gboolean *value)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *rclass = create_class_name(rname);
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
|
||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||
retvalue.addr != NULL) {
|
||||
if (!g_ascii_strcasecmp(retvalue.addr, "true"))
|
||||
*value = TRUE;
|
||||
else
|
||||
*value = FALSE;
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_free(rclass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean read_int(XrmDatabase db, char *rname, int *value)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *rclass = create_class_name(rname);
|
||||
char *rettype, *end;
|
||||
XrmValue retvalue;
|
||||
|
||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||
retvalue.addr != NULL) {
|
||||
*value = (int)strtol(retvalue.addr, &end, 10);
|
||||
if (end != retvalue.addr)
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_free(rclass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean read_string(XrmDatabase db, char *rname, char **value)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *rclass = create_class_name(rname);
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
|
||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||
retvalue.addr != NULL) {
|
||||
*value = retvalue.addr;
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_free(rclass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *rclass = create_class_name(rname);
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
|
||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||
retvalue.addr != NULL) {
|
||||
color_rgb *c = color_parse(retvalue.addr);
|
||||
if (c != NULL) {
|
||||
*value = c;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(rclass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void parse_appearance(char *tex, SurfaceColorType *grad,
|
||||
ReliefType *relief, BevelType *bevel,
|
||||
gboolean *interlaced, gboolean *border)
|
||||
{
|
||||
char *t;
|
||||
|
||||
/* convert to all lowercase */
|
||||
for (t = tex; *t != '\0'; ++t)
|
||||
*t = g_ascii_tolower(*t);
|
||||
|
||||
if (strstr(tex, "parentrelative") != NULL) {
|
||||
*grad = Background_ParentRelative;
|
||||
} else {
|
||||
if (strstr(tex, "gradient") != NULL) {
|
||||
if (strstr(tex, "crossdiagonal") != NULL)
|
||||
*grad = Background_CrossDiagonal;
|
||||
else if (strstr(tex, "rectangle") != NULL)
|
||||
*grad = Background_Rectangle;
|
||||
else if (strstr(tex, "pyramid") != NULL)
|
||||
*grad = Background_Pyramid;
|
||||
else if (strstr(tex, "pipecross") != NULL)
|
||||
*grad = Background_PipeCross;
|
||||
else if (strstr(tex, "elliptic") != NULL)
|
||||
*grad = Background_Elliptic;
|
||||
else if (strstr(tex, "horizontal") != NULL)
|
||||
*grad = Background_Horizontal;
|
||||
else if (strstr(tex, "vertical") != NULL)
|
||||
*grad = Background_Vertical;
|
||||
else
|
||||
*grad = Background_Diagonal;
|
||||
} else {
|
||||
*grad = Background_Solid;
|
||||
}
|
||||
|
||||
if (strstr(tex, "sunken") != NULL)
|
||||
*relief = Sunken;
|
||||
else if (strstr(tex, "flat") != NULL)
|
||||
*relief = Flat;
|
||||
else
|
||||
*relief = Raised;
|
||||
|
||||
*border = FALSE;
|
||||
if (*relief == Flat) {
|
||||
if (strstr(tex, "border") != NULL)
|
||||
*border = TRUE;
|
||||
} else {
|
||||
if (strstr(tex, "bevel2") != NULL)
|
||||
*bevel = Bevel2;
|
||||
else
|
||||
*bevel = Bevel1;
|
||||
}
|
||||
|
||||
if (strstr(tex, "interlaced") != NULL)
|
||||
*interlaced = TRUE;
|
||||
else
|
||||
*interlaced = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
|
||||
char *rettype;
|
||||
XrmValue retvalue;
|
||||
|
||||
cname = g_strconcat(rname, ".color", NULL);
|
||||
ctoname = g_strconcat(rname, ".colorTo", NULL);
|
||||
bcname = g_strconcat(rname, ".borderColor", NULL);
|
||||
|
||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||
retvalue.addr != NULL) {
|
||||
parse_appearance(retvalue.addr,
|
||||
&value->surface.data.planar.grad,
|
||||
&value->surface.data.planar.relief,
|
||||
&value->surface.data.planar.bevel,
|
||||
&value->surface.data.planar.interlaced,
|
||||
&value->surface.data.planar.border);
|
||||
if (!read_color(db, cname, &value->surface.data.planar.primary))
|
||||
value->surface.data.planar.primary = color_new(0, 0, 0);
|
||||
if (!read_color(db, ctoname, &value->surface.data.planar.secondary))
|
||||
value->surface.data.planar.secondary = color_new(0, 0, 0);
|
||||
if (value->surface.data.planar.border)
|
||||
if (!read_color(db, bcname,
|
||||
&value->surface.data.planar.border_color))
|
||||
value->surface.data.planar.border_color = color_new(0, 0, 0);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
g_free(bcname);
|
||||
g_free(ctoname);
|
||||
g_free(cname);
|
||||
g_free(rclass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void set_default_appearance(Appearance *a)
|
||||
{
|
||||
a->surface.data.planar.grad = Background_Solid;
|
||||
a->surface.data.planar.relief = Flat;
|
||||
a->surface.data.planar.bevel = Bevel1;
|
||||
a->surface.data.planar.interlaced = FALSE;
|
||||
a->surface.data.planar.border = FALSE;
|
||||
a->surface.data.planar.primary = color_new(0, 0, 0);
|
||||
a->surface.data.planar.secondary = color_new(0, 0, 0);
|
||||
}
|
||||
|
||||
gboolean load()
|
||||
{
|
||||
XrmDatabase db = NULL;
|
||||
|
||||
if (themerc_theme != NULL) {
|
||||
db = loaddb(themerc_theme);
|
||||
if (db == NULL) {
|
||||
g_warning("Failed to load the theme '%s'", themerc_theme);
|
||||
g_message("Falling back to the default: '%s'", DEFAULT_THEME);
|
||||
}
|
||||
}
|
||||
if (db == NULL) {
|
||||
db = loaddb(DEFAULT_THEME);
|
||||
if (db == NULL) {
|
||||
g_warning("Failed to load the theme '%s'.", DEFAULT_THEME);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX load the font, not from the theme file tho, its in themerc_font */
|
||||
s_font_height = 10;
|
||||
|
||||
if (!read_int(db, "handleWidth", &s_handle_height) ||
|
||||
s_handle_height < 0 || s_handle_height > 100) s_handle_height = 6;
|
||||
if (!read_int(db, "bevelWidth", &s_bevel) ||
|
||||
s_bevel <= 0 || s_bevel > 100) s_bevel = 3;
|
||||
if (!read_int(db, "borderWidth", &s_bwidth) ||
|
||||
s_bwidth < 0 || s_bwidth > 100) s_bwidth = 1;
|
||||
if (!read_int(db, "frameWidth", &s_cbwidth) ||
|
||||
s_cbwidth < 0 || s_cbwidth > 100) s_cbwidth = s_bevel;
|
||||
|
||||
if (!read_color(db, "borderColor", &s_b_color))
|
||||
s_b_color = color_new(0, 0, 0);
|
||||
if (!read_color(db, "window.frame.focusColor", &s_cb_focused_color))
|
||||
s_cb_focused_color = color_new(0xff, 0xff, 0xff);
|
||||
if (!read_color(db, "window.frame.unfocusColor", &s_cb_unfocused_color))
|
||||
s_cb_unfocused_color = color_new(0xff, 0xff, 0xff);
|
||||
|
||||
if (!read_appearance(db, "window.title.focus", a_focused_title))
|
||||
set_default_appearance(a_focused_title);
|
||||
if (!read_appearance(db, "window.title.unfocus", a_unfocused_title))
|
||||
set_default_appearance(a_unfocused_title);
|
||||
if (!read_appearance(db, "window.label.focus", a_focused_label))
|
||||
set_default_appearance(a_focused_label);
|
||||
if (!read_appearance(db, "window.label.unfocus", a_unfocused_label))
|
||||
set_default_appearance(a_unfocused_label);
|
||||
if (!read_appearance(db, "window.handle.focus", a_focused_handle))
|
||||
set_default_appearance(a_focused_handle);
|
||||
if (!read_appearance(db, "window.handle.unfocus", a_unfocused_handle))
|
||||
set_default_appearance(a_unfocused_handle);
|
||||
if (!read_appearance(db, "window.grip.focus", a_focused_grip))
|
||||
set_default_appearance(a_focused_grip);
|
||||
if (!read_appearance(db, "window.grip.unfocus", a_unfocused_grip))
|
||||
set_default_appearance(a_unfocused_grip);
|
||||
|
||||
if (!read_appearance(db, "window.button.pressed.focus",
|
||||
a_focused_pressed_max))
|
||||
if (!read_appearance(db, "window.button.pressed",
|
||||
a_focused_pressed_max))
|
||||
set_default_appearance(a_focused_pressed_max);
|
||||
if (!read_appearance(db, "window.button.pressed.unfocus",
|
||||
a_unfocused_pressed_max))
|
||||
if (!read_appearance(db, "window.button.pressed",
|
||||
a_unfocused_pressed_max))
|
||||
set_default_appearance(a_unfocused_pressed_max);
|
||||
if (!read_appearance(db, "window.button.focus",
|
||||
a_focused_unpressed_max))
|
||||
set_default_appearance(a_focused_unpressed_max);
|
||||
if (!read_appearance(db, "window.button.unfocus",
|
||||
a_unfocused_unpressed_max))
|
||||
set_default_appearance(a_unfocused_unpressed_max);
|
||||
|
||||
a_unfocused_unpressed_close = appearance_copy(a_unfocused_unpressed_max);
|
||||
a_unfocused_pressed_close = appearance_copy(a_unfocused_pressed_max);
|
||||
a_focused_unpressed_close = appearance_copy(a_focused_unpressed_max);
|
||||
a_focused_pressed_close = appearance_copy(a_focused_pressed_max);
|
||||
a_unfocused_unpressed_desk = appearance_copy(a_unfocused_unpressed_max);
|
||||
a_unfocused_pressed_desk = appearance_copy(a_unfocused_pressed_max);
|
||||
a_focused_unpressed_desk = appearance_copy(a_focused_unpressed_max);
|
||||
a_focused_pressed_desk = appearance_copy(a_focused_pressed_max);
|
||||
a_unfocused_unpressed_iconify = appearance_copy(a_unfocused_unpressed_max);
|
||||
a_unfocused_pressed_iconify = appearance_copy(a_unfocused_pressed_max);
|
||||
a_focused_unpressed_iconify = appearance_copy(a_focused_unpressed_max);
|
||||
a_focused_pressed_iconify = appearance_copy(a_focused_pressed_max);
|
||||
|
||||
a_icon->surface.data.planar.grad = Background_ParentRelative;
|
||||
|
||||
/* XXX load the button masks */
|
||||
|
||||
XrmDestroyDatabase(db);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
8
engines/openbox/theme.h
Normal file
8
engines/openbox/theme.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef __engine_theme_h
|
||||
#define __engine_theme_h
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
gboolean load();
|
||||
|
||||
#endif
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# Check if the user has requested a debug build.
|
||||
# Sets the DEBUG or NDEBUG variables as appropriate
|
||||
# Sets the CVS environment variable when building CVS sources.
|
||||
AC_DEFUN([OB_DEBUG],
|
||||
[
|
||||
DEBUG="no"
|
||||
|
@ -28,47 +29,55 @@ AC_DEFUN([OB_DEBUG],
|
|||
# keep the asserts in
|
||||
# AC_DEFINE([NDEBUG], [1], [Creating a release build])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(CVS, test "$CVS" = "yes")
|
||||
])
|
||||
|
||||
|
||||
# OB_COMPILER_FLAGS()
|
||||
#
|
||||
# Check what compiler is being used for compilation.
|
||||
# It sets the CXXFLAGS variable appropriately for the compiler, including flags
|
||||
# It sets the CFLAGS variable appropriately for the compiler, including flags
|
||||
# for debug builds.
|
||||
AC_DEFUN([OB_COMPILER_FLAGS],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CXXCPP])
|
||||
AC_REQUIRE([AC_PROG_CXX])
|
||||
AC_REQUIRE([AC_PROG_CPP])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
|
||||
FLAGS=""
|
||||
|
||||
# Check what compiler we are using
|
||||
AC_MSG_CHECKING([for GNU C++])
|
||||
if test "$GXX" = "yes"; then
|
||||
AC_MSG_CHECKING([for GNU CC])
|
||||
if test "$GCC" = "yes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
FLAGS="-Wall -W -fno-check-new -fno-exceptions"
|
||||
# -pedantic
|
||||
test "$DEBUG" = "yes" && FLAGS="$FLAGS -g -fno-inline"
|
||||
else
|
||||
AC_MSG_RESULT([no, trying other compilers])
|
||||
AC_MSG_CHECKING(for MIPSpro)
|
||||
mips_pro_ver=`$CXX -version 2>&1 | grep -i mipspro | cut -f4 -d ' '`
|
||||
if test -z "$mips_pro_ver"; then
|
||||
AC_MSG_RESULT([no])
|
||||
if test "$DEBUG" = "yes"; then
|
||||
FLAGS="-g -fno-inline"
|
||||
FLAGS="$FLAGS -Wall -Wsign-compare -Waggregate-return"
|
||||
FLAGS="$FLAGS -Wcast-qual -Wbad-function-cast -Wpointer-arith"
|
||||
# for Python.h
|
||||
FLAGS="$FLAGS -Wno-long-long"
|
||||
else
|
||||
AC_MSG_RESULT([yes, version $mips_pro_ver.])
|
||||
AC_MSG_CHECKING(for -LANG:std in CXXFLAGS)
|
||||
lang_std_not_set=`echo $CXXFLAGS | grep "\-LANG:std"`
|
||||
if test "x$lang_std_not_set" = "x"; then
|
||||
AC_MSG_RESULT([not set, setting.])
|
||||
FLAGS="-LANG:std"
|
||||
else
|
||||
AC_MSG_RESULT([already set.])
|
||||
fi
|
||||
FLAGS=""
|
||||
fi
|
||||
# else
|
||||
# AC_MSG_RESULT([no, trying other compilers])
|
||||
# AC_MSG_CHECKING(for MIPSpro)
|
||||
# mips_pro_ver=`$CC -version 2>&1 | grep -i mipspro | cut -f4 -d ' '`
|
||||
# if test -z "$mips_pro_ver"; then
|
||||
# AC_MSG_RESULT([no])
|
||||
# else
|
||||
# AC_MSG_RESULT([yes, version $mips_pro_ver.])
|
||||
# AC_MSG_CHECKING(for -LANG:std in CFLAGS)
|
||||
# lang_std_not_set=`echo $CFLAGS | grep "\-LANG:std"`
|
||||
# if test "x$lang_std_not_set" = "x"; then
|
||||
# AC_MSG_RESULT([not set, setting.])
|
||||
# FLAGS="-LANG:std"
|
||||
# else
|
||||
# AC_MSG_RESULT([already set.])
|
||||
# fi
|
||||
# fi
|
||||
fi
|
||||
AC_MSG_CHECKING([for compiler specific flags])
|
||||
AC_MSG_RESULT([$FLAGS])
|
||||
CXXFLAGS="$CXXFLAGS $FLAGS"
|
||||
CFLAGS="$CFLAGS $FLAGS"
|
||||
])
|
||||
|
|
90
m4/swig.m4
90
m4/swig.m4
|
@ -1,90 +0,0 @@
|
|||
# SWIG_PROG([required-version])
|
||||
#
|
||||
# Checks for the SWIG program. If found you can (and should) call SWIG via $(SWIG).
|
||||
# You can use the optional first argument to check if the version of the available SWIG
|
||||
# is greater or equal to the value of the argument. It should have the format:
|
||||
# N[.N[.N]] (N is a number between 0 and 999. Only the first N is mandatory.)
|
||||
AC_DEFUN([SWIG_PROG],[
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])
|
||||
AC_CHECK_PROG(SWIG,swig,[`which swig`])
|
||||
if test -z "$SWIG" ; then
|
||||
AC_MSG_WARN([cannot find 'swig' program])
|
||||
SWIG=false
|
||||
elif test -n "$1" ; then
|
||||
AC_MSG_CHECKING([for SWIG version])
|
||||
swig_version=`$SWIG -version 2>&1 | \
|
||||
awk '/^SWIG Version [[0-9]+\.[0-9]+\.[0-9]]+.*$/ { split($[3],a,"[[^.0-9]]"); print a[[1]] }'`
|
||||
AC_MSG_RESULT([$swig_version])
|
||||
if test -n "$swig_version" ; then
|
||||
swig_version=`echo $swig_version | \
|
||||
awk '{ split($[1],a,"\."); print [a[1]*1000000+a[2]*1000+a[3]] }' 2>/dev/null`
|
||||
swig_required_version=`echo $1 | \
|
||||
awk '{ split($[1],a,"\."); print [a[1]*1000000+a[2]*1000+a[3]] }' 2>/dev/null`
|
||||
if test $swig_required_version -gt $swig_version ; then
|
||||
AC_MSG_WARN([SWIG version $1 required])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([cannot determine SWIG version])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
# SWIG_ENABLE_CXX()
|
||||
#
|
||||
# Enable swig C++ support. This effects all invocations of $(SWIG).
|
||||
AC_DEFUN([SWIG_ENABLE_CXX],[
|
||||
AC_REQUIRE([SWIG_PROG])
|
||||
AC_REQUIRE([AC_PROG_CXX])
|
||||
if test "$SWIG" != "false" ; then
|
||||
SWIG="$SWIG -c++"
|
||||
fi
|
||||
])
|
||||
|
||||
# SWIG_MULTI_MODULE_SUPPORT()
|
||||
#
|
||||
# Enable support for multiple modules. This effects all invocations of $(SWIG).
|
||||
# You have to link all generated modules against the appropriate SWIG library.
|
||||
# If you want to build Python modules for example, use the SWIG_PYTHON() macro
|
||||
# and link the modules against $(SWIG_PYTHON_LIB). The $(SWIG_LDFLAGS) variable
|
||||
# can be used to help the linker to find this library.
|
||||
AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
|
||||
AC_REQUIRE([SWIG_PROG])
|
||||
if test "$SWIG" != "false" ; then
|
||||
SWIG="$SWIG -c"
|
||||
|
||||
# Check for SWIG library path
|
||||
AC_MSG_CHECKING([for SWIG library path])
|
||||
swig_path=${SWIG%/bin*}/lib
|
||||
swig_path=`find $swig_path -type f -name libswig*.a -o -name libswig*.so -print`
|
||||
for i in $swig_path ; do
|
||||
swig_path=${i%/libswig*}
|
||||
break
|
||||
done
|
||||
AC_MSG_RESULT([$swig_path])
|
||||
if test -n "$swig_path" ; then
|
||||
AC_SUBST(SWIG_LDFLAGS,[-L$swig_path])
|
||||
else
|
||||
AC_MSG_WARN([cannot find SWIG library path])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
# SWIG_PYTHON([use-shadow-classes])
|
||||
#
|
||||
# Checks for Python and provides the $(SWIG_PYTHON_CFLAGS), $(SWIG_PYTHON_LIB) and
|
||||
# $(SWIG_PYTHON_OPT) output variables. $(SWIG_PYTHON_OPT) contains all necessary swig
|
||||
# options to generate code for Python. Shadow classes are enabled unless the
|
||||
# value of the optional first argument is exactly 'no'. If you need multi module
|
||||
# support use $(SWIG_PYTHON_LIB) (provided by the SWIG_MULTI_MODULE_SUPPORT() macro)
|
||||
# to link against the appropriate library. It contains the SWIG Python runtime library
|
||||
# that is needed by the type check system for example.
|
||||
AC_DEFUN([SWIG_PYTHON],[
|
||||
AC_REQUIRE([SWIG_PROG])
|
||||
AC_REQUIRE([PYTHON_DEVEL])
|
||||
if test "$SWIG" != "false" ; then
|
||||
AC_SUBST(SWIG_PYTHON_LIB,[`$SWIG -python -ldflags`])
|
||||
test ! "x$1" = "xno" && swig_shadow=" -shadow" || swig_shadow=""
|
||||
AC_SUBST(SWIG_PYTHON_OPT,[-python$swig_shadow])
|
||||
fi
|
||||
AC_SUBST(SWIG_PYTHON_CFLAGS,[$PYTHON_CFLAGS])
|
||||
])
|
5
openbox/.cvsignore
Normal file
5
openbox/.cvsignore
Normal file
|
@ -0,0 +1,5 @@
|
|||
ob3
|
||||
Makefile.in
|
||||
Makefile
|
||||
.libs
|
||||
.deps
|
33
openbox/Makefile.am
Normal file
33
openbox/Makefile.am
Normal file
|
@ -0,0 +1,33 @@
|
|||
localedir=$(datadir)/locale
|
||||
themercdir=$(datadir)/openbox
|
||||
scriptdir=$(libdir)/openbox/python
|
||||
enginedir=$(libdir)/openbox/engines
|
||||
|
||||
CPPFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) $(GLIB_CFLAGS) $(GMODULE_CFLAGS) \
|
||||
@CPPFLAGS@ \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
-DTHEMERCDIR=\"$(themercdir)\" \
|
||||
-DSCRIPTDIR=\"$(scriptdir)\" \
|
||||
-DENGINEDIR=\"$(enginedir)\" \
|
||||
-DDEFAULT_ENGINE=\"openbox\" \
|
||||
-DG_LOG_DOMAIN=\"Openbox\"
|
||||
|
||||
LIBS=$(XFT_LIBS) $(PYTHON_LIBS) $(GLIB_LIBS) $(GMODULE_LIBS) @LIBS@
|
||||
|
||||
bin_PROGRAMS= ob3
|
||||
|
||||
ob3_LDADD=@LIBINTL@ ../render/librender.a
|
||||
ob3_LDFLAGS=-export-dynamic
|
||||
ob3_SOURCES=client.c event.c extensions.c focus.c frame.c openbox.c prop.c \
|
||||
python.c screen.c stacking.c xerror.c hooks.c themerc.c timer.c \
|
||||
clientwrap.c openboxwrap.c pointer.c keyboard.c engine.c
|
||||
|
||||
noinst_HEADERS=client.h event.h extensions.h focus.h frame.h geom.h gettext.h \
|
||||
openbox.h prop.h python.h screen.h stacking.h xerror.h themerc.h \
|
||||
timer.h hooks.h clientwrap.h openboxwrap.h pointer.h keyboard.h \
|
||||
engine.h
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
distclean-local:
|
||||
$(RM) *\~ *.orig *.rej .\#*
|
1896
openbox/client.c
Normal file
1896
openbox/client.c
Normal file
File diff suppressed because it is too large
Load diff
448
openbox/client.h
Normal file
448
openbox/client.h
Normal file
|
@ -0,0 +1,448 @@
|
|||
#ifndef __client_h
|
||||
#define __client_h
|
||||
|
||||
#include "geom.h"
|
||||
#include "stacking.h"
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct ClientWrap;
|
||||
struct Frame;
|
||||
|
||||
|
||||
/*! Holds an icon in ARGB format */
|
||||
typedef struct Icon {
|
||||
unsigned long w, h;
|
||||
unsigned long *data;
|
||||
} Icon;
|
||||
|
||||
/*! The MWM Hints as retrieved from the window property
|
||||
This structure only contains 3 elements, even though the Motif 2.0
|
||||
structure contains 5. We only use the first 3, so that is all gets
|
||||
defined.
|
||||
*/
|
||||
typedef struct MwmHints {
|
||||
/*! A bitmask of Client::MwmFlags values */
|
||||
unsigned long flags;
|
||||
/*! A bitmask of Client::MwmFunctions values */
|
||||
unsigned long functions;
|
||||
/*! A bitmask of Client::MwmDecorations values */
|
||||
unsigned long decorations;
|
||||
} MwmHints;
|
||||
/*! The number of elements in the Client::MwmHints struct */
|
||||
#define MWM_ELEMENTS 3
|
||||
|
||||
/*! Possible flags for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmFlag_Functions = 1 << 0, /*!< The MMW Hints define funcs */
|
||||
MwmFlag_Decorations = 1 << 1 /*!< The MWM Hints define decor */
|
||||
} MwmFlags;
|
||||
|
||||
/*! Possible functions for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmFunc_All = 1 << 0, /*!< All functions */
|
||||
MwmFunc_Resize = 1 << 1, /*!< Allow resizing */
|
||||
MwmFunc_Move = 1 << 2, /*!< Allow moving */
|
||||
MwmFunc_Iconify = 1 << 3, /*!< Allow to be iconfied */
|
||||
MwmFunc_Maximize = 1 << 4 /*!< Allow to be maximized */
|
||||
/*MwmFunc_Close = 1 << 5 /!< Allow to be closed */
|
||||
} MwmFunctions;
|
||||
|
||||
/*! Possible decorations for MWM Hints (defined by Motif 2.0) */
|
||||
typedef enum {
|
||||
MwmDecor_All = 1 << 0, /*!< All decorations */
|
||||
MwmDecor_Border = 1 << 1, /*!< Show a border */
|
||||
MwmDecor_Handle = 1 << 2, /*!< Show a handle (bottom) */
|
||||
MwmDecor_Title = 1 << 3, /*!< Show a titlebar */
|
||||
/*MwmDecor_Menu = 1 << 4, /!< Show a menu */
|
||||
MwmDecor_Iconify = 1 << 5, /*!< Show an iconify button */
|
||||
MwmDecor_Maximize = 1 << 6 /*!< Show a maximize button */
|
||||
} MemDecorations;
|
||||
|
||||
/*! Corners of the client window, used for anchor positions */
|
||||
typedef enum {
|
||||
Corner_TopLeft,
|
||||
Corner_TopRight,
|
||||
Corner_BottomLeft,
|
||||
Corner_BottomRight
|
||||
} Corner;
|
||||
|
||||
/*! Possible window types */
|
||||
typedef enum {
|
||||
Type_Desktop, /*!< A desktop (bottom-most window) */
|
||||
Type_Dock, /*!< A dock bar/panel window */
|
||||
Type_Toolbar, /*!< A toolbar window, pulled off an app */
|
||||
Type_Menu, /*!< An unpinned menu from an app */
|
||||
Type_Utility, /*!< A small utility window such as a palette */
|
||||
Type_Splash, /*!< A splash screen window */
|
||||
Type_Dialog, /*!< A dialog window */
|
||||
Type_Normal /*!< A normal application window */
|
||||
} WindowType;
|
||||
|
||||
/*! The things the user can do to the client window */
|
||||
typedef enum {
|
||||
Func_Resize = 1 << 0, /*!< Allow resizing */
|
||||
Func_Move = 1 << 1, /*!< Allow moving */
|
||||
Func_Iconify = 1 << 2, /*!< Allow to be iconified */
|
||||
Func_Maximize = 1 << 3, /*!< Allow to be maximized */
|
||||
Func_Shade = 1 << 4, /*!< Allow to be shaded */
|
||||
Func_Fullscreen = 1 << 5, /*!< Allow to be made fullscreen */
|
||||
Func_Close = 1 << 6 /*!< Allow to be closed */
|
||||
} Function;
|
||||
|
||||
/*! The decorations the client window wants to be displayed on it */
|
||||
typedef enum {
|
||||
Decor_Titlebar = 1 << 0, /*!< Display a titlebar */
|
||||
Decor_Handle = 1 << 1, /*!< Display a handle (bottom) */
|
||||
Decor_Border = 1 << 2, /*!< Display a border */
|
||||
Decor_Icon = 1 << 3, /*!< Display the window's icon */
|
||||
Decor_Iconify = 1 << 4, /*!< Display an iconify button */
|
||||
Decor_Maximize = 1 << 5, /*!< Display a maximize button */
|
||||
/*! Display a button to toggle the window's placement on
|
||||
all desktops */
|
||||
Decor_AllDesktops = 1 << 6,
|
||||
Decor_Close = 1 << 7 /*!< Display a close button */
|
||||
} Decoration;
|
||||
|
||||
|
||||
typedef struct Client {
|
||||
Window window;
|
||||
|
||||
struct Frame *frame;
|
||||
|
||||
/*! The number of unmap events to ignore on the window */
|
||||
int ignore_unmaps;
|
||||
|
||||
/*! The id of the group the window belongs to */
|
||||
Window group;
|
||||
/*! Whether or not the client is a transient window. This is guaranteed to
|
||||
be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
|
||||
transient_for == NULL. */
|
||||
gboolean transient;
|
||||
/*! The client which this client is a transient (child) for */
|
||||
struct Client *transient_for;
|
||||
/*! The clients which are transients (children) of this client */
|
||||
GSList *transients;
|
||||
/*! The desktop on which the window resides (0xffffffff for all
|
||||
desktops) */
|
||||
unsigned int desktop;
|
||||
|
||||
/*! Normal window title */
|
||||
gchar *title;
|
||||
/*! Window title when iconified */
|
||||
gchar *icon_title;
|
||||
|
||||
/*! The application that created the window */
|
||||
gchar *res_name;
|
||||
/*! The class of the window, can used for grouping */
|
||||
gchar *res_class;
|
||||
/*! The specified role of the window, used for identification */
|
||||
gchar *role;
|
||||
|
||||
/*! The type of window (what its function is) */
|
||||
WindowType type;
|
||||
|
||||
/*! Position and size of the window
|
||||
This will not always be the actual position of the window on screen, it
|
||||
is, rather, the position requested by the client, to which the window's
|
||||
gravity is applied.
|
||||
*/
|
||||
Rect area;
|
||||
|
||||
/*! The window's strut
|
||||
The strut defines areas of the screen that are marked off-bounds for
|
||||
window placement. In theory, where this window exists.
|
||||
*/
|
||||
Strut strut;
|
||||
|
||||
/*! The logical size of the window
|
||||
The "logical" size of the window is refers to the user's perception of
|
||||
the size of the window, and is the value that should be displayed to the
|
||||
user. For example, with xterms, this value it the number of characters
|
||||
being displayed in the terminal, instead of the number of pixels.
|
||||
*/
|
||||
Size logical_size;
|
||||
|
||||
/*! Width of the border on the window.
|
||||
The window manager will set this to 0 while the window is being managed,
|
||||
but needs to restore it afterwards, so it is saved here.
|
||||
*/
|
||||
guint border_width;
|
||||
|
||||
/*! The minimum aspect ratio the client window can be sized to.
|
||||
A value of 0 means this is ignored.
|
||||
*/
|
||||
float min_ratio;
|
||||
/*! The maximum aspect ratio the client window can be sized to.
|
||||
A value of 0 means this is ignored.
|
||||
*/
|
||||
float max_ratio;
|
||||
|
||||
/*! The minimum size of the client window
|
||||
If the min is > the max, then the window is not resizable
|
||||
*/
|
||||
Size min_size;
|
||||
/*! The maximum size of the client window
|
||||
If the min is > the max, then the window is not resizable
|
||||
*/
|
||||
Size max_size;
|
||||
/*! The size of increments to resize the client window by */
|
||||
Size size_inc;
|
||||
/*! The base size of the client window
|
||||
This value should be subtracted from the window's actual size when
|
||||
displaying its size to the user, or working with its min/max size
|
||||
*/
|
||||
Size base_size;
|
||||
|
||||
/*! Window decoration and functionality hints */
|
||||
MwmHints mwmhints;
|
||||
|
||||
/*! Where to place the decorated window in relation to the undecorated
|
||||
window */
|
||||
int gravity;
|
||||
|
||||
/*! The state of the window, one of WithdrawnState, IconicState, or
|
||||
NormalState */
|
||||
long wmstate;
|
||||
|
||||
/*! True if the client supports the delete_window protocol */
|
||||
gboolean delete_window;
|
||||
|
||||
/*! Was the window's position requested by the application? if not, we
|
||||
should place the window ourselves when it first appears */
|
||||
gboolean positioned;
|
||||
|
||||
/*! Can the window receive input focus? */
|
||||
gboolean can_focus;
|
||||
/*! Urgency flag */
|
||||
gboolean urgent;
|
||||
/*! Notify the window when it receives focus? */
|
||||
gboolean focus_notify;
|
||||
/*! Does the client window have the input focus? */
|
||||
gboolean focused;
|
||||
|
||||
/*! The window uses shape extension to be non-rectangular? */
|
||||
gboolean shaped;
|
||||
|
||||
/*! The window is modal, so it must be processed before any windows it is
|
||||
related to can be focused */
|
||||
gboolean modal;
|
||||
/*! Only the window's titlebar is displayed */
|
||||
gboolean shaded;
|
||||
/*! The window is iconified */
|
||||
gboolean iconic;
|
||||
/*! The window is maximized to fill the screen vertically */
|
||||
gboolean max_vert;
|
||||
/*! The window is maximized to fill the screen horizontally */
|
||||
gboolean max_horz;
|
||||
/*! The window should not be displayed by pagers */
|
||||
gboolean skip_pager;
|
||||
/*! The window should not be displayed by taskbars */
|
||||
gboolean skip_taskbar;
|
||||
/*! The window is a 'fullscreen' window, and should be on top of all
|
||||
others */
|
||||
gboolean fullscreen;
|
||||
/*! The window should be on top of other windows of the same type.
|
||||
above takes priority over below. */
|
||||
gboolean above;
|
||||
/*! The window should be underneath other windows of the same type.
|
||||
above takes priority over below. */
|
||||
gboolean below;
|
||||
|
||||
/*! The layer in which the window will be stacked, windows in lower layers
|
||||
are always below windows in higher layers. */
|
||||
StackLayer layer;
|
||||
|
||||
/*! A bitmask of values in the Decoration enum
|
||||
The values in the variable are the decorations that the client wants to
|
||||
be displayed around it.
|
||||
*/
|
||||
int decorations;
|
||||
|
||||
/*! A bitmask of values in the Decoration enum.
|
||||
Specifies the decorations that should NOT be displayed on the client.
|
||||
*/
|
||||
int disabled_decorations;
|
||||
|
||||
/*! A bitmask of values in the Function enum
|
||||
The values in the variable specify the ways in which the user is allowed
|
||||
to modify this window.
|
||||
*/
|
||||
int functions;
|
||||
|
||||
/*! Icons for the client as specified on the client window */
|
||||
Icon *icons;
|
||||
/*! The number of icons in icons */
|
||||
int nicons;
|
||||
|
||||
/*! The icon for the client specified in the WMHints or the KWM hints */
|
||||
Pixmap pixmap_icon;
|
||||
/*! The mask for the pixmap_icon, or None if its not masked */
|
||||
Pixmap pixmap_icon_mask;
|
||||
|
||||
/* The instance of the wrapper class if one exists */
|
||||
struct ClientWrap *wrap;
|
||||
} Client;
|
||||
|
||||
extern GSList *client_list;
|
||||
extern GHashTable *client_map;
|
||||
|
||||
void client_startup();
|
||||
void client_shutdown();
|
||||
|
||||
/*! Manages all existing windows */
|
||||
void client_manage_all();
|
||||
/*! Manages a given window */
|
||||
void client_manage(Window win);
|
||||
/*! Unmanages all managed windows */
|
||||
void client_unmanage_all();
|
||||
/*! Unmanages a given client */
|
||||
void client_unmanage(Client *client);
|
||||
|
||||
/*! Sets the client list on the root window from the client_list */
|
||||
void client_set_list();
|
||||
|
||||
/*! Reapplies the maximized state to the window
|
||||
Use this to make the window readjust its maximized size to new
|
||||
surroundings (struts, etc). */
|
||||
void client_remaximize(Client *self);
|
||||
|
||||
/*! Shows the window if it should be shown, or hides it
|
||||
Used when changing desktops, the window's state, etc. */
|
||||
void client_showhide(Client *self, gboolean firehook);
|
||||
|
||||
/*! Returns if the window should be treated as a normal window.
|
||||
Some windows (desktops, docks, splash screens) have special rules applied
|
||||
to them in a number of places regarding focus or user interaction. */
|
||||
gboolean client_normal(Client *self);
|
||||
|
||||
/*! Move and/or resize the window.
|
||||
This also maintains things like the client's minsize, and size increments.
|
||||
@param anchor The corner to keep in the same position when resizing.
|
||||
@param x The x coordiante of the new position for the client.
|
||||
@param y The y coordiante of the new position for the client.
|
||||
@param w The width component of the new size for the client.
|
||||
@param h The height component of the new size for the client.
|
||||
@param user Specifies whether this is a user-requested change or a
|
||||
program requested change. For program requested changes, the
|
||||
constraints are not checked.
|
||||
@param final If user is true, then this should specify if this is a final
|
||||
configuration. e.g. Final should be FALSE if doing an
|
||||
interactive move/resize, and then be TRUE for the last call
|
||||
only.
|
||||
*/
|
||||
void client_configure(Client *self, Corner anchor, int x, int y, int w, int h,
|
||||
gboolean user, gboolean final);
|
||||
|
||||
/*! Fullscreen's or unfullscreen's the client window
|
||||
@param fs true if the window should be made fullscreen; false if it should
|
||||
be returned to normal state.
|
||||
@param savearea true to have the client's current size and position saved;
|
||||
otherwise, they are not. You should not save when mapping a
|
||||
new window that is set to fullscreen. This has no effect
|
||||
when restoring a window from fullscreen.
|
||||
*/
|
||||
void client_fullscreen(Client *self, gboolean fs, gboolean savearea);
|
||||
|
||||
/*! Iconifies or uniconifies the client window
|
||||
@param iconic true if the window should be iconified; false if it should be
|
||||
restored.
|
||||
@param curdesk If iconic is FALSE, then this determines if the window will
|
||||
be uniconified to the current viewable desktop (true) or to
|
||||
its previous desktop (false)
|
||||
*/
|
||||
void client_iconify(Client *self, gboolean iconic, gboolean curdesk);
|
||||
|
||||
/*! Maximize or unmaximize the client window
|
||||
@param max true if the window should be maximized; false if it should be
|
||||
returned to normal size.
|
||||
@param dir 0 to set both horz and vert, 1 to set horz, 2 to set vert.
|
||||
@param savearea true to have the client's current size and position saved;
|
||||
otherwise, they are not. You should not save when mapping a
|
||||
new window that is set to fullscreen. This has no effect
|
||||
when unmaximizing a window.
|
||||
*/
|
||||
void client_maximize(Client *self, gboolean max, int dir,
|
||||
gboolean savearea);
|
||||
|
||||
/*! Shades or unshades the client window
|
||||
@param shade true if the window should be shaded; false if it should be
|
||||
unshaded.
|
||||
*/
|
||||
void client_shade(Client *self, gboolean shade);
|
||||
|
||||
/*! Request the client to close its window. */
|
||||
void client_close(Client *self);
|
||||
|
||||
/*! Sends the window to the specified desktop */
|
||||
void client_set_desktop(Client *self, unsigned int target);
|
||||
|
||||
/*! Return a modal child of the client window
|
||||
@return A modal child of the client window, or 0 if none was found.
|
||||
*/
|
||||
Client *client_find_modal_child(Client *self);
|
||||
|
||||
/*! Validate client, by making sure no Destroy or Unmap events exist in
|
||||
the event queue for the window.
|
||||
@return true if the client is valid; false if the client has already
|
||||
been unmapped/destroyed, and so is invalid.
|
||||
*/
|
||||
gboolean client_validate(Client *self);
|
||||
|
||||
/*! Sets the wm_state to the specified value */
|
||||
void client_set_wm_state(Client *self, long state);
|
||||
|
||||
/*! Adjusts the window's net_state
|
||||
This should not be called as part of the window mapping process! It is for
|
||||
use when updating the state post-mapping.<br>
|
||||
client_apply_startup_state is used to do the same things during the mapping
|
||||
process.
|
||||
*/
|
||||
void client_set_state(Client *self, Atom action, long data1, long data2);
|
||||
|
||||
/*! Attempt to focus the client window */
|
||||
gboolean client_focus(Client *self);
|
||||
|
||||
/*! Remove focus from the client window */
|
||||
void client_unfocus(Client *self);
|
||||
|
||||
/*! Calculates the stacking layer for the client window */
|
||||
void client_calc_layer(Client *self);
|
||||
|
||||
/*! Updates the window's transient status, and any parents of it */
|
||||
void client_update_transient_for(Client *self);
|
||||
/*! Update the protocols that the window supports and adjusts things if they
|
||||
change */
|
||||
void client_update_protocols(Client *self);
|
||||
/*! Updates the WMNormalHints and adjusts things if they change */
|
||||
void client_update_normal_hints(Client *self);
|
||||
|
||||
/*! Updates the WMHints and adjusts things if they change
|
||||
@param initstate Whether to read the initial_state property from the
|
||||
WMHints. This should only be used during the mapping
|
||||
process.
|
||||
*/
|
||||
void client_update_wmhints(Client *self);
|
||||
/*! Updates the window's title */
|
||||
void client_update_title(Client *self);
|
||||
/*! Updates the window's icon title */
|
||||
void client_update_icon_title(Client *self);
|
||||
/*! Updates the window's application name and class */
|
||||
void client_update_class(Client *self);
|
||||
/*! Updates the strut for the client */
|
||||
void client_update_strut(Client *self);
|
||||
/*! Updates the window's icons */
|
||||
void client_update_icons(Client *self);
|
||||
/*! Updates the window's kwm icon */
|
||||
void client_update_kwm_icon(Client *self);
|
||||
|
||||
/*! Set up what decor should be shown on the window and what functions should
|
||||
be allowed (Client::decorations and Client::functions).
|
||||
This also updates the NET_WM_ALLOWED_ACTIONS hint.
|
||||
*/
|
||||
void client_setup_decor_and_functions(Client *self);
|
||||
|
||||
/*! Retrieves the window's type and sets Client->type */
|
||||
void client_get_type(Client *self);
|
||||
|
||||
#endif
|
1029
openbox/clientwrap.c
Normal file
1029
openbox/clientwrap.c
Normal file
File diff suppressed because it is too large
Load diff
19
openbox/clientwrap.h
Normal file
19
openbox/clientwrap.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __clientwrap_h
|
||||
#define __clientwrap_h
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
/* ClientWrap is a PyObject */
|
||||
typedef struct ClientWrap {
|
||||
PyObject_HEAD
|
||||
struct Client *client;
|
||||
} ClientWrap;
|
||||
|
||||
void clientwrap_startup();
|
||||
void clientwrap_shutdown();
|
||||
|
||||
PyObject *clientwrap_new(struct Client *client);
|
||||
|
||||
#endif
|
84
openbox/engine.c
Normal file
84
openbox/engine.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include "engine.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
static GModule *module;
|
||||
static EngineStartup *estartup;
|
||||
static EngineShutdown *eshutdown;
|
||||
|
||||
#define LOADSYM(name, var) \
|
||||
if (!g_module_symbol(module, #name, (gpointer*)&var)) { \
|
||||
g_warning("Failed to load symbol %s from engine", #name); \
|
||||
return FALSE; \
|
||||
}
|
||||
|
||||
static gboolean load(char *name)
|
||||
{
|
||||
char *path;
|
||||
|
||||
g_assert(module == NULL);
|
||||
|
||||
path = g_build_filename(ENGINEDIR, name, NULL);
|
||||
module = g_module_open(path, G_MODULE_BIND_LAZY);
|
||||
g_free(path);
|
||||
|
||||
if (module == NULL) {
|
||||
path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name,
|
||||
NULL);
|
||||
module = g_module_open(path, G_MODULE_BIND_LAZY);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
if (module == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* load the engine's symbols */
|
||||
LOADSYM(startup, estartup);
|
||||
LOADSYM(shutdown, eshutdown);
|
||||
LOADSYM(frame_new, engine_frame_new);
|
||||
LOADSYM(frame_grab_client, engine_frame_grab_client);
|
||||
LOADSYM(frame_release_client, engine_frame_release_client);
|
||||
LOADSYM(frame_adjust_size, engine_frame_adjust_size);
|
||||
LOADSYM(frame_adjust_position, engine_frame_adjust_position);
|
||||
LOADSYM(frame_adjust_shape, engine_frame_adjust_shape);
|
||||
LOADSYM(frame_adjust_state, engine_frame_adjust_state);
|
||||
LOADSYM(frame_adjust_focus, engine_frame_adjust_focus);
|
||||
LOADSYM(frame_adjust_title, engine_frame_adjust_title);
|
||||
LOADSYM(frame_adjust_icon, engine_frame_adjust_icon);
|
||||
LOADSYM(frame_show, engine_frame_show);
|
||||
LOADSYM(frame_hide, engine_frame_hide);
|
||||
LOADSYM(get_context, engine_get_context);
|
||||
|
||||
if (!estartup())
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void engine_startup(char *engine)
|
||||
{
|
||||
module = NULL;
|
||||
|
||||
if (engine != NULL) {
|
||||
if (load(engine))
|
||||
return;
|
||||
g_warning("Failed to load the engine '%s'", engine);
|
||||
g_message("Falling back to the default: '%s'", DEFAULT_ENGINE);
|
||||
}
|
||||
if (!load(DEFAULT_ENGINE)) {
|
||||
g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void engine_shutdown()
|
||||
{
|
||||
if (module != NULL) {
|
||||
eshutdown();
|
||||
g_module_close(module);
|
||||
}
|
||||
}
|
27
openbox/engine.h
Normal file
27
openbox/engine.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef __engine_h
|
||||
#define __engine_h
|
||||
|
||||
#include "../engines/engineinterface.h"
|
||||
|
||||
void engine_startup(char *engine);
|
||||
void engine_shutdown();
|
||||
|
||||
EngineFrameNew *engine_frame_new;
|
||||
|
||||
EngineFrameGrabClient *engine_frame_grab_client;
|
||||
EngineFrameReleaseClient *engine_frame_release_client;
|
||||
|
||||
EngineFrameAdjustSize *engine_frame_adjust_size;
|
||||
EngineFrameAdjustPosition *engine_frame_adjust_position;
|
||||
EngineFrameAdjustShape *engine_frame_adjust_shape;
|
||||
EngineFrameAdjustState *engine_frame_adjust_state;
|
||||
EngineFrameAdjustFocus *engine_frame_adjust_focus;
|
||||
EngineFrameAdjustTitle *engine_frame_adjust_title;
|
||||
EngineFrameAdjustIcon *engine_frame_adjust_icon;
|
||||
|
||||
EngineFrameShow *engine_frame_show;
|
||||
EngineFrameHide *engine_frame_hide;
|
||||
|
||||
EngineGetContext *engine_get_context;
|
||||
|
||||
#endif
|
598
openbox/event.c
Normal file
598
openbox/event.c
Normal file
|
@ -0,0 +1,598 @@
|
|||
#include "openbox.h"
|
||||
#include "client.h"
|
||||
#include "xerror.h"
|
||||
#include "prop.h"
|
||||
#include "screen.h"
|
||||
#include "frame.h"
|
||||
#include "engine.h"
|
||||
#include "focus.h"
|
||||
#include "stacking.h"
|
||||
#include "keyboard.h"
|
||||
#include "pointer.h"
|
||||
#include "hooks.h"
|
||||
#include "extensions.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static void event_process(XEvent *e);
|
||||
static void event_handle_root(XEvent *e);
|
||||
static void event_handle_client(Client *c, XEvent *e);
|
||||
|
||||
Time event_lasttime = 0;
|
||||
|
||||
/*! A list of all possible combinations of keyboard lock masks */
|
||||
static unsigned int mask_list[8];
|
||||
/*! The value of the mask for the NumLock modifier */
|
||||
static unsigned int NumLockMask;
|
||||
/*! The value of the mask for the ScrollLock modifier */
|
||||
static unsigned int ScrollLockMask;
|
||||
/*! The key codes for the modifier keys */
|
||||
static XModifierKeymap *modmap;
|
||||
/*! Table of the constant modifier masks */
|
||||
static const int mask_table[] = {
|
||||
ShiftMask, LockMask, ControlMask, Mod1Mask,
|
||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
};
|
||||
static int mask_table_size;
|
||||
|
||||
void event_startup()
|
||||
{
|
||||
mask_table_size = sizeof(mask_table) / sizeof(mask_table[0]);
|
||||
|
||||
/* get lock masks that are defined by the display (not constant) */
|
||||
modmap = XGetModifierMapping(ob_display);
|
||||
g_assert(modmap);
|
||||
if (modmap && modmap->max_keypermod > 0) {
|
||||
size_t cnt;
|
||||
const size_t size = mask_table_size * 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 = XKeysymToKeycode(ob_display, XK_Num_Lock);
|
||||
const KeyCode scroll_lock = XKeysymToKeycode(ob_display,
|
||||
XK_Scroll_Lock);
|
||||
|
||||
for (cnt = 0; cnt < size; ++cnt) {
|
||||
if (! modmap->modifiermap[cnt]) continue;
|
||||
|
||||
if (num_lock == modmap->modifiermap[cnt])
|
||||
NumLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
if (scroll_lock == modmap->modifiermap[cnt])
|
||||
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
|
||||
mask_list[0] = 0;
|
||||
mask_list[1] = LockMask;
|
||||
mask_list[2] = NumLockMask;
|
||||
mask_list[3] = LockMask | NumLockMask;
|
||||
mask_list[4] = ScrollLockMask;
|
||||
mask_list[5] = ScrollLockMask | LockMask;
|
||||
mask_list[6] = ScrollLockMask | NumLockMask;
|
||||
mask_list[7] = ScrollLockMask | LockMask | NumLockMask;
|
||||
}
|
||||
|
||||
void event_shutdown()
|
||||
{
|
||||
XFreeModifiermap(modmap);
|
||||
}
|
||||
|
||||
void event_loop()
|
||||
{
|
||||
fd_set selset;
|
||||
XEvent e;
|
||||
int x_fd;
|
||||
struct timeval *wait;
|
||||
|
||||
while (TRUE) {
|
||||
/*
|
||||
There are slightly different event retrieval semantics here for
|
||||
local (or high bandwidth) versus remote (or low bandwidth)
|
||||
connections to the display/Xserver.
|
||||
*/
|
||||
if (ob_remote) {
|
||||
if (!XPending(ob_display))
|
||||
break;
|
||||
} else {
|
||||
/*
|
||||
This XSync allows for far more compression of events, which
|
||||
makes things like Motion events perform far far better. Since
|
||||
it also means network traffic for every event instead of every
|
||||
X events (where X is the number retrieved at a time), it
|
||||
probably should not be used for setups where Openbox is
|
||||
running on a remote/low bandwidth display/Xserver.
|
||||
*/
|
||||
XSync(ob_display, FALSE);
|
||||
if (!XEventsQueued(ob_display, QueuedAlready))
|
||||
break;
|
||||
}
|
||||
XNextEvent(ob_display, &e);
|
||||
|
||||
event_process(&e);
|
||||
}
|
||||
|
||||
timer_dispatch((GTimeVal**)&wait);
|
||||
x_fd = ConnectionNumber(ob_display);
|
||||
FD_ZERO(&selset);
|
||||
FD_SET(x_fd, &selset);
|
||||
select(x_fd + 1, &selset, NULL, NULL, wait);
|
||||
}
|
||||
|
||||
void event_process(XEvent *e)
|
||||
{
|
||||
XEvent ce;
|
||||
KeyCode *kp;
|
||||
Window window;
|
||||
int i, k;
|
||||
Client *client;
|
||||
|
||||
/* pick a window */
|
||||
switch (e->type) {
|
||||
case UnmapNotify:
|
||||
window = e->xunmap.window;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
window = e->xdestroywindow.window;
|
||||
break;
|
||||
case ConfigureRequest:
|
||||
window = e->xconfigurerequest.window;
|
||||
break;
|
||||
default:
|
||||
/* XKB events */
|
||||
if (e->type == extensions_xkb_event_basep) {
|
||||
switch (((XkbAnyEvent*)&e)->xkb_type) {
|
||||
case XkbBellNotify:
|
||||
window = ((XkbBellNotifyEvent*)&e)->window;
|
||||
default:
|
||||
window = None;
|
||||
}
|
||||
} else
|
||||
window = e->xany.window;
|
||||
}
|
||||
|
||||
/* grab the lasttime and hack up the state */
|
||||
switch (e->type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
event_lasttime = e->xbutton.time;
|
||||
e->xbutton.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xbutton.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
break;
|
||||
case KeyPress:
|
||||
event_lasttime = e->xkey.time;
|
||||
e->xkey.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xkey.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* add to the state the mask of the modifier being pressed, if it is
|
||||
a modifier key being pressed (this is a little ugly..) */
|
||||
/* I'm commenting this out cuz i don't want "C-Control_L" being returned. */
|
||||
/* kp = modmap->modifiermap;*/
|
||||
/* for (i = 0; i < mask_table_size; ++i) {*/
|
||||
/* for (k = 0; k < modmap->max_keypermod; ++k) {*/
|
||||
/* if (*kp == e->xkey.keycode) {*/ /* found the keycode */
|
||||
/* add the mask for it */
|
||||
/* e->xkey.state |= mask_table[i];*/
|
||||
/* cause the first loop to break; */
|
||||
/* i = mask_table_size;*/
|
||||
/* break;*/ /* get outta here! */
|
||||
/* }*/
|
||||
/* ++kp;*/
|
||||
/* }*/
|
||||
/* }*/
|
||||
|
||||
break;
|
||||
case KeyRelease:
|
||||
event_lasttime = e->xkey.time;
|
||||
e->xkey.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xkey.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* remove from the state the mask of the modifier being released, if
|
||||
it is a modifier key being released (this is a little ugly..) */
|
||||
kp = modmap->modifiermap;
|
||||
for (i = 0; i < mask_table_size; ++i) {
|
||||
for (k = 0; k < modmap->max_keypermod; ++k) {
|
||||
if (*kp == e->xkey.keycode) { /* found the keycode */
|
||||
/* remove the mask for it */
|
||||
e->xkey.state &= ~mask_table[i];
|
||||
/* cause the first loop to break; */
|
||||
i = mask_table_size;
|
||||
break; /* get outta here! */
|
||||
}
|
||||
++kp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
event_lasttime = e->xmotion.time;
|
||||
e->xmotion.state &= ~(LockMask | NumLockMask | ScrollLockMask);
|
||||
/* kill off the Button1Mask etc, only want the modifiers */
|
||||
e->xmotion.state &= (ControlMask | ShiftMask | Mod1Mask |
|
||||
Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
|
||||
/* compress events */
|
||||
while (XCheckTypedWindowEvent(ob_display, window, e->type, &ce)) {
|
||||
e->xmotion.x_root = ce.xmotion.x_root;
|
||||
e->xmotion.y_root = ce.xmotion.y_root;
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
event_lasttime = e->xproperty.time;
|
||||
break;
|
||||
case FocusIn:
|
||||
case FocusOut:
|
||||
if (e->xfocus.mode == NotifyGrab)
|
||||
/*|| e.xfocus.mode == NotifyUngrab ||*/
|
||||
|
||||
/* From Metacity, from WindowMaker, ignore all funky pointer
|
||||
root events. Its commented out cuz I don't think we need this
|
||||
at all. If problems arise we can look into it */
|
||||
/*e.xfocus.detail > NotifyNonlinearVirtual) */
|
||||
return; /* skip me! */
|
||||
if (e->type == FocusOut) {
|
||||
/* FocusOut events just make us look for FocusIn events. They
|
||||
are mostly ignored otherwise. */
|
||||
XEvent fi;
|
||||
if (XCheckTypedEvent(ob_display, FocusIn, &fi)) {
|
||||
event_process(&fi);
|
||||
/* dont unfocus the window we just focused! */
|
||||
if (fi.xfocus.window == e->xfocus.window)
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
event_lasttime = e->xcrossing.time;
|
||||
if (e->xcrossing.mode != NotifyNormal)
|
||||
return; /* skip me! */
|
||||
break;
|
||||
}
|
||||
|
||||
client = g_hash_table_lookup(client_map, (gpointer)window);
|
||||
|
||||
if (client) {
|
||||
event_handle_client(client, e);
|
||||
} else if (window == ob_root)
|
||||
event_handle_root(e);
|
||||
else if (e->type == ConfigureRequest) {
|
||||
/* unhandled configure requests must be used to configure the
|
||||
window directly */
|
||||
XWindowChanges xwc;
|
||||
|
||||
xwc.x = e->xconfigurerequest.x;
|
||||
xwc.y = e->xconfigurerequest.y;
|
||||
xwc.width = e->xconfigurerequest.width;
|
||||
xwc.height = e->xconfigurerequest.height;
|
||||
xwc.border_width = e->xconfigurerequest.border_width;
|
||||
xwc.sibling = e->xconfigurerequest.above;
|
||||
xwc.stack_mode = e->xconfigurerequest.detail;
|
||||
|
||||
g_message("Proxying configure event for 0x%lx", window);
|
||||
|
||||
/* we are not to be held responsible if someone sends us an
|
||||
invalid request! */
|
||||
xerror_set_ignore(TRUE);
|
||||
XConfigureWindow(ob_display, window,
|
||||
e->xconfigurerequest.value_mask, &xwc);
|
||||
xerror_set_ignore(FALSE);
|
||||
}
|
||||
|
||||
/* dispatch Crossing, Pointer and Key events to the hooks */
|
||||
switch(e->type) {
|
||||
case EnterNotify:
|
||||
HOOKFIRECLIENT(pointerenter, client);
|
||||
break;
|
||||
case LeaveNotify:
|
||||
HOOKFIRECLIENT(pointerleave, client);
|
||||
break;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
case MotionNotify:
|
||||
pointer_event(e, client);
|
||||
break;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
keyboard_event(&e->xkey);
|
||||
break;
|
||||
default:
|
||||
/* XKB events */
|
||||
if (e->type == extensions_xkb_event_basep) {
|
||||
switch (((XkbAnyEvent*)&e)->xkb_type) {
|
||||
case XkbBellNotify:
|
||||
HOOKFIRECLIENT(bell, client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handle_root(XEvent *e)
|
||||
{
|
||||
Atom msgtype;
|
||||
|
||||
switch(e->type) {
|
||||
case MapRequest:
|
||||
g_message("MapRequest on root");
|
||||
client_manage(e->xmap.window);
|
||||
break;
|
||||
case ClientMessage:
|
||||
if (e->xclient.format != 32) break;
|
||||
|
||||
msgtype = e->xclient.message_type;
|
||||
if (msgtype == prop_atoms.net_current_desktop) {
|
||||
unsigned int d = e->xclient.data.l[0];
|
||||
if (d <= screen_num_desktops)
|
||||
screen_set_desktop(d);
|
||||
} else if (msgtype == prop_atoms.net_number_of_desktops) {
|
||||
unsigned int d = e->xclient.data.l[0];
|
||||
if (d > 0)
|
||||
screen_set_num_desktops(d);
|
||||
} else if (msgtype == prop_atoms.net_showing_desktop) {
|
||||
screen_show_desktop(e->xclient.data.l[0] != 0);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
if (e->xproperty.atom == prop_atoms.net_desktop_names)
|
||||
screen_update_desktop_names();
|
||||
else if (e->xproperty.atom == prop_atoms.net_desktop_layout)
|
||||
screen_update_layout();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void event_handle_client(Client *client, XEvent *e)
|
||||
{
|
||||
XEvent ce;
|
||||
Atom msgtype;
|
||||
|
||||
switch (e->type) {
|
||||
case FocusIn:
|
||||
client->focused = TRUE;
|
||||
engine_frame_adjust_focus(client->frame);
|
||||
|
||||
/* focus state can affect the stacking layer */
|
||||
client_calc_layer(client);
|
||||
|
||||
focus_set_client(client);
|
||||
break;
|
||||
case FocusOut:
|
||||
client->focused = FALSE;
|
||||
engine_frame_adjust_focus(client->frame);
|
||||
|
||||
/* focus state can affect the stacking layer */
|
||||
client_calc_layer(client);
|
||||
|
||||
if (focus_client == client)
|
||||
focus_set_client(NULL);
|
||||
break;
|
||||
case ConfigureRequest:
|
||||
g_message("ConfigureRequest for window %lx", client->window);
|
||||
/* compress these */
|
||||
while (XCheckTypedWindowEvent(ob_display, client->window,
|
||||
ConfigureRequest, &ce)) {
|
||||
/* XXX if this causes bad things.. we can compress config req's
|
||||
with the same mask. */
|
||||
e->xconfigurerequest.value_mask |=
|
||||
ce.xconfigurerequest.value_mask;
|
||||
if (ce.xconfigurerequest.value_mask & CWX)
|
||||
e->xconfigurerequest.x = ce.xconfigurerequest.x;
|
||||
if (ce.xconfigurerequest.value_mask & CWY)
|
||||
e->xconfigurerequest.y = ce.xconfigurerequest.y;
|
||||
if (ce.xconfigurerequest.value_mask & CWWidth)
|
||||
e->xconfigurerequest.width = ce.xconfigurerequest.width;
|
||||
if (ce.xconfigurerequest.value_mask & CWHeight)
|
||||
e->xconfigurerequest.height = ce.xconfigurerequest.height;
|
||||
if (ce.xconfigurerequest.value_mask & CWBorderWidth)
|
||||
e->xconfigurerequest.border_width =
|
||||
ce.xconfigurerequest.border_width;
|
||||
if (ce.xconfigurerequest.value_mask & CWStackMode)
|
||||
e->xconfigurerequest.detail = ce.xconfigurerequest.detail;
|
||||
}
|
||||
|
||||
/* if we are iconic (or shaded (fvwm does this)) ignore the event */
|
||||
if (client->iconic || client->shaded) return;
|
||||
|
||||
if (e->xconfigurerequest.value_mask & CWBorderWidth)
|
||||
client->border_width = e->xconfigurerequest.border_width;
|
||||
|
||||
/* resize, then move, as specified in the EWMH section 7.7 */
|
||||
if (e->xconfigurerequest.value_mask & (CWWidth | CWHeight |
|
||||
CWX | CWY)) {
|
||||
int x, y, w, h;
|
||||
Corner corner;
|
||||
|
||||
x = (e->xconfigurerequest.value_mask & CWX) ?
|
||||
e->xconfigurerequest.x : client->area.x;
|
||||
y = (e->xconfigurerequest.value_mask & CWY) ?
|
||||
e->xconfigurerequest.y : client->area.y;
|
||||
w = (e->xconfigurerequest.value_mask & CWWidth) ?
|
||||
e->xconfigurerequest.width : client->area.width;
|
||||
h = (e->xconfigurerequest.value_mask & CWHeight) ?
|
||||
e->xconfigurerequest.height : client->area.height;
|
||||
|
||||
switch (client->gravity) {
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
corner = Corner_TopRight;
|
||||
break;
|
||||
case SouthWestGravity:
|
||||
case SouthGravity:
|
||||
corner = Corner_BottomLeft;
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
corner = Corner_BottomRight;
|
||||
break;
|
||||
default: /* NorthWest, Static, etc */
|
||||
corner = Corner_TopLeft;
|
||||
}
|
||||
|
||||
client_configure(client, corner, x, y, w, h, FALSE, FALSE);
|
||||
}
|
||||
|
||||
if (e->xconfigurerequest.value_mask & CWStackMode) {
|
||||
switch (e->xconfigurerequest.detail) {
|
||||
case Below:
|
||||
case BottomIf:
|
||||
stacking_lower(client);
|
||||
break;
|
||||
|
||||
case Above:
|
||||
case TopIf:
|
||||
default:
|
||||
stacking_raise(client);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UnmapNotify:
|
||||
if (client->ignore_unmaps) {
|
||||
client->ignore_unmaps--;
|
||||
break;
|
||||
}
|
||||
g_message("UnmapNotify for %lx", client->window);
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
g_message("DestroyNotify for %lx", client->window);
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case ReparentNotify:
|
||||
/* this is when the client is first taken captive in the frame */
|
||||
if (e->xreparent.parent == client->frame->plate) break;
|
||||
|
||||
/*
|
||||
This event is quite rare and is usually handled in unmapHandler.
|
||||
However, if the window is unmapped when the reparent event occurs,
|
||||
the window manager never sees it because an unmap event is not sent
|
||||
to an already unmapped window.
|
||||
*/
|
||||
|
||||
/* we don't want the reparent event, put it back on the stack for the
|
||||
X server to deal with after we unmanage the window */
|
||||
XPutBackEvent(ob_display, e);
|
||||
|
||||
client_unmanage(client);
|
||||
break;
|
||||
case MapRequest:
|
||||
/* we shouldn't be able to get this unless we're iconic */
|
||||
g_assert(client->iconic);
|
||||
|
||||
HOOKFIRECLIENT(requestactivate, client);
|
||||
break;
|
||||
case ClientMessage:
|
||||
/* validate cuz we query stuff off the client here */
|
||||
if (!client_validate(client)) break;
|
||||
|
||||
if (e->xclient.format != 32) return;
|
||||
|
||||
msgtype = e->xclient.message_type;
|
||||
if (msgtype == prop_atoms.wm_change_state) {
|
||||
/* compress changes into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL messages of a
|
||||
type, not just messages in a row without other
|
||||
message types between. */
|
||||
if (ce.xclient.message_type != msgtype) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
e->xclient = ce.xclient;
|
||||
}
|
||||
client_set_wm_state(client, e->xclient.data.l[0]);
|
||||
} else if (msgtype == prop_atoms.net_wm_desktop) {
|
||||
/* compress changes into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL messages of a
|
||||
type, not just messages in a row without other
|
||||
message types between. */
|
||||
if (ce.xclient.message_type != msgtype) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
e->xclient = ce.xclient;
|
||||
}
|
||||
client_set_desktop(client, e->xclient.data.l[0]);
|
||||
} else if (msgtype == prop_atoms.net_wm_state) {
|
||||
/* can't compress these */
|
||||
g_message("net_wm_state %s %ld %ld for 0x%lx\n",
|
||||
(e->xclient.data.l[0] == 0 ? "Remove" :
|
||||
e->xclient.data.l[0] == 1 ? "Add" :
|
||||
e->xclient.data.l[0] == 2 ? "Toggle" : "INVALID"),
|
||||
e->xclient.data.l[1], e->xclient.data.l[2],
|
||||
client->window);
|
||||
client_set_state(client, e->xclient.data.l[0],
|
||||
e->xclient.data.l[1], e->xclient.data.l[2]);
|
||||
} else if (msgtype == prop_atoms.net_close_window) {
|
||||
g_message("net_close_window for 0x%lx\n", client->window);
|
||||
client_close(client);
|
||||
} else if (msgtype == prop_atoms.net_active_window) {
|
||||
g_message("net_active_window for 0x%lx\n", client->window);
|
||||
if (screen_showing_desktop)
|
||||
screen_show_desktop(FALSE);
|
||||
if (client->iconic)
|
||||
client_iconify(client, FALSE, TRUE);
|
||||
else if (!client->frame->visible)
|
||||
/* if its not visible for other reasons, then don't mess
|
||||
with it */
|
||||
return;
|
||||
HOOKFIRECLIENT(requestactivate, client);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
/* validate cuz we query stuff off the client here */
|
||||
if (!client_validate(client)) break;
|
||||
|
||||
/* compress changes to a single property into a single change */
|
||||
while (XCheckTypedWindowEvent(ob_display, e->type,
|
||||
client->window, &ce)) {
|
||||
/* XXX: it would be nice to compress ALL changes to a property,
|
||||
not just changes in a row without other props between. */
|
||||
if (ce.xproperty.atom != e->xproperty.atom) {
|
||||
XPutBackEvent(ob_display, &ce);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
msgtype = e->xproperty.atom;
|
||||
if (msgtype == XA_WM_NORMAL_HINTS) {
|
||||
client_update_normal_hints(client);
|
||||
/* normal hints can make a window non-resizable */
|
||||
client_setup_decor_and_functions(client);
|
||||
}
|
||||
else if (msgtype == XA_WM_HINTS)
|
||||
client_update_wmhints(client);
|
||||
else if (msgtype == XA_WM_TRANSIENT_FOR) {
|
||||
client_update_transient_for(client);
|
||||
client_get_type(client);
|
||||
/* type may have changed, so update the layer */
|
||||
client_calc_layer(client);
|
||||
client_setup_decor_and_functions(client);
|
||||
}
|
||||
else if (msgtype == prop_atoms.net_wm_name ||
|
||||
msgtype == prop_atoms.wm_name)
|
||||
client_update_title(client);
|
||||
else if (msgtype == prop_atoms.net_wm_icon_name ||
|
||||
msgtype == prop_atoms.wm_icon_name)
|
||||
client_update_icon_title(client);
|
||||
else if (msgtype == prop_atoms.wm_class)
|
||||
client_update_class(client);
|
||||
else if (msgtype == prop_atoms.wm_protocols) {
|
||||
client_update_protocols(client);
|
||||
client_setup_decor_and_functions(client);
|
||||
}
|
||||
else if (msgtype == prop_atoms.net_wm_strut)
|
||||
client_update_strut(client);
|
||||
else if (msgtype == prop_atoms.net_wm_icon)
|
||||
client_update_icons(client);
|
||||
else if (msgtype == prop_atoms.kwm_win_icon)
|
||||
client_update_kwm_icon(client);
|
||||
}
|
||||
}
|
12
openbox/event.h
Normal file
12
openbox/event.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef __events_h
|
||||
#define __events_h
|
||||
|
||||
/*! Time at which the last event with a timestamp occured. */
|
||||
extern Time event_lasttime;
|
||||
|
||||
void event_startup();
|
||||
void event_shutdown();
|
||||
|
||||
void event_loop();
|
||||
|
||||
#endif
|
34
openbox/extensions.c
Normal file
34
openbox/extensions.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "openbox.h"
|
||||
#include "extensions.h"
|
||||
|
||||
gboolean extensions_xkb = FALSE;
|
||||
int extensions_xkb_event_basep;
|
||||
gboolean extensions_shape = FALSE;
|
||||
int extensions_shape_event_basep;
|
||||
gboolean extensions_xinerama = FALSE;
|
||||
int extensions_xinerama_event_basep;
|
||||
|
||||
|
||||
void extensions_query_all()
|
||||
{
|
||||
int junk;
|
||||
(void)junk;
|
||||
|
||||
#ifdef XKB
|
||||
extensions_xkb =
|
||||
XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep,
|
||||
&junk, NULL, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef SHAPE
|
||||
extensions_shape =
|
||||
XShapeQueryExtension(ob_display, &extensions_shape_event_basep,
|
||||
&junk);
|
||||
#endif
|
||||
|
||||
#ifdef XINERAMA
|
||||
extensions_xinerama =
|
||||
XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep,
|
||||
&junk);
|
||||
#endif
|
||||
}
|
33
openbox/extensions.h
Normal file
33
openbox/extensions.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef __extensions_h
|
||||
#define __extensions_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#ifdef XKB
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
#ifdef SHAPE
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
#ifdef XINERAMA
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#endif
|
||||
#include <glib.h>
|
||||
|
||||
/*! Does the display have the XKB extension? */
|
||||
extern gboolean extensions_xkb;
|
||||
/*! Base for events for the XKB extension */
|
||||
extern int extensions_xkb_event_basep;
|
||||
|
||||
/*! Does the display have the Shape extension? */
|
||||
extern gboolean extensions_shape;
|
||||
/*! Base for events for the Shape extension */
|
||||
extern int extensions_shape_event_basep;
|
||||
|
||||
/*! Does the display have the Xinerama extension? */
|
||||
extern gboolean extensions_xinerama;
|
||||
/*! Base for events for the Xinerama extension */
|
||||
extern int extensions_xinerama_event_basep;
|
||||
|
||||
void extensions_query_all();
|
||||
|
||||
#endif
|
57
openbox/focus.c
Normal file
57
openbox/focus.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "openbox.h"
|
||||
#include "client.h"
|
||||
#include "screen.h"
|
||||
#include "prop.h"
|
||||
#include "hooks.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
Client *focus_client = NULL;
|
||||
|
||||
Window focus_backup = None;
|
||||
|
||||
void focus_set_client(Client *client);
|
||||
|
||||
void focus_startup()
|
||||
{
|
||||
/* create the window which gets focus when no clients get it. Have to
|
||||
make it override-redirect so we don't try manage it, since it is
|
||||
mapped. */
|
||||
XSetWindowAttributes attrib;
|
||||
|
||||
attrib.override_redirect = TRUE;
|
||||
focus_backup = XCreateWindow(ob_display, ob_root,
|
||||
-100, -100, 1, 1, 0, 0, InputOnly,
|
||||
CopyFromParent, CWOverrideRedirect, &attrib);
|
||||
XMapRaised(ob_display, focus_backup);
|
||||
|
||||
/* start with nothing focused */
|
||||
focus_set_client(NULL);
|
||||
}
|
||||
|
||||
void focus_set_client(Client *client)
|
||||
{
|
||||
Window active;
|
||||
|
||||
/* sometimes this is called with the already-focused window, this is
|
||||
important for the python scripts to work (eg, c = 0 twice). don't just
|
||||
return if _focused_client == c */
|
||||
|
||||
/* uninstall the old colormap, and install the new one */
|
||||
screen_install_colormap(focus_client, FALSE);
|
||||
screen_install_colormap(client, TRUE);
|
||||
|
||||
|
||||
if (client == NULL) {
|
||||
/* when nothing will be focused, send focus to the backup target */
|
||||
XSetInputFocus(ob_display, focus_backup, RevertToNone, CurrentTime);
|
||||
}
|
||||
|
||||
focus_client = client;
|
||||
|
||||
/* set the NET_ACTIVE_WINDOW hint */
|
||||
active = client ? client->window : None;
|
||||
PROP_SET32(ob_root, net_active_window, window, active);
|
||||
|
||||
HOOKFIRECLIENT(focused, client);
|
||||
}
|
20
openbox/focus.h
Normal file
20
openbox/focus.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __focus_h
|
||||
#define __focus_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
struct Client;
|
||||
|
||||
/*! The window which gets focus when nothing else will be focused */
|
||||
extern Window focus_backup;
|
||||
|
||||
/*! The client which is currently focused */
|
||||
extern struct Client *focus_client;
|
||||
|
||||
void focus_startup();
|
||||
|
||||
/*! Specify which client is currently focused, this doesn't actually
|
||||
send focus anywhere, its called by the Focus event handlers */
|
||||
void focus_set_client(struct Client *client);
|
||||
|
||||
#endif
|
105
openbox/frame.c
Normal file
105
openbox/frame.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include "frame.h"
|
||||
|
||||
void frame_client_gravity(Frame *self, int *x, int *y)
|
||||
{
|
||||
/* horizontal */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case SouthWestGravity:
|
||||
case WestGravity:
|
||||
break;
|
||||
|
||||
case NorthGravity:
|
||||
case SouthGravity:
|
||||
case CenterGravity:
|
||||
*x -= (self->size.left + self->size.right) / 2;
|
||||
break;
|
||||
|
||||
case NorthEastGravity:
|
||||
case SouthEastGravity:
|
||||
case EastGravity:
|
||||
*x -= self->size.left + self->size.right;
|
||||
break;
|
||||
|
||||
case ForgetGravity:
|
||||
case StaticGravity:
|
||||
*x -= self->size.left;
|
||||
break;
|
||||
}
|
||||
|
||||
/* vertical */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case NorthEastGravity:
|
||||
case NorthGravity:
|
||||
break;
|
||||
|
||||
case CenterGravity:
|
||||
case EastGravity:
|
||||
case WestGravity:
|
||||
*y -= (self->size.top + self->size.bottom) / 2;
|
||||
break;
|
||||
|
||||
case SouthWestGravity:
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
*y -= self->size.top + self->size.bottom;
|
||||
break;
|
||||
|
||||
case ForgetGravity:
|
||||
case StaticGravity:
|
||||
*y -= self->size.top;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void frame_frame_gravity(Frame *self, int *x, int *y)
|
||||
{
|
||||
/* horizontal */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
*x += (self->size.left + self->size.right) / 2;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
*x += self->size.left + self->size.right;
|
||||
break;
|
||||
case StaticGravity:
|
||||
case ForgetGravity:
|
||||
x += self->size.left;
|
||||
break;
|
||||
}
|
||||
|
||||
/* vertical */
|
||||
switch (self->client->gravity) {
|
||||
default:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
*y += (self->size.top + self->size.bottom) / 2;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
*y += self->size.top + self->size.bottom;
|
||||
break;
|
||||
case StaticGravity:
|
||||
case ForgetGravity:
|
||||
*y += self->size.top;
|
||||
break;
|
||||
}
|
||||
}
|
31
openbox/frame.h
Normal file
31
openbox/frame.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef __frame_h
|
||||
#define __frame_h
|
||||
|
||||
#include "geom.h"
|
||||
#include "client.h"
|
||||
|
||||
typedef struct Frame {
|
||||
Client *client;
|
||||
|
||||
Window window;
|
||||
Window plate;
|
||||
|
||||
Strut size;
|
||||
Rect area;
|
||||
gboolean visible;
|
||||
} Frame;
|
||||
|
||||
/*! Applies gravity to the client's position to find where the frame should
|
||||
be positioned.
|
||||
@return The proper coordinates for the frame, based on the client.
|
||||
*/
|
||||
void frame_client_gravity(Frame *self, int *x, int *y);
|
||||
|
||||
/*! Reversly applies gravity to the frame's position to find where the client
|
||||
should be positioned.
|
||||
@return The proper coordinates for the client, based on the frame.
|
||||
*/
|
||||
void frame_frame_gravity(Frame *self, int *x, int *y);
|
||||
|
||||
|
||||
#endif
|
49
openbox/geom.h
Normal file
49
openbox/geom.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef __geom_h
|
||||
#define __geom_h
|
||||
|
||||
typedef struct Point {
|
||||
int x;
|
||||
int y;
|
||||
} Point;
|
||||
|
||||
#define POINT_SET(pt, nx, ny) {pt.x = nx; pt.y = ny;}
|
||||
|
||||
typedef struct Size {
|
||||
int width;
|
||||
int height;
|
||||
} Size;
|
||||
|
||||
#define SIZE_SET(sz, w, h) {sz.width = w; sz.height = h;}
|
||||
|
||||
typedef struct Rect {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} Rect;
|
||||
|
||||
#define RECT_SET_POINT(r, nx, ny) \
|
||||
{r.x = ny; r.y = ny;}
|
||||
#define RECT_SET_SIZE(r, w, h) \
|
||||
{r.width = w; r.height = h;}
|
||||
#define RECT_SET(r, nx, ny, w, h) \
|
||||
{r.x = nx; r.y = ny; r.width = w; r.height = h;}
|
||||
|
||||
#define RECT_EQUAL(r1, r2) (r1.x == r2.x && r1.y == r2.y && \
|
||||
r1.width == r2.width && r1.height == r2.height)
|
||||
|
||||
typedef struct Strut {
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
} Strut;
|
||||
|
||||
#define STRUT_SET(s, l, t, r, b) \
|
||||
{s.left = l; s.top = t; s.right = r; s.bottom = b; }
|
||||
|
||||
#define STRUT_ADD(s1, s2) \
|
||||
{s1.left = MAX(s1.left, s2.left); s1.right = MAX(s1.right, s2.right); \
|
||||
s1.top = MAX(s1.top, s2.top); s1.bottom = MAX(s1.bottom, s2.bottom); }
|
||||
|
||||
#endif
|
73
openbox/gettext.h
Normal file
73
openbox/gettext.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option. */
|
||||
#if ENABLE_NLS
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
/* Custom macro to make life easier */
|
||||
#define _(str) gettext(str)
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
295
openbox/hooks.c
Normal file
295
openbox/hooks.c
Normal file
|
@ -0,0 +1,295 @@
|
|||
#include "hooks.h"
|
||||
#include <glib.h>
|
||||
|
||||
/*
|
||||
*
|
||||
* Define the 'Hook' class type
|
||||
*
|
||||
*/
|
||||
#define IS_HOOK(v) ((v)->ob_type == &HookType)
|
||||
|
||||
staticforward PyTypeObject HookType;
|
||||
|
||||
typedef struct HookObject {
|
||||
PyObject_HEAD
|
||||
GSList *funcs;
|
||||
} HookObject;
|
||||
|
||||
static int hook_init(HookObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
char *keywords[] = { 0 };
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, ":__init__", keywords))
|
||||
return -1;
|
||||
self->funcs = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hook_dealloc(HookObject *self)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
for (it = self->funcs; it != NULL; it = it->next)
|
||||
Py_DECREF((PyObject*) it->data);
|
||||
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyObject *hook_fire(HookObject *self, PyObject *args)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'fire' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (it = self->funcs; it != NULL; it = it->next) {
|
||||
PyObject *ret = PyObject_CallObject(it->data, args);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *hook_append(HookObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'append' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "O:append", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'append' requires a callable argument");
|
||||
return NULL;
|
||||
}
|
||||
self->funcs = g_slist_append(self->funcs, func);
|
||||
Py_INCREF(func);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *hook_remove(HookObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
GSList *it;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'remove' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "O:remove", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor 'remove' requires a callable argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
it = g_slist_find(self->funcs, func);
|
||||
if (it != NULL) {
|
||||
self->funcs = g_slist_delete_link(self->funcs, it);
|
||||
Py_DECREF(func);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"given callable object was not found in Hook");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *hook_call(HookObject *self, PyObject *args)
|
||||
{
|
||||
GSList *it, *next;
|
||||
gboolean stop = FALSE;
|
||||
|
||||
if (!IS_HOOK(self)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"descriptor '__call__' requires a 'Hook' object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (it = self->funcs; !stop && it != NULL;) {
|
||||
next = it->next; /* incase the hook removes itself */
|
||||
|
||||
PyObject *ret = PyObject_CallObject(it->data, args);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
if (ret != Py_None)
|
||||
stop = TRUE;
|
||||
Py_DECREF(ret);
|
||||
|
||||
it = next;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyTypeObject HookType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Hook",
|
||||
sizeof(HookObject),
|
||||
0,
|
||||
(destructor) hook_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
static PyMethodDef HookMethods[] = {
|
||||
{"append", (PyCFunction)hook_append, METH_VARARGS,
|
||||
"hook.add(func) -- Add a function to the hook." },
|
||||
{"remove", (PyCFunction)hook_remove, METH_VARARGS,
|
||||
"hook.remove(func) -- Remove a function from the hook." },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Module initialization/finalization
|
||||
*
|
||||
*/
|
||||
|
||||
static PyObject *hooks, *hooksdict;
|
||||
|
||||
static PyMethodDef HooksMethods[] = {
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
struct HookObject *hooks_create(char *name)
|
||||
{
|
||||
HookObject *hook;
|
||||
int ret;
|
||||
|
||||
hook = PyObject_New(HookObject, &HookType);
|
||||
hook->funcs = NULL;
|
||||
|
||||
/* add it to the hooks module */
|
||||
ret = PyDict_SetItemString(hooksdict, name, (PyObject*) hook);
|
||||
g_assert(ret != -1);
|
||||
|
||||
return hook;
|
||||
}
|
||||
|
||||
void hooks_startup()
|
||||
{
|
||||
HookType.ob_type = &PyType_Type;
|
||||
HookType.tp_methods = HookMethods;
|
||||
HookType.tp_alloc = PyType_GenericAlloc;
|
||||
HookType.tp_new = PyType_GenericNew;
|
||||
HookType.tp_init = (initproc) hook_init;
|
||||
HookType.tp_call = (ternaryfunc) hook_call;
|
||||
PyType_Ready(&HookType);
|
||||
|
||||
Py_InitModule("hooks", HooksMethods);
|
||||
|
||||
/* get the hooks module/dict */
|
||||
hooks = PyImport_ImportModule("hooks"); /* new */
|
||||
g_assert(hooks != NULL);
|
||||
hooksdict = PyModule_GetDict(hooks); /* borrowed */
|
||||
g_assert(hooksdict != NULL);
|
||||
|
||||
/* add the Hook type to the hooks module */
|
||||
PyDict_SetItemString(hooksdict, "Hook", (PyObject*) &HookType);
|
||||
|
||||
hook_startup = hooks_create("startup");
|
||||
hook_shutdown = hooks_create("shutdown");
|
||||
hook_visibledesktop = hooks_create("visibledesktop");
|
||||
hook_numdesktops = hooks_create("numdesktops");
|
||||
hook_desktopnames = hooks_create("desktopnames");
|
||||
hook_showdesktop = hooks_create("showdesktop");
|
||||
hook_screenconfiguration = hooks_create("screenconfiguration");
|
||||
hook_screenarea = hooks_create("screenarea");
|
||||
hook_managed = hooks_create("managed");
|
||||
hook_closed = hooks_create("closed");
|
||||
hook_bell = hooks_create("bell");
|
||||
hook_urgent = hooks_create("urgent");
|
||||
hook_pointerenter = hooks_create("pointerenter");
|
||||
hook_pointerleave = hooks_create("pointerleave");
|
||||
hook_focused = hooks_create("focused");
|
||||
hook_requestactivate = hooks_create("requestactivate");
|
||||
hook_title = hooks_create("title");
|
||||
hook_desktop = hooks_create("desktop");
|
||||
hook_iconic = hooks_create("iconic");
|
||||
hook_shaded = hooks_create("shaded");
|
||||
hook_maximized = hooks_create("maximized");
|
||||
hook_fullscreen = hooks_create("fullscreen");
|
||||
hook_visible = hooks_create("visible");
|
||||
hook_configuration = hooks_create("configuration");
|
||||
}
|
||||
|
||||
void hooks_shutdown()
|
||||
{
|
||||
Py_DECREF(hook_startup);
|
||||
Py_DECREF(hook_shutdown);
|
||||
Py_DECREF(hook_visibledesktop);
|
||||
Py_DECREF(hook_numdesktops);
|
||||
Py_DECREF(hook_desktopnames);
|
||||
Py_DECREF(hook_showdesktop);
|
||||
Py_DECREF(hook_screenconfiguration);
|
||||
Py_DECREF(hook_screenarea);
|
||||
Py_DECREF(hook_managed);
|
||||
Py_DECREF(hook_closed);
|
||||
Py_DECREF(hook_bell);
|
||||
Py_DECREF(hook_urgent);
|
||||
Py_DECREF(hook_pointerenter);
|
||||
Py_DECREF(hook_pointerleave);
|
||||
Py_DECREF(hook_focused);
|
||||
Py_DECREF(hook_requestactivate);
|
||||
Py_DECREF(hook_title);
|
||||
Py_DECREF(hook_desktop);
|
||||
Py_DECREF(hook_iconic);
|
||||
Py_DECREF(hook_shaded);
|
||||
Py_DECREF(hook_maximized);
|
||||
Py_DECREF(hook_fullscreen);
|
||||
Py_DECREF(hook_visible);
|
||||
Py_DECREF(hook_configuration);
|
||||
|
||||
Py_DECREF(hooks);
|
||||
}
|
||||
|
||||
void hooks_fire(struct HookObject *hook, PyObject *args)
|
||||
{
|
||||
PyObject *ret = hook_call(hook, args);
|
||||
if (ret == NULL)
|
||||
PyErr_Print();
|
||||
Py_XDECREF(ret);
|
||||
}
|
||||
|
||||
void hooks_fire_client(struct HookObject *hook, struct Client *client)
|
||||
{
|
||||
PyObject *args;
|
||||
|
||||
if (client != NULL) {
|
||||
PyObject *c = clientwrap_new(client);
|
||||
g_assert(c != NULL);
|
||||
args = Py_BuildValue("(O)", c);
|
||||
Py_DECREF(c);
|
||||
} else {
|
||||
args = Py_BuildValue("(O)", Py_None);
|
||||
}
|
||||
|
||||
g_assert(args != NULL);
|
||||
hooks_fire(hook, args);
|
||||
Py_DECREF(args);
|
||||
}
|
56
openbox/hooks.h
Normal file
56
openbox/hooks.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
#ifndef __hooks_h
|
||||
#define __hooks_h
|
||||
|
||||
#include "clientwrap.h"
|
||||
#include <Python.h>
|
||||
|
||||
void hooks_startup();
|
||||
void hooks_shutdown();
|
||||
|
||||
struct HookObject;
|
||||
|
||||
struct HookObject *hooks_create(char *name);
|
||||
|
||||
struct HookObject *hook_startup;
|
||||
struct HookObject *hook_shutdown;
|
||||
struct HookObject *hook_visibledesktop;
|
||||
struct HookObject *hook_numdesktops;
|
||||
struct HookObject *hook_desktopnames;
|
||||
struct HookObject *hook_showdesktop;
|
||||
struct HookObject *hook_screenconfiguration;
|
||||
struct HookObject *hook_screenarea;
|
||||
struct HookObject *hook_managed;
|
||||
struct HookObject *hook_closed;
|
||||
struct HookObject *hook_bell;
|
||||
struct HookObject *hook_urgent;
|
||||
struct HookObject *hook_pointerenter;
|
||||
struct HookObject *hook_pointerleave;
|
||||
struct HookObject *hook_focused;
|
||||
struct HookObject *hook_requestactivate;
|
||||
struct HookObject *hook_title;
|
||||
struct HookObject *hook_desktop;
|
||||
struct HookObject *hook_iconic;
|
||||
struct HookObject *hook_shaded;
|
||||
struct HookObject *hook_maximized;
|
||||
struct HookObject *hook_fullscreen;
|
||||
struct HookObject *hook_visible;
|
||||
struct HookObject *hook_configuration;
|
||||
|
||||
#define HOOKFIRE(hook, ...) \
|
||||
{ \
|
||||
PyObject *args = Py_BuildValue(__VA_ARGS__); \
|
||||
g_assert(args != NULL); \
|
||||
hooks_fire(hook_##hook, args); \
|
||||
Py_DECREF(args); \
|
||||
}
|
||||
|
||||
#define HOOKFIRECLIENT(hook, client) \
|
||||
{ \
|
||||
hooks_fire_client(hook_##hook, client); \
|
||||
}
|
||||
|
||||
void hooks_fire(struct HookObject *hook, PyObject *args);
|
||||
|
||||
void hooks_fire_client(struct HookObject *hook, struct Client *client);
|
||||
|
||||
#endif
|
696
openbox/keyboard.c
Normal file
696
openbox/keyboard.c
Normal file
|
@ -0,0 +1,696 @@
|
|||
#include "focus.h"
|
||||
#include "openbox.h"
|
||||
#include "keyboard.h"
|
||||
#include "clientwrap.h"
|
||||
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
typedef struct KeyBindingTree {
|
||||
guint state;
|
||||
guint key;
|
||||
GList *keylist;
|
||||
PyObject *func;
|
||||
|
||||
/* the next binding in the tree at the same level */
|
||||
struct KeyBindingTree *next_sibling;
|
||||
/* the first child of this binding (next binding in a chained sequence).*/
|
||||
struct KeyBindingTree *first_child;
|
||||
} KeyBindingTree;
|
||||
|
||||
|
||||
static KeyBindingTree *firstnode, *curpos;
|
||||
static guint reset_key, reset_state;
|
||||
static gboolean grabbed, user_grabbed;
|
||||
static PyObject *grab_func;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'KeyboardData'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct KeyboardData {
|
||||
PyObject_HEAD
|
||||
PyObject *keychain;
|
||||
guint state;
|
||||
guint keycode;
|
||||
gboolean press;
|
||||
} KeyboardData;
|
||||
|
||||
staticforward PyTypeObject KeyboardDataType;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *keybdata_new(PyObject *keychain, guint state,
|
||||
guint keycode, gboolean press)
|
||||
{
|
||||
KeyboardData *data = PyObject_New(KeyboardData, &KeyboardDataType);
|
||||
data->keychain = keychain;
|
||||
Py_INCREF(keychain);
|
||||
data->state = state;
|
||||
data->keycode = keycode;
|
||||
data->press = press;
|
||||
return (PyObject*) data;
|
||||
}
|
||||
|
||||
static void keybdata_dealloc(KeyboardData *self)
|
||||
{
|
||||
Py_DECREF(self->keychain);
|
||||
PyObject_Del((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject *keybdata_getattr(KeyboardData *self, char *name)
|
||||
{
|
||||
if (!strcmp(name, "keychain")) {
|
||||
Py_INCREF(self->keychain);
|
||||
return self->keychain;
|
||||
} else if (!strcmp(name, "state"))
|
||||
return PyInt_FromLong(self->state);
|
||||
else if (!strcmp(name, "keycode"))
|
||||
return PyInt_FromLong(self->keycode);
|
||||
else if (!strcmp(name, "press"))
|
||||
return PyInt_FromLong(!!self->press);
|
||||
|
||||
PyErr_Format(PyExc_AttributeError, "no such attribute '%s'", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyTypeObject KeyboardDataType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"KeyboardData",
|
||||
sizeof(KeyboardData),
|
||||
0,
|
||||
(destructor) keybdata_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) keybdata_getattr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
guint keyboard_translate_modifier(char *str)
|
||||
{
|
||||
if (!strcmp("Mod1", str)) return Mod1Mask;
|
||||
else if (!strcmp("Mod2", str)) return Mod2Mask;
|
||||
else if (!strcmp("Mod3", str)) return Mod3Mask;
|
||||
else if (!strcmp("Mod4", str)) return Mod4Mask;
|
||||
else if (!strcmp("Mod5", str)) return Mod5Mask;
|
||||
else if (!strcmp("C", str)) return ControlMask;
|
||||
else if (!strcmp("S", str)) return ShiftMask;
|
||||
g_warning("Invalid modifier '%s' in binding.", str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean translate(char *str, guint *state, guint *keycode)
|
||||
{
|
||||
char **parsed;
|
||||
char *l;
|
||||
int i;
|
||||
gboolean ret = FALSE;
|
||||
KeySym sym;
|
||||
|
||||
parsed = g_strsplit(str, "-", -1);
|
||||
|
||||
/* first, find the key (last token) */
|
||||
l = NULL;
|
||||
for (i = 0; parsed[i] != NULL; ++i)
|
||||
l = parsed[i];
|
||||
if (l == NULL)
|
||||
goto translation_fail;
|
||||
|
||||
/* figure out the mod mask */
|
||||
*state = 0;
|
||||
for (i = 0; parsed[i] != l; ++i) {
|
||||
guint m = keyboard_translate_modifier(parsed[i]);
|
||||
if (!m) goto translation_fail;
|
||||
*state |= m;
|
||||
}
|
||||
|
||||
/* figure out the keycode */
|
||||
sym = XStringToKeysym(l);
|
||||
if (sym == NoSymbol) {
|
||||
g_warning("Invalid key name '%s' in key binding.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
*keycode = XKeysymToKeycode(ob_display, sym);
|
||||
if (!keycode) {
|
||||
g_warning("Key '%s' does not exist on the display.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
translation_fail:
|
||||
g_strfreev(parsed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void destroytree(KeyBindingTree *tree)
|
||||
{
|
||||
KeyBindingTree *c;
|
||||
|
||||
while (tree) {
|
||||
destroytree(tree->next_sibling);
|
||||
c = tree->first_child;
|
||||
if (c == NULL) {
|
||||
GList *it;
|
||||
for (it = tree->keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(tree->keylist);
|
||||
Py_XDECREF(tree->func);
|
||||
}
|
||||
g_free(tree);
|
||||
tree = c;
|
||||
}
|
||||
}
|
||||
|
||||
static KeyBindingTree *buildtree(GList *keylist)
|
||||
{
|
||||
GList *it;
|
||||
KeyBindingTree *ret = NULL, *p;
|
||||
|
||||
if (g_list_length(keylist) <= 0)
|
||||
return NULL; /* nothing in the list.. */
|
||||
|
||||
for (it = g_list_last(keylist); it != NULL; it = it->prev) {
|
||||
p = ret;
|
||||
ret = g_new(KeyBindingTree, 1);
|
||||
ret->next_sibling = NULL;
|
||||
ret->func = NULL;
|
||||
if (p == NULL) {
|
||||
GList *it;
|
||||
|
||||
/* this is the first built node, the bottom node of the tree */
|
||||
ret->keylist = g_list_copy(keylist); /* shallow copy */
|
||||
for (it = ret->keylist; it != NULL; it = it->next) /* deep copy */
|
||||
it->data = g_strdup(it->data);
|
||||
}
|
||||
ret->first_child = p;
|
||||
if (!translate(it->data, &ret->state, &ret->key)) {
|
||||
destroytree(ret);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void assimilate(KeyBindingTree *node)
|
||||
{
|
||||
KeyBindingTree *a, *b, *tmp, *last;
|
||||
|
||||
if (firstnode == NULL) {
|
||||
/* there are no nodes at this level yet */
|
||||
firstnode = node;
|
||||
} else {
|
||||
a = firstnode;
|
||||
last = a;
|
||||
b = node;
|
||||
while (a) {
|
||||
last = a;
|
||||
if (!(a->state == b->state && a->key == b->key)) {
|
||||
a = a->next_sibling;
|
||||
} else {
|
||||
tmp = b;
|
||||
b = b->first_child;
|
||||
g_free(tmp);
|
||||
a = a->first_child;
|
||||
}
|
||||
}
|
||||
if (!(last->state == b->state && last->key == b->key))
|
||||
last->next_sibling = b;
|
||||
else {
|
||||
last->first_child = b->first_child;
|
||||
g_free(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static KeyBindingTree *find(KeyBindingTree *search, gboolean *conflict)
|
||||
{
|
||||
KeyBindingTree *a, *b;
|
||||
|
||||
*conflict = FALSE;
|
||||
|
||||
a = firstnode;
|
||||
b = search;
|
||||
while (a && b) {
|
||||
if (!(a->state == b->state && a->key == b->key)) {
|
||||
a = a->next_sibling;
|
||||
} else {
|
||||
if ((a->first_child == NULL) == (b->first_child == NULL)) {
|
||||
if (a->first_child == NULL) {
|
||||
/* found it! (return the actual node, not the search's) */
|
||||
return a;
|
||||
}
|
||||
} else {
|
||||
*conflict = TRUE;
|
||||
return NULL; /* the chain status' don't match (conflict!) */
|
||||
}
|
||||
b = b->first_child;
|
||||
a = a->first_child;
|
||||
}
|
||||
}
|
||||
return NULL; // it just isn't in here
|
||||
}
|
||||
|
||||
static void grab_keys(gboolean grab)
|
||||
{
|
||||
if (!grab) {
|
||||
XUngrabKey(ob_display, AnyKey, AnyModifier, ob_root);
|
||||
} else {
|
||||
KeyBindingTree *p = firstnode;
|
||||
while (p) {
|
||||
XGrabKey(ob_display, p->key, p->state, ob_root, FALSE,
|
||||
GrabModeAsync, GrabModeSync);
|
||||
p = p->next_sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_chains()
|
||||
{
|
||||
/* XXX kill timer */
|
||||
curpos = NULL;
|
||||
if (grabbed) {
|
||||
grabbed = FALSE;
|
||||
g_message("reset chains. user_grabbed: %d", user_grabbed);
|
||||
if (!user_grabbed)
|
||||
XUngrabKeyboard(ob_display, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
void keyboard_event(XKeyEvent *e)
|
||||
{
|
||||
PyObject *chain, *client, *args, *keybdata, *ret;
|
||||
gboolean press = e->type == KeyPress;
|
||||
|
||||
if (focus_client) client = clientwrap_new(focus_client);
|
||||
else client = Py_None;
|
||||
|
||||
if (user_grabbed) {
|
||||
GString *str = g_string_sized_new(0);
|
||||
KeySym sym;
|
||||
|
||||
/* build the 'chain' */
|
||||
if (e->state & ControlMask)
|
||||
g_string_append(str, "C-");
|
||||
if (e->state & ShiftMask)
|
||||
g_string_append(str, "S-");
|
||||
if (e->state & Mod1Mask)
|
||||
g_string_append(str, "Mod1-");
|
||||
if (e->state & Mod2Mask)
|
||||
g_string_append(str, "Mod2-");
|
||||
if (e->state & Mod3Mask)
|
||||
g_string_append(str, "Mod3-");
|
||||
if (e->state & Mod4Mask)
|
||||
g_string_append(str, "Mod4-");
|
||||
if (e->state & Mod5Mask)
|
||||
g_string_append(str, "Mod5-");
|
||||
|
||||
sym = XKeycodeToKeysym(ob_display, e->keycode, 0);
|
||||
if (sym == NoSymbol)
|
||||
g_string_append(str, "NoSymbol");
|
||||
else {
|
||||
char *name = XKeysymToString(sym);
|
||||
if (name == NULL)
|
||||
name = "Undefined";
|
||||
g_string_append(str, name);
|
||||
}
|
||||
|
||||
chain = PyTuple_New(1);
|
||||
PyTuple_SET_ITEM(chain, 0, PyString_FromString(str->str));
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
keybdata = keybdata_new(chain, e->state, e->keycode, press);
|
||||
|
||||
args = Py_BuildValue("OO", keybdata, client);
|
||||
|
||||
ret = PyObject_CallObject(grab_func, args);
|
||||
if (ret == NULL) PyErr_Print();
|
||||
Py_XDECREF(ret);
|
||||
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(keybdata);
|
||||
Py_DECREF(chain);
|
||||
}
|
||||
|
||||
if (press) {
|
||||
if (e->keycode == reset_key && e->state == reset_state) {
|
||||
reset_chains();
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
} else {
|
||||
KeyBindingTree *p;
|
||||
if (curpos == NULL)
|
||||
p = firstnode;
|
||||
else
|
||||
p = curpos->first_child;
|
||||
while (p) {
|
||||
if (p->key == e->keycode && p->state == e->state) {
|
||||
if (p->first_child != NULL) { /* part of a chain */
|
||||
/* XXX TIMER */
|
||||
if (!grabbed && !user_grabbed) {
|
||||
/*grab should never fail because we should have a
|
||||
sync grab at this point */
|
||||
XGrabKeyboard(ob_display, ob_root, 0,
|
||||
GrabModeAsync, GrabModeSync,
|
||||
CurrentTime);
|
||||
}
|
||||
grabbed = TRUE;
|
||||
curpos = p;
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
} else {
|
||||
GList *it;
|
||||
int i;
|
||||
|
||||
chain = PyTuple_New(g_list_length(p->keylist));
|
||||
for (i = 0, it = p->keylist; it != NULL;
|
||||
it = it->next, ++i)
|
||||
PyTuple_SET_ITEM(chain, i,
|
||||
PyString_FromString(it->data));
|
||||
|
||||
keybdata = keybdata_new(chain, e->state, e->keycode,
|
||||
press);
|
||||
|
||||
args = Py_BuildValue("OO", keybdata, client);
|
||||
|
||||
ret = PyObject_CallObject(p->func, args);
|
||||
if (ret == NULL) PyErr_Print();
|
||||
Py_XDECREF(ret);
|
||||
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(keybdata);
|
||||
Py_DECREF(chain);
|
||||
|
||||
XAllowEvents(ob_display, AsyncKeyboard, CurrentTime);
|
||||
reset_chains();
|
||||
}
|
||||
break;
|
||||
}
|
||||
p = p->next_sibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (client != Py_None) { Py_DECREF(client); }
|
||||
}
|
||||
|
||||
static void clearall()
|
||||
{
|
||||
grab_keys(FALSE);
|
||||
destroytree(firstnode);
|
||||
firstnode = NULL;
|
||||
grab_keys(TRUE);
|
||||
}
|
||||
|
||||
static gboolean grab_keyboard(gboolean grab)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
g_message("grab_keyboard(%s). grabbed: %d", (grab?"True":"False"),grabbed);
|
||||
|
||||
user_grabbed = grab;
|
||||
if (!grabbed) {
|
||||
if (grab)
|
||||
ret = XGrabKeyboard(ob_display, ob_root, 0, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime) == GrabSuccess;
|
||||
else
|
||||
XUngrabKeyboard(ob_display, CurrentTime);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'Keyboard'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_KEYBOARD(v) ((v)->ob_type == &KeyboardType)
|
||||
#define CHECK_KEYBOARD(self, funcname) { \
|
||||
if (!IS_KEYBOARD(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires a 'Keyboard' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
typedef struct Keyboard {
|
||||
PyObject_HEAD
|
||||
} Keyboard;
|
||||
|
||||
staticforward PyTypeObject KeyboardType;
|
||||
|
||||
static PyObject *keyb_bind(Keyboard *self, PyObject *args)
|
||||
{
|
||||
KeyBindingTree *tree = NULL, *t;
|
||||
gboolean conflict;
|
||||
PyObject *item, *tuple, *func;
|
||||
GList *keylist = NULL, *it;
|
||||
int i, s;
|
||||
|
||||
CHECK_KEYBOARD(self, "grab");
|
||||
if (!PyArg_ParseTuple(args, "OO:grab", &tuple, &func))
|
||||
return NULL;
|
||||
|
||||
if (!PyTuple_Check(tuple)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a tuple of strings");
|
||||
goto binderror;
|
||||
}
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a callable object");
|
||||
goto binderror;
|
||||
}
|
||||
|
||||
s = PyTuple_GET_SIZE(tuple);
|
||||
if (s <= 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a tuple of strings");
|
||||
goto binderror;
|
||||
}
|
||||
|
||||
for (i = 0; i < s; ++i) {
|
||||
item = PyTuple_GET_ITEM(tuple, i);
|
||||
if (!PyString_Check(item)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a tuple of strings");
|
||||
goto binderror;
|
||||
}
|
||||
keylist = g_list_append(keylist,
|
||||
g_strdup(PyString_AsString(item)));
|
||||
}
|
||||
|
||||
if (!(tree = buildtree(keylist))) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid binding");
|
||||
goto binderror;
|
||||
}
|
||||
|
||||
t = find(tree, &conflict);
|
||||
if (conflict) {
|
||||
PyErr_SetString(PyExc_ValueError, "conflict with binding");
|
||||
goto binderror;
|
||||
}
|
||||
if (t != NULL) {
|
||||
/* already bound to something */
|
||||
PyErr_SetString(PyExc_ValueError, "keychain is already bound");
|
||||
goto binderror;
|
||||
}
|
||||
|
||||
/* grab the server here to make sure no key pressed go missed */
|
||||
XGrabServer(ob_display);
|
||||
XSync(ob_display, FALSE);
|
||||
|
||||
grab_keys(FALSE);
|
||||
|
||||
/* set the function */
|
||||
t = tree;
|
||||
while (t->first_child) t = t->first_child;
|
||||
t->func = func;
|
||||
Py_INCREF(func);
|
||||
|
||||
/* assimilate this built tree into the main tree */
|
||||
assimilate(tree); // assimilation destroys/uses the tree
|
||||
|
||||
grab_keys(TRUE);
|
||||
|
||||
XUngrabServer(ob_display);
|
||||
XFlush(ob_display);
|
||||
|
||||
for (it = keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(it);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
binderror:
|
||||
if (tree != NULL) destroytree(tree);
|
||||
for (it = keylist; it != NULL; it = it->next)
|
||||
g_free(it->data);
|
||||
g_list_free(it);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *keyb_clearBinds(Keyboard *self, PyObject *args)
|
||||
{
|
||||
CHECK_KEYBOARD(self, "clearBinds");
|
||||
if (!PyArg_ParseTuple(args, ":clearBinds"))
|
||||
return NULL;
|
||||
clearall();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *keyb_grab(Keyboard *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
|
||||
CHECK_KEYBOARD(self, "grab");
|
||||
if (!PyArg_ParseTuple(args, "O:grab", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a callable object");
|
||||
return NULL;
|
||||
}
|
||||
if (!grab_keyboard(TRUE)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "failed to grab keyboard");
|
||||
return NULL;
|
||||
}
|
||||
grab_func = func;
|
||||
Py_INCREF(grab_func);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *keyb_ungrab(Keyboard *self, PyObject *args)
|
||||
{
|
||||
CHECK_KEYBOARD(self, "ungrab");
|
||||
if (!PyArg_ParseTuple(args, ":ungrab"))
|
||||
return NULL;
|
||||
grab_keyboard(FALSE);
|
||||
Py_XDECREF(grab_func);
|
||||
grab_func = NULL;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#define METH(n, d) {#n, (PyCFunction)keyb_##n, METH_VARARGS, #d}
|
||||
|
||||
static PyMethodDef KeyboardMethods[] = {
|
||||
METH(bind,
|
||||
"bind(keychain, func)\n\n"
|
||||
"Binds a key-chain to a function. The keychain is a tuple of strings "
|
||||
"which define a chain of key presses. Each member of the tuple has "
|
||||
"the format [Modifier-]...[Key]. Modifiers can be 'mod1', 'mod2', "
|
||||
"'mod3', 'mod4', 'mod5', 'control', and 'shift'. The keys on your "
|
||||
"keyboard that are bound to each of these modifiers can be found by "
|
||||
"running 'xmodmap'. The Key can be any valid key definition. Key "
|
||||
"definitions can be found by running 'xev', pressing the key while "
|
||||
"its window is focused, and watching its output. Here are some "
|
||||
"examples of valid keychains: ('a'), ('F7'), ('control-a', 'd'), "
|
||||
"('control-mod1-x', 'control-mod4-g'), ('F1', 'space'). The func "
|
||||
"must have a definition similar to 'def func(keydata, client)'. A "
|
||||
"keychain cannot be bound to more than one function."),
|
||||
METH(clearBinds,
|
||||
"clearBinds()\n\n"
|
||||
"Removes all bindings that were previously made by bind()."),
|
||||
METH(grab,
|
||||
"grab(func)\n\n"
|
||||
"Grabs the entire keyboard, causing all possible keyboard events to "
|
||||
"be passed to the given function. CAUTION: Be sure when you grab() "
|
||||
"that you also have an ungrab() that will execute, or you will not "
|
||||
"be able to type until you restart Openbox. The func must have a "
|
||||
"definition similar to 'def func(keydata)'. The keyboard cannot be "
|
||||
"grabbed if it is already grabbed."),
|
||||
METH(ungrab,
|
||||
"ungrab()\n\n"
|
||||
"Ungrabs the keyboard. The keyboard cannot be ungrabbed if it is not "
|
||||
"grabbed."),
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static void keyb_dealloc(PyObject *self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
static PyTypeObject KeyboardType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Keyboard",
|
||||
sizeof(Keyboard),
|
||||
0,
|
||||
(destructor) keyb_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void keyboard_startup()
|
||||
{
|
||||
PyObject *input, *inputdict, *ptr;
|
||||
gboolean b;
|
||||
|
||||
curpos = firstnode = NULL;
|
||||
grabbed = user_grabbed = FALSE;
|
||||
|
||||
b = translate("C-G", &reset_state, &reset_key);
|
||||
g_assert(b);
|
||||
|
||||
KeyboardType.ob_type = &PyType_Type;
|
||||
KeyboardType.tp_methods = KeyboardMethods;
|
||||
PyType_Ready(&KeyboardType);
|
||||
PyType_Ready(&KeyboardDataType);
|
||||
|
||||
/* get the input module/dict */
|
||||
input = PyImport_ImportModule("input"); /* new */
|
||||
g_assert(input != NULL);
|
||||
inputdict = PyModule_GetDict(input); /* borrowed */
|
||||
g_assert(inputdict != NULL);
|
||||
|
||||
/* add a Keyboard instance to the input module */
|
||||
ptr = (PyObject*) PyObject_New(Keyboard, &KeyboardType);
|
||||
PyDict_SetItemString(inputdict, "Keyboard", ptr);
|
||||
Py_DECREF(ptr);
|
||||
|
||||
Py_DECREF(input);
|
||||
}
|
||||
|
||||
void keyboard_shutdown()
|
||||
{
|
||||
if (grabbed || user_grabbed) {
|
||||
grabbed = FALSE;
|
||||
grab_keyboard(FALSE);
|
||||
}
|
||||
grab_keys(FALSE);
|
||||
destroytree(firstnode);
|
||||
firstnode = NULL;
|
||||
}
|
||||
|
13
openbox/keyboard.h
Normal file
13
openbox/keyboard.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef __keyboard_h
|
||||
#define __keyboard_h
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
void keyboard_startup();
|
||||
void keyboard_shutdown();
|
||||
|
||||
guint keyboard_translate_modifier(char *str);
|
||||
|
||||
void keyboard_event(XKeyEvent *e);
|
||||
|
||||
#endif
|
210
openbox/openbox.c
Normal file
210
openbox/openbox.c
Normal file
|
@ -0,0 +1,210 @@
|
|||
#include "openbox.h"
|
||||
#include "event.h"
|
||||
#include "client.h"
|
||||
#include "xerror.h"
|
||||
#include "prop.h"
|
||||
#include "screen.h"
|
||||
#include "focus.h"
|
||||
#include "extensions.h"
|
||||
#include "gettext.h"
|
||||
#include "keyboard.h"
|
||||
#include "pointer.h"
|
||||
#include "engine.h"
|
||||
#include "python.h"
|
||||
#include "hooks.h"
|
||||
#include "clientwrap.h"
|
||||
#include "openboxwrap.h"
|
||||
#include "themerc.h"
|
||||
#include "timer.h"
|
||||
#include "../render/render.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
Display *ob_display = NULL;
|
||||
int ob_screen;
|
||||
Window ob_root;
|
||||
State ob_state;
|
||||
gboolean ob_shutdown = FALSE;
|
||||
gboolean ob_restart = FALSE;
|
||||
char *ob_restart_path = NULL;
|
||||
gboolean ob_remote = FALSE;
|
||||
gboolean ob_sync = TRUE;
|
||||
Cursors ob_cursors;
|
||||
|
||||
void signal_handler(int signal);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct sigaction action;
|
||||
sigset_t sigset;
|
||||
|
||||
ob_state = State_Starting;
|
||||
|
||||
/* initialize the locale */
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
g_warning("Couldn't set locale from environment.\n");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
||||
textdomain(PACKAGE);
|
||||
|
||||
/* set up signal handler */
|
||||
sigemptyset(&sigset);
|
||||
action.sa_handler = signal_handler;
|
||||
action.sa_mask = sigset;
|
||||
action.sa_flags = SA_NOCLDSTOP | SA_NODEFER;
|
||||
sigaction(SIGUSR1, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGPIPE, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGSEGV, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGFPE, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGTERM, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGINT, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGHUP, &action, (struct sigaction *) NULL);
|
||||
sigaction(SIGCHLD, &action, (struct sigaction *) NULL);
|
||||
|
||||
/* anything that died while we were restarting won't give us a SIGCHLD */
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
|
||||
/* XXX parse out command line args */
|
||||
(void)argc;(void)argv;
|
||||
|
||||
ob_display = XOpenDisplay(NULL);
|
||||
if (ob_display == NULL) {
|
||||
/* print a message and exit */
|
||||
g_critical("Failed to open the display.");
|
||||
exit(1);
|
||||
}
|
||||
if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1) {
|
||||
/* print a message and exit */
|
||||
g_critical("Failed to set display as close-on-exec.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ob_screen = DefaultScreen(ob_display);
|
||||
ob_root = RootWindow(ob_display, ob_screen);
|
||||
|
||||
/* XXX fork self onto other screens */
|
||||
|
||||
XSynchronize(ob_display, ob_sync);
|
||||
|
||||
/* check for locale support */
|
||||
if (!XSupportsLocale())
|
||||
g_warning("X server does not support locale.");
|
||||
if (!XSetLocaleModifiers(""))
|
||||
g_warning("Cannot set locale modifiers for the X server.");
|
||||
|
||||
/* set our error handler */
|
||||
XSetErrorHandler(xerror_handler);
|
||||
|
||||
/* set the DISPLAY environment variable for any lauched children, to the
|
||||
display we're using, so they open in the right place. */
|
||||
putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display)));
|
||||
|
||||
ob_cursors.left_ptr = XCreateFontCursor(ob_display, XC_left_ptr);
|
||||
ob_cursors.ll_angle = XCreateFontCursor(ob_display, XC_ll_angle);
|
||||
ob_cursors.lr_angle = XCreateFontCursor(ob_display, XC_lr_angle);
|
||||
|
||||
prop_startup(); /* get atoms values for the display */
|
||||
extensions_query_all(); /* find which extensions are present */
|
||||
|
||||
if (screen_annex()) { /* it will be ours! */
|
||||
timer_startup();
|
||||
render_startup();
|
||||
themerc_startup();
|
||||
engine_startup(themerc_engine);
|
||||
python_startup();
|
||||
openboxwrap_startup();
|
||||
clientwrap_startup();
|
||||
hooks_startup();
|
||||
event_startup();
|
||||
screen_startup();
|
||||
focus_startup();
|
||||
client_startup();
|
||||
keyboard_startup();
|
||||
pointer_startup();
|
||||
|
||||
/* load the user's settings */
|
||||
if (!python_import("rc"))
|
||||
g_warning("ERROR LOADING RC FILE");
|
||||
|
||||
HOOKFIRE(startup, "()");
|
||||
|
||||
/* get all the existing windows */
|
||||
client_manage_all();
|
||||
|
||||
ob_state = State_Running;
|
||||
while (!ob_shutdown) {
|
||||
event_loop();
|
||||
}
|
||||
ob_state = State_Exiting;
|
||||
|
||||
client_unmanage_all();
|
||||
|
||||
HOOKFIRE(shutdown, "()");
|
||||
|
||||
pointer_shutdown();
|
||||
keyboard_shutdown();
|
||||
client_shutdown();
|
||||
screen_shutdown();
|
||||
event_shutdown();
|
||||
hooks_shutdown();
|
||||
clientwrap_shutdown();
|
||||
openboxwrap_shutdown();
|
||||
python_shutdown();
|
||||
engine_shutdown();
|
||||
themerc_shutdown();
|
||||
render_shutdown();
|
||||
timer_shutdown();
|
||||
}
|
||||
|
||||
XCloseDisplay(ob_display);
|
||||
|
||||
/* XXX if (ob_restart) */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void signal_handler(int signal)
|
||||
{
|
||||
switch (signal) {
|
||||
case SIGUSR1:
|
||||
g_message("Caught SIGUSR1 signal. Restarting.");
|
||||
ob_shutdown = ob_restart = TRUE;
|
||||
break;
|
||||
|
||||
case SIGCHLD:
|
||||
wait(NULL);
|
||||
break;
|
||||
|
||||
case SIGHUP:
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
case SIGPIPE:
|
||||
g_message("Caught signal %d. Exiting.", signal);
|
||||
ob_shutdown = TRUE;
|
||||
break;
|
||||
|
||||
case SIGFPE:
|
||||
case SIGSEGV:
|
||||
g_error("Caught signal %d. Aborting and dumping core.", signal);
|
||||
}
|
||||
}
|
44
openbox/openbox.h
Normal file
44
openbox/openbox.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef __openbox_h
|
||||
#define __openbox_h
|
||||
|
||||
#include <glib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/*! The X display */
|
||||
extern Display *ob_display;
|
||||
/*! The number of the screen on which we're running */
|
||||
extern int ob_screen;
|
||||
/*! The root window */
|
||||
extern Window ob_root;
|
||||
|
||||
/*! States of execution for Openbox */
|
||||
typedef enum {
|
||||
State_Starting,
|
||||
State_Exiting,
|
||||
State_Running
|
||||
} State;
|
||||
|
||||
/* The state of execution of the window manager */
|
||||
State ob_state;
|
||||
|
||||
/*! When set to true, Openbox will exit */
|
||||
extern gboolean ob_shutdown;
|
||||
/*! When set to true, Openbox will restart instead of shutting down */
|
||||
extern gboolean ob_restart;
|
||||
/*! When restarting, if this is not NULL, it will be executed instead of
|
||||
restarting Openbox. */
|
||||
extern char *ob_restart_path;
|
||||
|
||||
/*! Runtime option to specify running on a remote display */
|
||||
extern gboolean ob_remote;
|
||||
/*! Runtime option to run in synchronous mode */
|
||||
extern gboolean ob_sync;
|
||||
|
||||
typedef struct Cursors {
|
||||
Cursor left_ptr;
|
||||
Cursor ll_angle;
|
||||
Cursor lr_angle;
|
||||
} Cursors;
|
||||
Cursors ob_cursors;
|
||||
|
||||
#endif
|
502
openbox/openboxwrap.c
Normal file
502
openbox/openboxwrap.c
Normal file
|
@ -0,0 +1,502 @@
|
|||
#include "openboxwrap.h"
|
||||
#include "openbox.h"
|
||||
#include "screen.h"
|
||||
#include "prop.h"
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'OpenboxWrap'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_OWRAP(v) ((v)->ob_type == &OpenboxWrapType)
|
||||
#define CHECK_OWRAP(self, funcname) { \
|
||||
if (!IS_OWRAP(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires a 'Openbox' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
staticforward PyTypeObject OpenboxWrapType;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Attribute methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *owrap_shutdown(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "shutdown");
|
||||
if (!PyArg_ParseTuple(args, ":shutdown"))
|
||||
return NULL;
|
||||
ob_shutdown = TRUE;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_restart(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
char *path = NULL;
|
||||
|
||||
CHECK_OWRAP(self, "restart");
|
||||
if (!PyArg_ParseTuple(args, "|s:restart", &path))
|
||||
return NULL;
|
||||
ob_shutdown = ob_restart = TRUE;
|
||||
ob_restart_path = path;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_state(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "state");
|
||||
if (!PyArg_ParseTuple(args, ":state"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_state);
|
||||
}
|
||||
|
||||
static PyObject *owrap_desktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "desktop");
|
||||
if (!PyArg_ParseTuple(args, ":desktop"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(screen_desktop);
|
||||
}
|
||||
|
||||
static PyObject *owrap_setDesktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
int desktop;
|
||||
|
||||
CHECK_OWRAP(self, "setDesktop");
|
||||
if (!PyArg_ParseTuple(args, "i:setDesktop", &desktop))
|
||||
return NULL;
|
||||
if (desktop < 0 || (unsigned)desktop >= screen_num_desktops) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid desktop");
|
||||
return NULL;
|
||||
}
|
||||
screen_set_desktop(desktop);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_setNextDesktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
gboolean wrap = TRUE;
|
||||
guint d;
|
||||
|
||||
CHECK_OWRAP(self, "setNextDesktop");
|
||||
if (!PyArg_ParseTuple(args, "|i:setNextDesktop", &wrap))
|
||||
return NULL;
|
||||
d = screen_desktop + 1;
|
||||
if (d >= screen_num_desktops && wrap)
|
||||
d = 0;
|
||||
if (d < screen_num_desktops)
|
||||
screen_set_desktop(d);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_setPreviousDesktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
gboolean wrap = TRUE;
|
||||
guint d;
|
||||
|
||||
CHECK_OWRAP(self, "setPreviousDesktop");
|
||||
if (!PyArg_ParseTuple(args, "|i:setPreviousDesktop", &wrap))
|
||||
return NULL;
|
||||
d = screen_desktop - 1;
|
||||
if (d >= screen_num_desktops && wrap)
|
||||
d = screen_num_desktops - 1;
|
||||
if (d < screen_num_desktops)
|
||||
screen_set_desktop(d);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_numDesktops(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "numDesktops");
|
||||
if (!PyArg_ParseTuple(args, ":numDesktops"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(screen_num_desktops);
|
||||
}
|
||||
|
||||
static PyObject *owrap_setNumDesktops(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
int desktops;
|
||||
|
||||
CHECK_OWRAP(self, "setNumDesktops");
|
||||
if (!PyArg_ParseTuple(args, "i:setNumDesktops", &desktops))
|
||||
return NULL;
|
||||
if (desktops <= 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid number of desktops");
|
||||
return NULL;
|
||||
}
|
||||
screen_set_num_desktops(desktops);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_desktopNames(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
int i, s;
|
||||
|
||||
CHECK_OWRAP(self, "desktopNames");
|
||||
if (!PyArg_ParseTuple(args, ":desktopNames"))
|
||||
return NULL;
|
||||
s = screen_desktop_names->len;
|
||||
tuple = PyTuple_New(s);
|
||||
for (i = 0; i < s; ++i)
|
||||
PyTuple_SET_ITEM(tuple, i, g_ptr_array_index(screen_desktop_names, i));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *owrap_setDesktopNames(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *seq;
|
||||
int i, s;
|
||||
GPtrArray *data;
|
||||
|
||||
CHECK_OWRAP(self, "setDesktopNames");
|
||||
if (!PyArg_ParseTuple(args, "O:setDesktopNames", &seq))
|
||||
return NULL;
|
||||
if (!PySequence_Check(seq))
|
||||
PyErr_SetString(PyExc_TypeError, "expected a sequence");
|
||||
return NULL;
|
||||
|
||||
s = PySequence_Size(seq);
|
||||
for (i = 0; i < s; ++i) {
|
||||
PyObject *item;
|
||||
gboolean check;
|
||||
item = PySequence_GetItem(seq, i); /* new */
|
||||
check = PyString_Check(item);
|
||||
Py_DECREF(item);
|
||||
if (!check) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected a sequence of strings");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
data = g_ptr_array_sized_new(s);
|
||||
for (i = 0; i < s; ++i) {
|
||||
PyObject *item;
|
||||
item = PySequence_GetItem(seq, i); /* new */
|
||||
g_ptr_array_index(data, i) = PyString_AsString(item); /* borrowed */
|
||||
Py_DECREF(item);
|
||||
}
|
||||
|
||||
PROP_SETSA(ob_root, net_desktop_names, utf8, data);
|
||||
g_ptr_array_free(data, TRUE);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_showingDesktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "showingDesktop");
|
||||
if (!PyArg_ParseTuple(args, ":showingDesktop"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(!!screen_showing_desktop);
|
||||
}
|
||||
|
||||
static PyObject *owrap_setShowingDesktop(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
int show;
|
||||
|
||||
CHECK_OWRAP(self, "setShowingDesktop");
|
||||
if (!PyArg_ParseTuple(args, "i:setShowingDesktop", &show))
|
||||
return NULL;
|
||||
screen_show_desktop(show);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *owrap_screenArea(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
int desktop;
|
||||
Rect *area;
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_OWRAP(self, "screenArea");
|
||||
if (!PyArg_ParseTuple(args, "i:screenArea", &desktop))
|
||||
return NULL;
|
||||
|
||||
area = screen_area(desktop);
|
||||
if (area == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid desktop");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(area->x));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(area->y));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(area->width));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(area->height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *owrap_screenStrut(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
int desktop;
|
||||
Strut *strut;
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_OWRAP(self, "screenStrut");
|
||||
if (!PyArg_ParseTuple(args, "i:screenStrut", &desktop))
|
||||
return NULL;
|
||||
|
||||
strut = screen_strut(desktop);
|
||||
if (strut == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid desktop");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tuple = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(strut->left));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(strut->top));
|
||||
PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(strut->right));
|
||||
PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(strut->bottom));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *owrap_physicalSize(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
PyObject *tuple;
|
||||
|
||||
CHECK_OWRAP(self, "physicalSize");
|
||||
if (!PyArg_ParseTuple(args, ":physicalSize"))
|
||||
return NULL;
|
||||
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(screen_physical_size.width));
|
||||
PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(screen_physical_size.height));
|
||||
return tuple;
|
||||
}
|
||||
|
||||
static PyObject *owrap_screenNumber(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "screenNumber");
|
||||
if (!PyArg_ParseTuple(args, ":screenNumber"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_screen);
|
||||
}
|
||||
|
||||
static PyObject *owrap_rootWindow(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "rootWindow");
|
||||
if (!PyArg_ParseTuple(args, ":rootWindow"))
|
||||
return NULL;
|
||||
return PyInt_FromLong(ob_root);
|
||||
}
|
||||
|
||||
static PyObject *owrap_clientList(OpenboxWrap *self, PyObject *args)
|
||||
{
|
||||
CHECK_OWRAP(self, "clientList");
|
||||
if (!PyArg_ParseTuple(args, ":clientList"))
|
||||
return NULL;
|
||||
Py_INCREF(self->client_list);
|
||||
return self->client_list;
|
||||
}
|
||||
|
||||
#define METH(n, d) {#n, (PyCFunction)owrap_##n, METH_VARARGS, #d}
|
||||
|
||||
static PyMethodDef OpenboxWrapMethods[] = {
|
||||
METH(shutdown,
|
||||
"Causes Openbox to shutdown and exit."),
|
||||
METH(restart,
|
||||
"Causes Openbox to shutdown and restart. If path is specified, "
|
||||
"Openbox will shutdown and attempt to run the specified executable "
|
||||
"instead of restarting itself. If that fails, however, it will "
|
||||
"restart itself."),
|
||||
METH(state,
|
||||
"Returns Openbox's current state, this will be one of the State "
|
||||
"constants."),
|
||||
METH(desktop,
|
||||
"Returns the number of the currently visible desktop. This will be "
|
||||
"in the range of [0, numDesktops())."),
|
||||
METH(setDesktop,
|
||||
"Sets the specified desktop as the visible desktop."),
|
||||
METH(setNextDesktop,
|
||||
"Sets the visible desktop to the next desktop, optionally wrapping "
|
||||
"around when reaching the last."),
|
||||
METH(setPreviousDesktop,
|
||||
"Sets the visible desktop to the previous desktop, optionally "
|
||||
"wrapping around when reaching the first."),
|
||||
METH(numDesktops,
|
||||
"Returns the number of desktops available."),
|
||||
METH(desktopNames,
|
||||
"Returns a tuple of names, containing a name for each desktop. The "
|
||||
"tuple may have a length greater than numDesktops() if more names "
|
||||
"have been specified."),
|
||||
METH(setDesktopNames,
|
||||
"Sets the names for the desktops."),
|
||||
METH(showingDesktop,
|
||||
"Returns True or False, depicting if Openbox is in 'showing the "
|
||||
"desktop' mode. In 'showing the desktop' mode, all normal clients "
|
||||
"are hidden and the desktop is given focus if possible."),
|
||||
METH(setShowingDesktop,
|
||||
"Enters or leaves 'showing the desktop' mode. See showingDesktop() "
|
||||
"for a description of this mode."),
|
||||
METH(screenArea,
|
||||
"Returns the on-screen available area. This is the area not reserved "
|
||||
"by applications' struts. Windows should be placed within this area, "
|
||||
"not within the physicalSize()."),
|
||||
METH(screenStrut,
|
||||
"Returns the combined strut which has been reserved by all "
|
||||
"applications on the desktops."),
|
||||
METH(physicalSize,
|
||||
"Returns the physical size of the display device (in pixels)."),
|
||||
METH(screenNumber,
|
||||
"Returns the number of the screen on which Openbox is running."),
|
||||
METH(rootWindow,
|
||||
"Return the window id of the root window."),
|
||||
METH(clientList,
|
||||
"Returns a all clients currently being managed by Openbox. This list "
|
||||
"is updated as clients are managed and closed/destroyed/released."),
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
/*static PyObject *owrap_getattr(OpenboxWrap *self, char *name)
|
||||
{
|
||||
CHECK_OWRAP(self, "getattr");
|
||||
return Py_FindMethod(OpenboxWrapAttributeMethods, (PyObject*)self, name);
|
||||
}*/
|
||||
|
||||
static void owrap_dealloc(OpenboxWrap *self)
|
||||
{
|
||||
PyObject_Del((PyObject*) self);
|
||||
}
|
||||
|
||||
static PyTypeObject OpenboxWrapType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Openbox",
|
||||
sizeof(OpenboxWrap),
|
||||
0,
|
||||
(destructor) owrap_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'OpenboxState'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_OSTATE(v) ((v)->ob_type == &OpenboxStateType)
|
||||
#define CHECK_OSTATE(self, funcname) { \
|
||||
if (!IS_OSTATE(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires a 'State' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
staticforward PyTypeObject OpenboxStateType;
|
||||
|
||||
typedef struct OpenboxState {
|
||||
PyObject_HEAD
|
||||
} OpenboxState;
|
||||
|
||||
static void ostate_dealloc(PyObject *self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
static PyObject *ostate_getattr(OpenboxState *self, char *name)
|
||||
{
|
||||
struct S { char *name; int val; };
|
||||
struct S s[] = {
|
||||
{ "Starting", State_Starting },
|
||||
{ "Running", State_Running },
|
||||
{ "Exiting", State_Exiting },
|
||||
{ NULL, 0 } };
|
||||
int i;
|
||||
|
||||
CHECK_OSTATE(self, "__getattr__");
|
||||
|
||||
for (i = 0; s[i].name != NULL; ++i)
|
||||
if (!strcmp(s[i].name, name))
|
||||
return PyInt_FromLong(s[i].val);
|
||||
PyErr_SetString(PyExc_AttributeError, "invalid attribute");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyTypeObject OpenboxStateType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"State",
|
||||
sizeof(OpenboxState),
|
||||
0,
|
||||
(destructor) ostate_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) ostate_getattr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
External methods
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
void openboxwrap_startup()
|
||||
{
|
||||
PyObject *ob, *obdict, *state;
|
||||
|
||||
OpenboxWrapType.ob_type = &PyType_Type;
|
||||
OpenboxWrapType.tp_methods = OpenboxWrapMethods;
|
||||
PyType_Ready(&OpenboxWrapType);
|
||||
|
||||
/* get the ob module/dict */
|
||||
ob = PyImport_ImportModule("ob"); /* new */
|
||||
g_assert(ob != NULL);
|
||||
obdict = PyModule_GetDict(ob); /* borrowed */
|
||||
g_assert(obdict != NULL);
|
||||
|
||||
/* add an Openbox instance to the ob module */
|
||||
openboxwrap_obj = PyObject_New(OpenboxWrap, &OpenboxWrapType);
|
||||
openboxwrap_obj->client_list = PyList_New(0);
|
||||
|
||||
PyDict_SetItemString(obdict, "Openbox", (PyObject*) openboxwrap_obj);
|
||||
|
||||
/* add an instance of OpenboxState */
|
||||
state = (PyObject*) PyObject_New(OpenboxState, &OpenboxStateType);
|
||||
PyDict_SetItemString(obdict, "State", state);
|
||||
Py_DECREF(state);
|
||||
|
||||
Py_DECREF(ob);
|
||||
}
|
||||
|
||||
void openboxwrap_shutdown()
|
||||
{
|
||||
Py_DECREF(openboxwrap_obj->client_list);
|
||||
Py_DECREF(openboxwrap_obj);
|
||||
}
|
17
openbox/openboxwrap.h
Normal file
17
openbox/openboxwrap.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef __openboxwrap_h
|
||||
#define __openboxwrap_h
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/* OpenboxWrap is a PyObject */
|
||||
typedef struct OpenboxWrap {
|
||||
PyObject_HEAD
|
||||
PyObject *client_list;
|
||||
} OpenboxWrap;
|
||||
|
||||
OpenboxWrap *openboxwrap_obj;
|
||||
|
||||
void openboxwrap_startup();
|
||||
void openboxwrap_shutdown();
|
||||
|
||||
#endif
|
729
openbox/pointer.c
Normal file
729
openbox/pointer.c
Normal file
|
@ -0,0 +1,729 @@
|
|||
#include "pointer.h"
|
||||
#include "keyboard.h"
|
||||
#include "frame.h"
|
||||
#include "engine.h"
|
||||
#include "openbox.h"
|
||||
#include "hooks.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <Python.h>
|
||||
#include <structmember.h> /* for PyMemberDef stuff */
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
Action_Press,
|
||||
Action_Release,
|
||||
Action_Click,
|
||||
Action_DoubleClick,
|
||||
Action_Motion,
|
||||
NUM_ACTIONS
|
||||
} Action;
|
||||
|
||||
/* GData of GSList*s of PointerBinding*s. */
|
||||
static GData *bound_contexts;
|
||||
static gboolean grabbed;
|
||||
static int double_click_rate, drag_threshold;
|
||||
PyObject *grab_func;
|
||||
|
||||
struct foreach_grab_temp {
|
||||
Client *client;
|
||||
gboolean grab;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
guint state;
|
||||
guint button;
|
||||
Action action;
|
||||
char *name;
|
||||
GSList *funcs[NUM_ACTIONS];
|
||||
} PointerBinding;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'ButtonData'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct PointerData {
|
||||
PyObject_HEAD
|
||||
Action action;
|
||||
GQuark context;
|
||||
char *button;
|
||||
guint state;
|
||||
guint buttonnum;
|
||||
int posx, posy;
|
||||
int pressposx, pressposy;
|
||||
int pcareax, pcareay, pcareaw, pcareah;
|
||||
} PointerData;
|
||||
|
||||
staticforward PyTypeObject PointerDataType;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static PyObject *ptrdata_new(char *button, GQuark context, Action action,
|
||||
guint state, guint buttonnum, int posx, int posy,
|
||||
int pressposx, int pressposy, int pcareax,
|
||||
int pcareay, int pcareaw, int pcareah)
|
||||
{
|
||||
PointerData *self = PyObject_New(PointerData, &PointerDataType);
|
||||
self->button = g_strdup(button);
|
||||
self->context = context;
|
||||
self->action = action;
|
||||
self->state = state;
|
||||
self->buttonnum = buttonnum;
|
||||
self->posx = posx;
|
||||
self->posy = posy;
|
||||
self->pressposx = pressposx;
|
||||
self->pressposy = pressposy;
|
||||
self->pcareax = pcareax;
|
||||
self->pcareay = pcareay;
|
||||
self->pcareaw = pcareaw;
|
||||
self->pcareah = pcareah;
|
||||
return (PyObject*) self;
|
||||
}
|
||||
|
||||
static void ptrdata_dealloc(PointerData *self)
|
||||
{
|
||||
g_free(self->button);
|
||||
PyObject_Del((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject *ptrdata_getattr(PointerData *self, char *name)
|
||||
{
|
||||
if (!strcmp(name, "button"))
|
||||
return PyString_FromString(self->button);
|
||||
if (!strcmp(name, "action"))
|
||||
return PyInt_FromLong(self->action);
|
||||
if (!strcmp(name, "context"))
|
||||
return PyString_FromString(g_quark_to_string(self->context));
|
||||
if (!strcmp(name, "state"))
|
||||
return PyInt_FromLong(self->state);
|
||||
if (!strcmp(name, "buttonnum"))
|
||||
return PyInt_FromLong(self->buttonnum);
|
||||
|
||||
if (self->action == Action_Motion) { /* the rest are only for motions */
|
||||
if (!strcmp(name, "pos")) {
|
||||
PyObject *pos = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(pos, 0, PyInt_FromLong(self->posx));
|
||||
PyTuple_SET_ITEM(pos, 1, PyInt_FromLong(self->posy));
|
||||
return pos;
|
||||
}
|
||||
if (!strcmp(name, "presspos")) {
|
||||
PyObject *presspos = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(presspos, 0, PyInt_FromLong(self->pressposx));
|
||||
PyTuple_SET_ITEM(presspos, 1, PyInt_FromLong(self->pressposy));
|
||||
return presspos;
|
||||
}
|
||||
if (!strcmp(name, "pressclientarea")) {
|
||||
if (self->pcareaw < 0) { /* < 0 indicates no client */
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
} else {
|
||||
PyObject *ca = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(ca, 0, PyInt_FromLong(self->pcareax));
|
||||
PyTuple_SET_ITEM(ca, 1, PyInt_FromLong(self->pcareay));
|
||||
PyTuple_SET_ITEM(ca, 2, PyInt_FromLong(self->pcareaw));
|
||||
PyTuple_SET_ITEM(ca, 3, PyInt_FromLong(self->pcareah));
|
||||
return ca;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_AttributeError, "no such attribute '%s'", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyTypeObject PointerDataType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"PointerData",
|
||||
sizeof(PointerData),
|
||||
0,
|
||||
(destructor) ptrdata_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
(getattrfunc) ptrdata_getattr, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static gboolean translate(char *str, guint *state, guint *button)
|
||||
{
|
||||
char **parsed;
|
||||
char *l;
|
||||
int i;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
parsed = g_strsplit(str, "-", -1);
|
||||
|
||||
/* first, find the button (last token) */
|
||||
l = NULL;
|
||||
for (i = 0; parsed[i] != NULL; ++i)
|
||||
l = parsed[i];
|
||||
if (l == NULL)
|
||||
goto translation_fail;
|
||||
|
||||
/* figure out the mod mask */
|
||||
*state = 0;
|
||||
for (i = 0; parsed[i] != l; ++i) {
|
||||
guint m = keyboard_translate_modifier(parsed[i]);
|
||||
if (!m) goto translation_fail;
|
||||
*state |= m;
|
||||
}
|
||||
|
||||
/* figure out the button */
|
||||
*button = atoi(l);
|
||||
if (!*button) {
|
||||
g_warning("Invalid button '%s' in pointer binding.", l);
|
||||
goto translation_fail;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
translation_fail:
|
||||
g_strfreev(parsed);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void grab_button(Client *client, guint state, guint button,
|
||||
GQuark context, gboolean grab)
|
||||
{
|
||||
Window win;
|
||||
int mode = GrabModeAsync;
|
||||
unsigned int mask;
|
||||
|
||||
if (context == g_quark_try_string("frame")) {
|
||||
win = client->frame->window;
|
||||
mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
|
||||
} else if (context == g_quark_try_string("client")) {
|
||||
win = client->frame->plate;
|
||||
mode = GrabModeSync; /* this is handled in pointer_event */
|
||||
mask = ButtonPressMask; /* can't catch more than this with Sync mode
|
||||
the release event is manufactured in
|
||||
pointer_fire */
|
||||
} else return;
|
||||
|
||||
if (grab)
|
||||
XGrabButton(ob_display, button, state, win, FALSE, mask, mode,
|
||||
GrabModeAsync, None, None);
|
||||
else
|
||||
XUngrabButton(ob_display, button, state, win);
|
||||
}
|
||||
|
||||
static void foreach_grab(GQuark key, gpointer data, gpointer user_data)
|
||||
{
|
||||
struct foreach_grab_temp *d = user_data;
|
||||
GSList *it;
|
||||
for (it = data; it != NULL; it = it->next) {
|
||||
PointerBinding *b = it->data;
|
||||
grab_button(d->client, b->state, b->button, key, d->grab);
|
||||
}
|
||||
}
|
||||
|
||||
void pointer_grab_all(Client *client, gboolean grab)
|
||||
{
|
||||
struct foreach_grab_temp bt;
|
||||
bt.client = client;
|
||||
bt.grab = grab;
|
||||
g_datalist_foreach(&bound_contexts, foreach_grab, &bt);
|
||||
}
|
||||
|
||||
static void grab_all_clients(gboolean grab)
|
||||
{
|
||||
GSList *it;
|
||||
|
||||
for (it = client_list; it != NULL; it = it->next)
|
||||
pointer_grab_all(it->data, grab);
|
||||
}
|
||||
|
||||
static gboolean grab_pointer(gboolean grab)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
if (grab)
|
||||
ret = XGrabPointer(ob_display, ob_root, FALSE, (ButtonPressMask |
|
||||
ButtonReleaseMask |
|
||||
ButtonMotionMask |
|
||||
PointerMotionMask),
|
||||
GrabModeAsync, GrabModeAsync, None, None,
|
||||
CurrentTime) == GrabSuccess;
|
||||
else
|
||||
XUngrabPointer(ob_display, CurrentTime);
|
||||
if (ret) grabbed = grab;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void foreach_clear(GQuark key, gpointer data, gpointer user_data)
|
||||
{
|
||||
GSList *it;
|
||||
user_data = user_data;
|
||||
for (it = data; it != NULL; it = it->next) {
|
||||
int i;
|
||||
|
||||
PointerBinding *b = it->data;
|
||||
for (i = 0; i < NUM_ACTIONS; ++i)
|
||||
while (b->funcs[i] != NULL) {
|
||||
Py_DECREF((PyObject*)b->funcs[i]->data);
|
||||
b->funcs[i] = g_slist_delete_link(b->funcs[i], b->funcs[i]);
|
||||
}
|
||||
g_free(b->name);
|
||||
g_free(b);
|
||||
}
|
||||
g_slist_free(data);
|
||||
}
|
||||
|
||||
static void clearall()
|
||||
{
|
||||
grab_all_clients(FALSE);
|
||||
g_datalist_foreach(&bound_contexts, foreach_clear, NULL);
|
||||
}
|
||||
|
||||
static void fire_event(char *button, GQuark context, Action action,
|
||||
guint state, guint buttonnum, int posx, int posy,
|
||||
int pressposx, int pressposy, int pcareax,
|
||||
int pcareay, int pcareaw, int pcareah,
|
||||
PyObject *client, GSList *functions)
|
||||
{
|
||||
PyObject *ptrdata, *args, *ret;
|
||||
GSList *it;
|
||||
|
||||
ptrdata = ptrdata_new(button, context, action,
|
||||
state, buttonnum, posx, posy, pressposx, pressposy,
|
||||
pcareax, pcareay, pcareaw, pcareah);
|
||||
args = Py_BuildValue("OO", ptrdata, client);
|
||||
|
||||
if (grabbed) {
|
||||
ret = PyObject_CallObject(grab_func, args);
|
||||
if (ret == NULL) PyErr_Print();
|
||||
Py_XDECREF(ret);
|
||||
} else {
|
||||
for (it = functions; it != NULL; it = it->next) {
|
||||
ret = PyObject_CallObject(it->data, args);
|
||||
if (ret == NULL) PyErr_Print();
|
||||
Py_XDECREF(ret);
|
||||
}
|
||||
}
|
||||
|
||||
Py_DECREF(args);
|
||||
Py_DECREF(ptrdata);
|
||||
}
|
||||
|
||||
void pointer_event(XEvent *e, Client *c)
|
||||
{
|
||||
static guint button = 0, lastbutton = 0;
|
||||
static Time time = 0;
|
||||
static Rect carea;
|
||||
static guint pressx, pressy;
|
||||
GQuark contextq;
|
||||
gboolean click = FALSE, dblclick = FALSE;
|
||||
PyObject *client;
|
||||
GString *str = g_string_sized_new(0);
|
||||
guint state;
|
||||
GSList *it = NULL;
|
||||
PointerBinding *b = NULL;
|
||||
|
||||
contextq = engine_get_context(c, e->xany.window);
|
||||
|
||||
/* pick a button, figure out clicks/double clicks */
|
||||
switch (e->type) {
|
||||
case ButtonPress:
|
||||
if (!button) {
|
||||
button = e->xbutton.button;
|
||||
if (c != NULL) carea = c->frame->area;
|
||||
else carea.width = -1; /* indicates no client */
|
||||
pressx = e->xbutton.x_root;
|
||||
pressy = e->xbutton.y_root;
|
||||
}
|
||||
state = e->xbutton.state;
|
||||
break;
|
||||
case ButtonRelease:
|
||||
state = e->xbutton.state;
|
||||
break;
|
||||
case MotionNotify:
|
||||
state = e->xmotion.state;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grabbed) {
|
||||
for (it = g_datalist_id_get_data(&bound_contexts, contextq);
|
||||
it != NULL; it = it->next) {
|
||||
b = it->data;
|
||||
if (b->state == state && b->button == button)
|
||||
break;
|
||||
}
|
||||
/* if not grabbed and not bound, then nothing to do! */
|
||||
if (it == NULL) return;
|
||||
}
|
||||
|
||||
if (c) client = clientwrap_new(c);
|
||||
else client = Py_None;
|
||||
|
||||
/* build the button string */
|
||||
if (state & ControlMask) g_string_append(str, "C-");
|
||||
if (state & ShiftMask) g_string_append(str, "S-");
|
||||
if (state & Mod1Mask) g_string_append(str, "Mod1-");
|
||||
if (state & Mod2Mask) g_string_append(str, "Mod2-");
|
||||
if (state & Mod3Mask) g_string_append(str, "Mod3-");
|
||||
if (state & Mod4Mask) g_string_append(str, "Mod4-");
|
||||
if (state & Mod5Mask) g_string_append(str, "Mod5-");
|
||||
g_string_append_printf(str, "%d", button);
|
||||
|
||||
/* figure out clicks/double clicks */
|
||||
switch (e->type) {
|
||||
case ButtonRelease:
|
||||
if (button == e->xbutton.button) {
|
||||
/* determine if this is a valid 'click'. Its not if the release is
|
||||
not over the window, or if a drag occured. */
|
||||
if (ABS(e->xbutton.x_root - pressx) < (unsigned)drag_threshold &&
|
||||
ABS(e->xbutton.y_root - pressy) < (unsigned)drag_threshold &&
|
||||
e->xbutton.x >= 0 && e->xbutton.y >= 0) {
|
||||
int junk;
|
||||
Window wjunk;
|
||||
guint ujunk, w, h;
|
||||
XGetGeometry(ob_display, e->xany.window, &wjunk, &junk, &junk,
|
||||
&w, &h, &ujunk, &ujunk);
|
||||
if (e->xbutton.x < (signed)w && e->xbutton.y < (signed)h)
|
||||
click =TRUE;
|
||||
}
|
||||
|
||||
/* determine if this is a valid 'double-click' */
|
||||
if (click) {
|
||||
if (lastbutton == button &&
|
||||
e->xbutton.time - double_click_rate < time) {
|
||||
dblclick = TRUE;
|
||||
lastbutton = 0;
|
||||
} else
|
||||
lastbutton = button;
|
||||
} else
|
||||
lastbutton = 0;
|
||||
time = e->xbutton.time;
|
||||
pressx = pressy = 0;
|
||||
button = 0;
|
||||
carea.x = carea.y = carea.width = carea.height = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* fire off the events */
|
||||
switch (e->type) {
|
||||
case ButtonPress:
|
||||
fire_event(str->str, contextq, Action_Press,
|
||||
state, button, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
client, b == NULL ? NULL : b->funcs[Action_Press]);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
fire_event(str->str, contextq, Action_Release,
|
||||
state, button, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
client, b == NULL ? NULL : b->funcs[Action_Release]);
|
||||
break;
|
||||
case MotionNotify:
|
||||
/* watch out for the drag threshold */
|
||||
if (ABS(e->xmotion.x_root - pressx) < (unsigned)drag_threshold &&
|
||||
ABS(e->xmotion.y_root - pressy) < (unsigned)drag_threshold)
|
||||
break;
|
||||
fire_event(str->str, contextq, Action_Motion,
|
||||
state, button, e->xmotion.x_root,
|
||||
e->xmotion.y_root, pressx, pressy,
|
||||
carea.x, carea.y, carea.width, carea.height,
|
||||
client, b == NULL ? NULL : b->funcs[Action_Motion]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (click)
|
||||
fire_event(str->str, contextq, Action_Click,
|
||||
state, button, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
client, b == NULL ? NULL : b->funcs[Action_Click]);
|
||||
if (dblclick)
|
||||
fire_event(str->str, contextq, Action_DoubleClick,
|
||||
state, button, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
client, b == NULL ? NULL : b->funcs[Action_DoubleClick]);
|
||||
|
||||
g_string_free(str, TRUE);
|
||||
if (client != Py_None) { Py_DECREF(client); }
|
||||
|
||||
if (contextq == g_quark_try_string("client")) {
|
||||
/* Replay the event, so it goes to the client*/
|
||||
XAllowEvents(ob_display, ReplayPointer, CurrentTime);
|
||||
/* generate a release event since we don't get real ones */
|
||||
if (e->type == ButtonPress) {
|
||||
e->type = ButtonRelease;
|
||||
pointer_event(e, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Define the type 'Pointer'
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define IS_POINTER(v) ((v)->ob_type == &PointerType)
|
||||
#define CHECK_POINTER(self, funcname) { \
|
||||
if (!IS_POINTER(self)) { \
|
||||
PyErr_SetString(PyExc_TypeError, \
|
||||
"descriptor '" funcname "' requires a 'Pointer' " \
|
||||
"object"); \
|
||||
return NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
typedef struct Pointer {
|
||||
PyObject_HEAD
|
||||
Action press;
|
||||
Action release;
|
||||
Action click;
|
||||
Action doubleclick;
|
||||
Action motion;
|
||||
} Pointer;
|
||||
|
||||
staticforward PyTypeObject PointerType;
|
||||
|
||||
static PyObject *ptr_bind(Pointer *self, PyObject *args)
|
||||
{
|
||||
char *buttonstr;
|
||||
char *contextstr;
|
||||
guint state, button;
|
||||
PointerBinding *b;
|
||||
GSList *it;
|
||||
GQuark context;
|
||||
PyObject *func;
|
||||
Action action;
|
||||
int i;
|
||||
|
||||
CHECK_POINTER(self, "grab");
|
||||
if (!PyArg_ParseTuple(args, "ssiO:grab",
|
||||
&buttonstr, &contextstr, &action, &func))
|
||||
return NULL;
|
||||
|
||||
if (!translate(buttonstr, &state, &button)) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid button");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context = g_quark_try_string(contextstr);
|
||||
if (!context) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (action < 0 || action >= NUM_ACTIONS) {
|
||||
PyErr_SetString(PyExc_ValueError, "invalid action");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a callable object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (it = g_datalist_id_get_data(&bound_contexts, context);
|
||||
it != NULL; it = it->next){
|
||||
b = it->data;
|
||||
if (b->state == state && b->button == button) {
|
||||
/* already bound */
|
||||
b->funcs[action] = g_slist_append(b->funcs[action], func);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
}
|
||||
|
||||
grab_all_clients(FALSE);
|
||||
|
||||
/* add the binding */
|
||||
b = g_new(PointerBinding, 1);
|
||||
b->state = state;
|
||||
b->button = button;
|
||||
b->name = g_strdup(buttonstr);
|
||||
for (i = 0; i < NUM_ACTIONS; ++i)
|
||||
if (i != (signed)action) b->funcs[i] = NULL;
|
||||
b->funcs[action] = g_slist_append(NULL, func);
|
||||
g_datalist_id_set_data(&bound_contexts, context,
|
||||
g_slist_append(g_datalist_id_get_data(&bound_contexts, context), b));
|
||||
grab_all_clients(TRUE);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *ptr_clearBinds(Pointer *self, PyObject *args)
|
||||
{
|
||||
CHECK_POINTER(self, "clearBinds");
|
||||
if (!PyArg_ParseTuple(args, ":clearBinds"))
|
||||
return NULL;
|
||||
clearall();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *ptr_grab(Pointer *self, PyObject *args)
|
||||
{
|
||||
PyObject *func;
|
||||
|
||||
CHECK_POINTER(self, "grab");
|
||||
if (!PyArg_ParseTuple(args, "O:grab", &func))
|
||||
return NULL;
|
||||
if (!PyCallable_Check(func)) {
|
||||
PyErr_SetString(PyExc_ValueError, "expected a callable object");
|
||||
return NULL;
|
||||
}
|
||||
if (!grab_pointer(TRUE)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "failed to grab pointer");
|
||||
return NULL;
|
||||
}
|
||||
grab_func = func;
|
||||
Py_INCREF(grab_func);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *ptr_ungrab(Pointer *self, PyObject *args)
|
||||
{
|
||||
CHECK_POINTER(self, "ungrab");
|
||||
if (!PyArg_ParseTuple(args, ":ungrab"))
|
||||
return NULL;
|
||||
grab_pointer(FALSE);
|
||||
Py_XDECREF(grab_func);
|
||||
grab_func = NULL;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
#define METH(n, d) {#n, (PyCFunction)ptr_##n, METH_VARARGS, #d}
|
||||
|
||||
static PyMethodDef PointerMethods[] = {
|
||||
METH(bind,
|
||||
"bind(button, context, func)\n\n"
|
||||
"Binds a pointer button for a context to a function. See the "
|
||||
"Terminology section for a decription and list of common contexts. "
|
||||
"The button is a string which defines a modifier and button "
|
||||
"combination with the format [Modifier-]...[Button]. Modifiers can "
|
||||
"be 'mod1', 'mod2', 'mod3', 'mod4', 'mod5', 'control', and 'shift'. "
|
||||
"The keys on your keyboard that are bound to each of these modifiers "
|
||||
"can be found by running 'xmodmap'. The button is the number of the "
|
||||
"button. Button numbers can be found by running 'xev', pressing the "
|
||||
"button with the pointer over its window, and watching its output. "
|
||||
"Here are some examples of valid buttons: 'control-1', '2', "
|
||||
"'mod1-shift-5'. The func must have a definition similar to "
|
||||
"'def func(keydata, client)'. A button and context may be bound to "
|
||||
"more than one function."),
|
||||
METH(clearBinds,
|
||||
"clearBinds()\n\n"
|
||||
"Removes all bindings that were previously made by bind()."),
|
||||
METH(grab,
|
||||
"grab(func)\n\n"
|
||||
"Grabs the pointer device, causing all possible pointer events to be "
|
||||
"sent to the given function. CAUTION: Be sure when you grab() that "
|
||||
"you also have an ungrab() that will execute, or you will not be "
|
||||
"able to use the pointer device until you restart Openbox. The func "
|
||||
"must have a definition similar to 'def func(keydata)'. The pointer "
|
||||
"cannot be grabbed if it is already grabbed."),
|
||||
METH(ungrab,
|
||||
"ungrab()\n\n"
|
||||
"Ungrabs the pointer. The pointer cannot be ungrabbed if it is not "
|
||||
"grabbed."),
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static PyMemberDef PointerMembers[] = {
|
||||
{"Action_Press", T_INT, offsetof(Pointer, press), READONLY,
|
||||
"a pointer button press"},
|
||||
{"Action_Release", T_INT, offsetof(Pointer, release), READONLY,
|
||||
"a pointer button release"},
|
||||
{"Action_Click", T_INT, offsetof(Pointer, click), READONLY,
|
||||
"a pointer button click (press-release)"},
|
||||
{"Action_DoubleClick", T_INT, offsetof(Pointer, doubleclick), READONLY,
|
||||
"a pointer button double-click"},
|
||||
{"Action_Motion", T_INT, offsetof(Pointer, motion), READONLY,
|
||||
"a pointer drag"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Type methods/struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static void ptr_dealloc(PyObject *self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
static PyTypeObject PointerType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Pointer",
|
||||
sizeof(Pointer),
|
||||
0,
|
||||
(destructor) ptr_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
0, /*tp_compare*/
|
||||
0, /*tp_repr*/
|
||||
0, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
0, /*tp_hash */
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void pointer_startup()
|
||||
{
|
||||
PyObject *input, *inputdict;
|
||||
Pointer *ptr;
|
||||
|
||||
grabbed = FALSE;
|
||||
double_click_rate = 300;
|
||||
drag_threshold = 3;
|
||||
g_datalist_init(&bound_contexts);
|
||||
|
||||
PointerType.ob_type = &PyType_Type;
|
||||
PointerType.tp_methods = PointerMethods;
|
||||
PointerType.tp_members = PointerMembers;
|
||||
PyType_Ready(&PointerType);
|
||||
PyType_Ready(&PointerDataType);
|
||||
|
||||
/* get the input module/dict */
|
||||
input = PyImport_ImportModule("input"); /* new */
|
||||
g_assert(input != NULL);
|
||||
inputdict = PyModule_GetDict(input); /* borrowed */
|
||||
g_assert(inputdict != NULL);
|
||||
|
||||
/* add a Pointer instance to the input module */
|
||||
ptr = PyObject_New(Pointer, &PointerType);
|
||||
ptr->press = Action_Press;
|
||||
ptr->release = Action_Release;
|
||||
ptr->click = Action_Click;
|
||||
ptr->doubleclick = Action_DoubleClick;
|
||||
ptr->motion = Action_Motion;
|
||||
PyDict_SetItemString(inputdict, "Pointer", (PyObject*) ptr);
|
||||
Py_DECREF(ptr);
|
||||
|
||||
Py_DECREF(input);
|
||||
}
|
||||
|
||||
void pointer_shutdown()
|
||||
{
|
||||
if (grabbed)
|
||||
grab_pointer(FALSE);
|
||||
clearall();
|
||||
g_datalist_clear(&bound_contexts);
|
||||
}
|
||||
|
14
openbox/pointer.h
Normal file
14
openbox/pointer.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef __pointer_h
|
||||
#define __pointer_h
|
||||
|
||||
#include "client.h"
|
||||
#include <glib.h>
|
||||
|
||||
void pointer_startup();
|
||||
void pointer_shutdown();
|
||||
|
||||
void pointer_grab_all(Client *client, gboolean grab);
|
||||
|
||||
void pointer_event(XEvent *e, Client *c);
|
||||
|
||||
#endif
|
288
openbox/prop.c
Normal file
288
openbox/prop.c
Normal file
|
@ -0,0 +1,288 @@
|
|||
#include "prop.h"
|
||||
#include "openbox.h"
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
Atoms prop_atoms;
|
||||
|
||||
#define CREATE(var, name) (prop_atoms.var = \
|
||||
XInternAtom(ob_display, name, FALSE))
|
||||
|
||||
void prop_startup()
|
||||
{
|
||||
g_assert(ob_display != NULL);
|
||||
|
||||
CREATE(cardinal, "CARDINAL");
|
||||
CREATE(window, "WINDOW");
|
||||
CREATE(pixmap, "PIXMAP");
|
||||
CREATE(atom, "ATOM");
|
||||
CREATE(string, "STRING");
|
||||
CREATE(utf8, "UTF8_STRING");
|
||||
|
||||
CREATE(wm_colormap_windows, "WM_COLORMAP_WINDOWS");
|
||||
CREATE(wm_protocols, "WM_PROTOCOLS");
|
||||
CREATE(wm_state, "WM_STATE");
|
||||
CREATE(wm_change_state, "WM_CHANGE_STATE");
|
||||
CREATE(wm_delete_window, "WM_DELETE_WINDOW");
|
||||
CREATE(wm_take_focus, "WM_TAKE_FOCUS");
|
||||
CREATE(wm_name, "WM_NAME");
|
||||
CREATE(wm_icon_name, "WM_ICON_NAME");
|
||||
CREATE(wm_class, "WM_CLASS");
|
||||
CREATE(wm_window_role, "WM_WINDOW_ROLE");
|
||||
CREATE(motif_wm_hints, "_MOTIF_WM_HINTS");
|
||||
|
||||
CREATE(net_supported, "_NET_SUPPORTED");
|
||||
CREATE(net_client_list, "_NET_CLIENT_LIST");
|
||||
CREATE(net_client_list_stacking, "_NET_CLIENT_LIST_STACKING");
|
||||
CREATE(net_number_of_desktops, "_NET_NUMBER_OF_DESKTOPS");
|
||||
CREATE(net_desktop_geometry, "_NET_DESKTOP_GEOMETRY");
|
||||
CREATE(net_desktop_viewport, "_NET_DESKTOP_VIEWPORT");
|
||||
CREATE(net_current_desktop, "_NET_CURRENT_DESKTOP");
|
||||
CREATE(net_desktop_names, "_NET_DESKTOP_NAMES");
|
||||
CREATE(net_active_window, "_NET_ACTIVE_WINDOW");
|
||||
CREATE(net_workarea, "_NET_WORKAREA");
|
||||
CREATE(net_supporting_wm_check, "_NET_SUPPORTING_WM_CHECK");
|
||||
/* CREATE(net_virtual_roots, "_NET_VIRTUAL_ROOTS"); */
|
||||
CREATE(net_desktop_layout, "_NET_DESKTOP_LAYOUT");
|
||||
CREATE(net_showing_desktop, "_NET_SHOWING_DESKTOP");
|
||||
|
||||
CREATE(net_close_window, "_NET_CLOSE_WINDOW");
|
||||
CREATE(net_wm_moveresize, "_NET_WM_MOVERESIZE");
|
||||
|
||||
/* CREATE(net_properties, "_NET_PROPERTIES"); */
|
||||
CREATE(net_wm_name, "_NET_WM_NAME");
|
||||
CREATE(net_wm_visible_name, "_NET_WM_VISIBLE_NAME");
|
||||
CREATE(net_wm_icon_name, "_NET_WM_ICON_NAME");
|
||||
CREATE(net_wm_visible_icon_name, "_NET_WM_VISIBLE_ICON_NAME");
|
||||
CREATE(net_wm_desktop, "_NET_WM_DESKTOP");
|
||||
CREATE(net_wm_window_type, "_NET_WM_WINDOW_TYPE");
|
||||
CREATE(net_wm_state, "_NET_WM_STATE");
|
||||
CREATE(net_wm_strut, "_NET_WM_STRUT");
|
||||
/* CREATE(net_wm_icon_geometry, "_NET_WM_ICON_GEOMETRY"); */
|
||||
CREATE(net_wm_icon, "_NET_WM_ICON");
|
||||
/* CREATE(net_wm_pid, "_NET_WM_PID"); */
|
||||
/* CREATE(net_wm_handled_icons, "_NET_WM_HANDLED_ICONS"); */
|
||||
CREATE(net_wm_allowed_actions, "_NET_WM_ALLOWED_ACTIONS");
|
||||
|
||||
/* CREATE(net_wm_ping, "_NET_WM_PING"); */
|
||||
|
||||
CREATE(net_wm_window_type_desktop, "_NET_WM_WINDOW_TYPE_DESKTOP");
|
||||
CREATE(net_wm_window_type_dock, "_NET_WM_WINDOW_TYPE_DOCK");
|
||||
CREATE(net_wm_window_type_toolbar, "_NET_WM_WINDOW_TYPE_TOOLBAR");
|
||||
CREATE(net_wm_window_type_menu, "_NET_WM_WINDOW_TYPE_MENU");
|
||||
CREATE(net_wm_window_type_utility, "_NET_WM_WINDOW_TYPE_UTILITY");
|
||||
CREATE(net_wm_window_type_splash, "_NET_WM_WINDOW_TYPE_SPLASH");
|
||||
CREATE(net_wm_window_type_dialog, "_NET_WM_WINDOW_TYPE_DIALOG");
|
||||
CREATE(net_wm_window_type_normal, "_NET_WM_WINDOW_TYPE_NORMAL");
|
||||
|
||||
CREATE(net_wm_moveresize_size_topleft, "_NET_WM_MOVERESIZE_SIZE_TOPLEFT");
|
||||
CREATE(net_wm_moveresize_size_topright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_TOPRIGHT");
|
||||
CREATE(net_wm_moveresize_size_bottomleft,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT");
|
||||
CREATE(net_wm_moveresize_size_bottomright,
|
||||
"_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT");
|
||||
CREATE(net_wm_moveresize_move, "_NET_WM_MOVERESIZE_MOVE");
|
||||
|
||||
CREATE(net_wm_action_move, "_NET_WM_ACTION_MOVE");
|
||||
CREATE(net_wm_action_resize, "_NET_WM_ACTION_RESIZE");
|
||||
CREATE(net_wm_action_minimize, "_NET_WM_ACTION_MINIMIZE");
|
||||
CREATE(net_wm_action_shade, "_NET_WM_ACTION_SHADE");
|
||||
CREATE(net_wm_action_stick, "_NET_WM_ACTION_STICK");
|
||||
CREATE(net_wm_action_maximize_horz, "_NET_WM_ACTION_MAXIMIZE_HORZ");
|
||||
CREATE(net_wm_action_maximize_vert, "_NET_WM_ACTION_MAXIMIZE_VERT");
|
||||
CREATE(net_wm_action_fullscreen, "_NET_WM_ACTION_FULLSCREEN");
|
||||
CREATE(net_wm_action_change_desktop, "_NET_WM_ACTION_CHANGE_DESKTOP");
|
||||
CREATE(net_wm_action_close, "_NET_WM_ACTION_CLOSE");
|
||||
CREATE(net_wm_state_modal, "_NET_WM_STATE_MODAL");
|
||||
CREATE(net_wm_state_sticky, "_NET_WM_STATE_STICKY");
|
||||
CREATE(net_wm_state_maximized_vert, "_NET_WM_STATE_MAXIMIZED_VERT");
|
||||
CREATE(net_wm_state_maximized_horz, "_NET_WM_STATE_MAXIMIZED_HORZ");
|
||||
CREATE(net_wm_state_shaded, "_NET_WM_STATE_SHADED");
|
||||
CREATE(net_wm_state_skip_taskbar, "_NET_WM_STATE_SKIP_TASKBAR");
|
||||
CREATE(net_wm_state_skip_pager, "_NET_WM_STATE_SKIP_PAGER");
|
||||
CREATE(net_wm_state_hidden, "_NET_WM_STATE_HIDDEN");
|
||||
CREATE(net_wm_state_fullscreen, "_NET_WM_STATE_FULLSCREEN");
|
||||
CREATE(net_wm_state_above, "_NET_WM_STATE_ABOVE");
|
||||
CREATE(net_wm_state_below, "_NET_WM_STATE_BELOW");
|
||||
|
||||
prop_atoms.net_wm_state_add = 1;
|
||||
prop_atoms.net_wm_state_remove = 0;
|
||||
prop_atoms.net_wm_state_toggle = 2;
|
||||
|
||||
prop_atoms.net_wm_orientation_horz = 0;
|
||||
prop_atoms.net_wm_orientation_vert = 1;
|
||||
prop_atoms.net_wm_topleft = 0;
|
||||
prop_atoms.net_wm_topright = 1;
|
||||
prop_atoms.net_wm_bottomright = 2;
|
||||
prop_atoms.net_wm_bottomleft = 3;
|
||||
|
||||
CREATE(kde_net_system_tray_windows, "_KDE_NET_SYSTEM_TRAY_WINDOWS");
|
||||
CREATE(kde_net_wm_system_tray_window_for,
|
||||
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR");
|
||||
CREATE(kde_net_wm_window_type_override,
|
||||
"_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
|
||||
|
||||
CREATE(kwm_win_icon, "KWM_WIN_ICON");
|
||||
|
||||
CREATE(rootpmapid, "_XROOTPMAP_ID");
|
||||
CREATE(esetrootid, "ESETROOT_PMAP_ID");
|
||||
|
||||
CREATE(openbox_pid, "_OPENBOX_PID");
|
||||
CREATE(openbox_premax, "_OPENBOX_PREMAX");
|
||||
}
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
*data = g_memdup(xdata, num * (size / 8));
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
long num32 = 32 / size * num; /* num in 32-bit elements */
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, num32,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success && ret_items && xdata) {
|
||||
if (ret_size == size && ret_items >= num) {
|
||||
gulong i;
|
||||
for (i = 0; i < num; ++i)
|
||||
switch (size) {
|
||||
case 8:
|
||||
data[i] = xdata[i];
|
||||
break;
|
||||
case 16:
|
||||
((guint16*)data)[i] = ((guint16*)xdata)[i];
|
||||
break;
|
||||
case 32:
|
||||
((guint32*)data)[i] = ((guint32*)xdata)[i];
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached(); /* unhandled size */
|
||||
}
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int res;
|
||||
guchar *xdata = NULL;
|
||||
Atom ret_type;
|
||||
int ret_size;
|
||||
gulong ret_items, bytes_left;
|
||||
|
||||
res = XGetWindowProperty(ob_display, win, prop, 0l, G_MAXLONG,
|
||||
FALSE, type, &ret_type, &ret_size,
|
||||
&ret_items, &bytes_left, &xdata);
|
||||
if (res == Success) {
|
||||
if (ret_size == size && ret_items > 0) {
|
||||
*data = g_memdup(xdata, ret_items * (size / 8));
|
||||
*num = ret_items;
|
||||
ret = TRUE;
|
||||
}
|
||||
XFree(xdata);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((char*)raw, num);
|
||||
g_assert(str->str[num] == '\0');
|
||||
|
||||
g_free(raw);
|
||||
|
||||
*data = (guchar*)g_string_free(str, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data)
|
||||
{
|
||||
guchar *raw;
|
||||
gulong num;
|
||||
GString *str, *str2;
|
||||
guint i, start;
|
||||
|
||||
if (prop_get_all(win, prop, type, 8, &raw, &num)) {
|
||||
str = g_string_new_len((gchar*)raw, num);
|
||||
g_assert(str->str[num] == '\0'); /* assuming this is always true.. */
|
||||
|
||||
g_free(raw);
|
||||
|
||||
/* split it into the list */
|
||||
for (start = 0, i = 0; i < str->len; ++i) {
|
||||
if (str->str[i] == '\0') {
|
||||
str2 = g_string_new_len(&str->str[start], i - start);
|
||||
g_ptr_array_add(data, g_string_free(str2, FALSE));
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
if (data->len > 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void prop_erase(Window win, Atom prop)
|
||||
{
|
||||
XDeleteProperty(ob_display, win, prop);
|
||||
}
|
||||
|
||||
void prop_message(Window about, Atom messagetype, long data0, long data1,
|
||||
long data2, long data3)
|
||||
{
|
||||
XEvent ce;
|
||||
ce.xclient.type = ClientMessage;
|
||||
ce.xclient.message_type = messagetype;
|
||||
ce.xclient.display = ob_display;
|
||||
ce.xclient.window = about;
|
||||
ce.xclient.format = 32;
|
||||
ce.xclient.data.l[0] = data0;
|
||||
ce.xclient.data.l[1] = data1;
|
||||
ce.xclient.data.l[2] = data2;
|
||||
ce.xclient.data.l[3] = data3;
|
||||
XSendEvent(ob_display, ob_root, FALSE,
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, &ce);
|
||||
}
|
214
openbox/prop.h
Normal file
214
openbox/prop.h
Normal file
|
@ -0,0 +1,214 @@
|
|||
#ifndef __atoms_h
|
||||
#define __atoms_h
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "openbox.h"
|
||||
|
||||
/*! The atoms on the X server which this class will cache */
|
||||
typedef struct Atoms {
|
||||
/* types */
|
||||
Atom cardinal; /*!< The atom which represents the Cardinal data type */
|
||||
Atom window; /*!< The atom which represents window ids */
|
||||
Atom pixmap; /*!< The atom which represents pixmap ids */
|
||||
Atom atom; /*!< The atom which represents atom values */
|
||||
Atom string; /*!< The atom which represents ascii strings */
|
||||
Atom utf8; /*!< The atom which represents utf8-encoded strings */
|
||||
|
||||
/* window hints */
|
||||
Atom wm_colormap_windows;
|
||||
Atom wm_protocols;
|
||||
Atom wm_state;
|
||||
Atom wm_delete_window;
|
||||
Atom wm_take_focus;
|
||||
Atom wm_change_state;
|
||||
Atom wm_name;
|
||||
Atom wm_icon_name;
|
||||
Atom wm_class;
|
||||
Atom wm_window_role;
|
||||
Atom motif_wm_hints;
|
||||
|
||||
/* NETWM atoms */
|
||||
|
||||
/* root window properties */
|
||||
Atom net_supported;
|
||||
Atom net_client_list;
|
||||
Atom net_client_list_stacking;
|
||||
Atom net_number_of_desktops;
|
||||
Atom net_desktop_geometry;
|
||||
Atom net_desktop_viewport;
|
||||
Atom net_current_desktop;
|
||||
Atom net_desktop_names;
|
||||
Atom net_active_window;
|
||||
Atom net_workarea;
|
||||
Atom net_supporting_wm_check;
|
||||
/* Atom net_virtual_roots; */
|
||||
Atom net_desktop_layout;
|
||||
Atom net_showing_desktop;
|
||||
/* root window messages */
|
||||
Atom net_close_window;
|
||||
Atom net_wm_moveresize;
|
||||
/* application window properties */
|
||||
/* Atom net_properties; */
|
||||
Atom net_wm_name;
|
||||
Atom net_wm_visible_name;
|
||||
Atom net_wm_icon_name;
|
||||
Atom net_wm_visible_icon_name;
|
||||
Atom net_wm_desktop;
|
||||
Atom net_wm_window_type;
|
||||
Atom net_wm_state;
|
||||
Atom net_wm_strut;
|
||||
/* Atom net_wm_icon_geometry; */
|
||||
Atom net_wm_icon;
|
||||
/* Atom net_wm_pid; */
|
||||
/* Atom net_wm_handled_icons; */
|
||||
Atom net_wm_allowed_actions;
|
||||
/* application protocols */
|
||||
/* Atom Atom net_wm_ping; */
|
||||
|
||||
Atom net_wm_window_type_desktop;
|
||||
Atom net_wm_window_type_dock;
|
||||
Atom net_wm_window_type_toolbar;
|
||||
Atom net_wm_window_type_menu;
|
||||
Atom net_wm_window_type_utility;
|
||||
Atom net_wm_window_type_splash;
|
||||
Atom net_wm_window_type_dialog;
|
||||
Atom net_wm_window_type_normal;
|
||||
|
||||
Atom net_wm_moveresize_size_topleft;
|
||||
Atom net_wm_moveresize_size_topright;
|
||||
Atom net_wm_moveresize_size_bottomleft;
|
||||
Atom net_wm_moveresize_size_bottomright;
|
||||
Atom net_wm_moveresize_move;
|
||||
|
||||
Atom net_wm_action_move;
|
||||
Atom net_wm_action_resize;
|
||||
Atom net_wm_action_minimize;
|
||||
Atom net_wm_action_shade;
|
||||
Atom net_wm_action_stick;
|
||||
Atom net_wm_action_maximize_horz;
|
||||
Atom net_wm_action_maximize_vert;
|
||||
Atom net_wm_action_fullscreen;
|
||||
Atom net_wm_action_change_desktop;
|
||||
Atom net_wm_action_close;
|
||||
|
||||
Atom net_wm_state_modal;
|
||||
Atom net_wm_state_sticky;
|
||||
Atom net_wm_state_maximized_vert;
|
||||
Atom net_wm_state_maximized_horz;
|
||||
Atom net_wm_state_shaded;
|
||||
Atom net_wm_state_skip_taskbar;
|
||||
Atom net_wm_state_skip_pager;
|
||||
Atom net_wm_state_hidden;
|
||||
Atom net_wm_state_fullscreen;
|
||||
Atom net_wm_state_above;
|
||||
Atom net_wm_state_below;
|
||||
|
||||
Atom net_wm_state_add;
|
||||
Atom net_wm_state_remove;
|
||||
Atom net_wm_state_toggle;
|
||||
|
||||
Atom net_wm_orientation_horz;
|
||||
Atom net_wm_orientation_vert;
|
||||
Atom net_wm_topleft;
|
||||
Atom net_wm_topright;
|
||||
Atom net_wm_bottomright;
|
||||
Atom net_wm_bottomleft;
|
||||
|
||||
/* Extra atoms */
|
||||
|
||||
Atom kde_net_system_tray_windows;
|
||||
Atom kde_net_wm_system_tray_window_for;
|
||||
Atom kde_net_wm_window_type_override;
|
||||
|
||||
Atom kwm_win_icon;
|
||||
|
||||
Atom rootpmapid;
|
||||
Atom esetrootid;
|
||||
|
||||
/* Openbox specific atoms */
|
||||
|
||||
Atom openbox_pid;
|
||||
Atom openbox_premax;
|
||||
} Atoms;
|
||||
Atoms prop_atoms;
|
||||
|
||||
void prop_startup();
|
||||
|
||||
gboolean prop_get(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong num);
|
||||
|
||||
gboolean prop_get_prealloc(Window win, Atom prop, Atom type, int size,
|
||||
guchar *data, gulong num);
|
||||
|
||||
gboolean prop_get_all(Window win, Atom prop, Atom type, int size,
|
||||
guchar **data, gulong *num);
|
||||
|
||||
gboolean prop_get_string(Window win, Atom prop, Atom type, guchar **data);
|
||||
gboolean prop_get_strings(Window win, Atom prop, Atom type,
|
||||
GPtrArray *data);
|
||||
|
||||
void prop_set_strings(Window win, Atom prop, Atom type, GPtrArray *data);
|
||||
|
||||
void prop_erase(Window win, Atom prop);
|
||||
|
||||
void prop_message(Window about, Atom messagetype, long data0, long data1,
|
||||
long data2, long data3);
|
||||
|
||||
#define PROP_MSG(about, msgtype, data0, data1, data2, data3) \
|
||||
(prop_message(about, prop_atoms.msgtype, data0, data1, data2, data3))
|
||||
|
||||
/* Set an 8-bit property from a string */
|
||||
#define PROP_SETS(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
PropModeReplace, (guchar*)value, strlen(value)))
|
||||
/* Set an 8-bit property array from a GPtrArray of strings */
|
||||
#define PROP_SETSA(win, prop, type, value) \
|
||||
(prop_set_strings(win, prop_atoms.prop, prop_atoms.type, value))
|
||||
|
||||
/* Set a 32-bit property from a single value */
|
||||
#define PROP_SET32(win, prop, type, value) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)&value, 1))
|
||||
/* Set a 32-bit property from an array */
|
||||
#define PROP_SET32A(win, prop, type, value, num) \
|
||||
(XChangeProperty(ob_display, win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
PropModeReplace, (guchar*)value, num))
|
||||
|
||||
/* Get an 8-bit property into a string */
|
||||
#define PROP_GETS(win, prop, type, value) \
|
||||
(prop_get_string(win, prop_atoms.prop, prop_atoms.type, \
|
||||
(guchar**)&value))
|
||||
/* Get an 8-bit property into a GPtrArray of strings
|
||||
(The strings must be freed, the GPtrArray must already be created.) */
|
||||
#define PROP_GETSA(win, prop, type, value) \
|
||||
(prop_get_strings(win, prop_atoms.prop, prop_atoms.type, \
|
||||
value))
|
||||
|
||||
/* Get an entire 8-bit property into an array (which must be freed) */
|
||||
#define PROP_GET8U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 8, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
/* Get 1 element of a 32-bit property into a given variable */
|
||||
#define PROP_GET32(win, prop, type, value) \
|
||||
(prop_get_prealloc(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar*)&value, 1))
|
||||
|
||||
/* Get an amount of a 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32A(win, prop, type, value, num) \
|
||||
(prop_get(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, num))
|
||||
|
||||
/* Get an entire 32-bit property into an array (which must be freed) */
|
||||
#define PROP_GET32U(win, prop, type, value, num) \
|
||||
(prop_get_all(win, prop_atoms.prop, prop_atoms.type, 32, \
|
||||
(guchar**)&value, &num))
|
||||
|
||||
#define PROP_ERASE(win, prop) (prop_erase(win, prop_atoms.prop))
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue