Ticket #2: feh-1.2.6-anti-lock.patch
| File feh-1.2.6-anti-lock.patch, 6.1 kB (added by giblet, 3 years ago) |
|---|
-
feh-1.2.6/src/keyevents.c
old new 33 33 feh_event_handle_keypress(XEvent * ev) 34 34 { 35 35 int len; 36 int tlen; 36 37 char kbuf[20]; 37 38 KeySym keysym; 38 39 XKeyEvent *kev; … … 53 54 kev = (XKeyEvent *) ev; 54 55 len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL); 55 56 57 if (opt.screen_lock){ 58 if( keysym == XK_Return ){ 59 if( !strcmp (opt.screen_lock_pass, opt.screen_lock_typed) ) { 60 winwidget_destroy_all(); 61 } else { 62 opt.screen_lock_typed[ 0 ] = 0; 63 } 64 D_RETURN_(4); 65 } 66 67 /* capture keys for password comparison */ 68 tlen=strlen(opt.screen_lock_typed); 69 if( tlen<15 ){ 70 if( isascii( kbuf[0] ) ){ 71 opt.screen_lock_typed[ tlen ] = kbuf[0]; 72 opt.screen_lock_typed[ tlen+1 ] = 0; 73 // printf( "Key so far: >>%s<<\n", opt.screen_lock_typed ); 74 } 75 } 76 D_RETURN_(4); 77 } 78 56 79 /* menus are showing, so this is a menu control keypress */ 57 80 if (ev->xbutton.window == menu_cover) { 58 81 selected_item = feh_menu_find_selected_r(menu_root, &selected_menu); … … 160 183 D_RETURN_(4); 161 184 } 162 185 163 186 164 187 switch (keysym) 165 188 { 166 189 case XK_Left: -
feh-1.2.6/src/options.c
old new 76 76 77 77 opt.xinerama = 0; 78 78 opt.screen_clip = 1; 79 opt.screen_lock = 0; 80 opt.screen_lock_pass = "rulor"; /* default password */ 81 opt.screen_lock_typed[0] = 0; 79 82 #ifdef HAVE_LIBXINERAMA 80 83 /* if we're using xinerama, then enable it by default */ 81 84 opt.xinerama = 1; … … 393 396 {"menu-border", 1, 0, 208}, 394 397 {"caption-path", 1, 0, 209}, 395 398 {"no-jump-on-resort",0,0,210}, 399 {"screen-lock", 1, 0, 211}, /* CHECK: assign a different number ? */ 400 {"screen-lockpass", 1, 0, 212}, /* CHECK: assign a different number ? */ 396 401 {0, 0, 0, 0} 397 402 }; 398 403 int optch = 0, cmdx = 0, i = 0; … … 679 684 case 210: 680 685 opt.no_jump_on_resort = 1; 681 686 break; 687 case 211: 688 opt.screen_lock = atoi(optarg); 689 break; 690 case 212: 691 opt.screen_lock_pass = estrdup(optarg); 692 /* overwrite arg to avoid spying (e.g. "ps ax|grep feh") */ 693 /* FIXME: the password length is still visible :( */ 694 while( *optarg ){ 695 *optarg='*'; 696 optarg++; 697 } 698 break; 682 699 default: 683 700 break; 684 701 } … … 958 975 " size. WARNING: with this option disabled,\n" 959 976 " image windows could become very large, making\n" 960 977 " them unmanageable in certain window managers.\n." 978 " --screen-lock [0|1] Enable/disable window locking.\n" 979 " --screen-lockpass <password> Set password for window (un)locking.\n" 961 980 " FORMAT SPECIFIERS\n" 962 981 " %%f image path/filename\n" 963 982 " %%n image name\n" -
feh-1.2.6/src/options.h
old new 66 66 unsigned char bgmode; 67 67 unsigned char xinerama; 68 68 unsigned char screen_clip; 69 unsigned char screen_lock; 70 unsigned char *screen_lock_pass; 71 unsigned char screen_lock_typed[16]; 69 72 70 73 char *output_file; 71 74 char *output_dir; -
feh-1.2.6/src/winwidget.c
old new 52 52 ret->im_angle = 0; 53 53 ret->bg_pmap = 0; 54 54 ret->bg_pmap_cache = 0; 55 ret->cursor_lock = 0; 55 56 ret->im = NULL; 56 57 ret->name = NULL; 57 58 ret->file = NULL; … … 261 262 XSetCommand(disp, ret->win, cmdargv, cmdargc); 262 263 263 264 winwidget_register(ret); 265 266 if (opt.screen_lock){ 267 /* create the cursor used for locking */ 268 ret->cursor_lock = XCreateFontCursor(disp, XC_circle); /* PLAN: use a user supplied icon or hide the cursor */ 269 XDefineCursor(disp, ret->win, ret->cursor_lock); 270 } 264 271 D_RETURN_(4); 265 272 } 266 273 … … 634 641 XFreePixmap(disp, winwid->bg_pmap); 635 642 winwid->bg_pmap = None; 636 643 } 644 if (opt.screen_lock){ 645 XUngrabPointer(disp, CurrentTime ); 646 XUngrabKeyboard(disp, CurrentTime ); 647 } 648 if (winwid->cursor_lock) { 649 XFreeCursor(disp, winwid->cursor_lock); 650 } 637 651 D_RETURN_(4); 638 652 } 639 653 … … 719 733 XMaskEvent(disp, StructureNotifyMask, &ev); 720 734 D(4, ("Window mapped\n")); 721 735 winwid->visible = 1; 736 if (opt.screen_lock){ 737 /* grab the pointer */ 738 XGrabPointer(disp, winwid->win, False, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, winwid->win, winwid->cursor_lock, CurrentTime ); 739 /* grab the keyboard */ 740 XGrabKeyboard(disp, winwid->win, False, GrabModeAsync, GrabModeAsync, CurrentTime ); 741 } 722 742 } 723 743 D_RETURN_(4); 724 744 } … … 990 1010 unsigned int c; 991 1011 Window r; 992 1012 1013 if (opt.screen_lock) { 1014 return; 1015 } 993 1016 XQueryPointer(disp, winwid->win, &r, &r, &x, &y, &b, &b, &c); 994 1017 if (winwid->type == WIN_TYPE_ABOUT) 995 1018 { -
feh-1.2.6/src/winwidget.h
old new 30 30 31 31 # include <X11/X.h> 32 32 # include <X11/Xproto.h> 33 # include <X11/cursorfont.h> 33 34 34 35 /* Motif window hints */ 35 36 #define MWM_HINTS_FUNCTIONS (1L << 0) … … 91 92 GC gc; 92 93 Pixmap bg_pmap; 93 94 Pixmap bg_pmap_cache; 95 Cursor cursor_lock; 94 96 char *name; 95 97 gib_list *file; 96 98 unsigned char visible;
