2017-04-15 10:32:05 +00:00
|
|
|
/*
|
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
2022-02-07 22:16:46 +00:00
|
|
|
* Copyright © 2013-2022 Qball Cow <qball@gmpclient.org>
|
2017-04-15 10:32:05 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-01 17:17:39 +00:00
|
|
|
#ifndef ROFI_XCB_H
|
|
|
|
#define ROFI_XCB_H
|
|
|
|
|
2017-05-31 22:12:03 +00:00
|
|
|
#include <cairo.h>
|
2021-08-19 11:34:01 +00:00
|
|
|
#include <xcb/xcb.h>
|
2017-05-31 22:12:03 +00:00
|
|
|
|
2016-10-15 13:39:08 +00:00
|
|
|
/**
|
|
|
|
* xcb data structure type declaration.
|
|
|
|
*/
|
2017-10-21 09:18:52 +00:00
|
|
|
typedef struct _xcb_stuff xcb_stuff;
|
2016-03-01 17:17:39 +00:00
|
|
|
|
2016-10-15 13:39:08 +00:00
|
|
|
/**
|
|
|
|
* Global pointer to xcb_stuff instance.
|
|
|
|
*/
|
2016-03-01 17:17:39 +00:00
|
|
|
extern xcb_stuff *xcb;
|
|
|
|
|
2016-10-15 13:39:08 +00:00
|
|
|
/**
|
|
|
|
* Get the root window.
|
|
|
|
*
|
|
|
|
* @returns the root window.
|
2016-10-15 13:45:28 +00:00
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
xcb_window_t xcb_stuff_get_root_window(void);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param w The xcb_window_t 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
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
char *window_get_text_prop(xcb_window_t w, xcb_atom_t atom);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param w The xcb_window_t to set property on
|
|
|
|
* @param prop Atom of the property to change
|
|
|
|
* @param atoms List of atoms to change the property too
|
|
|
|
* @param count The length of the atoms list.
|
|
|
|
*
|
|
|
|
* Set property on window.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void window_set_atom_prop(xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms,
|
|
|
|
int count);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/** For getting the atoms in an enum */
|
2021-08-19 11:34:01 +00:00
|
|
|
#define ATOM_ENUM(x) x
|
2017-05-31 22:12:03 +00:00
|
|
|
/** Get the atoms as strings. */
|
2021-08-19 11:34:01 +00:00
|
|
|
#define ATOM_CHAR(x) #x
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/** Atoms we want to pre-load */
|
2021-08-19 11:34:01 +00:00
|
|
|
#define EWMH_ATOMS(X) \
|
|
|
|
X(_NET_WM_WINDOW_OPACITY), X(I3_SOCKET_PATH), X(UTF8_STRING), X(STRING), \
|
|
|
|
X(CLIPBOARD), X(WM_WINDOW_ROLE), X(_XROOTPMAP_ID), X(_MOTIF_WM_HINTS), \
|
|
|
|
X(WM_TAKE_FOCUS), X(ESETROOT_PMAP_ID)
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/** enumeration of the atoms. */
|
2021-08-19 11:34:01 +00:00
|
|
|
enum { EWMH_ATOMS(ATOM_ENUM), NUM_NETATOMS };
|
2017-05-31 22:12:03 +00:00
|
|
|
/** atoms as string */
|
|
|
|
extern const char *netatom_names[];
|
|
|
|
/** atoms */
|
|
|
|
extern xcb_atom_t netatoms[NUM_NETATOMS];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure describing a workarea/monitor.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
typedef struct _workarea {
|
|
|
|
/** numeric monitor id. */
|
|
|
|
int monitor_id;
|
|
|
|
/** if monitor is set as primary monitor. */
|
|
|
|
int primary;
|
|
|
|
/** Horizontal location (in pixels) of the monitor. */
|
|
|
|
int x;
|
|
|
|
/** Vertical location (in pixels) of the monitor. */
|
|
|
|
int y;
|
|
|
|
/** Width of the monitor. */
|
|
|
|
int w;
|
|
|
|
/** Height of the monitor */
|
|
|
|
int h;
|
|
|
|
int mw, mh;
|
|
|
|
/** Output name of the monitor, e.g. eDP1 or VGA-1 */
|
|
|
|
char *name;
|
|
|
|
/** Pointer to next monitor */
|
|
|
|
struct _workarea *next;
|
2017-05-31 22:12:03 +00:00
|
|
|
} workarea;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mon workarea to be filled in.
|
|
|
|
*
|
|
|
|
* Fills in #mon with the information about the monitor rofi should show on.
|
|
|
|
*
|
|
|
|
* @returns TRUE if monitor is found, FALSE if no monitor could be detected.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
int monitor_active(workarea *mon);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
2021-05-05 19:53:29 +00:00
|
|
|
/**
|
|
|
|
* @param w rofis window
|
|
|
|
*
|
|
|
|
* Stores old input focus for reverting and set focus to rofi.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void rofi_xcb_set_input_focus(xcb_window_t w);
|
2021-05-05 19:53:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IF set, revert the focus back to the original applications.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void rofi_xcb_revert_input_focus(void);
|
2020-03-26 12:45:45 +00:00
|
|
|
|
2017-05-31 22:12:03 +00:00
|
|
|
/**
|
|
|
|
* Depth of visual
|
|
|
|
*/
|
|
|
|
extern xcb_depth_t *depth;
|
|
|
|
/**
|
|
|
|
* Visual to use for creating window
|
|
|
|
*/
|
|
|
|
extern xcb_visualtype_t *visual;
|
|
|
|
/**
|
|
|
|
* Color map to use for creating window
|
|
|
|
*/
|
|
|
|
extern xcb_colormap_t map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a surface containing the background image of the desktop.
|
|
|
|
*
|
|
|
|
* @returns a cairo surface with the background image of the desktop.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
cairo_surface_t *x11_helper_get_bg_surface(void);
|
2017-05-31 22:12:03 +00:00
|
|
|
/**
|
|
|
|
* Gets a surface for the root window of the desktop.
|
|
|
|
*
|
|
|
|
* Can be used to take screenshot.
|
|
|
|
*
|
|
|
|
* @returns a cairo surface for the root window of the desktop.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
cairo_surface_t *x11_helper_get_screenshot_surface(void);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param window The X11 window to modify
|
|
|
|
*
|
|
|
|
* Set the right hints to disable the window decoration.
|
|
|
|
* (Set MOTIF_WM_HINTS, decoration field)
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void x11_disable_decoration(xcb_window_t window);
|
2017-05-31 22:12:03 +00:00
|
|
|
|
2021-05-22 22:17:27 +00:00
|
|
|
/**
|
|
|
|
* List of cursor types.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
typedef enum {
|
|
|
|
/** Default arrow cursor */
|
|
|
|
CURSOR_DEFAULT = 0,
|
|
|
|
/** Cursor denoting a clickable area */
|
|
|
|
CURSOR_POINTER,
|
|
|
|
/** Cursor denoting an input field / selectable text */
|
|
|
|
CURSOR_TEXT,
|
|
|
|
NUM_CURSORS
|
2021-05-22 22:17:27 +00:00
|
|
|
} X11CursorType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param window
|
|
|
|
* @param type
|
|
|
|
*
|
|
|
|
* Change mouse cursor
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void x11_set_cursor(xcb_window_t window, X11CursorType type);
|
2021-05-22 22:17:27 +00:00
|
|
|
|
2017-05-31 22:12:03 +00:00
|
|
|
/**
|
|
|
|
* List of window managers that need different behaviour to functioning.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
typedef enum {
|
|
|
|
/** Default EWHM compatible window manager */
|
|
|
|
WM_EWHM = 0,
|
|
|
|
/** I3 Window manager */
|
|
|
|
WM_DO_NOT_CHANGE_CURRENT_DESKTOP = 1,
|
|
|
|
/** PANGO WORKSPACE NAMES */
|
|
|
|
WM_PANGO_WORKSPACE_NAMES = 2,
|
|
|
|
/** Root window offset (for bspwm) */
|
|
|
|
WM_ROOT_WINDOW_OFFSET = 4,
|
2017-09-17 19:40:36 +00:00
|
|
|
} WindowManagerQuirk;
|
2017-05-31 22:12:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates the current window manager.
|
|
|
|
* This is used for work-arounds.
|
|
|
|
*/
|
2017-09-17 19:40:36 +00:00
|
|
|
extern WindowManagerQuirk current_window_manager;
|
2017-05-31 22:12:03 +00:00
|
|
|
|
2019-10-17 19:19:19 +00:00
|
|
|
/**
|
|
|
|
* @param window the window the screenshot
|
|
|
|
* @param size Size of the thumbnail
|
|
|
|
*
|
|
|
|
* Creates a thumbnail of the window.
|
|
|
|
*
|
2021-08-19 11:34:01 +00:00
|
|
|
* @returns NULL if window was not found, or unmapped, otherwise returns a
|
|
|
|
* cairo_surface.
|
2019-10-17 19:19:19 +00:00
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
cairo_surface_t *x11_helper_get_screenshot_surface_window(xcb_window_t window,
|
|
|
|
int size);
|
2021-05-05 19:53:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param surface
|
|
|
|
* @param radius
|
|
|
|
* @param deviation
|
|
|
|
*
|
|
|
|
* Blur the content of the surface with radius and deviation.
|
|
|
|
*/
|
2021-08-19 11:34:01 +00:00
|
|
|
void cairo_image_surface_blur(cairo_surface_t *surface, double radius,
|
|
|
|
double deviation);
|
2021-05-22 22:17:27 +00:00
|
|
|
|
2016-03-01 17:17:39 +00:00
|
|
|
#endif
|