~hp/nk_pugl

ea01dabca6b148e47c6f8ca192717944ffcffebc — Hanspeter Portner a month ago 4f4f49f master
Fix wrong mouse button mapping

Kindly reported by Nedko Arnaudov:
https://gitea.ladish.org/LADI/nk_pugl/commit/eedf78a9bd19ae128d3487732cc324c5f71a3f0e
2 files changed, 25 insertions(+), 3 deletions(-)

M meson_options.txt
M src/nk_pugl.c
M meson_options.txt => meson_options.txt +1 -1
@@ 10,4 10,4 @@ option('build-examples',
	value : false,
	yield : true)

option('version', type : 'string', value : '0.4.6')
option('version', type : 'string', value : '0.5.23')

M src/nk_pugl.c => src/nk_pugl.c +24 -2
@@ 504,6 504,28 @@ _nk_pugl_expose(PuglView *view)
	_nk_pugl_render_gl2(win);
}

static void
_nk_pugl_button(struct nk_context *ctx, const PuglButtonEvent *ev, int state)
{
	switch(ev->button)
	{
		case 2:
		{
			nk_input_button(ctx, NK_BUTTON_MIDDLE, ev->x, ev->y, state);
		} break;
		case 1:
		{
			nk_input_button(ctx, NK_BUTTON_RIGHT, ev->x, ev->y, state);
		} break;
		case 0:
			// fall-through
		default:
		{
			nk_input_button(ctx, NK_BUTTON_LEFT, ev->x, ev->y, state);
		} break;
	}
}

static PuglStatus
_nk_pugl_event_func(PuglView *view, const PuglEvent *e)
{


@@ 526,7 548,7 @@ _nk_pugl_event_func(PuglView *view, const PuglEvent *e)
			const PuglButtonEvent *ev = (const PuglButtonEvent *)e;

			_nk_pugl_modifiers(win, ev->state);
			nk_input_button(ctx, ev->button, ev->x, ev->y, 1);
			_nk_pugl_button(ctx, ev, 1);

			puglPostRedisplay(win->view);
		} break;


@@ 535,7 557,7 @@ _nk_pugl_event_func(PuglView *view, const PuglEvent *e)
			const PuglButtonEvent *ev = (const PuglButtonEvent *)e;

			_nk_pugl_modifiers(win, ev->state);
			nk_input_button(ctx, ev->button, ev->x, ev->y, 0);
			_nk_pugl_button(ctx, ev, 0);

			puglPostRedisplay(win->view);
		} break;