1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00
rofi/include/x11-helper.h

182 lines
4.4 KiB
C
Raw Normal View History

2015-07-27 04:17:12 -04:00
#ifndef X11_ROFI_HELPER_H
#define X11_ROFI_HELPER_H
#include <glib.h>
#include <cairo.h>
#include <xcb/xcb.h>
2015-02-09 13:35:51 -05:00
#include "xkb.h"
2016-01-07 02:54:24 -05:00
/**
* @defgroup X11Helper X11Helper
* @ingroup HELPERS
* @{
*/
2015-02-09 13:35:51 -05:00
/**
* @param w The xcb_window_t to read property from.
2015-02-09 13:35:51 -05: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-03-01 12:11:55 -05:00
char* window_get_text_prop ( xcb_window_t w, xcb_atom_t atom );
2015-02-09 13:35:51 -05:00
2016-03-01 12:11:55 -05:00
void window_set_atom_prop ( xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count );
2015-02-09 13:35:51 -05:00
/**
* xcb_window_t info.
2015-02-09 13:35:51 -05:00
*/
#define ATOM_ENUM( x ) x
#define ATOM_CHAR( x ) # x
// usable space on a monitor
2016-02-28 09:32:53 -05:00
#define EWMH_ATOMS( X ) \
X ( _NET_WM_WINDOW_OPACITY ), \
X ( I3_SOCKET_PATH ), \
X ( UTF8_STRING ), \
X ( STRING ), \
X ( WM_WINDOW_ROLE ), \
X ( _XROOTPMAP_ID ), \
X ( _MOTIF_WM_HINTS ), \
X ( ESETROOT_PMAP_ID )
2015-02-09 13:35:51 -05:00
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
extern const char *netatom_names[];
extern xcb_atom_t netatoms[NUM_NETATOMS];
enum
{
X11MOD_SHIFT,
X11MOD_CONTROL,
X11MOD_ALT,
X11MOD_META,
X11MOD_SUPER,
X11MOD_HYPER,
X11MOD_ANY,
NUM_X11MOD
};
typedef struct _workarea
2015-02-09 13:35:51 -05:00
{
int monitor_id;
int primary;
int x, y, w, h;
char *name;
struct _workarea *next;
2015-02-09 13:35:51 -05:00
} workarea;
int monitor_active ( workarea *mon );
2015-02-09 13:35:51 -05:00
// find the dimensions of the monitor displaying point x,y
2016-03-01 12:11:55 -05:00
void monitor_dimensions ( 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 ( int monitor_id, workarea *mon );
2016-03-01 12:11:55 -05:00
int monitor_get_smallest_size ( void );
2015-02-09 13:35:51 -05:00
/**
* Release keyboard.
*/
2016-03-01 12:11:55 -05:00
void release_keyboard ( void );
2016-05-09 02:47:28 -04:00
void release_pointer ( void );
2015-02-09 13:35:51 -05:00
/**
* @param w xcb_window_t we want to grab keyboard on.
2015-02-09 13:35:51 -05:00
*
* Grab keyboard and mouse.
*
* @return 1 when keyboard is grabbed, 0 not.
*/
2016-03-01 12:11:55 -05:00
int take_keyboard ( xcb_window_t w );
2016-05-09 02:47:28 -04:00
int take_pointer ( xcb_window_t w );
2015-02-09 13:35:51 -05:00
/**
* @param mask The mask to canonilize
*
* @return The canonilized mask
*/
unsigned int x11_canonalize_mask ( unsigned int mask );
unsigned int x11_get_current_mask ( xkb_stuff *xkb );
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
2016-07-29 02:32:34 -04:00
* @param release [out] If it should react on key-release, not key-press
2015-02-09 14:05:30 -05:00
*
* Parse key from user input string.
*/
gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release );
2015-02-09 13:35:51 -05:00
/**
* @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-03-01 12:11:55 -05:00
void x11_set_window_opacity ( xcb_window_t box, unsigned int opacity );
2015-02-09 13:35:51 -05:00
/**
* Setup several items required.
* * Error handling,
* * Numlock detection
* * Cache
*/
2016-03-01 12:11:55 -05:00
void x11_setup ( xkb_stuff *xkb );
2015-02-14 13:42:04 -05: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 13:42:04 -05:00
/**
* This function tries to create a 32bit TrueColor colormap.
* If this fails, it falls back to the default for the connected display.
*/
2016-03-01 12:11:55 -05:00
void x11_create_visual_and_colormap ( void );
2015-02-14 13:42:04 -05:00
typedef struct
{
double red, green, blue, alpha;
} Color;
2015-02-14 13:42:04 -05:00
/**
* @param name String representing the color.
*
* Allocate a pixel value for an X named color
*/
Color color_get ( const char *const name );
2015-04-06 11:13:26 -04:00
void color_background ( cairo_t *d );
void color_border ( cairo_t *d );
void color_separator ( cairo_t *d );
2015-09-27 05:46:19 -04:00
void x11_helper_set_cairo_rgba ( cairo_t *d, Color col );
/**
* Gets a surface containing the background image of the desktop.
*
2016-07-29 02:32:34 -04:00
* @returns a cairo surface with the background image of the desktop.
*/
cairo_surface_t * x11_helper_get_bg_surface ( void );
/**
* Creates an internal represenation of the available monitors.
* Used for positioning rofi.
*/
void x11_build_monitor_layout ( void );
void x11_dump_monitor_layout ( void );
int x11_modifier_active ( unsigned int mask, int key );
/**
* @param window The X11 window to modify
*
* Set the right hints to disable the window decoration.
* (Set MOTIF_WM_HINTS, decoration field)
*/
void x11_disable_decoration ( xcb_window_t window );
2016-01-07 02:54:24 -05:00
/*@}*/
2015-02-09 13:35:51 -05:00
#endif