diff options
author | David Robillard <d@drobilla.net> | 2016-09-18 22:28:30 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-09-18 22:28:30 -0400 |
commit | 69b2d6336b3598957a59a37a6bc95bcb154bab95 (patch) | |
tree | c3bdd423f0f795993e96c093f4ecdba09a6cc78b /pugl | |
parent | 8150102ad806632e70f8bd8cd211dbe74bc40be5 (diff) | |
download | pugl-69b2d6336b3598957a59a37a6bc95bcb154bab95.tar.gz pugl-69b2d6336b3598957a59a37a6bc95bcb154bab95.tar.bz2 pugl-69b2d6336b3598957a59a37a6bc95bcb154bab95.zip |
Remove GLUT-like event callbacks
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/pugl.h | 136 | ||||
-rw-r--r-- | pugl/pugl.hpp | 2 | ||||
-rw-r--r-- | pugl/pugl_internal.h | 143 | ||||
-rw-r--r-- | pugl/pugl_x11.c | 5 |
4 files changed, 7 insertions, 279 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h index 91179c0..b4c723b 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -61,80 +61,6 @@ extern "C" { typedef void (*PuglEventFunc)(PuglView* view, const PuglEvent* event); /** - A function called when the window is closed. -*/ -typedef void (*PuglCloseFunc)(PuglView* view); - -/** - A function called to draw the view contents with OpenGL. -*/ -typedef void (*PuglDisplayFunc)(PuglView* view); - -/** - A function called when a key is pressed or released. - @param view The view the event occured in. - @param press True if the key was pressed, false if released. - @param key Unicode point of the key pressed. -*/ -typedef void (*PuglKeyboardFunc)(PuglView* view, bool press, uint32_t key); - -/** - A function called when the pointer moves. - @param view The view the event occured in. - @param x The window-relative x coordinate of the pointer. - @param y The window-relative y coordinate of the pointer. -*/ -typedef void (*PuglMotionFunc)(PuglView* view, int x, int y); - -/** - A function called when a mouse button is pressed or released. - @param view The view the event occured in. - @param button The button number (1 = left, 2 = middle, 3 = right). - @param press True if the key was pressed, false if released. - @param x The window-relative x coordinate of the pointer. - @param y The window-relative y coordinate of the pointer. -*/ -typedef void (*PuglMouseFunc)( - PuglView* view, int button, bool press, int x, int y); - -/** - A function called when the view is resized. - @param view The view being resized. - @param width The new view width. - @param height The new view height. -*/ -typedef void (*PuglReshapeFunc)(PuglView* view, int width, int height); - -/** - A function called on scrolling (e.g. mouse wheel or track pad). - - The distances used here are in "lines", a single tick of a clicking mouse - wheel. For example, @p dy = 1.0 scrolls 1 line up. Some systems and - devices support finer resolution and/or higher values for fast scrolls, - so programs should handle any value gracefully. - - @param view The view being scrolled. - @param dx The scroll x distance. - @param dx The scroll y distance. -*/ -typedef void (*PuglScrollFunc)(PuglView* view, - int x, - int y, - float dx, - float dy); - -/** - A function called when a special key is pressed or released. - - This callback allows the use of keys that do not have unicode points. - - @param view The view the event occured in. - @param press True if the key was pressed, false if released. - @param key The key pressed. -*/ -typedef void (*PuglSpecialFunc)(PuglView* view, bool press, PuglKey key); - -/** @name Initialization Configuration functions which must be called before creating a window. @{ @@ -288,20 +214,6 @@ PUGL_API void puglGetSize(PuglView* view, int* width, int* height); /** - Return the timestamp (if any) of the currently-processing event. -*/ -PUGL_API uint32_t -puglGetEventTimestamp(PuglView* view); - -/** - Get the currently active modifiers (PuglMod flags). - - This should only be called from an event handler. -*/ -PUGL_API int -puglGetModifiers(PuglView* view); - -/** Ignore synthetic repeated key events. */ PUGL_API void @@ -339,54 +251,6 @@ PUGL_API void puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc); /** - Set the function to call when the window is closed. -*/ -PUGL_API void -puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc); - -/** - Set the display function which should draw the UI using GL. -*/ -PUGL_API void -puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc); - -/** - Set the function to call on keyboard events. -*/ -PUGL_API void -puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc); - -/** - Set the function to call on mouse motion. -*/ -PUGL_API void -puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc); - -/** - Set the function to call on mouse button events. -*/ -PUGL_API void -puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc); - -/** - Set the function to call on scroll events. -*/ -PUGL_API void -puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc); - -/** - Set the function to call on special events. -*/ -PUGL_API void -puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc); - -/** - Set the function to call when the window size changes. -*/ -PUGL_API void -puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc); - -/** @} */ diff --git a/pugl/pugl.hpp b/pugl/pugl.hpp index 03816c2..d405759 100644 --- a/pugl/pugl.hpp +++ b/pugl/pugl.hpp @@ -87,8 +87,6 @@ public: virtual void onDisplay() {} virtual void* getContext() { return puglGetContext(_view); } - virtual uint32_t getEventTimestamp() { return puglGetEventTimestamp(_view); } - virtual int getModifiers() { return puglGetModifiers(_view); } virtual void ignoreKeyRepeat(bool ignore) { puglIgnoreKeyRepeat(_view, ignore); } virtual void grabFocus() { puglGrabFocus(_view); } virtual PuglStatus waitForEvent() { return puglWaitForEvent(_view); } diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h index aa55c6d..aeb580d 100644 --- a/pugl/pugl_internal.h +++ b/pugl/pugl_internal.h @@ -39,14 +39,6 @@ typedef struct PuglInternalsImpl PuglInternals; struct PuglViewImpl { PuglHandle handle; PuglEventFunc eventFunc; - PuglCloseFunc closeFunc; - PuglDisplayFunc displayFunc; - PuglKeyboardFunc keyboardFunc; - PuglMotionFunc motionFunc; - PuglMouseFunc mouseFunc; - PuglReshapeFunc reshapeFunc; - PuglScrollFunc scrollFunc; - PuglSpecialFunc specialFunc; PuglInternals* impl; @@ -63,13 +55,10 @@ struct PuglViewImpl { int min_aspect_y; int max_aspect_x; int max_aspect_y; - int mods; - bool mouse_in_view; bool ignoreKeyRepeat; bool redisplay; bool resizable; bool visible; - uint32_t event_timestamp_ms; }; PuglInternals* puglInitInternals(void); @@ -181,18 +170,6 @@ puglGetSize(PuglView* view, int* width, int* height) *height = view->height; } -uint32_t -puglGetEventTimestamp(PuglView* view) -{ - return view->event_timestamp_ms; -} - -int -puglGetModifiers(PuglView* view) -{ - return view->mods; -} - void puglIgnoreKeyRepeat(PuglView* view, bool ignore) { @@ -205,54 +182,6 @@ puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc) view->eventFunc = eventFunc; } -void -puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc) -{ - view->closeFunc = closeFunc; -} - -void -puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc) -{ - view->displayFunc = displayFunc; -} - -void -puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc) -{ - view->keyboardFunc = keyboardFunc; -} - -void -puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc) -{ - view->motionFunc = motionFunc; -} - -void -puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc) -{ - view->mouseFunc = mouseFunc; -} - -void -puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc) -{ - view->reshapeFunc = reshapeFunc; -} - -void -puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc) -{ - view->scrollFunc = scrollFunc; -} - -void -puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc) -{ - view->specialFunc = specialFunc; -} - /** Return the code point for buf, or the replacement character on error. */ static uint32_t puglDecodeUTF8(const uint8_t* buf) @@ -292,6 +221,8 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) { if (event->type == PUGL_NOTHING) { return; + } else if (event->type == PUGL_EXPOSE && event->expose.count > 0) { + return; } else if (view->eventFunc) { const bool is_draw = (event->type == PUGL_CONFIGURE || event->type == PUGL_EXPOSE); @@ -303,74 +234,4 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) puglLeaveContext(view, event->type == PUGL_EXPOSE); } } - - switch (event->type) { - case PUGL_CONFIGURE: - puglEnterContext(view); - view->width = event->configure.width; - view->height = event->configure.height; - if (view->reshapeFunc) { - view->reshapeFunc(view, view->width, view->height); - } - puglLeaveContext(view, false); - break; - case PUGL_EXPOSE: - if (event->expose.count == 0) { - puglEnterContext(view); - if (view->displayFunc) { - view->displayFunc(view); - } - view->redisplay = false; - puglLeaveContext(view, true); - } - break; - case PUGL_CLOSE: - if (view->closeFunc) { - view->closeFunc(view); - } - view->redisplay = false; - break; - case PUGL_MOTION_NOTIFY: - view->event_timestamp_ms = event->motion.time; - view->mods = event->motion.state; - if (view->motionFunc) { - view->motionFunc(view, event->motion.x, event->motion.y); - } - break; - case PUGL_SCROLL: - if (view->scrollFunc) { - view->scrollFunc(view, - event->scroll.x, event->scroll.y, - event->scroll.dx, event->scroll.dy); - } - break; - case PUGL_BUTTON_PRESS: - case PUGL_BUTTON_RELEASE: - view->event_timestamp_ms = event->button.time; - view->mods = event->button.state; - if (view->mouseFunc) { - view->mouseFunc(view, - event->button.button, - event->type == PUGL_BUTTON_PRESS, - event->button.x, - event->button.y); - } - break; - case PUGL_KEY_PRESS: - case PUGL_KEY_RELEASE: - view->event_timestamp_ms = event->key.time; - view->mods = event->key.state; - if (event->key.special && view->specialFunc) { - view->specialFunc(view, - event->type == PUGL_KEY_PRESS, - event->key.special); - } else if (event->key.character && view->keyboardFunc) { - view->keyboardFunc(view, - event->type == PUGL_KEY_PRESS, - event->key.character); - } - break; - default: - break; - } } diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index 7ceef29..75fedca 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -61,6 +61,8 @@ static int attrListDbl[] = { GLX_GREEN_SIZE , 4, GLX_BLUE_SIZE , 4, GLX_DEPTH_SIZE , 16, + /* GLX_SAMPLE_BUFFERS , 1, */ + /* GLX_SAMPLES , 4, */ None }; @@ -72,6 +74,8 @@ static int attrListSgl[] = { GLX_GREEN_SIZE , 4, GLX_BLUE_SIZE , 4, GLX_DEPTH_SIZE , 16, + /* GLX_SAMPLE_BUFFERS , 1, */ + /* GLX_SAMPLES , 4, */ None }; @@ -684,6 +688,7 @@ puglProcessEvents(PuglView* view) expose_event.expose.y = 0; expose_event.expose.width = view->width; expose_event.expose.height = view->height; + view->redisplay = false; } if (expose_event.type) { |