File: cursor.c

package info (click to toggle)
lwm 1.01-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 228 kB
  • ctags: 592
  • sloc: ansic: 1,884; makefile: 495; sh: 6; tcl: 6
file content (56 lines) | stat: -rw-r--r-- 1,262 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>

#include "lwm.h"

typedef struct CursorMapping CursorMapping;
struct CursorMapping {
	Edge edge;
	int font_char;
};

static CursorMapping cursor_map[] = {
	{ETopLeft,		XC_top_left_corner},
	{ETop,		XC_top_side},
	{ETopRight,	XC_top_right_corner},
	{ERight,		XC_right_side},
	{ENone,		XC_fleur},
	{ELeft,		XC_left_side},
	{EBottomLeft,	XC_bottom_left_corner},
	{EBottom,		XC_bottom_side},
	{EBottomRight,	XC_bottom_right_corner},
	
	{ENone,		0},
};

extern void
initialiseCursors(int screen) {
	XColor red, white, exact;
	Colormap cmp;
	int i;
	
	cmp = DefaultColormap(dpy, screen);
	
	XAllocNamedColor(dpy, cmp, "red", &red, &exact);
	XAllocNamedColor(dpy, cmp, "white", &white, &exact);
	
	screens[screen].root_cursor = XCreateFontCursor(dpy, XC_left_ptr);
	XRecolorCursor(dpy, screens[screen].root_cursor, &red, &white);
	
	for (i = 0; cursor_map[i].font_char != 0; i++) {
		Edge e = cursor_map[i].edge;
		screens[screen].cursor_map[e] =
			XCreateFontCursor(dpy, cursor_map[i].font_char);
		XRecolorCursor(dpy, screens[screen].cursor_map[e],
			&red, &white);
	}
}

extern Cursor
getEdgeCursor(Edge edge) {
	return screens[0].cursor_map[edge];
}