linux cursors. resizing ones flicker a bit currently

master
insofaras 2016-02-23 22:28:34 +00:00
parent fde2fda466
commit 9435396741
1 changed files with 17 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include <dirent.h> #include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <GL/glx.h> #include <GL/glx.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
@ -103,6 +104,8 @@ struct Linux_Vars{
Atom atom_CLIPBOARD; Atom atom_CLIPBOARD;
Atom atom_UTF8_STRING; Atom atom_UTF8_STRING;
Application_Mouse_Cursor cursor;
void *app_code; void *app_code;
void *custom; void *custom;
@ -1553,6 +1556,14 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
Cursor xcursors[APP_MOUSE_CURSOR_COUNT] = {
None,
XCreateFontCursor(linuxvars.XDisplay, XC_arrow),
XCreateFontCursor(linuxvars.XDisplay, XC_xterm),
XCreateFontCursor(linuxvars.XDisplay, XC_sb_h_double_arrow),
XCreateFontCursor(linuxvars.XDisplay, XC_sb_v_double_arrow)
};
XSetICFocus(linuxvars.input_context); XSetICFocus(linuxvars.input_context);
linuxvars.atom_CLIPBOARD = XInternAtom(linuxvars.XDisplay, "CLIPBOARD", False); linuxvars.atom_CLIPBOARD = XInternAtom(linuxvars.XDisplay, "CLIPBOARD", False);
@ -1843,6 +1854,12 @@ main(int argc, char **argv)
usleep(frame_useconds - time_diff); usleep(frame_useconds - time_diff);
} }
if(result.mouse_cursor_type != linuxvars.cursor){
Cursor c = xcursors[result.mouse_cursor_type];
XDefineCursor(linuxvars.XDisplay, linuxvars.XWindow, c);
linuxvars.cursor = result.mouse_cursor_type;
}
linuxvars.redraw = 0; linuxvars.redraw = 0;
linuxvars.key_data = {}; linuxvars.key_data = {};
linuxvars.mouse_data.left_button_pressed = 0; linuxvars.mouse_data.left_button_pressed = 0;