tPrefix all functions with wm_ - libwm - X windows manipulation library
(HTM) git clone git://z3bra.org/libwm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e25b0ebcae7b968af8a000740f9d006d316a9998
(DIR) parent 599df0a7d465932cd9120c18ec483644eab4e8dd
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Sat, 14 Nov 2015 15:51:20 +0100
Prefix all functions with wm_
Diffstat:
D README | 42 -------------------------------
A README.md | 43 ++++++++++++++++++++++++++++++
M libwm.c | 72 ++++++++++++++++----------------
M wm.h | 62 ++++++++++++++++----------------
4 files changed, 110 insertions(+), 109 deletions(-)
---
(DIR) diff --git a/README b/README
t@@ -1,42 +0,0 @@
-# libwm
-
-A small library for X window manipulation
-
-## documentation
-
-Here is the full list of all the function you can use from `libwm`:
-
- init_xcb();
- kill_xcb();
- is_alive(wid);
- is_ignored(wid);
- is_listable(wid, mask);
- is_mapped(wid);
- get_screen();
- get_windows(wid, **list);
- get_attribute(wid, attr);
- get_cursor(mode, wid, *x, *y);
- set_border(width, color, wid);
- set_focus(wid);
- set_cursor(x, y, mode);
- teleport(wid, w, h, x, y);
- move(wid, mode, x, y);
- resize(wid, mode, w, h);
- restack(wid, mode);
-
-Their usage is specified in the `wm.h` header file, as it is quite small for
-now.
-
-## installation
-
-`libwm` provides two files: libwm.a and wm.h.
-You can build/install them as follow:
-
- $ make
- # make install
-
-The makefile supports 2 macros: DESTDIR and PREFIX.
-
-Then to link your program against it, compile it as follow:
-
- cc pgm.c -lwm -o pgm
(DIR) diff --git a/README.md b/README.md
t@@ -0,0 +1,43 @@
+# libwm
+
+A small library for X window manipulation
+
+## documentation
+
+Here is the full list of all the function you can use from `libwm`:
+
+ wm_init_xcb();
+ wm_kill_xcb();
+ wm_is_alive(wid);
+ wm_is_ignored(wid);
+ wm_is_listable(wid, mask);
+ wm_is_mapped(wid);
+ wm_get_screen();
+ wm_get_windows(wid, **list);
+ wm_get_attribute(wid, attr);
+ wm_get_cursor(mode, wid, *x, *y);
+ wm_set_border(width, color, wid);
+ wm_set_focus(wid);
+ wm_set_cursor(x, y, mode);
+ wm_teleport(wid, w, h, x, y);
+ wm_move(wid, mode, x, y);
+ wm_remap(wid, mode);
+ wm_resize(wid, mode, w, h);
+ wm_restack(wid, mode);
+
+Their usage is specified in the `wm.h` header file, as it is quite small for
+now.
+
+## installation
+
+`libwm` provides two files: libwm.a and wm.h.
+You can build/install them as follow:
+
+ $ make
+ # make install
+
+The makefile supports 2 macros: DESTDIR and PREFIX.
+
+Then to link your program against it, compile it as follow:
+
+ cc pgm.c -lwm -o pgm
(DIR) diff --git a/libwm.c b/libwm.c
t@@ -6,7 +6,7 @@
#include "wm.h"
int
-init_xcb()
+wm_init_xcb()
{
conn = xcb_connect(NULL, NULL);
if (xcb_connection_has_error(conn))
t@@ -15,7 +15,7 @@ init_xcb()
}
int
-kill_xcb()
+wm_kill_xcb()
{
if (conn) {
xcb_disconnect(conn);
t@@ -25,7 +25,7 @@ kill_xcb()
}
int
-is_alive(xcb_window_t w)
+wm_is_alive(xcb_window_t w)
{
xcb_get_window_attributes_cookie_t c;
xcb_get_window_attributes_reply_t *r;
t@@ -41,7 +41,7 @@ is_alive(xcb_window_t w)
}
int
-is_mapped(xcb_window_t w)
+wm_is_mapped(xcb_window_t w)
{
int ms;
xcb_get_window_attributes_cookie_t c;
t@@ -60,7 +60,7 @@ is_mapped(xcb_window_t w)
}
int
-is_ignored(xcb_window_t wid)
+wm_is_ignored(xcb_window_t wid)
{
int or;
xcb_get_window_attributes_cookie_t c;
t@@ -79,7 +79,7 @@ is_ignored(xcb_window_t wid)
}
int
-get_screen()
+wm_get_screen()
{
scrn = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
if (scrn == NULL)
t@@ -88,7 +88,7 @@ get_screen()
}
int
-get_windows(xcb_window_t w, xcb_window_t **l)
+wm_get_windows(xcb_window_t w, xcb_window_t **l)
{
uint32_t childnum = 0;
xcb_query_tree_cookie_t c;
t@@ -110,7 +110,7 @@ get_windows(xcb_window_t w, xcb_window_t **l)
}
int
-get_attribute(xcb_window_t w, int attr)
+wm_get_attribute(xcb_window_t w, int attr)
{
xcb_get_geometry_cookie_t c;
xcb_get_geometry_reply_t *r;
t@@ -134,7 +134,7 @@ get_attribute(xcb_window_t w, int attr)
}
int
-get_cursor(int mode, uint32_t wid, int *x, int *y)
+wm_get_cursor(int mode, uint32_t wid, int *x, int *y)
{
xcb_query_pointer_reply_t *r;
xcb_query_pointer_cookie_t c;
t@@ -157,7 +157,7 @@ get_cursor(int mode, uint32_t wid, int *x, int *y)
}
int
-set_border(int width, int color, xcb_window_t win)
+wm_set_border(int width, int color, xcb_window_t win)
{
uint32_t values[1];
int mask, retval = 0;
t@@ -182,7 +182,7 @@ set_border(int width, int color, xcb_window_t win)
}
int
-set_cursor(int x, int y, int mode)
+wm_set_cursor(int x, int y, int mode)
{
xcb_warp_pointer(conn, XCB_NONE, mode ? XCB_NONE : scrn->root,
0, 0, 0, 0, x, y);
t@@ -190,19 +190,19 @@ set_cursor(int x, int y, int mode)
}
int
-is_listable(xcb_window_t w, int mask)
+wm_is_listable(xcb_window_t w, int mask)
{
if ((mask & LIST_ALL)
- || (!is_mapped (w) && mask & LIST_HIDDEN)
- || ( is_ignored(w) && mask & LIST_IGNORE)
- || ( is_mapped (w) && !is_ignored(w) && mask == 0))
+ || (!wm_is_mapped (w) && mask & LIST_HIDDEN)
+ || ( wm_is_ignored(w) && mask & LIST_IGNORE)
+ || ( wm_is_mapped (w) && !wm_is_ignored(w) && mask == 0))
return 1;
return 0;
}
int
-teleport(xcb_window_t wid, int x, int y, int w, int h)
+wm_teleport(xcb_window_t wid, int x, int y, int w, int h)
{
uint32_t values[4];
uint32_t mask = XCB_CONFIG_WINDOW_X
t@@ -220,18 +220,18 @@ teleport(xcb_window_t wid, int x, int y, int w, int h)
}
int
-move(xcb_window_t wid, int mode, int x, int y)
+wm_move(xcb_window_t wid, int mode, int x, int y)
{
int curx, cury, curw, curh, curb;
- if (!is_mapped(wid) || wid == scrn->root)
+ if (!wm_is_mapped(wid) || wid == scrn->root)
return -1;
- curb = get_attribute(wid, ATTR_B);
- curx = get_attribute(wid, ATTR_X);
- cury = get_attribute(wid, ATTR_Y);
- curw = get_attribute(wid, ATTR_W);
- curh = get_attribute(wid, ATTR_H);
+ curb = wm_get_attribute(wid, ATTR_B);
+ curx = wm_get_attribute(wid, ATTR_X);
+ cury = wm_get_attribute(wid, ATTR_Y);
+ curw = wm_get_attribute(wid, ATTR_W);
+ curh = wm_get_attribute(wid, ATTR_H);
if (mode == ABSOLUTE) {
x -= curx + curw /2;
t@@ -252,12 +252,12 @@ move(xcb_window_t wid, int mode, int x, int y)
else if (y > scrn->height_in_pixels - curh - 2*curb)
y = scrn->height_in_pixels - curh - 2*curb;
- teleport(wid, x, y, curw, curh);
+ wm_teleport(wid, x, y, curw, curh);
return 1;
}
int
-remap(xcb_window_t wid, int mode)
+wm_remap(xcb_window_t wid, int mode)
{
switch (mode) {
case MAP:
t@@ -267,7 +267,7 @@ remap(xcb_window_t wid, int mode)
xcb_unmap_window(conn, wid);
break;
case TOGGLE:
- if (is_mapped(wid))
+ if (wm_is_mapped(wid))
xcb_unmap_window(conn, wid);
else
xcb_map_window(conn, wid);
t@@ -278,18 +278,18 @@ remap(xcb_window_t wid, int mode)
}
int
-resize(xcb_window_t wid, int mode, int w, int h)
+wm_resize(xcb_window_t wid, int mode, int w, int h)
{
int curx, cury, curw, curh, curb;
- if (!is_mapped(wid) || wid == scrn->root)
+ if (!wm_is_mapped(wid) || wid == scrn->root)
return -1;
- curb = get_attribute(wid, ATTR_B);
- curx = get_attribute(wid, ATTR_X);
- cury = get_attribute(wid, ATTR_Y);
- curw = get_attribute(wid, ATTR_W);
- curh = get_attribute(wid, ATTR_H);
+ curb = wm_get_attribute(wid, ATTR_B);
+ curx = wm_get_attribute(wid, ATTR_X);
+ cury = wm_get_attribute(wid, ATTR_Y);
+ curw = wm_get_attribute(wid, ATTR_W);
+ curh = wm_get_attribute(wid, ATTR_H);
if (mode == ABSOLUTE) {
w -= curx + 2*curb;
t@@ -313,12 +313,12 @@ resize(xcb_window_t wid, int mode, int w, int h)
if (cury + h > scrn->height_in_pixels)
h = scrn->height_in_pixels - cury - 2*curb;
- teleport(wid, curx, cury, w, h);
+ wm_teleport(wid, curx, cury, w, h);
return 1;
}
int
-restack(xcb_window_t wid, uint32_t mode)
+wm_restack(xcb_window_t wid, uint32_t mode)
{
uint32_t values[1] = { mode };
xcb_configure_window(conn, wid, XCB_CONFIG_WINDOW_STACK_MODE, values);
t@@ -327,7 +327,7 @@ restack(xcb_window_t wid, uint32_t mode)
}
int
-set_focus(xcb_window_t wid)
+wm_set_focus(xcb_window_t wid)
{
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, wid,
XCB_CURRENT_TIME);
(DIR) diff --git a/wm.h b/wm.h
t@@ -10,7 +10,7 @@ extern xcb_screen_t *scrn;
/*
* Mask attributes used to select which windows have to be listed by the
- * function `is_listable(wid, mask)`.
+ * function `wm_is_listable(wid, mask)`.
*/
enum {
LIST_HIDDEN = 1 << 0, /* windows that are not on-screen */
t@@ -19,7 +19,7 @@ enum {
};
/*
- * Actions used by the `remap(wid, mode)` function to select what needs to be
+ * Actions used by the `wm_remap(wid, mode)` function to select what needs to be
* done.
*/
enum {
t@@ -44,7 +44,7 @@ enum {
};
/*
- * Selector used by both `move(wid, mode, x, y)` and `resize(wid, mode, w, h)`
+ * Selector used by both `wm_move(wid, mode, x, y)` and `wm_resize(wid, mode, w, h)`
* to choose between relative or absolute coordinates
*/
enum {
t@@ -56,26 +56,26 @@ enum {
* Initialize the connection to the X server. The connection could then be
* accessed by other functions through the "conn" variable.
*/
-int init_xcb();
+int wm_init_xcb();
/*
* Close connection to the X server.
*/
-int kill_xcb();
+int wm_kill_xcb();
/*
* Check existence of a window.
* + 1 - window exists
* + 0 - window doesn't exist
*/
-int is_alive(xcb_window_t wid);
+int wm_is_alive(xcb_window_t wid);
/*
* Returns the value of the "override_redirect" attribute of a window.
* When this attribute is set to 1, it means the window manager should NOT
* handle this window.
*/
-int is_ignored(xcb_window_t wid);
+int wm_is_ignored(xcb_window_t wid);
/*
* Returns 1 if a window match the mask, 0 otherwise.
t@@ -84,24 +84,24 @@ int is_ignored(xcb_window_t wid);
* LIST_IGNORE
* LIST_ALL
*/
-int is_listable(xcb_window_t wid, int mask);
+int wm_is_listable(xcb_window_t wid, int mask);
/*
* Returns 1 if the window is mapped on screen, 0 otherwise
*/
-int is_mapped(xcb_window_t wid);
+int wm_is_mapped(xcb_window_t wid);
/*
* Get the first screen, and set the `scrn` global variable accordingly.
*/
-int get_screen();
+int wm_get_screen();
/*
* Ask the list of all existing windows to the X server, and fills the `*list`
* argument with them.
* The windows are listed in stacking order, from lower to upper window.
*/
-int get_windows(xcb_window_t wid, xcb_window_t **list);
+int wm_get_windows(xcb_window_t wid, xcb_window_t **list);
/*
* Retrive the value of an attribute for a specific windows.
t@@ -114,7 +114,7 @@ int get_windows(xcb_window_t wid, xcb_window_t **list);
* ATTR_M - map state
* ATTR_I - ignore state (override_redirect)
*/
-int get_attribute(xcb_window_t wid, int attr);
+int wm_get_attribute(xcb_window_t wid, int attr);
/*
* Get the cursor position, and store its coordinates in the `x` and `y`
t@@ -122,40 +122,40 @@ int get_attribute(xcb_window_t wid, int attr);
* The `mode` attribute isn't used yet, but is reserved to ask for either
* absolute or relative coordinates
*/
-int get_cursor(int mode, uint32_t wid, int *x, int *y);
+int wm_get_cursor(int mode, uint32_t wid, int *x, int *y);
/*
* Set a window's border.
* The color should be an hexadecimal number, eg: 0xdeadca7
*/
-int set_border(int width, int color, xcb_window_t wid);
+int wm_set_border(int width, int color, xcb_window_t wid);
/*
* Give the input focus to the specified window
*/
-int set_focus(xcb_window_t wid);
+int wm_set_focus(xcb_window_t wid);
/*
* Change the cursor position, either relatively or absolutely, eg:
- * set_cursor(10, 10, ABSOLUTE);
- * set_cursor(-10, 20, RELATIVE);
+ * wm_set_cursor(10, 10, ABSOLUTE);
+ * wm_set_cursor(-10, 20, RELATIVE);
*/
-int set_cursor(int x, int y, int mode);
+int wm_set_cursor(int x, int y, int mode);
/*
* Teleport a window to the given position.
*/
-int teleport(xcb_window_t wid, int w, int h, int x, int y);
+int wm_teleport(xcb_window_t wid, int w, int h, int x, int y);
/*
* Move a window to the given position, either relatively or absolutely.
- * If the move is supposed to move the window outside the screen, then the
- * windows will only be moved to the edge of the screen.
+ * If the wm_move is supposed to wm_move the window outside the screen, then the
+ * windows will only be wm_moved to the edge of the screen.
*
- * You cannot move windows outside the screen with this method. Use
- * `teleport()` instead.
+ * You cannot wm_move windows outside the screen with this method. Use
+ * `wm_teleport()` instead.
*/
-int move(xcb_window_t wid, int mode, int x, int y);
+int wm_move(xcb_window_t wid, int mode, int x, int y);
/*
* Change the mapping state of a window. The `mode` attribute can be as follow:
t@@ -163,17 +163,17 @@ int move(xcb_window_t wid, int mode, int x, int y);
* UNMAP
* TOGGLE
*/
-int remap(xcb_window_t wid, int mode);
+int wm_remap(xcb_window_t wid, int mode);
/*
* Resize a window to the given size, either relatively or absolutely.
- * If the resize is supposed to put an area of the window outside the screen,
- * then the windows will only be resized to the edge of the screen.
+ * If the wm_resize is supposed to put an area of the window outside the screen,
+ * then the windows will only be wm_resized to the edge of the screen.
*
- * You cannot resize windows farther than the screen edge with this method. Use
- * `teleport()` instead.
+ * You cannot wm_resize windows farther than the screen edge with this method. Use
+ * `wm_teleport()` instead.
*/
-int resize(xcb_window_t wid, int mode, int w, int h);
+int wm_resize(xcb_window_t wid, int mode, int w, int h);
/*
* Change the position of the given window in the stack order.
t@@ -183,6 +183,6 @@ int resize(xcb_window_t wid, int mode, int w, int h);
* XCB_STACK_MODE_BELOW
* XCB_STACK_MODE_OPPOSITE
*/
-int restack(xcb_window_t wid, uint32_t mode);
+int wm_restack(xcb_window_t wid, uint32_t mode);
#endif /* __LIBWM_H__ */