2015-07-27 08:17:12 +00:00
|
|
|
#ifndef X11_ROFI_HELPER_H
|
|
|
|
#define X11_ROFI_HELPER_H
|
2016-01-09 15:22:09 +00:00
|
|
|
#include <cairo.h>
|
2016-02-21 18:42:32 +00:00
|
|
|
#include <xcb/xcb.h>
|
2015-02-09 18:35:51 +00:00
|
|
|
|
2016-02-22 10:39:52 +00:00
|
|
|
#include "xkb.h"
|
|
|
|
|
2016-01-07 07:54:24 +00:00
|
|
|
/**
|
|
|
|
* @defgroup X11Helper X11Helper
|
|
|
|
* @ingroup HELPERS
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-02-09 18:35:51 +00:00
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
2016-02-27 23:09:05 +00:00
|
|
|
* @param w The xcb_window_t to read property from.
|
2015-02-09 18:35:51 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2016-02-27 23:09:05 +00:00
|
|
|
char* window_get_text_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, Atom atom );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
2016-02-27 23:09:05 +00:00
|
|
|
void window_set_atom_prop ( xcb_connection_t *xcb_connection, xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
/**
|
2016-02-27 23:09:05 +00:00
|
|
|
* xcb_window_t info.
|
2015-02-09 18:35:51 +00:00
|
|
|
*/
|
|
|
|
#define ATOM_ENUM( x ) x
|
|
|
|
#define ATOM_CHAR( x ) # x
|
|
|
|
|
|
|
|
// usable space on a monitor
|
2015-04-02 20:23:17 +00:00
|
|
|
#define EWMH_ATOMS( X ) \
|
2016-02-27 23:09:05 +00:00
|
|
|
X ( _NET_WM_WINDOW_OPACITY ), \
|
2016-02-28 00:08:12 +00:00
|
|
|
X ( RESOURCE_MANAGER ), \
|
|
|
|
X ( I3_SOCKET_PATH ), \
|
2016-02-27 23:09:05 +00:00
|
|
|
X ( WM_WINDOW_ROLE)
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
|
|
|
|
|
|
|
|
extern const char *netatom_names[];
|
2016-02-27 23:09:05 +00:00
|
|
|
extern xcb_atom_t netatoms[NUM_NETATOMS];
|
2015-02-09 18:35:51 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
int l, r, t, b;
|
|
|
|
} workarea;
|
|
|
|
|
2016-02-27 19:45:47 +00:00
|
|
|
void monitor_active ( xcb_connection_t *xcb_connection, workarea *mon );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
2015-02-12 21:16:32 +00:00
|
|
|
// find the dimensions of the monitor displaying point x,y
|
2016-02-27 19:45:47 +00:00
|
|
|
void monitor_dimensions ( xcb_connection_t *xcb_connection, xcb_screen_t *screen, int x, int y, workarea *mon );
|
2015-08-02 13:45:52 +00:00
|
|
|
// Find the dimensions of the monitor specified by user.
|
2016-02-27 19:45:47 +00:00
|
|
|
int monitor_get_dimension ( xcb_connection_t *xcb_connection, xcb_screen_t *screen, int monitor, workarea *mon );
|
|
|
|
int monitor_get_smallest_size ( xcb_connection_t *xcb_connection );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display The display.
|
|
|
|
*
|
|
|
|
* Release keyboard.
|
|
|
|
*/
|
2016-02-27 23:09:05 +00:00
|
|
|
void release_keyboard ( xcb_connection_t *xcb_connection );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param display The display.
|
2016-02-27 23:09:05 +00:00
|
|
|
* @param w xcb_window_t we want to grab keyboard on.
|
2015-02-09 18:35:51 +00:00
|
|
|
*
|
|
|
|
* Grab keyboard and mouse.
|
|
|
|
*
|
|
|
|
* @return 1 when keyboard is grabbed, 0 not.
|
|
|
|
*/
|
2016-02-27 23:09:05 +00:00
|
|
|
int take_keyboard ( xcb_connection_t *xcb_connection, xcb_window_t w );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
2016-02-23 09:44:36 +00:00
|
|
|
/**
|
|
|
|
* @param mask The mask to canonilize
|
|
|
|
*
|
|
|
|
* @return The canonilized mask
|
|
|
|
*/
|
|
|
|
unsigned int x11_canonalize_mask ( unsigned int mask );
|
|
|
|
|
2015-02-09 19:05:30 +00: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.
|
|
|
|
*/
|
2016-02-21 12:10:32 +00:00
|
|
|
void x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
2016-02-27 23:09:05 +00:00
|
|
|
void x11_set_window_opacity ( xcb_connection_t *xcb_connection, xcb_window_t box, unsigned int opacity );
|
2015-02-09 18:35:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup several items required.
|
|
|
|
* * Error handling,
|
|
|
|
* * Numlock detection
|
|
|
|
* * Cache
|
|
|
|
*/
|
2016-02-27 23:09:05 +00:00
|
|
|
void x11_setup ( xcb_connection_t *xcb_connection, xkb_stuff *xkb );
|
2015-02-14 18:42:04 +00:00
|
|
|
|
2016-02-21 18:42:32 +00:00
|
|
|
extern xcb_depth_t *depth;
|
|
|
|
extern xcb_visualtype_t *visual;
|
|
|
|
extern xcb_colormap_t map;
|
|
|
|
extern xcb_depth_t *root_depth;
|
|
|
|
extern xcb_visualtype_t *root_visual;
|
2015-02-14 18:42:04 +00:00
|
|
|
/**
|
|
|
|
* This function tries to create a 32bit TrueColor colormap.
|
|
|
|
* If this fails, it falls back to the default for the connected display.
|
|
|
|
*/
|
2016-02-21 18:42:32 +00:00
|
|
|
void x11_create_visual_and_colormap ( xcb_connection_t *xcb_connection, xcb_screen_t *xcb_screen );
|
2015-02-14 18:42:04 +00:00
|
|
|
|
2016-02-21 18:27:53 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
double red, green, blue, alpha;
|
|
|
|
} Color;
|
|
|
|
|
2015-02-14 18:42:04 +00:00
|
|
|
/**
|
|
|
|
* @param display Connection to the X server.
|
|
|
|
* @param name String representing the color.
|
|
|
|
*
|
|
|
|
* Allocate a pixel value for an X named color
|
|
|
|
*/
|
2016-02-21 18:42:32 +00:00
|
|
|
Color color_get ( const char *const name );
|
2015-04-06 15:13:26 +00:00
|
|
|
|
2016-02-21 18:42:32 +00:00
|
|
|
void color_background ( cairo_t *d );
|
|
|
|
void color_border ( cairo_t *d );
|
|
|
|
void color_separator ( cairo_t *d );
|
2015-10-10 12:15:27 +00:00
|
|
|
void color_cache_reset ( void );
|
2015-09-27 09:46:19 +00:00
|
|
|
|
2016-02-21 18:27:53 +00:00
|
|
|
void x11_helper_set_cairo_rgba ( cairo_t *d, Color col );
|
2016-01-07 07:54:24 +00:00
|
|
|
/*@}*/
|
2015-02-09 18:35:51 +00:00
|
|
|
#endif
|