From 3d5f435be71525e56769d7a942f64d88a132508e Mon Sep 17 00:00:00 2001 From: kojima Date: Sun, 30 May 1999 05:02:55 +0000 Subject: [PATCH] fixed cosmetic bug in geom. dpy window for 8bpp removed --enable-kanji and added MultiByteText option rewrote font code to use WINGs made autoraise only work for the active window fixed compilation problem with OpenWindows and other non-X11R6 systems.. --- src/Makefile.in | 1 + src/WindowMaker.h | 1 + src/appicon.c | 69 ++++------ src/balloon.c | 26 ++-- src/config.h.in | 3 - src/defaults.c | 82 +++++------- src/dock.c | 23 ++-- src/event.c | 3 +- src/framewin.c | 391 +++++++++--------------------------------------------- src/framewin.h | 4 +- src/funcs.h | 20 +-- src/icon.c | 10 +- src/main.c | 2 +- src/menu.c | 26 ++-- src/misc.c | 43 ++---- src/moveres.c | 52 ++++---- src/placement.c | 2 +- src/resources.c | 92 ------------- src/resources.h | 3 +- src/screen.c | 6 +- src/screen.h | 25 +--- src/text.c | 42 ++---- src/text.h | 2 +- src/workspace.c | 20 +-- 24 files changed, 238 insertions(+), 710 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index a7be89f4..1bf752f4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -89,6 +89,7 @@ XGETTEXT = @XGETTEXT@ XLFLAGS = @XLFLAGS@ XLIBS = @XLIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBRARY_PATH = @X_LIBRARY_PATH@ wprefsdir = @wprefsdir@ AUTOMAKE_OPTIONS = no-dependencies diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 210950eb..5a94c7a8 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -317,6 +317,7 @@ typedef struct WPreferences { char title_shadow; #endif + char multi_byte_text; #ifdef KEEP_XKB_LOCK_STATUS char modelock; #endif diff --git a/src/appicon.c b/src/appicon.c index e55e8574..73149426 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -330,46 +330,35 @@ wAppIconMove(WAppIcon *aicon, int x, int y) static void updateDockNumbers(WScreen *scr) { - int length; - char *ws_numbers; - GC numbers_gc; - XGCValues my_gc_values; - unsigned long my_v_mask = (GCForeground); - WAppIcon *dicon = scr->dock->icon_array[0]; - - my_gc_values.foreground = scr->white_pixel; - numbers_gc = XCreateGC(dpy, dicon->icon->core->window, - my_v_mask, &my_gc_values); - - ws_numbers = malloc(20); - sprintf(ws_numbers, "%i [ %i ]", scr->current_workspace+1, - ((scr->current_workspace/10)+1)); - length = strlen(ws_numbers); - - XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, - scr->icon_title_font->y+1, False); - -#ifndef I18N_MB - XSetFont(dpy, numbers_gc, scr->icon_title_font->font->fid); - XSetForeground(dpy, numbers_gc, scr->black_pixel); - XDrawString(dpy, dicon->icon->core->window, - numbers_gc, 4, scr->icon_title_font->y+3, ws_numbers, length); - XSetForeground(dpy, numbers_gc, scr->white_pixel); - XDrawString(dpy, dicon->icon->core->window, - numbers_gc, 3, scr->icon_title_font->y+2, ws_numbers, length); -#else - XSetForeground(dpy, numbers_gc, scr->black_pixel); - XmbDrawString(dpy, dicon->icon->core->window, - scr->icon_title_font->font, numbers_gc, 4, - scr->icon_title_font->y+3, ws_numbers, length); - XSetForeground(dpy, numbers_gc, scr->white_pixel); - XmbDrawString(dpy, dicon->icon->core->window, - scr->icon_title_font->font, numbers_gc, 3, - scr->icon_title_font->y+2, ws_numbers, length); -#endif /* I18N_MB */ - - XFreeGC(dpy, numbers_gc); - free(ws_numbers); + int length; + char *ws_numbers; + GC numbers_gc; + XGCValues my_gc_values; + unsigned long my_v_mask = (GCForeground); + WAppIcon *dicon = scr->dock->icon_array[0]; + + my_gc_values.foreground = scr->white_pixel; + numbers_gc = XCreateGC(dpy, dicon->icon->core->window, + my_v_mask, &my_gc_values); + + ws_numbers = malloc(20); + sprintf(ws_numbers, "%i [ %i ]", scr->current_workspace+1, + ((scr->current_workspace/10)+1)); + length = strlen(ws_numbers); + + XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, + scr->icon_title_font->y+1, False); + + XSetForeground(dpy, numbers_gc, scr->black_pixel); + WMDrawString(scr->wmscreen, dicon->icon->core->window, numbers_gc, + scr->icon_title_font->font, 4, 3, ws_numbers, length); + + XSetForeground(dpy, numbers_gc, scr->white_pixel); + WMDrawString(scr->wmscreen, dicon->icon->core->window, numbers_gc, + scr->icon_title_font->font, 3, 2, ws_numbers, length); + + XFreeGC(dpy, numbers_gc); + free(ws_numbers); } #endif /* WS_INDICATOR */ diff --git a/src/balloon.c b/src/balloon.c index 695082fa..f5ff2531 100644 --- a/src/balloon.c +++ b/src/balloon.c @@ -170,7 +170,7 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) int height; Pixmap pixmap; Pixmap mask; - WFont *font = scr->info_text_font; + WMFont *font = scr->info_text_font; int side = 0; int ty; int bx, by; @@ -178,8 +178,8 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) if (scr->balloon->contents) XFreePixmap(dpy, scr->balloon->contents); - width = wTextWidth(font->font, text, strlen(text))+16; - height = font->height + 4; + width = WMWidthOfString(font, text, strlen(text))+16; + height = WMFontHeight(font) + 4; if (height < 16) height = 16; @@ -212,13 +212,13 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) XSetForeground(dpy, scr->info_text_gc, scr->black_pixel); - wDrawString(pixmap, font, scr->info_text_gc, 8, - ty + font->y + (height - font->height)/2, - text, strlen(text)); + WMDrawString(scr->wmscreen, pixmap, scr->info_text_gc, font, 8, + ty + (height - WMFontHeight(font))/2, + text, strlen(text)); XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap); scr->balloon->contents = pixmap; - + XResizeWindow(dpy, scr->balloon->window, width, height+SPACE); XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask, ShapeSet); @@ -235,13 +235,13 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) int width; int height; Pixmap pixmap; - WFont *font = scr->info_text_font; + WMFont *font = scr->info_text_font; if (scr->balloon->contents) XFreePixmap(dpy, scr->balloon->contents); - width = wTextWidth(font->font, text, strlen(text))+8; - height = font->height + 4; + width = WMWidthOfString(font, text, strlen(text))+8; + height = WMFontHeight(font) + 4; if (x < 0) x = 0; @@ -267,9 +267,9 @@ showText(WScreen *scr, int x, int y, int h, int w, char *text) XSetForeground(dpy, scr->info_text_gc, scr->window_title_pixel[0]); - wDrawString(pixmap, font->font, scr->info_text_gc, 4, font->y+2, text, - strlen(text)); - + WMDrawString(scr->wmscreen, pixmap, scr->info_text_gc, font, + 4, 2, text, strlen(text)); + XResizeWindow(dpy, scr->balloon->window, width, height); XMoveWindow(dpy, scr->balloon->window, x, y); diff --git a/src/config.h.in b/src/config.h.in index 4574bb9a..0241259f 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -99,9 +99,6 @@ * set by configure */ #undef I18N -/* Multi-byte (japanese, korean, chinese etc.) character support */ -#undef I18N_MB - /* define if you want sound support */ #undef WMSOUND diff --git a/src/defaults.c b/src/defaults.c index 917bdcb3..0ca2590e 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -174,7 +174,7 @@ static int setClipTitleFont(); static int setClipTitleColor(); static int setMenuStyle(); - +static int setMultiByte(); static int updateUsableArea(); @@ -351,6 +351,9 @@ WDefaultEntry staticOptionList[] = { {"DisableMiniwindows", "NO", NULL, &wPreferences.disable_miniwindows, getBool, NULL }, + {"MultiByteText", "NO", NULL, + &wPreferences.multi_byte_text, getBool, setMultiByte + } }; @@ -2104,14 +2107,14 @@ static int getFont(WScreen *scr, WDefaultEntry *entry, proplist_t value, void *addr, void **ret) { - static WFont *font; + static WMFont *font; char *val; STRINGP("Font"); val = PLGetString(value); - font = wLoadFont(val); + font = WMCreateFont(scr->wmscreen, val); if (!font) { wfatal(_("could not load any usable font!!!")); exit(1); @@ -2416,106 +2419,77 @@ setIconTile(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo) static int -setWinTitleFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setWinTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->title_font) { - wFreeFont(scr->title_font); + WMReleaseFont(scr->title_font); } - scr->title_font = font; - -#ifndef I18N_MB - XSetFont(dpy, scr->window_title_gc, font->font->fid); -#endif return REFRESH_WINDOW_FONT|REFRESH_BUTTON_IMAGES; } static int -setMenuTitleFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setMenuTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->menu_title_font) { - wFreeFont(scr->menu_title_font); + WMReleaseFont(scr->menu_title_font); } scr->menu_title_font = font; -#ifndef I18N_MB - XSetFont(dpy, scr->menu_title_gc, font->font->fid); -#endif - return REFRESH_MENU_TITLE_FONT; } static int -setMenuTextFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setMenuTextFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->menu_entry_font) { - wFreeFont(scr->menu_entry_font); - } - + WMReleaseFont(scr->menu_entry_font); + } scr->menu_entry_font = font; -#ifndef I18N_MB - XSetFont(dpy, scr->menu_entry_gc, font->font->fid); - XSetFont(dpy, scr->disabled_menu_entry_gc, font->font->fid); - XSetFont(dpy, scr->select_menu_gc, font->font->fid); -#endif - return REFRESH_MENU_FONT; } static int -setIconTitleFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setIconTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->icon_title_font) { - wFreeFont(scr->icon_title_font); + WMReleaseFont(scr->icon_title_font); } scr->icon_title_font = font; - -#ifndef I18N_MB - XSetFont(dpy, scr->icon_title_gc, font->font->fid); -#endif return REFRESH_ICON_FONT; } static int -setClipTitleFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setClipTitleFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->clip_title_font) { - wFreeFont(scr->clip_title_font); + WMReleaseFont(scr->clip_title_font); } scr->clip_title_font = font; -#ifndef I18N_MB - XSetFont(dpy, scr->clip_title_gc, font->font->fid); -#endif - return REFRESH_ICON_FONT; } static int -setDisplayFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setDisplayFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->info_text_font) { - wFreeFont(scr->info_text_font); + WMReleaseFont(scr->info_text_font); } - - scr->info_text_font = font; -#ifndef I18N_MB - XSetFont(dpy, scr->info_text_gc, font->font->fid); - XSetFont(dpy, scr->line_gc, font->font->fid); -#endif + scr->info_text_font = font; /* This test works because the scr structure is initially zeroed out and None = 0. Any other time, the window should be valid. */ @@ -2531,10 +2505,10 @@ setDisplayFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) static int -setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, WFont *font, void *foo) +setLargeDisplayFont(WScreen *scr, WDefaultEntry *entry, WMFont *font, void *foo) { if (scr->workspace_name_font) { - wFreeFont(scr->workspace_name_font); + WMReleaseFont(scr->workspace_name_font); } scr->workspace_name_font = font; @@ -3044,3 +3018,15 @@ setDoubleClick(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) return 0; } + + +static int +setMultiByte(WScreen *scr, WDefaultEntry *entry, int *value, void *foo) +{ + extern _WINGsConfiguration WINGsConfiguration; + + WINGsConfiguration.useMultiByte = *value; + + return 0; +} + diff --git a/src/dock.c b/src/dock.c index 2d3f62e8..bd5b54a5 100644 --- a/src/dock.c +++ b/src/dock.c @@ -1265,17 +1265,18 @@ wClipIconPaint(WAppIcon *aicon) else XSetForeground(dpy, gc, scr->clip_title_pixel[CLIP_COLLAPSED]); - ty = ICON_SIZE - scr->clip_title_font->height - 3; + ty = ICON_SIZE - WMFontHeight(scr->clip_title_font) - 3; tx = CLIP_BUTTON_SIZE*ICON_SIZE/64; - wDrawString(win, scr->clip_title_font, gc, tx, - ty + scr->clip_title_font->y, ws_name, length); + WMDrawString(scr->wmscreen, win, gc, scr->clip_title_font, tx, + ty, ws_name, length); - tx = (ICON_SIZE/2 - wTextWidth(scr->clip_title_font->font, ws_number, nlength))/2; + tx = (ICON_SIZE/2 - WMWidthOfString(scr->clip_title_font, ws_number, + nlength))/2; - wDrawString(win, scr->clip_title_font, gc, tx, - scr->clip_title_font->y + 2, ws_number, nlength); + WMDrawString(scr->wmscreen, win, gc, scr->clip_title_font, tx, + 2, ws_number, nlength); free(ws_name); @@ -4066,13 +4067,13 @@ showClipBalloon(WDock *dock, int workspace) text = scr->workspaces[workspace]->name; - w = wTextWidth(scr->clip_title_font->font, text, strlen(text)); + w = WMWidthOfString(scr->clip_title_font, text, strlen(text)); - h = scr->clip_title_font->height; + h = WMFontHeight(scr->clip_title_font); XResizeWindow(dpy, scr->clip_balloon, w, h); x = dock->x_pos + CLIP_BUTTON_SIZE*ICON_SIZE/64; - y = dock->y_pos + ICON_SIZE-scr->clip_title_font->height - 3; + y = dock->y_pos + ICON_SIZE - WMFontHeight(scr->clip_title_font) - 3; if (x+w > scr->scr_width) { x = scr->scr_width - w; @@ -4090,8 +4091,8 @@ showClipBalloon(WDock *dock, int workspace) XSetForeground(dpy, scr->clip_title_gc, scr->clip_title_pixel[CLIP_NORMAL]); XClearWindow(dpy, scr->clip_balloon); - wDrawString(scr->clip_balloon, scr->clip_title_font, scr->clip_title_gc, - 0, scr->clip_title_font->y, text, strlen(text)); + WMDrawString(scr->wmscreen, scr->clip_balloon, scr->clip_title_gc, + scr->clip_title_font, 0, 0, text, strlen(text)); } diff --git a/src/event.c b/src/event.c index 99b4a4de..80dd12b3 100644 --- a/src/event.c +++ b/src/event.c @@ -409,7 +409,6 @@ handleDeadProcess(void *foo) static void saveTimestamp(XEvent *event) { - WScreen *scr = wScreenForWindow(event->xany.window); LastTimestamp = CurrentTime; switch (event->type) { @@ -973,7 +972,7 @@ raiseWindow(WScreen *scr) if (!wwin) return; - if (!wwin->flags.destroyed) { + if (!wwin->flags.destroyed && wwin->flags.focused) { wRaiseFrame(wwin->frame->core); /* this is needed or a race condition will occur */ XSync(dpy, False); diff --git a/src/framewin.c b/src/framewin.c index a5aa87df..2ed11437 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -23,9 +23,6 @@ #include #include -#ifdef KEEP_XKB_LOCK_STATUS -#include -#endif /* KEEP_XKB_LOCK_STATUS */ #include #include @@ -65,7 +62,7 @@ WFrameWindow* wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, int width, int height, int flags, WTexture **title_texture, WTexture **resize_texture, - unsigned long *color, GC *gc, WFont **font) + unsigned long *color, GC *gc, WMFont **font) { WFrameWindow *fwin; @@ -81,10 +78,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, fwin->title_pixel = color; fwin->title_gc = gc; fwin->font = font; -#ifdef KEEP_XKB_LOCK_STATUS - fwin->languagemode = XkbGroup1Index; - fwin->last_languagemode = XkbGroup2Index; -#endif fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, FRAME_BORDER_WIDTH); @@ -129,7 +122,7 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) height = fwin->core->height - fwin->top_width - fwin->bottom_width; if (flags & WFF_TITLEBAR) - theight = (*fwin->font)->height + TITLEBAR_EXTRA_HEIGHT; + theight = WMFontHeight(*fwin->font) + TITLEBAR_EXTRA_HEIGHT; else theight = 0; @@ -151,16 +144,6 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) if (fwin->left_button) { wCoreConfigure(fwin->left_button, 0, 0, bsize, bsize); } -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - if (fwin->flags.hide_left_button || !fwin->left_button - || fwin->flags.lbutton_dont_fit) { - wCoreConfigure(fwin->language_button, 0, 0, bsize, bsize); - } else { - wCoreConfigure(fwin->language_button, bsize, 0, bsize, bsize); - } -#endif - if (fwin->right_button) { wCoreConfigure(fwin->right_button, width-bsize+1, @@ -171,14 +154,6 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) wCoreConfigure(fwin->left_button, 3, (theight-bsize)/2, bsize, bsize); } - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - wCoreConfigure(fwin->language_button, 6 + bsize, (theight-bsize)/2, - bsize, bsize); - - } -#endif if (fwin->right_button) { wCoreConfigure(fwin->right_button, width-bsize-3, @@ -189,25 +164,16 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) } else { /* we had a titlebar, but now we don't need it anymore */ for (i=0; i < (fwin->flags.single_texture ? 1 : 3); i++) { - FREE_PIXMAP(fwin->title_back[i]); - if (wPreferences.new_style) { - FREE_PIXMAP(fwin->lbutton_back[i]); - FREE_PIXMAP(fwin->rbutton_back[i]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[i]); -#endif - } + FREE_PIXMAP(fwin->title_back[i]); + if (wPreferences.new_style) { + FREE_PIXMAP(fwin->lbutton_back[i]); + FREE_PIXMAP(fwin->rbutton_back[i]); + } } if (fwin->left_button) wCoreDestroy(fwin->left_button); fwin->left_button = NULL; -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - wCoreDestroy(fwin->language_button); - fwin->language_button = NULL; -#endif - if (fwin->right_button) wCoreDestroy(fwin->right_button); fwin->right_button = NULL; @@ -227,59 +193,31 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) fwin->titlebar = wCoreCreate(fwin->core, 0, 0, width+1, theight); if (flags & WFF_LEFT_BUTTON) { - fwin->flags.left_button = 1; - if (wPreferences.new_style) { - fwin->left_button = wCoreCreate(fwin->core, 0, 0, - bsize, bsize); - if (width < theight*4) { - fwin->flags.lbutton_dont_fit = 1; + fwin->flags.left_button = 1; + if (wPreferences.new_style) { + fwin->left_button = wCoreCreate(fwin->core, 0, 0, + bsize, bsize); + if (width < theight*4) { + fwin->flags.lbutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->left_button->window); + } } else { - XMapRaised(dpy, fwin->left_button->window); - } - } else { - fwin->left_button = - wCoreCreate(fwin->titlebar, 3, (theight-bsize)/2, - bsize, bsize); + fwin->left_button = + wCoreCreate(fwin->titlebar, 3, (theight-bsize)/2, + bsize, bsize); - XSetWindowBackground(dpy, fwin->left_button->window, - scr->widget_texture->normal.pixel); + XSetWindowBackground(dpy, fwin->left_button->window, + scr->widget_texture->normal.pixel); - if (width < theight*3) { - fwin->flags.lbutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->left_button->window); + if (width < theight*3) { + fwin->flags.lbutton_dont_fit = 1; + } else { + XMapRaised(dpy, fwin->left_button->window); + } } - } } - -#ifdef XKB_BUTTON_HINT - if (flags & WFF_LANGUAGE_BUTTON) { - fwin->flags.language_button = 1; - if (wPreferences.new_style) { - fwin->language_button = wCoreCreate(fwin->core, - bsize, 0, bsize, bsize); - - if (width < theight*4) { - fwin->flags.languagebutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->language_button->window); - } - } else { - fwin->language_button = - wCoreCreate(fwin->titlebar, bsize + 6, (theight-bsize)/2, - bsize, bsize); - - XSetWindowBackground(dpy, fwin->language_button->window, - scr->widget_texture->normal.pixel); - - if (width < theight*3) { - fwin->flags.languagebutton_dont_fit = 1; - } else { - XMapRaised(dpy, fwin->language_button->window); - } - } - } -#endif + if (flags & WFF_RIGHT_BUTTON) { fwin->flags.right_button = 1; @@ -378,16 +316,6 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) fwin->left_button->descriptor.handle_mousedown = buttonMouseDown; } -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - fwin->language_button->descriptor.handle_expose = handleButtonExpose; - fwin->language_button->descriptor.parent = fwin; - fwin->language_button->descriptor.parent_type = WCLASS_FRAME; - fwin->language_button->descriptor.handle_mousedown = buttonMouseDown; - } -#endif - - if (fwin->right_button) { fwin->right_button->descriptor.parent = fwin; fwin->right_button->descriptor.parent_type = WCLASS_FRAME; @@ -408,11 +336,6 @@ wFrameWindowDestroy(WFrameWindow *fwin) if (fwin->left_button) wCoreDestroy(fwin->left_button); -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - wCoreDestroy(fwin->language_button); -#endif - if (fwin->right_button) wCoreDestroy(fwin->right_button); @@ -433,9 +356,6 @@ wFrameWindowDestroy(WFrameWindow *fwin) FREE_PIXMAP(fwin->title_back[i]); if (wPreferences.new_style) { FREE_PIXMAP(fwin->lbutton_back[i]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[i]); -#endif FREE_PIXMAP(fwin->rbutton_back[i]); } } @@ -463,7 +383,7 @@ updateTitlebar(WFrameWindow *fwin) int x, w; int theight; - theight = (*fwin->font)->height + TITLEBAR_EXTRA_HEIGHT; + theight = WMFontHeight(*fwin->font) + TITLEBAR_EXTRA_HEIGHT; x = 0; w = fwin->core->width + 1; @@ -472,50 +392,11 @@ updateTitlebar(WFrameWindow *fwin) if (fwin->flags.hide_left_button || !fwin->left_button || fwin->flags.lbutton_dont_fit) { x = 0; -#ifdef XKB_BUTTON_HINT - if(fwin->language_button) - wCoreConfigure(fwin->language_button, 0, 0, - fwin->language_button->width, - fwin->language_button->width); -#endif } else { -#ifdef XKB_BUTTON_HINT - if(fwin->language_button) - wCoreConfigure(fwin->language_button, fwin->left_button->width, 0, - fwin->language_button->width, - fwin->language_button->width); -#endif x = fwin->left_button->width; w -= fwin->left_button->width; } -#ifdef XKB_BUTTON_HINT - if (fwin->flags.hide_language_button || !fwin->language_button - || fwin->flags.languagebutton_dont_fit) { - } else { - x += fwin->language_button->width; - w -= fwin->language_button->width; - } -#endif } -#ifdef XKB_BUTTON_HINT - else { - int bsize = theight - 7; - if (fwin->flags.hide_left_button || !fwin->left_button - || fwin->flags.lbutton_dont_fit) { - if(fwin->language_button) - wCoreConfigure(fwin->language_button, 3, (theight-bsize)/2, - fwin->language_button->width, - fwin->language_button->width); - } - else { - if(fwin->language_button) - wCoreConfigure(fwin->language_button, - 6 + fwin->left_button->width, (theight-bsize)/2, - fwin->language_button->width, - fwin->language_button->width); - } - } -#endif if (wPreferences.new_style) { if (!fwin->flags.hide_right_button && fwin->right_button @@ -543,24 +424,13 @@ wFrameWindowHideButton(WFrameWindow *fwin, int flags) XUnmapWindow(dpy, fwin->left_button->window); fwin->flags.hide_left_button = 1; } - -#ifdef XKB_BUTTON_HINT - if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button) { - XUnmapWindow(dpy, fwin->language_button->window); - fwin->flags.hide_language_button = 1; - } -#endif if (fwin->titlebar) { if (wPreferences.new_style) { updateTitlebar(fwin); } else { -#ifdef XKB_BUTTON_HINT - updateTitlebar(fwin); -#else XClearWindow(dpy, fwin->titlebar->window); wFrameWindowPaint(fwin); -#endif } checkTitleSize(fwin); } @@ -578,17 +448,6 @@ wFrameWindowShowButton(WFrameWindow *fwin, int flags) fwin->flags.hide_right_button = 0; } - -#ifdef XKB_BUTTON_HINT - if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button - && fwin->flags.hide_language_button) { - - if (!fwin->flags.languagebutton_dont_fit) - XMapWindow(dpy, fwin->language_button->window); - - fwin->flags.hide_language_button = 0; - } -#endif if ((flags & WFF_LEFT_BUTTON) && fwin->left_button && fwin->flags.hide_left_button) { @@ -613,29 +472,17 @@ wFrameWindowShowButton(WFrameWindow *fwin, int flags) static void -#ifdef XKB_BUTTON_HINT -renderTexture(WScreen *scr, WTexture *texture, int width, int height, - int bwidth, int bheight, int left, int language, int right, - Pixmap *title, Pixmap *lbutton, Pixmap *languagebutton, Pixmap *rbutton) -#else renderTexture(WScreen *scr, WTexture *texture, int width, int height, int bwidth, int bheight, int left, int right, Pixmap *title, Pixmap *lbutton, Pixmap *rbutton) -#endif { RImage *img; RImage *limg, *rimg, *mimg; -#ifdef XKB_BUTTON_HINT - RImage *timg; -#endif int x, w; *title = None; *lbutton = None; *rbutton = None; -#ifdef XKB_BUTTON_HINT - *languagebutton = None; -#endif img = wTextureRenderImage(texture, width, height, WREL_FLAT); if (!img) { @@ -651,13 +498,6 @@ renderTexture(WScreen *scr, WTexture *texture, int width, int height, x = 0; w = img->width; - -#ifdef XKB_BUTTON_HINT - if (language) { - timg = RGetSubImage(img, bwidth, 0, bwidth, bheight); - } else - timg = NULL; -#endif if (limg) { RBevelImage(limg, RBEV_RAISED2); @@ -668,18 +508,6 @@ renderTexture(WScreen *scr, WTexture *texture, int width, int height, w -= limg->width; RDestroyImage(limg); } - -#ifdef XKB_BUTTON_HINT - if (timg) { - RBevelImage(timg, RBEV_RAISED2); - if (!RConvertImage(scr->rcontext, timg, languagebutton)) { - wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); - } - x += timg->width; - w -= timg->width; - RDestroyImage(timg); - } -#endif if (right) { rimg = RGetSubImage(img, width - bwidth, 0, bwidth, bheight); @@ -790,12 +618,6 @@ updateTexture(WFrameWindow *fwin) if (fwin->left_button && fwin->lbutton_back[i]) XSetWindowBackgroundPixmap(dpy, fwin->left_button->window, fwin->lbutton_back[i]); - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && fwin->languagebutton_back[i]) - XSetWindowBackgroundPixmap(dpy, fwin->language_button->window, - fwin->languagebutton_back[i]); -#endif if (fwin->right_button && fwin->rbutton_back[i]) XSetWindowBackgroundPixmap(dpy, fwin->right_button->window, @@ -808,11 +630,6 @@ updateTexture(WFrameWindow *fwin) if (fwin->left_button) XSetWindowBackground(dpy, fwin->left_button->window, pixel); -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - XSetWindowBackground(dpy, fwin->language_button->window, - pixel); -#endif if (fwin->right_button) XSetWindowBackground(dpy, fwin->right_button->window, pixel); @@ -824,12 +641,6 @@ updateTexture(WFrameWindow *fwin) XClearWindow(dpy, fwin->left_button->window); handleButtonExpose(&fwin->left_button->descriptor, NULL); } -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - XClearWindow(dpy, fwin->language_button->window); - handleButtonExpose(&fwin->language_button->descriptor, NULL); - } -#endif if (fwin->right_button) { XClearWindow(dpy, fwin->right_button->window); handleButtonExpose(&fwin->right_button->descriptor, NULL); @@ -843,58 +654,35 @@ static void remakeTexture(WFrameWindow *fwin, int state) { Pixmap pmap, lpmap, rpmap; -#ifdef XKB_BUTTON_HINT - Pixmap tpmap; -#endif if (fwin->title_texture[state] && fwin->titlebar) { FREE_PIXMAP(fwin->title_back[state]); if (wPreferences.new_style) { FREE_PIXMAP(fwin->lbutton_back[state]); FREE_PIXMAP(fwin->rbutton_back[state]); -#ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->languagebutton_back[state]); -#endif } if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { int left, right; -#ifdef XKB_BUTTON_HINT - int language; -#endif int width; /* eventually surrounded by if new_style */ left = fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit; -#ifdef XKB_BUTTON_HINT - language = fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit; -#endif right = fwin->right_button && !fwin->flags.hide_right_button && !fwin->flags.rbutton_dont_fit; width = fwin->core->width+1; -#ifdef XKB_BUTTON_HINT - renderTexture(fwin->screen_ptr, fwin->title_texture[state], - width, fwin->titlebar->height, - fwin->titlebar->height, fwin->titlebar->height, - left, language, right, &pmap, &lpmap, &tpmap, &rpmap); -#else renderTexture(fwin->screen_ptr, fwin->title_texture[state], width, fwin->titlebar->height, fwin->titlebar->height, fwin->titlebar->height, left, right, &pmap, &lpmap, &rpmap); -#endif fwin->title_back[state] = pmap; if (wPreferences.new_style) { fwin->lbutton_back[state] = lpmap; fwin->rbutton_back[state] = rpmap; -#ifdef XKB_BUTTON_HINT - fwin->languagebutton_back[state] = tpmap; -#endif } } } @@ -1010,6 +798,7 @@ wFrameWindowPaint(WFrameWindow *fwin) int titlelen; char *title; int allButtons = 1; + WScreen *scr = fwin->screen_ptr; if (!wPreferences.new_style) { @@ -1018,14 +807,6 @@ wFrameWindowPaint(WFrameWindow *fwin) lofs += fwin->left_button->width + 3; else allButtons = 0; - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit) - lofs += fwin->language_button->width; - else - allButtons = 0; -#endif if (fwin->right_button && !fwin->flags.hide_right_button && !fwin->flags.rbutton_dont_fit) @@ -1034,15 +815,26 @@ wFrameWindowPaint(WFrameWindow *fwin) allButtons = 0; } -#ifdef XKB_BUTTON_HINT - fwin->languagebutton_image = - fwin->screen_ptr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; -#endif - +#ifdef XKB_TITLE_HINT + if(fwin->flags.is_client_window_frame) { + char * freebuff; + freebuff = (char *)wmalloc((strlen(fwin->title)+6)*sizeof(char)); + if (fwin->flags.justification == WTJ_RIGHT) + sprintf(freebuff,"%s %s",fwin->title,fwin->languagemode?XKB_ON:XKB_OFF); + else + sprintf(freebuff,"%s %s",fwin->languagemode?XKB_ON:XKB_OFF,fwin->title); + title = ShrinkString(*fwin->font, freebuff, + fwin->titlebar->width - lofs - rofs); + free(freebuff); + } + else title = ShrinkString(*fwin->font, fwin->title, + fwin->titlebar->width - lofs - rofs); +#else title = ShrinkString(*fwin->font, fwin->title, fwin->titlebar->width - lofs - rofs); +#endif /* XKB_TITLE_HINT */ titlelen = strlen(title); - w = wTextWidth((*fwin->font)->font, title, titlelen); + w = WMWidthOfString(*fwin->font, title, titlelen); switch (fwin->flags.justification) { case WTJ_LEFT: @@ -1068,31 +860,25 @@ wFrameWindowPaint(WFrameWindow *fwin) fwin->title_pixel[fwin->flags.state+3]); for(shadowx=0;shadowxtitlebar->window, *fwin->font, - *fwin->title_gc, - x + shadowx + TITLE_TEXT_SHADOW_X_OFFSET, - (*fwin->font)->y + TITLEBAR_EXTRA_HEIGHT/2 - + shadowy + TITLE_TEXT_SHADOW_Y_OFFSET, title, - titlelen); + WMDrawString(scr->wmscreen, fwin->titlebar->window, + *fwin->title_gc, *fwin->font, + x + shadowx + TITLE_TEXT_SHADOW_X_OFFSET, + TITLEBAR_EXTRA_HEIGHT/2 + + shadowy + TITLE_TEXT_SHADOW_Y_OFFSET, title, + titlelen); } #endif /* TITLE_TEXT_SHADOW */ XSetForeground(dpy, *fwin->title_gc, fwin->title_pixel[fwin->flags.state]); - - wDrawString(fwin->titlebar->window, *fwin->font, - *fwin->title_gc, x, - (*fwin->font)->y + TITLEBAR_EXTRA_HEIGHT/2, title, - titlelen); + + WMDrawString(scr->wmscreen, fwin->titlebar->window, *fwin->title_gc, + *fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2, title, titlelen); free(title); if (fwin->left_button) handleButtonExpose(&fwin->left_button->descriptor, NULL); -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) - handleButtonExpose(&fwin->language_button->descriptor, NULL); -#endif if (fwin->right_button) handleButtonExpose(&fwin->right_button->descriptor, NULL); } @@ -1143,24 +929,6 @@ reconfigure(WFrameWindow *fwin, int x, int y, int width, int height, fwin->flags.lbutton_dont_fit = 0; } } - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button) { - if (width < fwin->top_width*k && !fwin->flags.languagebutton_dont_fit) { - - if (!fwin->flags.hide_language_button) { - XUnmapWindow(dpy, fwin->language_button->window); - } - fwin->flags.languagebutton_dont_fit = 1; - } else if (width >= fwin->top_width*k && fwin->flags.languagebutton_dont_fit) { - - if (!fwin->flags.hide_language_button) { - XMapWindow(dpy, fwin->language_button->window); - } - fwin->flags.languagebutton_dont_fit = 0; - } - } -#endif if (fwin->right_button) { if (width < fwin->top_width*2 && !fwin->flags.rbutton_dont_fit) { @@ -1260,16 +1028,6 @@ wFrameWindowUpdatePushButton(WFrameWindow *fwin, Bool pushed) #endif /* OLWM_HINTS */ -#ifdef XKB_BUTTON_HINT -void -wFrameWindowUpdateLanguageButton(WFrameWindow *fwin) -{ - paintButton(fwin->language_button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], - fwin->languagebutton_image, True); -} -#endif /* XKB_BUTTON_HINT */ - /*********************************************************************/ @@ -1310,19 +1068,12 @@ checkTitleSize(WFrameWindow *fwin) if (fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit) width -= fwin->left_button->width + 3; - -#ifdef XKB_BUTTON_HINT - if (fwin->language_button && !fwin->flags.hide_language_button - && !fwin->flags.languagebutton_dont_fit) - width -= fwin->language_button->width + 3; -#endif if (fwin->right_button && !fwin->flags.hide_right_button && !fwin->flags.rbutton_dont_fit) width -= fwin->right_button->width + 3; } - if (wTextWidth((*fwin->font)->font, fwin->title, - strlen(fwin->title)) > width) { + if (WMWidthOfString(*fwin->font, fwin->title, strlen(fwin->title)) > width) { fwin->flags.incomplete_title = 1; } else { fwin->flags.incomplete_title = 0; @@ -1429,21 +1180,12 @@ handleButtonExpose(WObjDescriptor *desc, XEvent *event) WFrameWindow *fwin = (WFrameWindow*)desc->parent; WCoreWindow *button = (WCoreWindow*)desc->self; -#ifdef XKB_BUTTON_HINT - if (button == fwin->language_button) { - if (wPreferences.modelock){ - paintButton(button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], - fwin->languagebutton_image, False); - } - } else -#endif if (button == fwin->left_button) { - paintButton(button, fwin->title_texture[fwin->flags.state], - fwin->title_pixel[fwin->flags.state], - fwin->lbutton_image, False); + paintButton(button, fwin->title_texture[fwin->flags.state], + fwin->title_pixel[fwin->flags.state], + fwin->lbutton_image, False); } else { - Bool pushed = False; + Bool pushed = False; #ifdef OLWM_HINTS if (fwin->flags.right_button_pushed_in) @@ -1508,12 +1250,6 @@ buttonMouseDown(WObjDescriptor *desc, XEvent *event) } else { image = fwin->rbutton_image; } -#ifdef XKB_BUTTON_HINT - if (button == fwin->language_button) { - if (!wPreferences.modelock) return; - image = fwin->languagebutton_image; - } -#endif pixel = fwin->title_pixel[fwin->flags.state]; texture = fwin->title_texture[fwin->flags.state]; @@ -1555,13 +1291,6 @@ buttonMouseDown(WObjDescriptor *desc, XEvent *event) if (fwin->on_click_right) (*fwin->on_click_right)(button, fwin->child, &ev); } -#ifdef XKB_BUTTON_HINT - else if (button == fwin->language_button) { - if (fwin->on_click_language) - (*fwin->on_click_language)(button, fwin->child, &ev); - } -#endif - } } diff --git a/src/framewin.h b/src/framewin.h index a34c9688..45aff6f3 100644 --- a/src/framewin.h +++ b/src/framewin.h @@ -82,7 +82,7 @@ typedef struct WFrameWindow { union WTexture **resizebar_texture; unsigned long *title_pixel; GC *title_gc; - WFont **font; + WMFont **font; char *title; /* window name (title) */ @@ -156,7 +156,7 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, int width, int height, int flags, union WTexture **title_texture, union WTexture **resize_texture, - unsigned long *color, GC *gc, WFont **font); + unsigned long *color, GC *gc, WMFont **font); void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags); diff --git a/src/funcs.h b/src/funcs.h index 33669e11..6784fe15 100644 --- a/src/funcs.h +++ b/src/funcs.h @@ -109,7 +109,7 @@ WWindow *PrevFocusWindow(WScreen *scr); void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y); -char *ShrinkString(WFont *font, char *string, int width); +char *ShrinkString(WMFont *font, char *string, int width); char *FindImage(char *paths, char *file); @@ -158,22 +158,4 @@ void ExecExitScript(); Bool wFetchName(Display *dpy, Window win, char **winname); Bool wGetIconName(Display *dpy, Window win, char **iconname); -#ifdef I18N_MB -/*void wTextWidth(XFontSet *font, char *text, int length);*/ -#define wDrawString(d,f,gc,x,y,text,textlen) \ - XmbDrawString(dpy, d, (f)->font, gc, (x), (y), text, textlen) - -#define wTextWidth(font,text,textlen) XmbTextEscapement(font,text,textlen) - -#else /* !I18N_MB */ - -#define wTextWidth(font,text,textlen) XTextWidth(font,text,textlen) - -/*void wTextWidth(XFontStruct *font, char *text, int length);*/ -#define wDrawString(d,font,gc,x,y,text,textlen) \ - XDrawString(dpy, d, gc, (x), (y), text, textlen) - -#endif /* !I18N_MB */ - - #endif diff --git a/src/icon.c b/src/icon.c index d55d8a95..3a167703 100644 --- a/src/icon.c +++ b/src/icon.c @@ -308,7 +308,7 @@ makeIcon(WScreen *scr, RImage *icon, int titled, int shadowed, int tileType) Pixmap pixmap; int x, y, sx, sy; unsigned w, h; - int theight = scr->icon_title_font->height; + int theight = WMFontHeight(scr->icon_title_font); if (tileType == TILE_NORMAL) tile = RCloneImage(scr->icon_tile); @@ -605,7 +605,7 @@ void wIconUpdate(WIcon *icon) { WScreen *scr = icon->core->screen_ptr; - int title_height = scr->icon_title_font->height; + int title_height = WMFontHeight(scr->icon_title_font); WWindow *wwin = icon->owner; assert(scr->icon_tile!=NULL); @@ -815,15 +815,15 @@ wIconPaint(WIcon *icon) tmp = ShrinkString(scr->icon_title_font, icon->icon_name, wPreferences.icon_size-4); - w = wTextWidth(scr->icon_title_font->font, tmp, l=strlen(tmp)); + w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp)); if (w > icon->core->width - 4) x = (icon->core->width - 4) - w; else x = (icon->core->width - w)/2; - wDrawString(icon->core->window, scr->icon_title_font, gc, - x, 1 + scr->icon_title_font->y, tmp, l); + WMDrawString(scr->wmscreen, icon->core->window, gc, + scr->icon_title_font, x, 1, tmp, l); free(tmp); } diff --git a/src/main.c b/src/main.c index c19573e9..b58e8557 100644 --- a/src/main.c +++ b/src/main.c @@ -358,7 +358,7 @@ main(int argc, char **argv) wsetabort(wAbort); /* for telling WPrefs what's the name of the wmaker binary being ran */ - str = wstrappend("WMAKER_BIN_NAME", argv[0]); + str = wstrappend("WMAKER_BIN_NAME=", argv[0]); putenv(str); ArgCount = argc; diff --git a/src/menu.c b/src/menu.c index 6cd96fdd..a35e0e9a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -552,15 +552,15 @@ wMenuRealize(WMenu *menu) wFrameWindowUpdateBorders(menu->frame, flags); if (menu->flags.titled) { - twidth = wTextWidth(scr->menu_title_font->font, menu->frame->title, - strlen(menu->frame->title)); + twidth = WMWidthOfString(scr->menu_title_font, menu->frame->title, + strlen(menu->frame->title)); theight = menu->frame->top_width; twidth += theight + (wPreferences.new_style ? 16 : 8); } else { twidth = 0; theight = 0; } - eheight = scr->menu_entry_font->height + 6; + eheight = WMFontHeight(scr->menu_entry_font) + 6; menu->entry_height = eheight; mrwidth = 0; mwidth = 0; @@ -569,7 +569,7 @@ wMenuRealize(WMenu *menu) /* search widest text */ text = menu->entries[i]->text; - width = wTextWidth(scr->menu_entry_font->font, text, strlen(text))+10; + width = WMWidthOfString(scr->menu_entry_font, text, strlen(text))+10; if (menu->entries[i]->flags.indicator) { width += MENU_INDICATOR_SPACE; @@ -581,8 +581,8 @@ wMenuRealize(WMenu *menu) /* search widest text on right */ text = menu->entries[i]->rtext; if (text) - rwidth = wTextWidth(scr->menu_entry_font->font, text, - strlen(text)) + 5; + rwidth = WMWidthOfString(scr->menu_entry_font, text, strlen(text)) + + 5; else if (menu->entries[i]->cascade>=0) rwidth = 16; else @@ -792,9 +792,8 @@ paintEntry(WMenu *menu, int index, int selected) if (entry->flags.indicator) x += MENU_INDICATOR_SPACE + 2; - wDrawString(win, scr->menu_entry_font, - textGC, x, 3+y+scr->menu_entry_font->y, entry->text, - strlen(entry->text)); + WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, + x, 3 + y, entry->text, strlen(entry->text)); if (entry->cascade>=0) { /* draw the cascade indicator */ @@ -847,12 +846,11 @@ paintEntry(WMenu *menu, int index, int selected) /* draw right text */ if (entry->rtext && entry->cascade<0) { - tw = wTextWidth(scr->menu_entry_font->font, entry->rtext, - strlen(entry->rtext)); + tw = WMWidthOfString(scr->menu_entry_font, entry->rtext, + strlen(entry->rtext)); - wDrawString(win, scr->menu_entry_font, textGC, w-6-tw, - 3+y+scr->menu_entry_font->y, entry->rtext, - strlen(entry->rtext)); + WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, w-6-tw, + y + 3, entry->rtext, strlen(entry->rtext)); } } diff --git a/src/misc.c b/src/misc.c index dab7f7bc..6f3f79b4 100644 --- a/src/misc.c +++ b/src/misc.c @@ -365,27 +365,6 @@ char **iconname; } -#if 0 -#ifdef I18N_MB -void -wTextWidth(XFontSet font, char *text, int length) -{ - XRectangle rect; - XRectangle AIXsucks; - - XmbTextExtents(font, text, length, &AIXsucks, &rec); - - return rect.width; -} -#else -void -wTextWidth(XFontStruct *font, char *text, int length) -{ - return XTextWidth(font, text, length); -} -#endif -#endif - static void eatExpose() { @@ -493,21 +472,19 @@ SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y) char* -ShrinkString(WFont *font, char *string, int width) +ShrinkString(WMFont *font, char *string, int width) { -#ifndef I18N_MB int w, w1=0; int p; char *pos; char *text; int p1, p2, t; -#endif -#ifdef I18N_MB - return wstrdup(string); -#else + if (wPreferences.multi_byte_text) + return wstrdup(string); + p = strlen(string); - w = wTextWidth(font->font, string, p); + w = WMWidthOfString(font, string, p); text = wmalloc(strlen(string)+8); strcpy(text, string); if (w<=width) @@ -520,8 +497,8 @@ ShrinkString(WFont *font, char *string, int width) if (pos) { *pos = 0; p = strlen(text); - w1=wTextWidth(font->font, text, p); - if (w1>width) { + w1 = WMWidthOfString(font, text, p); + if (w1 > width) { w1 = 0; p = 0; *pos = ' '; @@ -537,14 +514,14 @@ ShrinkString(WFont *font, char *string, int width) *text=0; } strcat(text, "..."); - width -= wTextWidth(font->font, "...", 3); + width -= WMWidthOfString(font, "...", 3); pos = string; p1=0; p2=p; t = (p2-p1)/2; while (p2>p1 && p1!=t) { - w = wTextWidth(font->font, &string[p-t], t); + w = WMWidthOfString(font, &string[p-t], t); if (w>width) { p2 = t; t = p1+(p2-p1)/2; @@ -555,8 +532,8 @@ ShrinkString(WFont *font, char *string, int width) p2=p1=t; } strcat(text, &string[p-p1]); + return text; -#endif /* I18N_MB */ } diff --git a/src/moveres.c b/src/moveres.c index bab53487..4ec56159 100644 --- a/src/moveres.c +++ b/src/moveres.c @@ -72,13 +72,9 @@ void wGetGeometryWindowSize(WScreen *scr, unsigned int *width, unsigned int *height) { -#ifdef I18N_MB - *width = XmbTextEscapement(scr->info_text_font->font, "-8888 x -8888", 13); - *height = (7 * scr->info_text_font->height) / 4 - 1; -#else - *width = XTextWidth(scr->info_text_font->font, "-8888 x -8888", 13); - *height = (7 * scr->info_text_font->font->ascent) / 4 - 1; -#endif + *width = WMWidthOfString(scr->info_text_font, "-8888 x -8888", 13); + + *height = (7 * WMFontHeight(scr->info_text_font)) / 4 - 1; } @@ -140,15 +136,15 @@ showPosition(WWindow *wwin, int x, int y) scr->geometry_display_width-2, scr->geometry_display_height-2, False); sprintf(num, "%+i %-+i", x, y); - fw = wTextWidth(scr->info_text_font->font, num, strlen(num)); + fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); XSetForeground(dpy, gc, scr->black_pixel); - fh = scr->info_text_font->height; - wDrawString(scr->geometry_display, scr->info_text_font, gc, + fh = WMFontHeight(scr->info_text_font); + WMDrawString(scr->wmscreen, scr->geometry_display, gc, + scr->info_text_font, (scr->geometry_display_width - 2 - fw) / 2, - (scr->geometry_display_height-fh)/2 + scr->info_text_font->y, - num, strlen(num)); + (scr->geometry_display_height-fh)/2, num, strlen(num)); wDrawBevel(scr->geometry_display, scr->geometry_display_width+1, scr->geometry_display_height+1, scr->widget_texture, WREL_RAISED); @@ -216,8 +212,8 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) ty = y1 + wwin->frame->top_width; by = y2 - wwin->frame->bottom_width; - fw = wTextWidth(scr->info_text_font->font, "8888", 4); - fh = scr->info_text_font->height; + fw = WMWidthOfString(scr->info_text_font, "8888", 4); + fh = WMFontHeight(scr->info_text_font); if (wPreferences.size_display == WDIS_NEW) { XSetForeground(dpy, gc, scr->line_pixel); @@ -270,14 +266,13 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) sprintf(num, "%i", (by - ty - wwin->normal_hints->base_height) / wwin->normal_hints->height_inc); - fw = wTextWidth(scr->info_text_font->font, num, strlen(num)); + fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); /* XSetForeground(dpy, gc, scr->window_title_pixel[WS_UNFOCUSED]); */ /* Display the height. */ - wDrawString(root, scr->info_text_font, gc, - x - s + 3 - fw/2, my - fh/2 + scr->info_text_font->y + 1, - num, strlen(num)); + WMDrawString(scr->wmscreen, root, gc, scr->info_text_font, + x - s + 3 - fw/2, my - fh/2 + 1, num, strlen(num)); XSetForeground(dpy, gc, scr->line_pixel); /* horizontal geometry */ if (y1 < 15) { @@ -290,7 +285,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) mx = x1 + (x2 - x1)/2; sprintf(num, "%i", (x2 - x1 - wwin->normal_hints->base_width) / wwin->normal_hints->width_inc); - fw = wTextWidth(scr->info_text_font->font, num, strlen(num)); + fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); /* left arrow */ /* end bar */ @@ -331,8 +326,8 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) /* XSetForeground(dpy, gc, scr->window_title_pixel[WS_UNFOCUSED]); */ /* Display the width. */ - wDrawString(root, scr->info_text_font, gc, - mx - fw/2 + 1, y - s + fh/2 + 1, num, strlen(num)); + WMDrawString(scr->wmscreen, root, gc, scr->info_text_font, + mx - fw/2 + 1, y - s + fh/2 + 1, num, strlen(num)); } else { XClearArea(dpy, scr->geometry_display, 1, 1, scr->geometry_display_width-2, scr->geometry_display_height-2, @@ -341,16 +336,15 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction) / wwin->normal_hints->width_inc, (by - ty - wwin->normal_hints->base_height) / wwin->normal_hints->height_inc); - fw = wTextWidth(scr->info_text_font->font, num, strlen(num)); + fw = WMWidthOfString(scr->info_text_font, num, strlen(num)); XSetForeground(dpy, scr->info_text_gc, scr->black_pixel); /* Display the height. */ - wDrawString(scr->geometry_display, scr->info_text_font, - scr->info_text_gc, + WMDrawString(scr->wmscreen, scr->geometry_display, scr->info_text_gc, + scr->info_text_font, (scr->geometry_display_width-fw)/2, - (scr->geometry_display_height-fh)/2 +scr->info_text_font->y, - num, strlen(num)); + (scr->geometry_display_height-fh)/2, num, strlen(num)); wDrawBevel(scr->geometry_display, scr->geometry_display_width+1, scr->geometry_display_height+1, scr->widget_texture, WREL_RAISED); @@ -451,7 +445,7 @@ drawTransparentFrame(WWindow *wwin, int x, int y, int width, int height) int bottom = 0; if (!WFLAGP(wwin, no_titlebar) && !wwin->flags.shaded) { - h = wwin->screen_ptr->title_font->height + TITLEBAR_EXTRA_HEIGHT; + h = WMFontHeight(wwin->screen_ptr->title_font) + TITLEBAR_EXTRA_HEIGHT; } if (!WFLAGP(wwin, no_resizebar) && !wwin->flags.shaded) { /* Can't use wwin-frame->bottom_width because, in some cases @@ -1765,7 +1759,7 @@ wMouseResizeWindow(WWindow *wwin, XEvent *ev) shiftl = XKeysymToKeycode(dpy, XK_Shift_L); shiftr = XKeysymToKeycode(dpy, XK_Shift_R); if (!WFLAGP(wwin, no_titlebar)) - h = wwin->screen_ptr->title_font->height + TITLEBAR_EXTRA_HEIGHT; + h = WMFontHeight(wwin->screen_ptr->title_font) + TITLEBAR_EXTRA_HEIGHT; else h = 0; while (1) { @@ -2060,7 +2054,7 @@ InteractivePlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, return; } if (!WFLAGP(wwin, no_titlebar)) { - h = scr->title_font->height + TITLEBAR_EXTRA_HEIGHT; + h = WMFontHeight(scr->title_font) + TITLEBAR_EXTRA_HEIGHT; height += h; } if (!WFLAGP(wwin, no_resizebar)) { diff --git a/src/placement.c b/src/placement.c index 5d61de49..638330d0 100644 --- a/src/placement.c +++ b/src/placement.c @@ -396,7 +396,7 @@ PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, unsigned width, unsigned height) { WScreen *scr = wwin->screen_ptr; - int h = scr->title_font->height+TITLEBAR_EXTRA_HEIGHT; + int h = WMFontHeight(scr->title_font) + TITLEBAR_EXTRA_HEIGHT; switch (wPreferences.window_placement) { case WPM_MANUAL: diff --git a/src/resources.c b/src/resources.c index de4dcf60..555a1c50 100644 --- a/src/resources.c +++ b/src/resources.c @@ -37,98 +37,6 @@ #include "pixmap.h" -/* - *---------------------------------------------------------------------- - * wLoadFont-- - * Loads a single font into a WFont structure, initializing - * data in it. If the font could not be loaded, fixed will be used. - * If fixed can't be loaded either, the function returns NULL. - * - * Returns: - * The font structure or NULL on error. - * - *---------------------------------------------------------------------- - */ -WFont* -wLoadFont(char *font_name) -{ - WFont *font; -#ifdef I18N_MB - char **missing; - int num_missing = 0; - char *default_string; - int skyline; -#endif - - font = malloc(sizeof(WFont)); - if (!font) - return NULL; - -#ifdef I18N_MB - font->font = XCreateFontSet(dpy, font_name, &missing, &num_missing, - &default_string); - if (num_missing > 0 && font->font) { - wwarning(_("The following character sets are missing in %s:"), - font_name); - for (skyline = 0; skyline < num_missing; skyline++) - wwarning(missing[skyline]); - XFreeStringList(missing); - wwarning(_("The string \"%s\" will be used in place"), - default_string); - wwarning(_("of any characters from those sets.")); - } - if (!font->font) { - wwarning(_("could not create font set %s. Trying fixed"), font_name); - font->font = XCreateFontSet(dpy, "-*-fixed-medium-r-normal-*-14-*-*-*-*-*-*-*", - &missing, &num_missing, &default_string); - if (num_missing > 0) { - XFreeStringList(missing); - } - if (!font->font) { - free(font); - return NULL; - } - } - font->height = XExtentsOfFontSet(font->font)->max_logical_extent.height; - font->y = font->height+XExtentsOfFontSet(font->font)->max_logical_extent.y; - font->y = font->height-font->y; -#else - font->font = XLoadQueryFont(dpy, font_name); - if (!font->font) { - wwarning(_("could not load font %s. Trying fixed"), font_name); - font->font = XLoadQueryFont(dpy, "fixed"); - if (!font->font) { - free(font); - return NULL; - } - } - font->height = font->font->ascent+font->font->descent; - font->y = font->font->ascent; -#endif /* !I18N_MB */ - - return font; -} - - - -void -wFreeFont(WFont *font) -{ -#ifdef I18N_MB - XFreeFontSet(dpy, font->font); -#else - XFreeFont(dpy, font->font); -#endif - free(font); -} - - -/* - * wfatal(_("could not load any usable font set")); - wfatal(_("could not load any usable font")); - */ - - int wGetColor(WScreen *scr, char *color_name, XColor *color) { diff --git a/src/resources.h b/src/resources.h index a490406a..bf964269 100644 --- a/src/resources.h +++ b/src/resources.h @@ -22,8 +22,7 @@ #ifndef WMRESOURCES_H_ #define WMRESOURCES_H_ -WFont *wLoadFont(char *font_name); -void wFreeFont(WFont *font); int wGetColor(WScreen *scr, char *color_name, XColor *color); void wFreeColor(WScreen *scr, unsigned long pixel); + #endif diff --git a/src/screen.c b/src/screen.c index 7587f097..bcb5973c 100644 --- a/src/screen.c +++ b/src/screen.c @@ -473,10 +473,8 @@ createPixmaps(WScreen *scr) scr->dock_dots = make3Dots(scr); -#ifndef NEWSTUFF /* titlebar button pixmaps */ allocButtonPixmaps(scr); -#endif } @@ -503,7 +501,7 @@ createInternalWindows(WScreen *scr) /* window for displaying geometry information during resizes and moves */ vmask = CWBorderPixel|CWBackPixmap|CWBackPixel|CWCursor|CWSaveUnder|CWOverrideRedirect; - attribs.border_pixel = 0; + attribs.border_pixel = scr->black_pixel; attribs.save_under = True; attribs.override_redirect = True; attribs.cursor = wCursor[WCUR_DEFAULT]; @@ -537,7 +535,7 @@ createInternalWindows(WScreen *scr) /* shadow window for dock buttons */ vmask = CWBorderPixel|CWBackPixmap|CWBackPixel|CWCursor|CWSaveUnder|CWOverrideRedirect; - attribs.border_pixel = 0; + attribs.border_pixel = scr->black_pixel; attribs.save_under = True; attribs.override_redirect = True; attribs.background_pixmap = None; diff --git a/src/screen.h b/src/screen.h index 7edaa83d..0343a8e3 100644 --- a/src/screen.h +++ b/src/screen.h @@ -29,17 +29,6 @@ #include -typedef struct WFont { -#ifndef I18N_MB - XFontStruct *font; -#else - XFontSet font; -#endif - short height; - short y; -} WFont; - - #define WTB_LEFT 0 #define WTB_RIGHT 1 @@ -146,14 +135,14 @@ typedef struct _WScreen { Pixmap stipple_bitmap; Pixmap transp_stipple; /* for making holes in icon masks for * transparent icon simulation */ - WFont *title_font; /* default font for the titlebars */ - WFont *menu_title_font; /* font for menu titlebars */ - WFont *menu_entry_font; /* font for menu items */ - WFont *icon_title_font; /* for icon titles */ - WFont *clip_title_font; /* for clip titles */ - WFont *info_text_font; /* text on things like geometry + WMFont *title_font; /* default font for the titlebars */ + WMFont *menu_title_font; /* font for menu titlebars */ + WMFont *menu_entry_font; /* font for menu items */ + WMFont *icon_title_font; /* for icon titles */ + WMFont *clip_title_font; /* for clip titles */ + WMFont *info_text_font; /* text on things like geometry * hint boxes */ - WFont *workspace_name_font; + WMFont *workspace_name_font; WMPixel select_pixel; WMPixel select_text_pixel; diff --git a/src/text.c b/src/text.c index 632a42b0..85702879 100644 --- a/src/text.c +++ b/src/text.c @@ -186,7 +186,7 @@ textXtoPos( WTextInput *wtext, int x ) if( x < 0 ) break; else - x -= wTextWidth( wtext->font->font, &(wtext->text.txt[pos]), 1 ); + x -= WMWidthOfString( wtext->font, &(wtext->text.txt[pos]), 1 ); } return pos; @@ -230,35 +230,23 @@ wTextCreate( WCoreWindow *core, int x, int y, int width, int height ) gcv.foreground = core->screen_ptr->black_pixel; gcv.background = core->screen_ptr->white_pixel; -#ifndef I18N_MB - gcv.font = wtext->font->font->fid; -#endif gcv.line_width = 1; gcv.function = GXcopy; wtext->gc = XCreateGC( dpy, wtext->core->window, (GCForeground|GCBackground| -#ifndef I18N_MB - GCFont| -#endif GCFunction|GCLineWidth), &gcv ); /* set up the regular context */ gcv.foreground = core->screen_ptr->black_pixel; gcv.background = core->screen_ptr->white_pixel; -#ifndef I18N_MB - gcv.font = wtext->font->font->fid; -#endif gcv.line_width = 1; gcv.function = GXcopy; wtext->regGC = XCreateGC( dpy, wtext->core->window, (GCForeground|GCBackground| -#ifndef I18N_MB - GCFont| -#endif - GCFunction|GCLineWidth), + GCFunction|GCLineWidth), &gcv ); /* set up the inverted context */ @@ -266,9 +254,6 @@ wTextCreate( WCoreWindow *core, int x, int y, int width, int height ) wtext->invGC = XCreateGC( dpy, wtext->core->window, (GCForeground|GCBackground| -#ifndef I18N_MB - GCFont| -#endif GCFunction|GCLineWidth), &gcv ); @@ -277,7 +262,7 @@ wTextCreate( WCoreWindow *core, int x, int y, int width, int height ) } /* Figure out the y-offset... */ - wtext->yOffset = (height - wtext->font->height)/2; + wtext->yOffset = (height - WMFontHeight(wtext->font))/2; wtext->xOffset = wtext->yOffset; wtext->canceled = False; @@ -351,16 +336,17 @@ textRefresh( WTextInput *wtext ) /* x2,y2 is the lower right corner of the text box */ x2 = wtext->core->width - wtext->xOffset; y2 = wtext->core->height - wtext->yOffset; - + /* Fill in the text field. Use the invGC to draw the rectangle, * becuase then it will be the background color */ XFillRectangle( dpy, wtext->core->window, wtext->invGC, x1, y1, x2-x1, y2-y1 ); /* Draw the text normally */ - wDrawString(wtext->core->window, wtext->font, wtext->regGC, - x1, y2+TEXT_SHIFT, ptr, wtext->text.length); - + WMDrawString(wtext->core->screen_ptr->wmscreen, wtext->core->window, + wtext->regGC, wtext->font, + x1, y2+TEXT_SHIFT, ptr, wtext->text.length); + /* Draw the selected text */ if( wtext->text.startPos != wtext->text.endPos ) { @@ -378,10 +364,10 @@ textRefresh( WTextInput *wtext ) } /* x1,y1 is now the upper-left of the selected area */ - x1 += wTextWidth( wtext->font->font, ptr, sp ); + x1 += WMWidthOfString( wtext->font, ptr, sp ); /* and x2,y2 is the lower-right of the selected area */ ptr += sp * sizeof(char); - x2 = x1 +wTextWidth( wtext->font->font, ptr, (ep - sp) ); + x2 = x1 + WMWidthOfString( wtext->font, ptr, (ep - sp) ); /* Fill in the area where the selected text will go: * * use the regGC to draw the rectangle, becuase then it * * will be the color of the non-selected text */ @@ -390,12 +376,12 @@ textRefresh( WTextInput *wtext ) /* Draw the selected text... use invGC so it will be the * opposite color as the filled rectangle */ - wDrawString(wtext->core->window, wtext->font, wtext->invGC, - x1, y2+TEXT_SHIFT, ptr, (ep - sp)); + WMDrawString(wtext->core->screen_ptr->wmscreen, wtext->core->window, + wtext->invGC, wtext->font, x1, y2+TEXT_SHIFT, ptr, (ep - sp)); } /* And draw a quick little line for the cursor position */ - x1 = wTextWidth( wtext->font->font, wtext->text.txt, wtext->text.endPos ) + x1 = WMWidthOfString( wtext->font, wtext->text.txt, wtext->text.endPos ) + wtext->xOffset; XDrawLine( dpy, wtext->core->window, wtext->regGC, x1, 2, x1, wtext->core->height - 3 ); @@ -571,7 +557,7 @@ blink(void *data) gc = wtext->invGC; wtext->blink_on = 1; } - x = wTextWidth( wtext->font->font, wtext->text.txt, wtext->text.endPos ) + x = WMWidthOfString( wtext->font, wtext->text.txt, wtext->text.endPos ) + wtext->xOffset; XDrawLine( dpy, wtext->core->window, gc, x, 2, x, wtext->core->height-3); diff --git a/src/text.h b/src/text.h index dc718c76..e287a81a 100644 --- a/src/text.h +++ b/src/text.h @@ -37,7 +37,7 @@ typedef struct { * cursor position. */ typedef struct { WCoreWindow *core; - WFont *font; + WMFont *font; WTextBlock text; GC gc; GC regGC; /* the normal GC */ diff --git a/src/workspace.c b/src/workspace.c index bfeffe23..f61387ce 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -307,15 +307,10 @@ showWorkspaceName(WScreen *scr, int workspace) free(scr->workspace_name_data); } -#ifndef I18N_MB - XSetFont(dpy, scr->mono_gc, scr->workspace_name_font->font->fid); - XSetFont(dpy, scr->draw_gc, scr->workspace_name_font->font->fid); -#endif - data = wmalloc(sizeof(WorkspaceNameData)); - w = wTextWidth(scr->workspace_name_font->font, name, len); - h = scr->workspace_name_font->height; + w = WMWidthOfString(scr->workspace_name_font, name, len); + h = WMFontHeight(scr->workspace_name_font); switch (wPreferences.workspace_name_display_position) { case WD_CENTER: @@ -362,16 +357,15 @@ showWorkspaceName(WScreen *scr, int workspace) XSetForeground(dpy, scr->mono_gc, 1); for (x = 0; x <= 4; x++) { for (y = 0; y <= 4; y++) { - wDrawString(mask, scr->workspace_name_font, scr->mono_gc, - x, scr->workspace_name_font->y + y, name, len); + WMDrawString(scr->wmscreen, mask, scr->mono_gc, + scr->workspace_name_font, x, y, name, len); } } XSetForeground(dpy, scr->draw_gc, scr->white_pixel); - wDrawString(text, scr->workspace_name_font, scr->draw_gc, - 2, scr->workspace_name_font->y + 2, - scr->workspaces[workspace]->name, - strlen(scr->workspaces[workspace]->name)); + WMDrawString(scr->wmscreen, text, scr->draw_gc, scr->workspace_name_font, + 2, 2, scr->workspaces[workspace]->name, + strlen(scr->workspaces[workspace]->name)); #ifdef SHAPE XShapeCombineMask(dpy, scr->workspace_name, ShapeBounding, 0, 0, mask, ShapeSet); -- 2.11.4.GIT