From fa83f224e2ec2541e45cf9ab2afc5a2b3b5f06cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Sat, 17 Jan 2026 18:35:27 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B6=BA=E9=BA=97=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 112 +++++++++++++++++++++++------------------------- src/control.c | 115 +++++++++++++++++++++++++++----------------------- src/control.h | 13 +++--- src/display.c | 18 ++++---- src/display.h | 4 +- src/program.h | 3 -- src/ui.h | 16 +++++++ src/utils.c | 29 ++++++------- src/utils.h | 5 +-- 9 files changed, 164 insertions(+), 151 deletions(-) diff --git a/main.c b/main.c index 456c304..6b4876f 100644 --- a/main.c +++ b/main.c @@ -4,73 +4,67 @@ #include "src/utils.h" #include "src/control.h" -XftColor color, btncolor; -Colormap colormap; -XftFont *font; -XftFont *prbfont; -XftFont *disfont; -Visual *visual; - const char *sofname = "ucalc"; const char *version = "0.0.0"; const char *disname = "Unix Calc"; int main() { - Display *display; - Window window; + UiSystem ui; XEvent event; int screen; - GC gc = NULL; XGCValues values; - display = XOpenDisplay(NULL); - if (display == NULL) { + ui.display = XOpenDisplay(NULL); + if (ui.display == NULL) { fprintf(stderr, "画面を開けられません。\n"); exit(1); } - screen = DefaultScreen(display); + screen = DefaultScreen(ui.display); - int sw = DisplayWidth(display, screen); - int sh = DisplayHeight(display, screen); + int sw = DisplayWidth(ui.display, screen); + int sh = DisplayHeight(ui.display, screen); int window_x = (sw - window_width) / 3; int window_y = (sh - window_height) / 2; - window = XCreateSimpleWindow(display, RootWindow(display, screen), + ui.window = XCreateSimpleWindow(ui.display, + RootWindow(ui.display, screen), window_x, window_y, window_width, window_height, 1, BTCOL, BGCOL); - if (!window) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + if (!ui.window) { + cleanup(&ui); fprintf(stderr, "ウィンドウを作成に失敗。\n"); exit(1); } - backbuf = XCreatePixmap(display, window, window_width, window_height, DefaultDepth(display, screen)); + ui.backbuf = XCreatePixmap(ui.display, ui.window, window_width, window_height, + DefaultDepth(ui.display, screen)); + ui.target = ui.backbuf; - Atom net_wm_window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); - Atom dialog = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + Atom net_wm_window_type = XInternAtom(ui.display, "_NET_WM_WINDOW_TYPE", False); + Atom dialog = XInternAtom(ui.display, "_NET_WM_WINDOW_TYPE_DIALOG", False); - XChangeProperty(display, window, net_wm_window_type, XA_ATOM, 32, + XChangeProperty(ui.display, ui.window, net_wm_window_type, XA_ATOM, 32, PropModeReplace, (unsigned char *)&dialog, 1); - XStoreName(display, window, disname); - Atom net_wm_name = XInternAtom(display, "_NET_WM_NAME", False); + XStoreName(ui.display, ui.window, disname); + Atom net_wm_name = XInternAtom(ui.display, "_NET_WM_NAME", False); char displayname[16]; snprintf(displayname, 16, "%s %s", disname, version); - XChangeProperty(display, window, net_wm_name, - XInternAtom(display, "UTF8_STRING", False), 8, + XChangeProperty(ui.display, ui.window, net_wm_name, + XInternAtom(ui.display, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *)displayname, strlen(displayname)); XClassHint *classHint = XAllocClassHint(); if (classHint) { classHint->res_name = "unixcalc"; classHint->res_class = "UnixCalc"; - XSetClassHint(display, window, classHint); + XSetClassHint(ui.display, ui.window, classHint); XFree(classHint); } - XSetWindowBackground(display, window, BGCOL); + XSetWindowBackground(ui.display, ui.window, BGCOL); - XSelectInput(display, window, + XSelectInput(ui.display, ui.window, ExposureMask | ButtonPressMask | ButtonReleaseMask @@ -80,84 +74,84 @@ int main() { // | StructureNotifyMask ); - gc = XCreateGC(display, window, 0, &values); - if (!gc) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + ui.gc = XCreateGC(ui.display, ui.window, 0, &values); + if (!ui.gc) { + cleanup(&ui); fprintf(stderr, "GCを作成に失敗。\n"); exit(1); } - visual = DefaultVisual(display, screen); + ui.visual = *DefaultVisual(ui.display, screen); - colormap = XCreateColormap(display, window, visual, AllocNone); - if (colormap == None) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + ui.colormap = XCreateColormap(ui.display, ui.window, &ui.visual, AllocNone); + if (ui.colormap == None) { + cleanup(&ui); fprintf(stderr, "カラーマップを作成に失敗。\n"); exit(1); } - font = XftFontOpenName(display, screen, "Noto Sans CJK-12"); - if (!font) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + ui.font = XftFontOpenName(ui.display, screen, "Noto Sans CJK-12"); + if (!ui.font) { + cleanup(&ui); fprintf(stderr, "フォントの読み込みに失敗。\n"); exit(1); } - prbfont = XftFontOpenName(display, screen, "Noto Sans CJK-24"); - if (!prbfont) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + ui.prbfont = XftFontOpenName(ui.display, screen, "Noto Sans CJK-24"); + if (!ui.prbfont) { + cleanup(&ui); fprintf(stderr, "問題フォントの読み込みに失敗。\n"); exit(1); } - disfont = XftFontOpenName(display, screen, "Noto Sans CJK-72"); - if (!disfont) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + ui.disfont = XftFontOpenName(ui.display, screen, "Noto Sans CJK-72"); + if (!ui.disfont) { + cleanup(&ui); fprintf(stderr, "解決フォントの読み込みに失敗。\n"); exit(1); } - if (!XftColorAllocName(display, visual, colormap, "#232020", &color)) { - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + if (!XftColorAllocName(ui.display, &ui.visual, ui.colormap, "#232020", &ui.color)) { + cleanup(&ui); fprintf(stderr, "色の役割に失敗。\n"); exit(1); } - XMapWindow(display, window); + XMapWindow(ui.display, ui.window); { XWindowAttributes attr; - XGetWindowAttributes(display, window, &attr); + XGetWindowAttributes(ui.display, ui.window, &attr); XEvent fake = { .type = Expose }; - fake.xexpose.window = window; + fake.xexpose.window = ui.window; fake.xexpose.width = attr.width; fake.xexpose.height = attr.height; - control_expose(display, window, gc, &event, &color, font, disfont, prbfont); + control_expose(&ui, &event); } while (isrunning) { - XNextEvent(display, &event); + XNextEvent(ui.display, &event); switch (event.type) { case Expose: case ConfigureNotify: - XClearWindow(display, window); - control_expose(display, window, gc, &event, &color, font, disfont, prbfont); + XClearWindow(ui.display, ui.window); + control_expose(&ui, &event); break; case ButtonPress: if (event.xbutton.button == Button1) { - handle_button_press(display, gc, event.xbutton.x, event.xbutton.y, &color, font); + handle_button_press(&ui, event.xbutton.x, event.xbutton.y); break; } case ButtonRelease: if (event.xbutton.button == Button1) { - handle_button_release(display, window, gc, event.xbutton.x, event.xbutton.y, &color, font, disfont, prbfont); + handle_button_release(&ui, event.xbutton.x, event.xbutton.y); break; } case KeyPress: - handle_key_press(display, window, gc, &event, &color, font, disfont, prbfont); + handle_key_press(&ui, &event); break; // case MotionNotify: - // handle_mouse_hover(display, window, gc, &event, &color, font); + // handle_mouse_hover(&ui, &event); // break; case ClientMessage: // WM_DELETE_WINDOW @@ -165,7 +159,7 @@ int main() { } } - cleanup(display, window, gc, &color, &btncolor, font, disfont, prbfont, colormap, visual, backbuf); + cleanup(&ui); return 0; } diff --git a/src/control.c b/src/control.c index dff9fef..9e93a25 100644 --- a/src/control.c +++ b/src/control.c @@ -120,78 +120,85 @@ double evaluate_simple(const char *expr) { return res; } -void control_expose(Display *dpy, Window wnd, GC gc, XEvent *e, XftColor *color, XftFont *f, XftFont *df, XftFont *pf) { - (void)color; +void control_expose(UiSystem *ui, XEvent *e) { if (e->type != Expose && e->type != ConfigureNotify) return; XWindowAttributes attr; - XGetWindowAttributes(dpy, wnd, &attr); + XGetWindowAttributes(ui->display, ui->window, &attr); int w = attr.width; int h = attr.height; - if (backbuf != None) { - XFreePixmap(dpy, backbuf); + if (ui->backbuf != None) { + XFreePixmap(ui->display, ui->backbuf); + ui->backbuf = None; } - backbuf = XCreatePixmap(dpy, wnd, w, h, DefaultDepth(dpy, DefaultScreen(dpy))); + ui->backbuf = XCreatePixmap(ui->display, ui->window, w, h, + DefaultDepth(ui->display, DefaultScreen(ui->display))); - if (backbuf == None) { - backbuf = wnd; + if (ui->backbuf == None) { + fprintf(stderr, "バックバッファ作成失敗!\n"); + ui->backbuf = ui->window; } - XftDraw *backdraw = XftDrawCreate(dpy, backbuf, - DefaultVisual(dpy, DefaultScreen(dpy)), DefaultColormap(dpy, DefaultScreen(dpy))); + ui->target = ui->backbuf; + + XftDraw *backdraw = XftDrawCreate(ui->display, ui->backbuf, + DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display))); if (!backdraw) { fprintf(stderr, "Pixmap向けXftDrawの作成に失敗。\n"); - XFreePixmap(dpy, backbuf); - backbuf = None; + XFreePixmap(ui->display, ui->backbuf); + ui->backbuf = None; return; } - XSetForeground(dpy, gc, BGCOL); - XFillRectangle(dpy, backbuf, gc, 0, 0, w, h); + XSetForeground(ui->display, ui->gc, BGCOL); + XFillRectangle(ui->display, ui->backbuf, ui->gc, 0, 0, w, h); // 出力 - if (displaytxt[0] != '\0' && df) { + if (displaytxt[0] != '\0' && ui->disfont) { const FcChar8 *text = (const FcChar8 *)displaytxt; int len = strlen((const char *)text); XGlyphInfo extents; - XftTextExtentsUtf8(dpy, df, text, len, &extents); + XftTextExtentsUtf8(ui->display, ui->disfont, text, len, &extents); int tx = w - 20 - extents.xOff; int ty = 160; XftColor discol; - XftColorAllocName(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), - DefaultColormap(dpy, DefaultScreen(dpy)), + XftColorAllocName(ui->display, DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display)), "#ee4030", &discol); - XftDrawStringUtf8(backdraw, &discol, df, tx, ty, text, len); + XftDrawStringUtf8(backdraw, &discol, ui->disfont, tx, ty, text, len); - XftColorFree(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), - DefaultColormap(dpy, DefaultScreen(dpy)), &discol); + XftColorFree(ui->display, DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display)), &discol); } - if (displayprb[0] != '\0' && pf) { + if (displayprb[0] != '\0' && ui->prbfont) { const FcChar8 *text = (const FcChar8 *)displayprb; int len = strlen((const char *)text); XGlyphInfo extents; - XftTextExtentsUtf8(dpy, pf, text, len, &extents); + XftTextExtentsUtf8(ui->display, ui->prbfont, text, len, &extents); int tx = w - 20 - extents.xOff; int ty = 80; XftColor discol; - XftColorAllocName(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), - DefaultColormap(dpy, DefaultScreen(dpy)), - "#b61729", &discol); + XftColorAllocName(ui->display, + DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display)), + "#b61729", &discol); - XftDrawStringUtf8(backdraw, &discol, pf, tx, ty, text, len); + XftDrawStringUtf8(backdraw, &discol, ui->prbfont, tx, ty, text, len); - XftColorFree(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), - DefaultColormap(dpy, DefaultScreen(dpy)), &discol); + XftColorFree(ui->display, + DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display)), &discol); } int width = 93; @@ -219,50 +226,54 @@ void control_expose(Display *dpy, Window wnd, GC gc, XEvent *e, XftColor *color, btn.label = label; btn.pressed = 0; - drawbuttons(dpy, backbuf, gc, &btn, backdraw, color, f); + drawbuttons(ui, &btn, backdraw); } } - XCopyArea(dpy, backbuf, wnd, gc, 0, 0, w, h, 0, 0); + XCopyArea(ui->display, ui->backbuf, ui->window, ui->gc, 0, 0, w, h, 0, 0); XftDrawDestroy(backdraw); - XFlush(dpy); + XFlush(ui->display); } -void handle_button_press(Display *dpy, GC gc, int mx, int my, XftColor *col, XftFont *f) { +void handle_button_press(UiSystem *ui, int mx, int my) { SuwaButton *btn = find_button_at(mx, my); if (!btn) return; btn->pressed = 1; - XftDraw *backdraw = XftDrawCreate(dpy, backbuf, - DefaultVisual(dpy, DefaultScreen(dpy)), DefaultColormap(dpy, DefaultScreen(dpy))); + XftDraw *backdraw = XftDrawCreate(ui->display, ui->backbuf, + DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display))); if (!backdraw) { fprintf(stderr, "Pixmap向けXftDrawの作成に失敗。\n"); - XFreePixmap(dpy, backbuf); - backbuf = None; + XFreePixmap(ui->display, ui->backbuf); + ui->backbuf = None; return; } - drawbuttons(dpy, backbuf, gc, btn, backdraw, col, f); - XFlush(dpy); + drawbuttons(ui, btn, backdraw); + XFlush(ui->display); } -void handle_button_release(Display *dpy, Window wnd, GC gc, int mx, int my, XftColor *col, XftFont *f, XftFont *df, XftFont *pf) { +void handle_button_release(UiSystem *ui, int mx, int my) { SuwaButton *btn = find_button_at(mx, my); if (!btn) return; btn->pressed = 0; - XftDraw *backdraw = XftDrawCreate(dpy, backbuf, - DefaultVisual(dpy, DefaultScreen(dpy)), DefaultColormap(dpy, DefaultScreen(dpy))); + XftDraw *backdraw = XftDrawCreate(ui->display, ui->backbuf, + DefaultVisual(ui->display, DefaultScreen(ui->display)), + DefaultColormap(ui->display, DefaultScreen(ui->display))); if (!backdraw) { fprintf(stderr, "Pixmap向けXftDrawの作成に失敗。\n"); - XFreePixmap(dpy, backbuf); - backbuf = None; + XFreePixmap(ui->display, ui->backbuf); + ui->backbuf = None; return; } - drawbuttons(dpy, backbuf, gc, btn, backdraw, col, f); + + ui->target = ui->backbuf; + drawbuttons(ui, btn, backdraw); XftDrawDestroy(backdraw); - XFlush(dpy); + XFlush(ui->display); const char *label = btn->label; if (strcmp(label, "C") == 0) { @@ -283,10 +294,10 @@ void handle_button_release(Display *dpy, Window wnd, GC gc, int mx, int my, XftC append_to_input(label[0]); } - control_expose(dpy, wnd, gc, &(XEvent){.type = Expose}, col, f, df, pf); + control_expose(ui, &(XEvent){.type = Expose}); } -void handle_key_press(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor *col, XftFont *f, XftFont *df, XftFont *pf) { +void handle_key_press(UiSystem *ui, XEvent *event) { KeySym keysym; char buf[32]; int len; @@ -369,21 +380,21 @@ void handle_key_press(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor * return; redraw: - control_expose(dpy, wnd, gc, &(XEvent){.type = Expose}, col, f, df, pf); + control_expose(ui, &(XEvent){.type = Expose}); } -// void handle_mouse_hover(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor *col, XftFont *f) { +// void handle_mouse_hover(UiSystem *ui, XEvent *event) { // SuwaButton *hover = find_button_at(event->xmotion.x, event->xmotion.y); // if (hover != hovered_btn) { // if (hovered_btn) { // hovered_btn->pressed = 0; -// redraw_single_button(dpy, wnd, gc, col, f, hovered_btn); +// redraw_single_button(&ui, hovered_btn); // } // hovered_btn = hover; // if (hovered_btn) { -// redraw_single_button(dpy, wnd, gc, col, f, hovered_btn); +// redraw_single_button(&ui, hovered_btn); // } // } // } diff --git a/src/control.h b/src/control.h index e313856..c8d430a 100644 --- a/src/control.h +++ b/src/control.h @@ -1,10 +1,9 @@ #pragma once -#include -#include +#include "ui.h" -void control_expose(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor *color, XftFont *f, XftFont *df, XftFont *pf); -void handle_button_press(Display *dpy, GC gc, int mx, int my, XftColor *col, XftFont *f); -void handle_button_release(Display *dpy, Window wnd, GC gc, int mx, int my, XftColor *col, XftFont *f, XftFont *df, XftFont *pf); -void handle_key_press(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor *col, XftFont *f, XftFont *df, XftFont *pf); -void handle_mouse_hover(Display *dpy, Window wnd, GC gc, XEvent *event, XftColor *col, XftFont *f); +void control_expose(UiSystem *ui, XEvent *event); +void handle_button_press(UiSystem *ui, int mx, int my); +void handle_button_release(UiSystem *ui, int mx, int my); +void handle_key_press(UiSystem *ui, XEvent *event); +void handle_mouse_hover(UiSystem *ui, XEvent *event); diff --git a/src/display.c b/src/display.c index 0080708..d6ae93d 100644 --- a/src/display.c +++ b/src/display.c @@ -3,28 +3,28 @@ #include -void drawbuttons(Display *dpy, Drawable target, GC gc, SuwaButton *btn, - XftDraw *xftdraw, XftColor *textcolor, XftFont *font) { +void drawbuttons(UiSystem *ui, SuwaButton *btn, XftDraw *xftdraw) { unsigned long curbg = btn->pressed ? BTSEL : BTCOL; - XSetForeground(dpy, gc, curbg); - XFillRectangle(dpy, target, gc, btn->x, btn->y, btn->width, btn->height); + XSetForeground(ui->display, ui->gc, curbg); + XFillRectangle(ui->display, ui->target, ui->gc, btn->x, btn->y, btn->width, btn->height); // 文字の中央に - if (btn->label && font && xftdraw) { + if (btn->label && ui->font && xftdraw) { const FcChar8 *str = (const FcChar8 *)btn->label; int len = strlen((const char *)str); XGlyphInfo extents; - XftTextExtentsUtf8(dpy, font, str, len, &extents); + XftTextExtentsUtf8(ui->display, ui->font, str, len, &extents); int text_w = extents.xOff; - int text_h = font->ascent + font->descent; + int text_h = ui->font->ascent + ui->font->descent; int tx = btn->x + (btn->width - text_w) / 2; - int ty = btn->y + (btn->height - text_h) / 2 + font->ascent; + int ty = btn->y + (btn->height - text_h) / 2 + ui->font->ascent; // tx -= extents.x; - XftDrawStringUtf8(xftdraw, textcolor, font, tx, ty, (FcChar8 *)btn->label, len); + XftDrawStringUtf8(xftdraw, &ui->textcolor, ui->font, tx, ty, + (FcChar8 *)btn->label, len); } } diff --git a/src/display.h b/src/display.h index f164249..c67db60 100644 --- a/src/display.h +++ b/src/display.h @@ -1,6 +1,6 @@ #pragma once #include "program.h" +#include "ui.h" -void drawbuttons(Display *dpy, Drawable target, GC gc, SuwaButton *btn, - XftDraw *xftdraw, XftColor *textcolor, XftFont *font); +void drawbuttons(UiSystem *ui, SuwaButton *btn, XftDraw *xftdraw); diff --git a/src/program.h b/src/program.h index 67b0dc2..9b6cf45 100644 --- a/src/program.h +++ b/src/program.h @@ -1,7 +1,5 @@ #pragma once -#include -#include #include "ui.h" #define FGCOL 0xfcfcfc @@ -17,6 +15,5 @@ extern char displayprb[128]; extern char curinput[256]; extern char displaytxt[64]; extern int input_pos; -extern Pixmap backbuf; extern SuwaButton *hovered_btn; extern SuwaButton *pressed_btn; diff --git a/src/ui.h b/src/ui.h index 7a3236f..66cb489 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,5 +1,21 @@ #pragma once +#include +#include + +typedef struct { + Display *display; + Window window; + Drawable target; + GC gc; + Visual visual; + XftDraw *xftdraw; + XftColor color, btncolor, textcolor; + XftFont *font, *prbfont, *disfont; + Colormap colormap; + Pixmap backbuf; +} UiSystem; + typedef struct { int x, y, width, height; const char *label; diff --git a/src/utils.c b/src/utils.c index db9a542..7c2bb44 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,19 +1,18 @@ #include "utils.h" -void cleanup(Display *display, Window window, GC gc, - XftColor *color, XftColor *btncolor, XftFont *font, - XftFont *disfont, XftFont *prbfont, Colormap colormap, Visual *visual, - Pixmap backbuf) { - if (btncolor) XftColorFree(display, visual, colormap, btncolor); - if (color) XftColorFree(display, visual, colormap, color); - if (disfont) XftFontClose(display, disfont); - if (prbfont) XftFontClose(display, prbfont); - if (font) XftFontClose(display, font); - if (gc) XFreeGC(display, gc); - if (backbuf) { - XFreePixmap(display, backbuf); - backbuf = None; +void cleanup(UiSystem *ui) { + if (ui->btncolor.pixel != 0) + XftColorFree(ui->display, &ui->visual, ui->colormap, &ui->btncolor); + if (ui->color.pixel != 0) + XftColorFree(ui->display, &ui->visual, ui->colormap, &ui->color); + if (ui->disfont) XftFontClose(ui->display, ui->disfont); + if (ui->prbfont) XftFontClose(ui->display, ui->prbfont); + if (ui->font) XftFontClose(ui->display, ui->font); + if (ui->gc) XFreeGC(ui->display, ui->gc); + if (ui->backbuf) { + XFreePixmap(ui->display, ui->backbuf); + ui->backbuf = None; } - if (window) XDestroyWindow(display, window); - if (display) XCloseDisplay(display); + if (ui->window) XDestroyWindow(ui->display, ui->window); + if (ui->display) XCloseDisplay(ui->display); } diff --git a/src/utils.h b/src/utils.h index fdf356f..b97648f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -2,7 +2,4 @@ #include "program.h" -void cleanup(Display *display, Window window, GC gc, - XftColor *color, XftColor *btncolor, XftFont *font, - XftFont *disfont, XftFont *prbfont, Colormap colormap, Visual *visual, - Pixmap backbuf); +void cleanup(UiSystem *ui);