X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=bd98c9d0b9ab5dc1c13d1a953149e0f2df0d28e0;hb=8e5c5f067be2b08dfa8f6ebc9e9582d8c0c57131;hp=334dad34be1d3c4db9141792006d069c4ab53d43;hpb=759e9ab081cd59dd8658f958820b664aafc1d20c;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 334dad3..bd98c9d 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -112,15 +112,17 @@ static const char *buildstr = SPECTRWM_BUILDSTR; static const char *buildstr = SPECTRWM_VERSION; #endif -#if RANDR_MAJOR < 1 -# error XRandR versions less than 1.0 are not supported +#if !defined(__CYGWIN__) /* cygwin chokes on xrandr stuff */ +# if RANDR_MAJOR < 1 +# error XRandR versions less than 1.0 are not supported #endif -#if RANDR_MAJOR >= 1 -#if RANDR_MINOR >= 2 -#define SWM_XRR_HAS_CRTC -#endif -#endif +# if RANDR_MAJOR >= 1 +# if RANDR_MINOR >= 2 +# define SWM_XRR_HAS_CRTC +# endif +# endif +#endif /* __CYGWIN__ */ #ifndef XCB_ICCCM_NUM_WM_HINTS_ELEMENTS #define XCB_ICCCM_SIZE_HINT_P_MIN_SIZE XCB_SIZE_HINT_P_MIN_SIZE @@ -323,11 +325,11 @@ double dialog_ratio = 0.6; #define SWM_BAR_JUSTIFY_CENTER (1) #define SWM_BAR_JUSTIFY_RIGHT (2) #define SWM_BAR_OFFSET (4) -#define SWM_BAR_FONTS "-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*," \ - "-*-profont-*-*-*-*-*-*-*-*-*-*-*-*," \ - "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*," \ - "-misc-fixed-medium-r-*-*-*-*-*-*-*-*-*-*," \ - "-*-*-*-r-*--*-*-*-*-*-*-*-*" +#define SWM_BAR_FONTS "-*-terminus-medium-*-*-*-12-*-*-*-*-*-*-*," \ + "-*-profont-*-*-*-*-12-*-*-*-*-*-*-*," \ + "-*-times-medium-r-*-*-12-*-*-*-*-*-*-*," \ + "-misc-fixed-medium-r-*-*-12-*-*-*-*-*-*-*," \ + "-*-*-*-r-*-*-*-*-*-*-*-*-*-*" #ifdef X_HAVE_UTF8_STRING #define DRAWSTRING(x...) Xutf8DrawString(x) @@ -371,7 +373,7 @@ pid_t bar_pid; XFontSet bar_fs; XFontSetExtents *bar_fs_extents; XftFont *bar_font; -int bar_font_legacy = 0; +int bar_font_legacy = 1; char *bar_fonts; XftColor bar_font_color; struct passwd *pwd; @@ -704,6 +706,7 @@ int parse_rgb(const char *, uint16_t *, uint16_t *, uint16_t *); void propertynotify(xcb_property_notify_event_t *); void spawn_select(struct swm_region *, union arg *, char *, int *); void screenchange(xcb_randr_screen_change_notify_event_t *); +void shutdown_cleanup(void); void store_float_geom(struct ws_win *, struct swm_region *); void unmanage_window(struct ws_win *); void unmapnotify(xcb_unmap_notify_event_t *); @@ -1494,12 +1497,6 @@ bar_print(struct swm_region *r, const char *s) sizeof(rect), &rect); /* draw back buffer */ -#if 0 - gcv[0] = r->s->c[SWM_S_COLOR_BAR].pixel; - xcb_change_gc(conn, r->s->bar_gc, XCB_GC_BACKGROUND, gcv); - gcv[0] = r->s->c[SWM_S_COLOR_BAR_FONT].pixel; - xcb_change_gc(conn, r->s->bar_gc, XCB_GC_FOREGROUND, gcv); -#endif draw = XftDrawCreate(display, r->bar->buffer, DefaultVisual(display, r->s->idx), DefaultColormap(display, r->s->idx)); @@ -2415,29 +2412,12 @@ void restart(struct swm_region *r, union arg *args) { /* suppress unused warning since var is needed */ + (void)r; (void)args; DNPRINTF(SWM_D_MISC, "restart: %s\n", start_argv[0]); - /* disable alarm because the following code may not be interrupted */ - alarm(0); - if (signal(SIGALRM, SIG_IGN) == SIG_ERR) - err(1, "can't disable alarm"); - - bar_extra_stop(); - bar_extra = 1; - unmap_all(); - - if (bar_font_legacy) - XFreeFontSet(display, bar_fs); - else { - XftFontClose(display, bar_font); - XftColorFree(display, DefaultVisual(display, r->s->idx), - DefaultColormap(display, r->s->idx), &bar_font_color); - } - xcb_key_symbols_free(syms); - xcb_flush(conn); - xcb_disconnect(conn); + shutdown_cleanup(); execvp(start_argv[0], start_argv); warn("execvp failed"); @@ -4091,7 +4071,7 @@ search_win(struct swm_region *r, union arg *args) struct ws_win *win = NULL; struct search_window *sw = NULL; xcb_window_t w; - uint32_t gcv, wa[2]; + uint32_t wa[2]; int i, width, height; char s[8]; FILE *lfile; @@ -4170,12 +4150,6 @@ search_win(struct swm_region *r, union arg *args) XFreeGC(display, l_draw); } else { -#if 0 - sw->gc = xcb_generate_id(conn); - gcv = 0; - xcb_create_gc(conn, sw->gc, w, XCB_GC_GRAPHICS_EXPOSURES, - &gcv); -#endif draw = XftDrawCreate(display, w, DefaultVisual(display, r->s->idx), @@ -4186,7 +4160,6 @@ search_win(struct swm_region *r, union arg *args) bar_font->descent, (FcChar8 *)s, len); XftDrawDestroy(draw); -/* xcb_free_gc(conn, sw->gc);*/ } DNPRINTF(SWM_D_MISC, "search_win: mapped window: 0x%x\n", w); @@ -6072,8 +6045,19 @@ setconfvalue(char *selector, char *value, int flags) "memory for bar_fonts."); free(b); - if (isxlfd(value)) - bar_font_legacy = 1; + /* If already in xft mode, then we are done. */ + if (!bar_font_legacy) + break; + + /* If there are any non-XLFD entries, switch to Xft mode. */ + while ((b = strsep(&value, ",")) != NULL) { + if (*b == '\0') + continue; + if (!isxlfd(b)) { + bar_font_legacy = 0; + break; + } + } break; case SWM_S_BAR_FORMAT: free(bar_format); @@ -8063,6 +8047,42 @@ workaround(void) } void +shutdown_cleanup(void) +{ + int i, num_screens; + + /* disable alarm because the following code may not be interrupted */ + alarm(0); + if (signal(SIGALRM, SIG_IGN) == SIG_ERR) + err(1, "can't disable alarm"); + + bar_extra_stop(); + bar_extra = 1; + unmap_all(); + + teardown_ewmh(); + + num_screens = xcb_setup_roots_length(xcb_get_setup(conn)); + for (i = 0; i < num_screens; ++i) { + if (screens[i].bar_gc != 0) + xcb_free_gc(conn, screens[i].bar_gc); + if (!bar_font_legacy) + XftColorFree(display, DefaultVisual(display, i), + DefaultColormap(display, i), &bar_font_color); + } + + if (bar_font_legacy) + XFreeFontSet(display, bar_fs); + else { + XftFontClose(display, bar_font); + } + + xcb_key_symbols_free(syms); + xcb_flush(conn); + xcb_disconnect(conn); +} + +void event_error(xcb_generic_error_t *e) { (void)e; @@ -8167,9 +8187,6 @@ main(int argc, char *argv[]) sact.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sact, NULL); - if (!X_HAVE_UTF8_STRING) - warnx("no UTF-8 support"); - if (!(display = XOpenDisplay(0))) errx(1, "can not open display"); @@ -8322,23 +8339,7 @@ noconfig: } } done: - teardown_ewmh(); - bar_extra_stop(); - - for (i = 0; i < num_screens; ++i) - if (screens[i].bar_gc != 0) - xcb_free_gc(conn, screens[i].bar_gc); - - if (bar_font_legacy) { - XFreeFontSet(display, bar_fs); - } else { - XftFontClose(display, bar_font); - XftColorFree(display, DefaultVisual(display, r->s->idx), - DefaultColormap(display, r->s->idx), &bar_font_color); - } - xcb_key_symbols_free(syms); - xcb_flush(conn); - xcb_disconnect(conn); + shutdown_cleanup(); return (0); }