aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-20 19:43:34 -0400
committerDavid Robillard <d@drobilla.net>2022-05-21 16:49:47 -0400
commit0fc1422e858bf9849b84aee2abeca3b553214b73 (patch)
treeba6fca0afcdee06b9283d408b71a11dab0a5e6fd
parent692dbf482859e91f0dbadaa97152ab779f9a4648 (diff)
downloadpugl-0fc1422e858bf9849b84aee2abeca3b553214b73.tar.gz
pugl-0fc1422e858bf9849b84aee2abeca3b553214b73.tar.bz2
pugl-0fc1422e858bf9849b84aee2abeca3b553214b73.zip
X11: Remove redundant display member
-rw-r--r--src/x11.c71
-rw-r--r--src/x11.h1
-rw-r--r--src/x11_cairo.c2
-rw-r--r--src/x11_gl.c25
4 files changed, 52 insertions, 47 deletions
diff --git a/src/x11.c b/src/x11.c
index 046211c..64397bd 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -332,8 +332,7 @@ puglRealize(PuglView* const view)
}
// Configure the backend to get the visual info
- impl->display = display;
- impl->screen = screen;
+ impl->screen = screen;
if ((st = view->backend->configure(view)) || !impl->vi) {
view->backend->destroy(view);
return st ? st : PUGL_BACKEND_FAILED;
@@ -425,7 +424,7 @@ puglShow(PuglView* const view)
PuglStatus st = view->impl->win ? PUGL_SUCCESS : puglRealize(view);
if (!st) {
- XMapRaised(view->impl->display, view->impl->win);
+ XMapRaised(view->world->impl->display, view->impl->win);
st = puglPostRedisplay(view);
}
@@ -435,7 +434,7 @@ puglShow(PuglView* const view)
PuglStatus
puglHide(PuglView* const view)
{
- XUnmapWindow(view->impl->display, view->impl->win);
+ XUnmapWindow(view->world->impl->display, view->impl->win);
return PUGL_SUCCESS;
}
@@ -449,8 +448,8 @@ puglFreeViewInternals(PuglView* const view)
if (view->backend) {
view->backend->destroy(view);
}
- if (view->impl->display) {
- XDestroyWindow(view->impl->display, view->impl->win);
+ if (view->world->impl->display && view->impl->win) {
+ XDestroyWindow(view->world->impl->display, view->impl->win);
}
XFree(view->impl->vi);
free(view->impl);
@@ -586,7 +585,7 @@ getAtomProperty(PuglView* const view,
int actualFormat = 0;
unsigned long bytesAfter = 0;
- return (XGetWindowProperty(view->impl->display,
+ return (XGetWindowProperty(view->world->impl->display,
window,
property,
0,
@@ -808,10 +807,11 @@ translateEvent(PuglView* const view, XEvent xevent)
PuglStatus
puglGrabFocus(PuglView* const view)
{
- PuglInternals* const impl = view->impl;
- XWindowAttributes attrs = {0};
+ PuglInternals* const impl = view->impl;
+ Display* const display = view->world->impl->display;
+ XWindowAttributes attrs = {0};
- if (!impl->win || !XGetWindowAttributes(impl->display, impl->win, &attrs)) {
+ if (!impl->win || !XGetWindowAttributes(display, impl->win, &attrs)) {
return PUGL_UNKNOWN_ERROR;
}
@@ -819,7 +819,7 @@ puglGrabFocus(PuglView* const view)
return PUGL_FAILURE;
}
- XSetInputFocus(impl->display, impl->win, RevertToNone, CurrentTime);
+ XSetInputFocus(display, impl->win, RevertToNone, CurrentTime);
return PUGL_SUCCESS;
}
@@ -828,16 +828,17 @@ puglHasFocus(const PuglView* const view)
{
int revertTo = 0;
Window focusedWindow = 0;
- XGetInputFocus(view->impl->display, &focusedWindow, &revertTo);
+ XGetInputFocus(view->world->impl->display, &focusedWindow, &revertTo);
return focusedWindow == view->impl->win;
}
PuglStatus
puglRequestAttention(PuglView* const view)
{
- PuglInternals* const impl = view->impl;
- const PuglX11Atoms* const atoms = &view->world->impl->atoms;
- XEvent event = {0};
+ PuglInternals* const impl = view->impl;
+ Display* const display = view->world->impl->display;
+ const PuglX11Atoms* const atoms = &view->world->impl->atoms;
+ XEvent event = {0};
event.type = ClientMessage;
event.xclient.window = impl->win;
@@ -849,9 +850,9 @@ puglRequestAttention(PuglView* const view)
event.xclient.data.l[3] = 1;
event.xclient.data.l[4] = 0;
- const Window root = RootWindow(impl->display, impl->screen);
+ const Window root = RootWindow(display, impl->screen);
- return XSendEvent(impl->display,
+ return XSendEvent(display,
root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
@@ -950,7 +951,7 @@ eventToX(PuglView* const view, const PuglEvent* const event)
xev.xexpose.type = Expose;
xev.xexpose.serial = 0;
- xev.xexpose.display = view->impl->display;
+ xev.xexpose.display = view->world->impl->display;
xev.xexpose.window = view->impl->win;
xev.xexpose.x = (int)x;
xev.xexpose.y = (int)y;
@@ -963,7 +964,7 @@ eventToX(PuglView* const view, const PuglEvent* const event)
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.display = view->impl->display;
+ xev.xclient.display = view->world->impl->display;
xev.xclient.window = view->impl->win;
xev.xclient.message_type = view->world->impl->atoms.PUGL_CLIENT_MSG;
xev.xclient.format = 32;
@@ -984,7 +985,8 @@ puglSendEvent(PuglView* const view, const PuglEvent* const event)
XEvent xev = eventToX(view, event);
if (xev.type) {
- return XSendEvent(view->impl->display, view->impl->win, False, 0, &xev)
+ return XSendEvent(
+ view->world->impl->display, view->impl->win, False, 0, &xev)
? PUGL_SUCCESS
: PUGL_UNKNOWN_ERROR;
}
@@ -997,7 +999,7 @@ PuglStatus
puglWaitForEvent(PuglView* const view)
{
XEvent xevent;
- XPeekEvent(view->impl->display, &xevent);
+ XPeekEvent(view->world->impl->display, &xevent);
return PUGL_SUCCESS;
}
#endif
@@ -1218,7 +1220,7 @@ dispatchX11Events(PuglWorld* const world)
} else if (event.type == PUGL_MAP) {
// Get initial window position and size
XWindowAttributes attrs;
- XGetWindowAttributes(view->impl->display, view->impl->win, &attrs);
+ XGetWindowAttributes(view->world->impl->display, view->impl->win, &attrs);
// Build an initial configure event in case the WM doesn't send one
PuglEvent configureEvent = {{PUGL_CONFIGURE, 0}};
@@ -1421,16 +1423,17 @@ puglGetClipboard(PuglView* const view,
const char** const type,
size_t* const len)
{
- PuglInternals* const impl = view->impl;
- const PuglX11Atoms* const atoms = &view->world->impl->atoms;
+ PuglInternals* const impl = view->impl;
+ Display* const display = view->world->impl->display;
+ const PuglX11Atoms* const atoms = &view->world->impl->atoms;
- const Window owner = XGetSelectionOwner(impl->display, atoms->CLIPBOARD);
+ const Window owner = XGetSelectionOwner(display, atoms->CLIPBOARD);
if (owner != None && owner != impl->win) {
// Clear internal selection
puglSetBlob(&view->clipboard, NULL, 0);
// Request selection from the owner
- XConvertSelection(impl->display,
+ XConvertSelection(display,
atoms->CLIPBOARD,
atoms->UTF8_STRING,
XA_PRIMARY,
@@ -1452,12 +1455,13 @@ puglSetClipboard(PuglView* const view,
const void* const data,
const size_t len)
{
- PuglInternals* const impl = view->impl;
- const PuglX11Atoms* const atoms = &view->world->impl->atoms;
+ PuglInternals* const impl = view->impl;
+ Display* const display = view->world->impl->display;
+ const PuglX11Atoms* const atoms = &view->world->impl->atoms;
PuglStatus st = puglSetInternalClipboard(view, type, data, len);
if (!st) {
- XSetSelectionOwner(impl->display, atoms->CLIPBOARD, impl->win, CurrentTime);
+ XSetSelectionOwner(display, atoms->CLIPBOARD, impl->win, CurrentTime);
}
return st;
@@ -1494,12 +1498,13 @@ puglSetCursor(PuglView* const view, const PuglCursor cursor)
PuglStatus
puglX11Configure(PuglView* view)
{
- PuglInternals* const impl = view->impl;
- XVisualInfo pat = PUGL_INIT_STRUCT;
- int n = 0;
+ PuglInternals* const impl = view->impl;
+ Display* const display = view->world->impl->display;
+ XVisualInfo pat = PUGL_INIT_STRUCT;
+ int n = 0;
pat.screen = impl->screen;
- if (!(impl->vi = XGetVisualInfo(impl->display, VisualScreenMask, &pat, &n))) {
+ if (!(impl->vi = XGetVisualInfo(display, VisualScreenMask, &pat, &n))) {
return PUGL_BAD_CONFIGURATION;
}
diff --git a/src/x11.h b/src/x11.h
index 720dbeb..49a1d06 100644
--- a/src/x11.h
+++ b/src/x11.h
@@ -48,7 +48,6 @@ struct PuglWorldInternalsImpl {
};
struct PuglInternalsImpl {
- Display* display;
XVisualInfo* vi;
Window win;
XIC xic;
diff --git a/src/x11_cairo.c b/src/x11_cairo.c
index 6aafb50..74de735 100644
--- a/src/x11_cairo.c
+++ b/src/x11_cairo.c
@@ -36,7 +36,7 @@ puglX11CairoOpen(PuglView* view)
PuglInternals* const impl = view->impl;
PuglX11CairoSurface* const surface = (PuglX11CairoSurface*)impl->surface;
- surface->back = cairo_xlib_surface_create(impl->display,
+ surface->back = cairo_xlib_surface_create(view->world->impl->display,
impl->win,
impl->vi->visual,
(int)view->frame.width,
diff --git a/src/x11_gl.c b/src/x11_gl.c
index 41007cd..2e15092 100644
--- a/src/x11_gl.c
+++ b/src/x11_gl.c
@@ -44,7 +44,7 @@ puglX11GlConfigure(PuglView* view)
{
PuglInternals* const impl = view->impl;
const int screen = impl->screen;
- Display* const display = impl->display;
+ Display* const display = view->world->impl->display;
PuglX11GlSurface* const surface =
(PuglX11GlSurface*)calloc(1, sizeof(PuglX11GlSurface));
@@ -75,7 +75,7 @@ puglX11GlConfigure(PuglView* view)
}
surface->fb_config = fbc[0];
- impl->vi = glXGetVisualFromFBConfig(impl->display, fbc[0]);
+ impl->vi = glXGetVisualFromFBConfig(display, fbc[0]);
view->hints[PUGL_RED_BITS] =
puglX11GlGetAttrib(display, fbc[0], GLX_RED_SIZE);
@@ -103,25 +103,26 @@ static PuglStatus
puglX11GlEnter(PuglView* view, const PuglExposeEvent* PUGL_UNUSED(expose))
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
+ Display* const display = view->world->impl->display;
if (!surface || !surface->ctx) {
return PUGL_FAILURE;
}
- return glXMakeCurrent(view->impl->display, view->impl->win, surface->ctx)
- ? PUGL_SUCCESS
- : PUGL_FAILURE;
+ return glXMakeCurrent(display, view->impl->win, surface->ctx) ? PUGL_SUCCESS
+ : PUGL_FAILURE;
}
PUGL_WARN_UNUSED_RESULT
static PuglStatus
puglX11GlLeave(PuglView* view, const PuglExposeEvent* expose)
{
+ Display* const display = view->world->impl->display;
+
if (expose && view->hints[PUGL_DOUBLE_BUFFER]) {
- glXSwapBuffers(view->impl->display, view->impl->win);
+ glXSwapBuffers(display, view->impl->win);
}
- return glXMakeCurrent(view->impl->display, None, NULL) ? PUGL_SUCCESS
- : PUGL_FAILURE;
+ return glXMakeCurrent(display, None, NULL) ? PUGL_SUCCESS : PUGL_FAILURE;
}
static PuglStatus
@@ -129,7 +130,7 @@ puglX11GlCreate(PuglView* view)
{
PuglInternals* const impl = view->impl;
PuglX11GlSurface* const surface = (PuglX11GlSurface*)impl->surface;
- Display* const display = impl->display;
+ Display* const display = view->world->impl->display;
GLXFBConfig fb_config = surface->fb_config;
PuglStatus st = PUGL_SUCCESS;
@@ -188,7 +189,7 @@ puglX11GlCreate(PuglView* view)
}
// Get the actual current swap interval
- glXQueryDrawable(impl->display,
+ glXQueryDrawable(display,
impl->win,
GLX_SWAP_INTERVAL_EXT,
(unsigned int*)&view->hints[PUGL_SWAP_INTERVAL]);
@@ -198,7 +199,7 @@ puglX11GlCreate(PuglView* view)
}
}
- return !glXGetConfig(impl->display,
+ return !glXGetConfig(display,
impl->vi,
GLX_DOUBLEBUFFER,
&view->hints[PUGL_DOUBLE_BUFFER])
@@ -211,7 +212,7 @@ puglX11GlDestroy(PuglView* view)
{
PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface;
if (surface) {
- glXDestroyContext(view->impl->display, surface->ctx);
+ glXDestroyContext(view->world->impl->display, surface->ctx);
free(surface);
view->impl->surface = NULL;
}