Added initial support for Xlib cursor themes
I hope this time i got all right with git format-patch. Signed-off-by: Tumin Alexander <iamtakingiteasy@eientei.org> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
ed9f218669
commit
531f8b415c
12
awesome.c
12
awesome.c
|
@ -32,6 +32,8 @@
|
|||
#include <xcb/xinerama.h>
|
||||
#include <xcb/xtest.h>
|
||||
|
||||
#include <X11/Xlib-xcb.h>
|
||||
|
||||
#include "awesome.h"
|
||||
#include "spawn.h"
|
||||
#include "objects/client.h"
|
||||
|
@ -369,7 +371,15 @@ main(int argc, char **argv)
|
|||
sigaction(SIGSEGV, &sa, 0);
|
||||
|
||||
/* X stuff */
|
||||
globalconf.connection = xcb_connect(NULL, &globalconf.default_screen);
|
||||
globalconf.display = XOpenDisplay(NULL);
|
||||
if (globalconf.display == NULL) {
|
||||
fatal("cannot open display");
|
||||
}
|
||||
globalconf.default_screen = XDefaultScreen(globalconf.display);
|
||||
|
||||
globalconf.connection = XGetXCBConnection(globalconf.display);
|
||||
|
||||
/* Double checking that connection is good and operatable with xcb */
|
||||
if(xcb_connection_has_error(globalconf.connection))
|
||||
fatal("cannot open display");
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED
|
|||
glib-2.0
|
||||
cairo
|
||||
x11
|
||||
xcursor
|
||||
xcb-randr
|
||||
xcb-xtest
|
||||
xcb-xinerama
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* CURSORFONT */
|
||||
#include <X11/Xlibint.h>
|
||||
|
||||
#include "common/xcursor.h"
|
||||
#include "common/util.h"
|
||||
|
||||
|
@ -137,25 +134,12 @@ xcursor_font_tostr(uint16_t c)
|
|||
* \return Allocated cursor font.
|
||||
*/
|
||||
xcb_cursor_t
|
||||
xcursor_new(xcb_connection_t *conn, uint16_t cursor_font)
|
||||
xcursor_new(Display *conn, uint16_t cursor_font)
|
||||
{
|
||||
static xcb_font_t font = XCB_NONE;
|
||||
static xcb_cursor_t xcursor[countof(xcursor_font)];
|
||||
|
||||
/* Get the font for the cursor */
|
||||
if(!font)
|
||||
{
|
||||
font = xcb_generate_id(conn);
|
||||
xcb_open_font(conn, font, sizeof(CURSORFONT) - 1, CURSORFONT);
|
||||
}
|
||||
|
||||
if(!xcursor[cursor_font])
|
||||
{
|
||||
xcursor[cursor_font] = xcb_generate_id(conn);
|
||||
xcb_create_glyph_cursor(conn, xcursor[cursor_font], font, font,
|
||||
cursor_font, cursor_font + 1,
|
||||
0, 0, 0,
|
||||
65535, 65535, 65535);
|
||||
if (!xcursor[cursor_font]) {
|
||||
xcursor[cursor_font] = XcursorLibraryLoadCursor(conn, xcursor_font_tostr(cursor_font));
|
||||
}
|
||||
|
||||
return xcursor[cursor_font];
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
#include <X11/cursorfont.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
uint16_t xcursor_font_fromstr(const char *);
|
||||
const char * xcursor_font_tostr(uint16_t);
|
||||
xcb_cursor_t xcursor_new(xcb_connection_t *, uint16_t);
|
||||
xcb_cursor_t xcursor_new(Display *, uint16_t);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -63,6 +63,8 @@ ARRAY_TYPE(drawin_t *, drawin)
|
|||
/** Main configuration structure */
|
||||
typedef struct
|
||||
{
|
||||
/** Xlib Display */
|
||||
Display * display;
|
||||
/** Connection ref */
|
||||
xcb_connection_t *connection;
|
||||
/** Default screen number */
|
||||
|
|
|
@ -82,7 +82,7 @@ luaA_mousegrabber_run(lua_State *L)
|
|||
|
||||
if(cfont)
|
||||
{
|
||||
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cfont);
|
||||
xcb_cursor_t cursor = xcursor_new(globalconf.display, cfont);
|
||||
|
||||
luaA_registerfct(L, 1, &globalconf.mousegrabber);
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ drawin_init(drawin_t *w)
|
|||
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
||||
| XCB_EVENT_MASK_PROPERTY_CHANGE,
|
||||
globalconf.default_cmap,
|
||||
xcursor_new(globalconf.connection, xcursor_font_fromstr(w->cursor))
|
||||
xcursor_new(globalconf.display, xcursor_font_fromstr(w->cursor))
|
||||
});
|
||||
|
||||
/* Set the right properties */
|
||||
|
@ -502,7 +502,7 @@ luaA_drawin_set_cursor(lua_State *L, drawin_t *drawin)
|
|||
uint16_t cursor_font = xcursor_font_fromstr(buf);
|
||||
if(cursor_font)
|
||||
{
|
||||
xcb_cursor_t cursor = xcursor_new(globalconf.connection, cursor_font);
|
||||
xcb_cursor_t cursor = xcursor_new(globalconf.display, cursor_font);
|
||||
p_delete(&drawin->cursor);
|
||||
drawin->cursor = a_strdup(buf);
|
||||
xwindow_set_cursor(drawin->window, cursor);
|
||||
|
|
2
root.c
2
root.c
|
@ -298,7 +298,7 @@ luaA_root_cursor(lua_State *L)
|
|||
|
||||
if(cursor_font)
|
||||
{
|
||||
uint32_t change_win_vals[] = { xcursor_new(globalconf.connection, cursor_font) };
|
||||
uint32_t change_win_vals[] = { xcursor_new(globalconf.display, cursor_font) };
|
||||
|
||||
xcb_change_window_attributes(globalconf.connection,
|
||||
globalconf.screen->root,
|
||||
|
|
Loading…
Reference in New Issue