2015-07-27 04:17:12 -04:00
|
|
|
#ifndef X11_ROFI_HELPER_H
|
|
|
|
#define X11_ROFI_HELPER_H
|
2016-01-09 10:22:09 -05:00
|
|
|
#include <cairo.h>
|
2015-02-09 13:35:51 -05:00
|
|
|
|
2016-01-07 02:54:24 -05:00
|
|
|
/**
|
|
|
|
* @defgroup X11Helper X11Helper
|
|
|
|
* @ingroup HELPERS
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-02-09 13:35:51 -05:00
|
|
|
int window_get_prop ( Display *display, Window w, Atom prop,
|
|
|
|
Atom *type, int *items,
|
|
|
|
void *buffer, unsigned int bytes ) __attribute__ ( ( nonnull ( 4, 5 ) ) );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
* @param w The Window to read property from.
|
|
|
|
* @param atom The property identifier
|
|
|
|
*
|
|
|
|
* Get text property defined by atom from window.
|
|
|
|
* Support utf8.
|
|
|
|
*
|
|
|
|
* @returns a newly allocated string with the result or NULL
|
|
|
|
*/
|
|
|
|
char* window_get_text_prop ( Display *display, Window w, Atom atom );
|
|
|
|
|
|
|
|
int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, int count );
|
|
|
|
void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms, int count );
|
2015-09-19 06:21:30 -04:00
|
|
|
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
|
|
|
|
int count );
|
2015-02-09 13:35:51 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Window info.
|
|
|
|
*/
|
|
|
|
#define ATOM_ENUM( x ) x
|
|
|
|
#define ATOM_CHAR( x ) # x
|
|
|
|
|
|
|
|
// usable space on a monitor
|
2015-04-02 16:23:17 -04:00
|
|
|
#define EWMH_ATOMS( X ) \
|
|
|
|
X ( _NET_CLIENT_LIST_STACKING ), \
|
|
|
|
X ( _NET_NUMBER_OF_DESKTOPS ), \
|
|
|
|
X ( _NET_CURRENT_DESKTOP ), \
|
|
|
|
X ( _NET_ACTIVE_WINDOW ), \
|
2015-11-10 17:52:52 -05:00
|
|
|
X ( _NET_CLIENT_LIST ), \
|
2015-04-02 16:23:17 -04:00
|
|
|
X ( _NET_WM_NAME ), \
|
|
|
|
X ( _NET_WM_STATE ), \
|
|
|
|
X ( _NET_WM_STATE_SKIP_TASKBAR ), \
|
|
|
|
X ( _NET_WM_STATE_SKIP_PAGER ), \
|
|
|
|
X ( _NET_WM_STATE_ABOVE ), \
|
|
|
|
X ( _NET_WM_STATE_DEMANDS_ATTENTION ), \
|
2015-05-10 06:08:08 -04:00
|
|
|
X ( _NET_WM_STATE_WITHDRAWN ), \
|
2015-08-27 15:09:12 -04:00
|
|
|
X ( _NET_WM_WINDOW_TYPE ), \
|
|
|
|
X ( _NET_WM_WINDOW_TYPE_DOCK ), \
|
2015-08-31 02:00:23 -04:00
|
|
|
X ( _NET_WM_WINDOW_TYPE_DESKTOP ), \
|
2015-09-10 13:24:23 -04:00
|
|
|
X ( _NET_WM_WINDOW_TYPE_NORMAL ), \
|
2015-10-16 14:51:37 -04:00
|
|
|
X ( _NET_WM_STATE_FULLSCREEN ), \
|
2015-04-02 16:23:17 -04:00
|
|
|
X ( _NET_WM_DESKTOP ), \
|
|
|
|
X ( CLIPBOARD ), \
|
|
|
|
X ( UTF8_STRING ), \
|
2015-02-09 13:35:51 -05:00
|
|
|
X ( _NET_WM_WINDOW_OPACITY )
|
|
|
|
|
|
|
|
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
|
|
|
|
|
|
|
|
extern const char *netatom_names[];
|
|
|
|
extern Atom netatoms[NUM_NETATOMS];
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
int l, r, t, b;
|
|
|
|
} workarea;
|
|
|
|
|
|
|
|
void monitor_active ( Display *display, workarea *mon );
|
|
|
|
|
|
|
|
int window_send_message ( Display *display, Window target, Window subject,
|
|
|
|
Atom atom, unsigned long protocol,
|
|
|
|
unsigned long mask, Time time );
|
|
|
|
|
2015-02-12 16:16:32 -05:00
|
|
|
// find the dimensions of the monitor displaying point x,y
|
|
|
|
void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon );
|
2015-08-02 09:45:52 -04:00
|
|
|
// Find the dimensions of the monitor specified by user.
|
|
|
|
int monitor_get_dimension ( Display *display, Screen *screen, int monitor, workarea *mon );
|
2015-10-18 07:40:39 -04:00
|
|
|
int monitor_get_smallest_size ( Display *display );
|
2015-02-09 13:35:51 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display The display.
|
|
|
|
*
|
|
|
|
* Release keyboard.
|
|
|
|
*/
|
|
|
|
void release_keyboard ( Display *display );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display The display.
|
|
|
|
* @param w Window we want to grab keyboard on.
|
|
|
|
*
|
|
|
|
* Grab keyboard and mouse.
|
|
|
|
*
|
|
|
|
* @return 1 when keyboard is grabbed, 0 not.
|
|
|
|
*/
|
|
|
|
int take_keyboard ( Display *display, Window w );
|
|
|
|
|
2015-02-09 14:05:30 -05:00
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
* @param modmask Modifier mask.
|
|
|
|
* @param key Key.
|
|
|
|
*
|
|
|
|
* Grab key on display.
|
|
|
|
*/
|
|
|
|
void x11_grab_key ( Display *display, unsigned int modmask, KeySym key );
|
2015-02-09 13:35:51 -05:00
|
|
|
|
2015-07-29 03:37:40 -04:00
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
* @param modmask Modifier mask.
|
|
|
|
* @param key Key.
|
|
|
|
*
|
|
|
|
* Ungrab key on display.
|
|
|
|
*/
|
|
|
|
void x11_ungrab_key ( Display *display, unsigned int modmask, KeySym key );
|
|
|
|
|
2015-02-09 14:05:30 -05:00
|
|
|
/**
|
|
|
|
* @param combo String representing the key combo
|
|
|
|
* @param mod [out] The modifier specified (or AnyModifier if not specified)
|
|
|
|
* @param key [out] The key specified
|
|
|
|
*
|
|
|
|
* Parse key from user input string.
|
|
|
|
*/
|
2015-02-09 13:35:51 -05:00
|
|
|
void x11_parse_key ( char *combo, unsigned int *mod, KeySym *key );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display The connection to the X server.
|
|
|
|
* @param box The window to set the opacity on.
|
|
|
|
* @param opacity The opacity value. (0-100)
|
|
|
|
*
|
|
|
|
* Set the opacity of the window and sub-windows.
|
|
|
|
*/
|
|
|
|
void x11_set_window_opacity ( Display *display, Window box, unsigned int opacity );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup several items required.
|
|
|
|
* * Error handling,
|
|
|
|
* * Numlock detection
|
|
|
|
* * Cache
|
|
|
|
*/
|
|
|
|
void x11_setup ( Display *display );
|
2015-02-14 13:42:04 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
*
|
|
|
|
* This function tries to create a 32bit TrueColor colormap.
|
|
|
|
* If this fails, it falls back to the default for the connected display.
|
|
|
|
*/
|
|
|
|
void create_visual_and_colormap ( Display *display );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
* @param name String representing the color.
|
|
|
|
*
|
|
|
|
* Allocate a pixel value for an X named color
|
|
|
|
*/
|
2015-07-31 06:23:41 -04:00
|
|
|
unsigned int color_get ( Display *display, const char *const name, const char * const defn );
|
2015-04-06 11:13:26 -04:00
|
|
|
|
2015-10-10 07:03:11 -04:00
|
|
|
void color_background ( Display *display, cairo_t *d );
|
|
|
|
void color_border ( Display *display, cairo_t *d );
|
|
|
|
void color_separator ( Display *display, cairo_t *d );
|
2015-10-10 08:15:27 -04:00
|
|
|
void color_cache_reset ( void );
|
2015-09-27 05:46:19 -04:00
|
|
|
|
2015-09-27 06:57:54 -04:00
|
|
|
cairo_format_t get_format ( void );
|
2015-10-10 07:03:11 -04:00
|
|
|
|
|
|
|
void x11_helper_set_cairo_rgba ( cairo_t *d, unsigned int pixel );
|
2016-01-07 02:54:24 -05:00
|
|
|
/*@}*/
|
2015-02-09 13:35:51 -05:00
|
|
|
#endif
|