aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--calmwm.c14
-rw-r--r--calmwm.h19
-rw-r--r--conf.c20
-rw-r--r--menu.c9
-rw-r--r--mousefunc.c6
-rw-r--r--screen.c4
6 files changed, 42 insertions, 30 deletions
diff --git a/calmwm.c b/calmwm.c
index e001f63..6a6d01b 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.c,v 1.77 2013/06/17 14:08:51 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.78 2013/06/17 17:11:10 okan Exp $
*/
#include <sys/param.h>
@@ -38,12 +38,6 @@
char **cwm_argv;
Display *X_Dpy;
-Cursor Cursor_default;
-Cursor Cursor_move;
-Cursor Cursor_normal;
-Cursor Cursor_question;
-Cursor Cursor_resize;
-
struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
@@ -139,11 +133,7 @@ x_init(const char *dpyname)
xu_getatoms();
- Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
- Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
- Cursor_normal = XCreateFontCursor(X_Dpy, XC_left_ptr);
- Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
- Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
+ conf_cursor(&Conf);
for (i = 0; i < ScreenCount(X_Dpy); i++)
screen_init(i);
diff --git a/calmwm.h b/calmwm.h
index 70ed03a..d3398d9 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.212 2013/06/10 21:37:30 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.213 2013/06/17 17:11:10 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -85,6 +85,15 @@ union arg {
int i;
};
+enum cursor_font {
+ CF_DEFAULT,
+ CF_MOVE,
+ CF_NORMAL,
+ CF_QUESTION,
+ CF_RESIZE,
+ CF_NITEMS
+};
+
enum color {
CWM_COLOR_BORDER_ACTIVE,
CWM_COLOR_BORDER_INACTIVE,
@@ -294,6 +303,7 @@ struct conf {
char known_hosts[MAXPATHLEN];
#define CONF_FONT "sans-serif:pixelsize=14:bold"
char *font;
+ Cursor cursor[CF_NITEMS];
};
/* MWM hints */
@@ -437,6 +447,7 @@ void conf_bindname(struct conf *, char *, char *);
void conf_clear(struct conf *);
void conf_client(struct client_ctx *);
void conf_cmd_add(struct conf *, char *, char *);
+void conf_cursor(struct conf *);
void conf_grab_kbd(Window);
void conf_grab_mouse(Window);
void conf_init(struct conf *);
@@ -498,12 +509,6 @@ int xasprintf(char **, const char *, ...)
/* Externs */
extern Display *X_Dpy;
-extern Cursor Cursor_default;
-extern Cursor Cursor_move;
-extern Cursor Cursor_normal;
-extern Cursor Cursor_question;
-extern Cursor Cursor_resize;
-
extern struct screen_ctx_q Screenq;
extern struct client_ctx_q Clientq;
extern struct conf Conf;
diff --git a/conf.c b/conf.c
index f0f17a4..0729690 100644
--- a/conf.c
+++ b/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: conf.c,v 1.134 2013/06/17 00:57:47 okan Exp $
+ * $OpenBSD: conf.c,v 1.135 2013/06/17 17:11:10 okan Exp $
*/
#include <sys/param.h>
@@ -625,6 +625,23 @@ conf_mouseunbind(struct conf *c, struct mousebinding *unbind)
}
}
+static int cursor_binds[CF_NITEMS] = {
+ XC_X_cursor, /* CF_DEFAULT */
+ XC_fleur, /* CF_MOVE */
+ XC_left_ptr, /* CF_NORMAL */
+ XC_question_arrow, /* CF_QUESTION */
+ XC_bottom_right_corner, /* CF_RESIZE */
+};
+
+void
+conf_cursor(struct conf *c)
+{
+ u_int i;
+
+ for (i = 0; i < nitems(cursor_binds); i++)
+ c->cursor[i] = XCreateFontCursor(X_Dpy, cursor_binds[i]);
+}
+
void
conf_grab_mouse(Window win)
{
@@ -647,4 +664,3 @@ conf_grab_kbd(Window win)
TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
xu_key_grab(win, kb->modmask, kb->keysym);
}
-
diff --git a/menu.c b/menu.c
index 75cc1f6..9c56980 100644
--- a/menu.c
+++ b/menu.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: menu.c,v 1.65 2013/05/20 21:32:00 okan Exp $
+ * $OpenBSD: menu.c,v 1.66 2013/06/17 17:11:10 okan Exp $
*/
#include <sys/param.h>
@@ -122,7 +122,8 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
XSelectInput(X_Dpy, sc->menuwin, evmask);
XMapRaised(X_Dpy, sc->menuwin);
- if (xu_ptr_grab(sc->menuwin, MENUGRABMASK, Cursor_question) < 0) {
+ if (xu_ptr_grab(sc->menuwin, MENUGRABMASK,
+ Conf.cursor[CF_QUESTION]) < 0) {
XUnmapWindow(X_Dpy, sc->menuwin);
return (NULL);
}
@@ -472,10 +473,10 @@ menu_handle_move(XEvent *e, struct menu_ctx *mc, struct menu_q *resultq)
if (mc->prev != -1)
menu_draw_entry(mc, resultq, mc->prev, 0);
if (mc->entry != -1) {
- (void)xu_ptr_regrab(MENUGRABMASK, Cursor_normal);
+ (void)xu_ptr_regrab(MENUGRABMASK, Conf.cursor[CF_NORMAL]);
menu_draw_entry(mc, resultq, mc->entry, 1);
} else
- (void)xu_ptr_regrab(MENUGRABMASK, Cursor_default);
+ (void)xu_ptr_regrab(MENUGRABMASK, Conf.cursor[CF_DEFAULT]);
if (mc->hasprompt)
menu_draw_entry(mc, resultq, 1, 1);
diff --git a/mousefunc.c b/mousefunc.c
index 1b52433..1872aef 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -16,7 +16,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: mousefunc.c,v 1.52 2013/05/20 20:21:04 okan Exp $
+ * $OpenBSD: mousefunc.c,v 1.53 2013/06/17 17:11:10 okan Exp $
*/
#include <sys/param.h>
@@ -81,7 +81,7 @@ mousefunc_window_resize(struct client_ctx *cc, void *arg)
client_raise(cc);
client_ptrsave(cc);
- if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_resize) < 0)
+ if (xu_ptr_grab(cc->win, MOUSEMASK, Conf.cursor[CF_RESIZE]) < 0)
return;
xu_ptr_setpos(cc->win, cc->geom.w, cc->geom.h);
@@ -137,7 +137,7 @@ mousefunc_window_move(struct client_ctx *cc, void *arg)
if (cc->flags & CLIENT_FREEZE)
return;
- if (xu_ptr_grab(cc->win, MOUSEMASK, Cursor_move) < 0)
+ if (xu_ptr_grab(cc->win, MOUSEMASK, Conf.cursor[CF_MOVE]) < 0)
return;
xu_ptr_getpos(cc->win, &px, &py);
diff --git a/screen.c b/screen.c
index 864e120..dce4065 100644
--- a/screen.c
+++ b/screen.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: screen.c,v 1.51 2013/05/20 20:21:04 okan Exp $
+ * $OpenBSD: screen.c,v 1.52 2013/06/17 17:11:10 okan Exp $
*/
#include <sys/param.h>
@@ -57,7 +57,7 @@ screen_init(int which)
group_init(sc);
- rootattr.cursor = Cursor_normal;
+ rootattr.cursor = Conf.cursor[CF_NORMAL];
rootattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|
PropertyChangeMask|EnterWindowMask|LeaveWindowMask|
ColormapChangeMask|BUTTONMASK;