Commit 72b77e61 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add keybinding to toggle cursor visibility at runtime

parent a067d336
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ git HEAD

    * Fix memory leak related to the menu
    * Make --start-at work with filenames instead of list positions
    * Add keybinding to toggle pointer visibility (see --hide-pointer)

Thu Apr 22 22:28:09 CEST 2010  Daniel Friesel <derf@chaosdorf.de>

+2 −0
Original line number Diff line number Diff line
@@ -537,6 +537,8 @@ Show next image
Reload current image.  Useful for webcams
.It v , V
Toggle fullscreen
.It o, O
Toggle pointer visibility
.It m , M
Show menu
.It c , C
+5 −0
Original line number Diff line number Diff line
@@ -322,6 +322,11 @@ void feh_event_handle_keypress(XEvent * ev)
		if (opt.slideshow)
			slideshow_change_image(winwid, SLIDE_NEXT);
		break;
	case 'o':
	case 'O':
		winwidget_set_pointer(winwid, opt.hide_pointer);
		opt.hide_pointer = !opt.hide_pointer;
		break;
	case 'p':
	case 'P':
	case '\b':
+20 −11
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ static void winwidget_unregister(winwidget win);
static void winwidget_register(winwidget win);
static winwidget winwidget_allocate(void);

static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

int window_num = 0;		/* For window list */
winwidget *windows = NULL;	/* List of windows to loop though */
@@ -280,16 +279,8 @@ void winwidget_create_window(winwidget ret, int w, int h)
		XSetWMNormalHints(disp, ret->win, &xsz);
		XMoveWindow(disp, ret->win, x, y);
	}
	if (ret->full_screen && opt.hide_pointer) {
		Cursor no_ptr;
		XColor black, dummy;
		Pixmap bm_no;
		bm_no = XCreateBitmapFromData(disp, ret->win, bm_no_data, 8, 8);
		XAllocNamedColor(disp, DefaultColormapOfScreen(DefaultScreenOfDisplay(disp)), "black", &black, &dummy);

		no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0);
		XDefineCursor(disp, ret->win, no_ptr);
	}
	if (ret->full_screen && opt.hide_pointer)
		winwidget_set_pointer(ret, 0);

	/* set the icon name property */
	XSetIconName(disp, ret->win, "feh");
@@ -975,6 +966,24 @@ void winwidget_size_to_image(winwidget winwid)
	D_RETURN_(4);
}

void winwidget_set_pointer(winwidget winwid, int visible)
{
	Cursor no_ptr;
	XColor black, dummy;
	Pixmap bm_no;
	static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

	if (visible)
		XUndefineCursor(disp, winwid->win);
	else {
		bm_no = XCreateBitmapFromData(disp, winwid->win, bm_no_data, 8, 8);
		XAllocNamedColor(disp, DefaultColormapOfScreen(DefaultScreenOfDisplay(disp)), "black", &black, &dummy);

		no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0);
		XDefineCursor(disp, winwid->win, no_ptr);
	}
}

int winwidget_get_width(winwidget winwid)
{
	int rect[4];
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ void winwidget_rerender_all(int resize, int alias);
void winwidget_destroy_xwin(winwidget winwid);
int winwidget_count(void);

void winwidget_set_pointer(winwidget winwid, int visible);

void winwidget_get_geometry(winwidget winwid, int *rect);
int winwidget_get_width(winwidget winwid);
int winwidget_get_height(winwidget winwid);