summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-01-29 22:37:40 +0100
committerBert <ber.t@gmx.com>2011-01-29 22:37:40 +0100
commitc52c4fa69e2a6a58813fe35a5c4a1fe23661db03 (patch)
tree6ddefe9122c481495caceec023a79786e5412b84 /window.c
parent4ab4be31a7fed20c2d1bde4b76c1d22bfd4312aa (diff)
downloadnsxiv-c52c4fa69e2a6a58813fe35a5c4a1fe23661db03.tar.zst
Mouse-panning while pressing button2
Diffstat (limited to 'window.c')
-rw-r--r--window.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/window.c b/window.c
index ea86ad3..d5f5f4f 100644
--- a/window.c
+++ b/window.c
@@ -21,12 +21,16 @@
#include <string.h>
#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
#include "sxiv.h"
#include "options.h"
#include "window.h"
-GC bgc;
+static Cursor arrow;
+static Cursor hand;
+
+static GC bgc;
void win_open(win_t *win) {
win_env_t *e;
@@ -66,8 +70,11 @@ void win_open(win_t *win) {
if (win->xwin == None)
DIE("could not create window");
- XSelectInput(e->dpy, win->xwin,
- StructureNotifyMask | KeyPressMask | ButtonPressMask);
+ XSelectInput(e->dpy, win->xwin, StructureNotifyMask | KeyPressMask |
+ ButtonPressMask | ButtonReleaseMask | Button2MotionMask);
+
+ arrow = XCreateFontCursor(e->dpy, XC_left_ptr);
+ hand = XCreateFontCursor(e->dpy, XC_fleur);
bgc = XCreateGC(e->dpy, win->xwin, 0, None);
@@ -91,6 +98,11 @@ void win_close(win_t *win) {
if (!win)
return;
+ XFreeCursor(win->env.dpy, arrow);
+ XFreeCursor(win->env.dpy, hand);
+
+ XFreeGC(win->env.dpy, bgc);
+
XDestroyWindow(win->env.dpy, win->xwin);
XCloseDisplay(win->env.dpy);
}
@@ -174,3 +186,18 @@ void win_draw(win_t *win) {
XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm);
XClearWindow(win->env.dpy, win->xwin);
}
+
+void win_set_cursor(win_t *win, win_cur_t cursor) {
+ if (!win)
+ return;
+
+ switch (cursor) {
+ case CURSOR_HAND:
+ XDefineCursor(win->env.dpy, win->xwin, hand);
+ break;
+ case CURSOR_ARROW:
+ default:
+ XDefineCursor(win->env.dpy, win->xwin, arrow);
+ break;
+ }
+}