From 204c24cafdc8ae5c1d1085b08c43ef5990a36fa7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 15 Apr 2014 21:59:47 -0400 Subject: more cleanups --- window-xlib.c | 48 ++++++++++++++++++++---------------------------- window-xlib.h | 2 +- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/window-xlib.c b/window-xlib.c index fe839ad..2a467f6 100644 --- a/window-xlib.c +++ b/window-xlib.c @@ -60,7 +60,6 @@ static struct function_key keys[] = { }; #undef RUNES_KEY -static cairo_surface_t *runes_window_backend_surface_create(RunesTerm *t); static void runes_window_backend_get_next_event(uv_work_t *req); static void runes_window_backend_process_event(uv_work_t *req, int status); static void runes_window_backend_map_window(RunesTerm *t); @@ -79,6 +78,7 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[]) XIM im; Cursor cursor; XColor cursor_fg, cursor_bg; + Visual *vis; wm_hints.flags = InputHint | StateHint; wm_hints.input = True; @@ -137,7 +137,11 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[]) XRecolorCursor(w->dpy, cursor, &cursor_fg, &cursor_bg); XDefineCursor(w->dpy, w->w, cursor); - t->backend_cr = cairo_create(runes_window_backend_surface_create(t)); + vis = DefaultVisual(w->dpy, DefaultScreen(w->dpy)); + t->backend_cr = cairo_create( + cairo_xlib_surface_create( + w->dpy, w->w, vis, + normal_hints.base_width, normal_hints.base_height)); runes_window_backend_map_window(t); } @@ -179,6 +183,20 @@ void runes_window_backend_request_flush(RunesTerm *t) XUnlockDisplay(t->w.dpy); } +void runes_window_backend_request_close(RunesTerm *t) +{ + XEvent e; + + e.xclient.type = ClientMessage; + e.xclient.window = t->w.w; + e.xclient.message_type = t->w.atoms[RUNES_ATOM_WM_PROTOCOLS]; + e.xclient.format = 32; + e.xclient.data.l[0] = t->w.atoms[RUNES_ATOM_WM_DELETE_WINDOW]; + e.xclient.data.l[1] = CurrentTime; + + XSendEvent(t->w.dpy, t->w.w, False, NoEventMask, &e); +} + void runes_window_backend_get_size(RunesTerm *t, int *xpixel, int *ypixel) { cairo_surface_t *surface; @@ -227,20 +245,6 @@ void runes_window_backend_visual_bell(RunesTerm *t) runes_window_backend_flush(t); } -void runes_window_backend_request_close(RunesTerm *t) -{ - XEvent e; - - e.xclient.type = ClientMessage; - e.xclient.window = t->w.w; - e.xclient.message_type = t->w.atoms[RUNES_ATOM_WM_PROTOCOLS]; - e.xclient.format = 32; - e.xclient.data.l[0] = t->w.atoms[RUNES_ATOM_WM_DELETE_WINDOW]; - e.xclient.data.l[1] = CurrentTime; - - XSendEvent(t->w.dpy, t->w.w, False, NoEventMask, &e); -} - void runes_window_backend_cleanup(RunesTerm *t) { RunesWindowBackend *w = &t->w; @@ -253,18 +257,6 @@ void runes_window_backend_cleanup(RunesTerm *t) XCloseDisplay(w->dpy); } -static cairo_surface_t *runes_window_backend_surface_create(RunesTerm *t) -{ - RunesWindowBackend *w = &t->w; - Visual *vis; - XWindowAttributes attrs; - - XGetWindowAttributes(w->dpy, w->w, &attrs); - vis = DefaultVisual(w->dpy, DefaultScreen(w->dpy)); - return cairo_xlib_surface_create( - w->dpy, w->w, vis, attrs.width, attrs.height); -} - static void runes_window_backend_get_next_event(uv_work_t *req) { RunesXlibLoopData *data; diff --git a/window-xlib.h b/window-xlib.h index 7c0aecf..703ec9d 100644 --- a/window-xlib.h +++ b/window-xlib.h @@ -32,12 +32,12 @@ typedef struct { void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[]); void runes_window_backend_start_loop(RunesTerm *t); void runes_window_backend_request_flush(RunesTerm *t); +void runes_window_backend_request_close(RunesTerm *t); void runes_window_backend_get_size(RunesTerm *t, int *xpixel, int *ypixel); void runes_window_backend_set_icon_name(RunesTerm *t, char *name, size_t len); void runes_window_backend_set_window_title( RunesTerm *t, char *name, size_t len); void runes_window_backend_visual_bell(RunesTerm *t); -void runes_window_backend_request_close(RunesTerm *t); void runes_window_backend_cleanup(RunesTerm *t); #endif -- cgit v1.2.3-54-g00ecf