| @@ -321,9 +321,9 @@ bool ci_scroll_to_edge(arg_t dir) |
| 321 | 321 | | return img_pan_edge(&img, dir); |
| 322 | 322 | | } |
| 323 | 323 | | |
| 324 | | − | bool ci_drag(arg_t _) |
| 324 | + | bool ci_drag(arg_t mode) |
| 325 | 325 | | { |
| 326 | | − | int x, y; |
| 326 | + | int x, y, ox, oy; |
| 327 | 327 | | float px, py; |
| 328 | 328 | | XEvent e; |
| 329 | 329 | | |
| @@ -333,12 +333,19 @@ bool ci_drag(arg_t _) |
| 333 | 333 | | win_set_cursor(&win, CURSOR_DRAG); |
| 334 | 334 | | |
| 335 | 335 | | win_cursor_pos(&win, &x, &y); |
| 336 | + | ox = x; |
| 337 | + | oy = y; |
| 336 | 338 | | |
| 337 | 339 | | for (;;) { |
| 338 | | − | px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8) |
| 339 | | − | * (win.w - img.w * img.zoom); |
| 340 | | − | py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) / (win.h*0.8) |
| 341 | | − | * (win.h - img.h * img.zoom); |
| 340 | + | if (mode == DRAG_ABSOLUTE) { |
| 341 | + | px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8) |
| 342 | + | * (win.w - img.w * img.zoom); |
| 343 | + | py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) / (win.h*0.8) |
| 344 | + | * (win.h - img.h * img.zoom); |
| 345 | + | } else { |
| 346 | + | px = img.x + x - ox; |
| 347 | + | py = img.y + y - oy; |
| 348 | + | } |
| 342 | 349 | | |
| 343 | 350 | | if (img_pos(&img, px, py)) { |
| 344 | 351 | | img_render(&img); |
| @@ -349,6 +356,8 @@ bool ci_drag(arg_t _) |
| 349 | 356 | | if (e.type == ButtonPress || e.type == ButtonRelease) |
| 350 | 357 | | break; |
| 351 | 358 | | while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e)); |
| 359 | + | ox = x; |
| 360 | + | oy = y; |
| 352 | 361 | | x = e.xmotion.x; |
| 353 | 362 | | y = e.xmotion.y; |
| 354 | 363 | | } |