Browse Source

add enable_rsvg option, use pugl fix for immediate expose

master
Alexandros Theodotou 3 years ago
parent
commit
399704f75c
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 9
      meson.build
  2. 7
      meson_options.txt
  3. 12
      pugl/.gitlab-ci.yml
  4. 23
      pugl/pugl/detail/win.c
  5. 88
      pugl/pugl/detail/x11.c
  6. 3
      pugl/pugl/detail/x11.h

9
meson.build

@ -53,8 +53,12 @@ endif @@ -53,8 +53,12 @@ endif
# dependencies
deps = [
# for drawing
dependency('cairo', version: '>=1.0.0'),
# for rendering SVGs with cairo
dependency('librsvg-2.0'),
# math functions might be implemented in libm
cc.find_library('m', required: false),
]
@ -65,6 +69,11 @@ if os_linux @@ -65,6 +69,11 @@ if os_linux
cdata.set('HAVE_X11', 1)
endif
if get_option('enable_rsvg')
deps += dependency('librsvg-2.0')
cdata.set('HAVE_RSVG', 1)
endif
# create config.h
config_h = configure_file (
output: 'config.h',

7
meson_options.txt

@ -20,3 +20,10 @@ option ( @@ -20,3 +20,10 @@ option (
type: 'boolean',
value: false,
description: 'Enable strict compilation flags')
option (
'enable_rsvg',
type: 'boolean',
value: false,
description: '''Enable SVG support through librsvg.
This requires the whole glib stack.''')

12
pugl/.gitlab-ci.yml

@ -85,27 +85,23 @@ mingw64_rel: @@ -85,27 +85,23 @@ mingw64_rel:
mac_dbg:
<<: *build_definition
script: python ./waf configure build -dsT --no-coverage
tags:
- macos
tags: [macos]
mac_rel:
<<: *build_definition
script: python ./waf configure build -sT --no-coverage
tags:
- macos
tags: [macos]
win_dbg:
<<: *build_definition
script:
- python ./waf configure build -dT --no-coverage
tags:
- windows
tags: [windows,msvc,python]
win_rel:
<<: *build_definition
script: python ./waf configure build -T --no-coverage
tags:
- windows
tags: [windows,msvc,python]
pages:
stage: deploy

23
pugl/pugl/detail/win.c

@ -435,20 +435,25 @@ handleConfigure(PuglView* view, PuglEvent* event) @@ -435,20 +435,25 @@ handleConfigure(PuglView* view, PuglEvent* event)
(LPPOINT)&rect,
2);
view->frame.x = rect.left;
view->frame.y = rect.top;
view->frame.width = rect.right - rect.left;
view->frame.height = rect.bottom - rect.top;
const LONG width = rect.right - rect.left;
const LONG height = rect.bottom - rect.top;
view->frame.x = rect.left;
view->frame.y = rect.top;
event->configure.type = PUGL_CONFIGURE;
event->configure.x = view->frame.x;
event->configure.y = view->frame.y;
event->configure.width = view->frame.width;
event->configure.height = view->frame.height;
event->configure.width = width;
event->configure.height = height;
if (view->frame.width != width || view->frame.height != height) {
view->frame.width = width;
view->frame.height = height;
view->backend->resize(view, width, height);
}
view->backend->resize(view,
rect.right - rect.left,
rect.bottom - rect.top);
return rect;
}

88
pugl/pugl/detail/x11.c

@ -621,20 +621,45 @@ mergeExposeEvents(PuglEvent* dst, const PuglEvent* src) @@ -621,20 +621,45 @@ mergeExposeEvents(PuglEvent* dst, const PuglEvent* src)
}
}
static void
addPendingExpose(PuglView* view, const PuglEvent* expose)
{
if (view->impl->pendingConfigure.type ||
(view->impl->pendingExpose.type &&
exposeEventsIntersect(&view->impl->pendingExpose, expose))) {
// Pending configure or an intersecting expose, expand it
mergeExposeEvents(&view->impl->pendingExpose, expose);
} else {
if (view->impl->pendingExpose.type) {
// Pending non-intersecting expose, dispatch it now
// This isn't ideal, but avoids needing to maintain an expose list
puglEnterContext(view, true);
puglDispatchEvent(view, &view->impl->pendingExpose);
puglLeaveContext(view, true);
}
view->impl->pendingExpose = *expose;
}
}
static void
flushPendingConfigure(PuglView* view)
{
PuglEvent* const configure = &view->impl->pendingConfigure;
if (configure->type) {
view->frame.x = configure->configure.x;
view->frame.y = configure->configure.y;
view->frame.width = configure->configure.width;
view->frame.height = configure->configure.height;
view->frame.x = configure->configure.x;
view->frame.y = configure->configure.y;
view->backend->resize(view,
(int)view->frame.width,
(int)view->frame.height);
if (configure->configure.width != view->frame.width ||
configure->configure.height != view->frame.height) {
view->frame.width = configure->configure.width;
view->frame.height = configure->configure.height;
view->backend->resize(view,
(int)view->frame.width,
(int)view->frame.height);
}
view->eventFunc(view, configure);
configure->type = 0;
@ -650,6 +675,8 @@ puglDispatchEvents(PuglWorld* world) @@ -650,6 +675,8 @@ puglDispatchEvents(PuglWorld* world)
Display* display = world->impl->display;
XFlush(display);
world->impl->dispatchingEvents = true;
// Process all queued events (locally, without flushing or reading)
while (XEventsQueued(display, QueuedAlready) > 0) {
XEvent xevent;
@ -730,20 +757,7 @@ puglDispatchEvents(PuglWorld* world) @@ -730,20 +757,7 @@ puglDispatchEvents(PuglWorld* world)
if (event.type == PUGL_EXPOSE) {
// Expand expose event to be dispatched after loop
if (view->impl->pendingConfigure.type ||
(view->impl->pendingExpose.type &&
exposeEventsIntersect(&view->impl->pendingExpose, &event))) {
mergeExposeEvents(&view->impl->pendingExpose, &event);
} else {
if (view->impl->pendingExpose.type) {
puglEnterContext(view, true);
flushPendingConfigure(view);
puglDispatchEvent(view, &view->impl->pendingExpose);
puglLeaveContext(view, true);
}
view->impl->pendingExpose = event;
}
addPendingExpose(view, &event);
} else if (event.type == PUGL_CONFIGURE) {
// Expand configure event to be dispatched after loop
view->impl->pendingConfigure = event;
@ -775,6 +789,8 @@ puglDispatchEvents(PuglWorld* world) @@ -775,6 +789,8 @@ puglDispatchEvents(PuglWorld* world)
}
}
world->impl->dispatchingEvents = false;
return PUGL_SUCCESS;
}
@ -803,18 +819,26 @@ puglPostRedisplay(PuglView* view) @@ -803,18 +819,26 @@ puglPostRedisplay(PuglView* view)
PuglStatus
puglPostRedisplayRect(PuglView* view, PuglRect rect)
{
const int x = (int)floor(rect.x);
const int y = (int)floor(rect.y);
const int w = (int)ceil(rect.x + rect.width) - x;
const int h = (int)ceil(rect.y + rect.height) - y;
XExposeEvent ev = {Expose, 0, True,
view->impl->display, view->impl->win,
x, y,
w, h,
0};
if (view->world->impl->dispatchingEvents) {
// Currently dispatching events, add/expand expose for the loop end
const PuglEventExpose event = {
PUGL_EXPOSE, 0, rect.x, rect.y, rect.width, rect.height, 0
};
addPendingExpose(view, (const PuglEvent*)&event);
} else if (view->visible) {
// Not dispatching events, send an X expose so we wake up next time
const int x = (int)floor(rect.x);
const int y = (int)floor(rect.y);
const int w = (int)ceil(rect.x + rect.width) - x;
const int h = (int)ceil(rect.y + rect.height) - y;
XExposeEvent ev = {Expose, 0, True,
view->impl->display, view->impl->win,
x, y,
w, h,
0};
if (view->visible) {
XSendEvent(view->impl->display, view->impl->win, False, 0, (XEvent*)&ev);
}

3
pugl/pugl/detail/x11.h

@ -23,6 +23,8 @@ @@ -23,6 +23,8 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdbool.h>
typedef struct {
Atom CLIPBOARD;
Atom UTF8_STRING;
@ -37,6 +39,7 @@ struct PuglWorldInternalsImpl { @@ -37,6 +39,7 @@ struct PuglWorldInternalsImpl {
Display* display;
PuglX11Atoms atoms;
XIM xim;
bool dispatchingEvents;
};
struct PuglInternalsImpl {

Loading…
Cancel
Save