aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-21 18:35:55 +0200
committerDavid Robillard <d@drobilla.net>2019-07-21 21:31:00 +0200
commita322ffa38b537e5e03c31ed7fe967cec9d468bb8 (patch)
treeaf11872d26db73f3a7ce4154304edb494a18a832
parentcb897c6f91db4d87fe113e8c5139322a9d2f112b (diff)
downloadpugl-a322ffa38b537e5e03c31ed7fe967cec9d468bb8.tar.gz
pugl-a322ffa38b537e5e03c31ed7fe967cec9d468bb8.tar.bz2
pugl-a322ffa38b537e5e03c31ed7fe967cec9d468bb8.zip
Use local display and window variables for brevity
-rw-r--r--pugl/pugl_x11.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 15142e1..9fadc41 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -71,10 +71,11 @@ puglLeaveContext(PuglView* view, bool flush)
int
puglCreateWindow(PuglView* view, const char* title)
{
- PuglInternals* const impl = view->impl;
+ PuglInternals* const impl = view->impl;
+ Display* const display = XOpenDisplay(0);
- impl->display = XOpenDisplay(0);
- impl->screen = DefaultScreen(impl->display);
+ impl->display = display;
+ impl->screen = DefaultScreen(display);
if (view->ctx_type == PUGL_GL) {
#ifdef PUGL_HAVE_GL
@@ -98,10 +99,10 @@ puglCreateWindow(PuglView* view, const char* title)
Window xParent = view->parent
? (Window)view->parent
- : RootWindow(impl->display, impl->screen);
+ : RootWindow(display, impl->screen);
Colormap cmap = XCreateColormap(
- impl->display, xParent, impl->vi->visual, AllocNone);
+ display, xParent, impl->vi->visual, AllocNone);
XSetWindowAttributes attr;
memset(&attr, 0, sizeof(XSetWindowAttributes));
@@ -112,8 +113,8 @@ puglCreateWindow(PuglView* view, const char* title)
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | FocusChangeMask);
- impl->win = XCreateWindow(
- impl->display, xParent,
+ const Window win = impl->win = XCreateWindow(
+ display, xParent,
0, 0, view->width, view->height, 0, impl->vi->depth, InputOutput,
impl->vi->visual, CWColormap | CWEventMask, &attr);
@@ -129,7 +130,7 @@ puglCreateWindow(PuglView* view, const char* title)
sizeHints.min_height = view->height;
sizeHints.max_width = view->width;
sizeHints.max_height = view->height;
- XSetNormalHints(impl->display, impl->win, &sizeHints);
+ XSetNormalHints(display, win, &sizeHints);
} else {
if (view->min_width || view->min_height) {
sizeHints.flags = PMinSize;
@@ -144,27 +145,26 @@ puglCreateWindow(PuglView* view, const char* title)
sizeHints.max_aspect.y = view->max_aspect_y;
}
- XSetNormalHints(impl->display, impl->win, &sizeHints);
+ XSetNormalHints(display, win, &sizeHints);
}
if (title) {
- XStoreName(impl->display, impl->win, title);
+ XStoreName(display, win, title);
}
if (!view->parent) {
- Atom wmDelete = XInternAtom(impl->display, "WM_DELETE_WINDOW", True);
- XSetWMProtocols(impl->display, impl->win, &wmDelete, 1);
+ Atom wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
+ XSetWMProtocols(display, win, &wmDelete, 1);
}
if (view->transient_parent) {
- XSetTransientForHint(impl->display, impl->win,
- (Window)(view->transient_parent));
+ XSetTransientForHint(display, win, (Window)(view->transient_parent));
}
XSetLocaleModifiers("");
- if (!(impl->xim = XOpenIM(impl->display, NULL, NULL, NULL))) {
+ if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) {
XSetLocaleModifiers("@im=");
- if (!(impl->xim = XOpenIM(impl->display, NULL, NULL, NULL))) {
+ if (!(impl->xim = XOpenIM(display, NULL, NULL, NULL))) {
fprintf(stderr, "warning: XOpenIM failed\n");
}
}
@@ -172,8 +172,8 @@ puglCreateWindow(PuglView* view, const char* title)
const XIMStyle im_style = XIMPreeditNothing | XIMStatusNothing;
if (!(impl->xic = XCreateIC(impl->xim,
XNInputStyle, im_style,
- XNClientWindow, impl->win,
- XNFocusWindow, impl->win,
+ XNClientWindow, win,
+ XNFocusWindow, win,
NULL))) {
fprintf(stderr, "warning: XCreateIC failed\n");
}