|
|
@@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
Copyright 2012 David Robillard <http://drobilla.net> |
|
|
|
Copyright 2012-2014 David Robillard <http://drobilla.net> |
|
|
|
Copyright 2011-2012 Ben Loftis, Harrison Consoles |
|
|
|
Copyright 2013 Robin Gareus <robin@gareus.org> |
|
|
|
|
|
|
@@ -114,7 +114,7 @@ puglCreate(PuglNativeWindow parent, |
|
|
|
int glxMajor, glxMinor; |
|
|
|
glXQueryVersion(impl->display, &glxMajor, &glxMinor); |
|
|
|
#ifdef VERBOSE_PUGL |
|
|
|
printf("puGL: GLX-Version : %d.%d\n", glxMajor, glxMinor); |
|
|
|
printf("puGL: GLX-Version %d.%d\n", glxMajor, glxMinor); |
|
|
|
#endif |
|
|
|
|
|
|
|
impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE); |
|
|
@@ -295,6 +295,27 @@ setModifiers(PuglView* view, unsigned xstate, unsigned xtime) |
|
|
|
view->mods |= (xstate & Mod4Mask) ? PUGL_MOD_SUPER : 0; |
|
|
|
} |
|
|
|
|
|
|
|
static void |
|
|
|
dispatchKey(PuglView* view, XEvent* event, bool press) |
|
|
|
{ |
|
|
|
KeySym sym; |
|
|
|
char str[5]; |
|
|
|
const int n = XLookupString(&event->xkey, str, 4, &sym, NULL); |
|
|
|
if (n == 0) { |
|
|
|
return; |
|
|
|
} else if (n > 1) { |
|
|
|
fprintf(stderr, "warning: Unsupported multi-byte key %X\n", (int)sym); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const PuglKey special = keySymToSpecial(sym); |
|
|
|
if (special && view->specialFunc) { |
|
|
|
view->specialFunc(view, press, special); |
|
|
|
} else if (!special && view->keyboardFunc) { |
|
|
|
view->keyboardFunc(view, press, str[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PuglStatus |
|
|
|
puglProcessEvents(PuglView* view) |
|
|
|
{ |
|
|
@@ -336,7 +357,9 @@ puglProcessEvents(PuglView* view) |
|
|
|
case 6: dx = -1.0f; break; |
|
|
|
case 7: dx = 1.0f; break; |
|
|
|
} |
|
|
|
view->scrollFunc(view, dx, dy); |
|
|
|
view->scrollFunc(view, |
|
|
|
event.xbutton.x, event.xbutton.y, |
|
|
|
dx, dy); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
@@ -350,25 +373,12 @@ puglProcessEvents(PuglView* view) |
|
|
|
event.xbutton.x, event.xbutton.y); |
|
|
|
} |
|
|
|
break; |
|
|
|
case KeyPress: { |
|
|
|
case KeyPress: |
|
|
|
setModifiers(view, event.xkey.state, event.xkey.time); |
|
|
|
KeySym sym; |
|
|
|
char str[5]; |
|
|
|
int n = XLookupString(&event.xkey, str, 4, &sym, NULL); |
|
|
|
PuglKey key = keySymToSpecial(sym); |
|
|
|
if (!key && view->keyboardFunc) { |
|
|
|
if (n == 1) { |
|
|
|
view->keyboardFunc(view, true, str[0]); |
|
|
|
} else { |
|
|
|
fprintf(stderr, "warning: Unknown key %X\n", (int)sym); |
|
|
|
} |
|
|
|
} else if (view->specialFunc) { |
|
|
|
view->specialFunc(view, true, key); |
|
|
|
} |
|
|
|
} break; |
|
|
|
case KeyRelease: { |
|
|
|
dispatchKey(view, &event, true); |
|
|
|
break; |
|
|
|
case KeyRelease: |
|
|
|
setModifiers(view, event.xkey.state, event.xkey.time); |
|
|
|
bool repeated = false; |
|
|
|
if (view->ignoreKeyRepeat && |
|
|
|
XEventsQueued(view->impl->display, QueuedAfterReading)) { |
|
|
|
XEvent next; |
|
|
@@ -377,20 +387,11 @@ puglProcessEvents(PuglView* view) |
|
|
|
next.xkey.time == event.xkey.time && |
|
|
|
next.xkey.keycode == event.xkey.keycode) { |
|
|
|
XNextEvent(view->impl->display, &event); |
|
|
|
repeated = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!repeated && view->keyboardFunc) { |
|
|
|
KeySym sym = XLookupKeysym(&event.xkey, 0); |
|
|
|
PuglKey special = keySymToSpecial(sym); |
|
|
|
if (!special) { |
|
|
|
view->keyboardFunc(view, false, sym); |
|
|
|
} else if (view->specialFunc) { |
|
|
|
view->specialFunc(view, false, special); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} break; |
|
|
|
dispatchKey(view, &event, false); |
|
|
|
break; |
|
|
|
case ClientMessage: |
|
|
|
if (!strcmp(XGetAtomName(view->impl->display, |
|
|
|
event.xclient.message_type), |
|
|
|