Own win method for mouse cursor location
This commit is contained in:
parent
b8fd923e74
commit
d81442f55d
10
commands.c
10
commands.c
@ -322,19 +322,17 @@ bool ci_scroll_to_edge(arg_t dir)
|
|||||||
|
|
||||||
bool ci_drag(arg_t _)
|
bool ci_drag(arg_t _)
|
||||||
{
|
{
|
||||||
int i, x, y;
|
int x, y;
|
||||||
float px, py;
|
float px, py;
|
||||||
unsigned int ui;
|
|
||||||
XEvent e;
|
XEvent e;
|
||||||
Window w;
|
|
||||||
|
|
||||||
if ((int)(img.w * img.zoom) < win.w && (int)(img.h * img.zoom) < win.h)
|
if ((int)(img.w * img.zoom) <= win.w && (int)(img.h * img.zoom) <= win.h)
|
||||||
return false;
|
|
||||||
if (!XQueryPointer(win.env.dpy, win.xwin, &w, &w, &i, &i, &x, &y, &ui))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
win_set_cursor(&win, CURSOR_DRAG);
|
win_set_cursor(&win, CURSOR_DRAG);
|
||||||
|
|
||||||
|
win_cursor_pos(&win, &x, &y);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8)
|
px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8)
|
||||||
* (win.w - img.w * img.zoom);
|
* (win.w - img.w * img.zoom);
|
||||||
|
11
window.c
11
window.c
@ -470,3 +470,14 @@ void win_set_cursor(win_t *win, cursor_t cursor)
|
|||||||
XFlush(win->env.dpy);
|
XFlush(win->env.dpy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void win_cursor_pos(win_t *win, int *x, int *y)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
unsigned int ui;
|
||||||
|
Window w;
|
||||||
|
|
||||||
|
if (!XQueryPointer(win->env.dpy, win->xwin, &w, &w, &i, &i, x, y, &ui))
|
||||||
|
*x = *y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
1
window.h
1
window.h
@ -106,5 +106,6 @@ int win_textwidth(const win_env_t*, const char*, unsigned int, bool);
|
|||||||
|
|
||||||
void win_set_title(win_t*, const char*);
|
void win_set_title(win_t*, const char*);
|
||||||
void win_set_cursor(win_t*, cursor_t);
|
void win_set_cursor(win_t*, cursor_t);
|
||||||
|
void win_cursor_pos(win_t*, int*, int*);
|
||||||
|
|
||||||
#endif /* WINDOW_H */
|
#endif /* WINDOW_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user