From b3112e2b3c7a1fb36900d8baf38e7d9df7f3c5f1 Mon Sep 17 00:00:00 2001 From: id Date: Sat, 22 May 1999 21:30:35 +0000 Subject: [PATCH] Fixes relate to modelock. --- src/WindowMaker.h | 10 +-- src/def_pixmaps.h | 66 ++++++++++---- src/dialog.c | 6 +- src/event.c | 26 +++--- src/framewin.c | 223 ++++++++++++++++++++++------------------------ src/framewin.h | 17 ++-- src/screen.c | 20 +++-- src/screen.h | 9 +- src/window.c | 29 +++--- src/window.h | 2 +- 10 files changed, 216 insertions(+), 192 deletions(-) diff --git a/src/WindowMaker.h b/src/WindowMaker.h index bad87032..210950eb 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -109,12 +109,12 @@ typedef enum { #define WBUT_ICONIFY 2 #define WBUT_KILL 3 #ifdef XKB_BUTTON_HINT -#define WBUT_THAI 4 -#define WBUT_ENGL 5 - -#define PRED_BPIXMAPS 6 /* count of WBUT icons */ +#define WBUT_XKBGROUP1 4 +#define WBUT_XKBGROUP2 5 +#define WBUT_XKBGROUP3 6 +#define WBUT_XKBGROUP4 7 +#define PRED_BPIXMAPS 8 /* reserved for 4 groups */ #else - #define PRED_BPIXMAPS 4 /* count of WBUT icons */ #endif /* XKB_BUTTON_HINT */ diff --git a/src/def_pixmaps.h b/src/def_pixmaps.h index 933fd414..45cebd99 100644 --- a/src/def_pixmaps.h +++ b/src/def_pixmaps.h @@ -99,23 +99,7 @@ static char *PRED_ICONIFY_XPM[] = { #ifdef XKB_BUTTON_HINT -static char *PRED_THAI_XPM[] = { -" 10 10 2 1", -". c #000000", -"# c None", -"#..###..##", -".#..#.#..#", -".#...###..", -"#...####..", -"##..####..", -"##..####..", -"##..####..", -"##..####..", -"##..####..", -"##.#####.#" -}; - -static char *PRED_ENGL_XPM[] = { +static char *PRED_XKBGROUP1_XPM[] = { " 10 10 2 1", ". c #000000", "# c None", @@ -131,6 +115,54 @@ static char *PRED_ENGL_XPM[] = { "........##" }; +static char *PRED_XKBGROUP2_XPM[] = { +" 10 10 2 1", +". c #000000", +"# c None", +"#..###..##", +".#..#.#..#", +".#...###..", +"#...####..", +"##..####..", +"##..####..", +"##..####..", +"##..####..", +"##..####..", +"##.#####.#" +}; + +static char *PRED_XKBGROUP3_XPM[] = { +" 10 10 2 1", +". c #000000", +"# c None", +"##########", +"##########", +"##..##..##", +"##..##..##", +"##########", +"##########", +"#........#", +"##......##", +"###....###", +"##########" +}; + +static char *PRED_XKBGROUP4_XPM[] = { +" 10 10 2 1", +". c #000000", +"# c None", +"##########", +"##########", +"##..##..##", +"##..##..##", +"##########", +"##########", +"#........#", +"##......##", +"###....###", +"##########" +}; + #endif /* XKB_BUTTON_HINT */ diff --git a/src/dialog.c b/src/dialog.c index 513785a4..06d35542 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1143,7 +1143,7 @@ wShowInfoPanel(WScreen *scr) WSETUFLAG(wwin, no_closable, 0); WSETUFLAG(wwin, no_close_button, 0); #ifdef XKB_BUTTON_HINT - wFrameWindowHideButton(wwin->frame, WFF_THAI_BUTTON); + wFrameWindowHideButton(wwin->frame, WFF_XKB_BUTTON); #endif wWindowUpdateButtonImages(wwin); wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON); @@ -1262,7 +1262,7 @@ wShowLegalPanel(WScreen *scr) wWindowUpdateButtonImages(wwin); wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON); #ifdef XKB_BUTTON_HINT - wFrameWindowHideButton(wwin->frame, WFF_THAI_BUTTON); + wFrameWindowHideButton(wwin->frame, WFF_XKB_BUTTON); #endif wwin->frame->on_click_right = destroyLegalPanel; @@ -1682,7 +1682,7 @@ wShowGNUstepPanel(WScreen *scr) wWindowUpdateButtonImages(wwin); wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON); #ifdef XKB_BUTTON_HINT - wFrameWindowHideButton(wwin->frame, WFF_THAI_BUTTON); + wFrameWindowHideButton(wwin->frame, WFF_XKB_BUTTON); #endif wwin->frame->on_click_right = destroyGNUstepPanel; diff --git a/src/event.c b/src/event.c index 79c31560..eb1fa064 100644 --- a/src/event.c +++ b/src/event.c @@ -446,13 +446,16 @@ saveTimestamp(XEvent *event) static void handleExtensions(XEvent *event) { + XkbEvent *xkbevent; + xkbevent = event; #ifdef SHAPE if (wShapeSupported && event->type == (wShapeEventBase+ShapeNotify)) { handleShapeNotify(event); } #endif #ifdef KEEP_XKB_LOCK_STATUS - if (wPreferences.modelock && event->type == (0x50|XkbIndicatorStateNotify)){ + if (wPreferences.modelock && + (event->type == 0x54)){ /* if someone know how to call this 0x50 * or how to clean code this please tell ]d */ handleXkbIndicatorStateNotify(event); @@ -1157,23 +1160,20 @@ handleXkbIndicatorStateNotify(XEvent *event) XkbStateRec staterec; int i; - XkbGetState(dpy,XkbUseCoreKbd,&staterec); for (i=0; ifocused_window; if (wwin->flags.focused) { - wwin->frame->languagemode=staterec.compat_state&32?1:0; + XkbGetState(dpy,XkbUseCoreKbd,&staterec); + if (wwin->frame->languagemode != staterec.group) { + wwin->frame->last_languagemode = wwin->frame->languagemode; + wwin->frame->languagemode = staterec.group; + } #ifdef XKB_BUTTON_HINT if (wwin->frame->titlebar) { wFrameWindowPaint(wwin->frame); } #endif -#ifdef XKB_TITLE_HINT - if (wwin->frame->titlebar) { - XClearWindow(dpy, wwin->frame->titlebar->window); - wFrameWindowPaint(wwin->frame); - } -#endif /* XKB_TITLE_HINT */ } } } @@ -1774,11 +1774,11 @@ handleKeyPress(XEvent *event) if (wwin && wwin->flags.mapped && wwin->frame->workspace == wwin->screen_ptr->current_workspace && !wwin->flags.miniaturized && !wwin->flags.hidden) { - XkbGetState(dpy,XkbUseCoreKbd,&staterec); + XkbGetState(dpy,XkbUseCoreKbd,&staterec); - wwin->frame->languagemode = staterec.compat_state&32 - ? 0 : 1; - XkbLockGroup(dpy,XkbUseCoreKbd, wwin->frame->languagemode); + wwin->frame->languagemode = wwin->frame->last_languagemode; + wwin->frame->last_languagemode = staterec.group; + XkbLockGroup(dpy,XkbUseCoreKbd, wwin->frame->languagemode); } } diff --git a/src/framewin.c b/src/framewin.c index ea32b2f5..c90b5646 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -23,6 +23,9 @@ #include #include +#ifdef KEEP_XKB_LOCK_STATUS +#include +#endif /* KEEP_XKB_LOCK_STATUS */ #include #include @@ -78,6 +81,10 @@ 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); @@ -145,12 +152,12 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) wCoreConfigure(fwin->left_button, 0, 0, bsize, bsize); } #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) + if (fwin->language_button) if (fwin->flags.hide_left_button || !fwin->left_button || fwin->flags.lbutton_dont_fit) { - wCoreConfigure(fwin->thai_button, 0, 0, bsize, bsize); + wCoreConfigure(fwin->language_button, 0, 0, bsize, bsize); } else { - wCoreConfigure(fwin->thai_button, bsize, 0, bsize, bsize); + wCoreConfigure(fwin->language_button, bsize, 0, bsize, bsize); } #endif @@ -166,8 +173,8 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) } #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) { - wCoreConfigure(fwin->thai_button, 6 + bsize, (theight-bsize)/2, + if (fwin->language_button) { + wCoreConfigure(fwin->language_button, 6 + bsize, (theight-bsize)/2, bsize, bsize); } @@ -187,7 +194,7 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) FREE_PIXMAP(fwin->lbutton_back[i]); FREE_PIXMAP(fwin->rbutton_back[i]); #ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->tbutton_back[i]); + FREE_PIXMAP(fwin->languagebutton_back[i]); #endif } } @@ -196,9 +203,9 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) fwin->left_button = NULL; #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) - wCoreDestroy(fwin->thai_button); - fwin->thai_button = NULL; + if (fwin->language_button) + wCoreDestroy(fwin->language_button); + fwin->language_button = NULL; #endif if (fwin->right_button) @@ -246,29 +253,29 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) } #ifdef XKB_BUTTON_HINT - if (flags & WFF_THAI_BUTTON) { - fwin->flags.thai_button = 1; + if (flags & WFF_XKB_BUTTON) { + fwin->flags.language_button = 1; if (wPreferences.new_style) { - fwin->thai_button = wCoreCreate(fwin->core, + fwin->language_button = wCoreCreate(fwin->core, bsize, 0, bsize, bsize); if (width < theight*4) { - fwin->flags.tbutton_dont_fit = 1; + fwin->flags.languagebutton_dont_fit = 1; } else { - XMapRaised(dpy, fwin->thai_button->window); + XMapRaised(dpy, fwin->language_button->window); } } else { - fwin->thai_button = + fwin->language_button = wCoreCreate(fwin->titlebar, bsize + 6, (theight-bsize)/2, bsize, bsize); - XSetWindowBackground(dpy, fwin->thai_button->window, + XSetWindowBackground(dpy, fwin->language_button->window, scr->widget_texture->normal.pixel); if (width < theight*3) { - fwin->flags.tbutton_dont_fit = 1; + fwin->flags.languagebutton_dont_fit = 1; } else { - XMapRaised(dpy, fwin->thai_button->window); + XMapRaised(dpy, fwin->language_button->window); } } } @@ -372,11 +379,11 @@ wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags) } #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) { - fwin->thai_button->descriptor.handle_expose = handleButtonExpose; - fwin->thai_button->descriptor.parent = fwin; - fwin->thai_button->descriptor.parent_type = WCLASS_FRAME; - fwin->thai_button->descriptor.handle_mousedown = buttonMouseDown; + 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 @@ -402,8 +409,8 @@ wFrameWindowDestroy(WFrameWindow *fwin) wCoreDestroy(fwin->left_button); #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) - wCoreDestroy(fwin->thai_button); + if (fwin->language_button) + wCoreDestroy(fwin->language_button); #endif if (fwin->right_button) @@ -427,7 +434,7 @@ wFrameWindowDestroy(WFrameWindow *fwin) if (wPreferences.new_style) { FREE_PIXMAP(fwin->lbutton_back[i]); #ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->tbutton_back[i]); + FREE_PIXMAP(fwin->languagebutton_back[i]); #endif FREE_PIXMAP(fwin->rbutton_back[i]); } @@ -466,27 +473,27 @@ updateTitlebar(WFrameWindow *fwin) || fwin->flags.lbutton_dont_fit) { x = 0; #ifdef XKB_BUTTON_HINT - if(fwin->thai_button) - wCoreConfigure(fwin->thai_button, 0, 0, - fwin->thai_button->width, - fwin->thai_button->width); + 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->thai_button) - wCoreConfigure(fwin->thai_button, fwin->left_button->width, 0, - fwin->thai_button->width, - fwin->thai_button->width); + 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_thai_button || !fwin->thai_button - || fwin->flags.tbutton_dont_fit) { + if (fwin->flags.hide_language_button || !fwin->language_button + || fwin->flags.languagebutton_dont_fit) { } else { - x += fwin->thai_button->width; - w -= fwin->thai_button->width; + x += fwin->language_button->width; + w -= fwin->language_button->width; } #endif } @@ -495,17 +502,17 @@ updateTitlebar(WFrameWindow *fwin) int bsize = theight - 7; if (fwin->flags.hide_left_button || !fwin->left_button || fwin->flags.lbutton_dont_fit) { - if(fwin->thai_button) - wCoreConfigure(fwin->thai_button, 3, (theight-bsize)/2, - fwin->thai_button->width, - fwin->thai_button->width); + if(fwin->language_button) + wCoreConfigure(fwin->language_button, 3, (theight-bsize)/2, + fwin->language_button->width, + fwin->language_button->width); } else { - if(fwin->thai_button) - wCoreConfigure(fwin->thai_button, + if(fwin->language_button) + wCoreConfigure(fwin->language_button, 6 + fwin->left_button->width, (theight-bsize)/2, - fwin->thai_button->width, - fwin->thai_button->width); + fwin->language_button->width, + fwin->language_button->width); } } #endif @@ -538,9 +545,9 @@ wFrameWindowHideButton(WFrameWindow *fwin, int flags) } #ifdef XKB_BUTTON_HINT - if ((flags & WFF_THAI_BUTTON) && fwin->thai_button) { - XUnmapWindow(dpy, fwin->thai_button->window); - fwin->flags.hide_thai_button = 1; + if ((flags & WFF_XKB_BUTTON) && fwin->language_button) { + XUnmapWindow(dpy, fwin->language_button->window); + fwin->flags.hide_language_button = 1; } #endif @@ -573,13 +580,13 @@ wFrameWindowShowButton(WFrameWindow *fwin, int flags) } #ifdef XKB_BUTTON_HINT - if ((flags & WFF_THAI_BUTTON) && fwin->thai_button - && fwin->flags.hide_thai_button) { + if ((flags & WFF_XKB_BUTTON) && fwin->language_button + && fwin->flags.hide_language_button) { - if (!fwin->flags.tbutton_dont_fit) - XMapWindow(dpy, fwin->thai_button->window); + if (!fwin->flags.languagebutton_dont_fit) + XMapWindow(dpy, fwin->language_button->window); - fwin->flags.hide_thai_button = 0; + fwin->flags.hide_language_button = 0; } #endif @@ -608,8 +615,8 @@ 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 thai, int right, - Pixmap *title, Pixmap *lbutton, Pixmap *tbutton, Pixmap *rbutton) + 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, @@ -627,7 +634,7 @@ renderTexture(WScreen *scr, WTexture *texture, int width, int height, *lbutton = None; *rbutton = None; #ifdef XKB_BUTTON_HINT - *tbutton = None; + *languagebutton = None; #endif img = wTextureRenderImage(texture, width, height, WREL_FLAT); @@ -646,7 +653,7 @@ renderTexture(WScreen *scr, WTexture *texture, int width, int height, w = img->width; #ifdef XKB_BUTTON_HINT - if (thai) { + if (language) { timg = RGetSubImage(img, bwidth, 0, bwidth, bheight); } else timg = NULL; @@ -665,7 +672,7 @@ renderTexture(WScreen *scr, WTexture *texture, int width, int height, #ifdef XKB_BUTTON_HINT if (timg) { RBevelImage(timg, RBEV_RAISED2); - if (!RConvertImage(scr->rcontext, timg, tbutton)) { + if (!RConvertImage(scr->rcontext, timg, languagebutton)) { wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode)); } x += timg->width; @@ -785,9 +792,9 @@ updateTexture(WFrameWindow *fwin) fwin->lbutton_back[i]); #ifdef XKB_BUTTON_HINT - if (fwin->thai_button && fwin->tbutton_back[i]) - XSetWindowBackgroundPixmap(dpy, fwin->thai_button->window, - fwin->tbutton_back[i]); + 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]) @@ -802,8 +809,8 @@ updateTexture(WFrameWindow *fwin) XSetWindowBackground(dpy, fwin->left_button->window, pixel); #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) - XSetWindowBackground(dpy, fwin->thai_button->window, + if (fwin->language_button) + XSetWindowBackground(dpy, fwin->language_button->window, pixel); #endif if (fwin->right_button) @@ -818,9 +825,9 @@ updateTexture(WFrameWindow *fwin) handleButtonExpose(&fwin->left_button->descriptor, NULL); } #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) { - XClearWindow(dpy, fwin->thai_button->window); - handleButtonExpose(&fwin->thai_button->descriptor, NULL); + if (fwin->language_button) { + XClearWindow(dpy, fwin->language_button->window); + handleButtonExpose(&fwin->language_button->descriptor, NULL); } #endif if (fwin->right_button) { @@ -846,14 +853,14 @@ remakeTexture(WFrameWindow *fwin, int state) FREE_PIXMAP(fwin->lbutton_back[state]); FREE_PIXMAP(fwin->rbutton_back[state]); #ifdef XKB_BUTTON_HINT - FREE_PIXMAP(fwin->tbutton_back[state]); + FREE_PIXMAP(fwin->languagebutton_back[state]); #endif } if (fwin->title_texture[state]->any.type!=WTEX_SOLID) { int left, right; #ifdef XKB_BUTTON_HINT - int thai; + int language; #endif int width; @@ -861,8 +868,8 @@ remakeTexture(WFrameWindow *fwin, int state) left = fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit; #ifdef XKB_BUTTON_HINT - thai = fwin->thai_button && !fwin->flags.hide_thai_button - && !fwin->flags.tbutton_dont_fit; + 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; @@ -873,7 +880,7 @@ remakeTexture(WFrameWindow *fwin, int state) renderTexture(fwin->screen_ptr, fwin->title_texture[state], width, fwin->titlebar->height, fwin->titlebar->height, fwin->titlebar->height, - left, thai, right, &pmap, &lpmap, &tpmap, &rpmap); + left, language, right, &pmap, &lpmap, &tpmap, &rpmap); #else renderTexture(fwin->screen_ptr, fwin->title_texture[state], width, fwin->titlebar->height, @@ -886,7 +893,7 @@ remakeTexture(WFrameWindow *fwin, int state) fwin->lbutton_back[state] = lpmap; fwin->rbutton_back[state] = rpmap; #ifdef XKB_BUTTON_HINT - fwin->tbutton_back[state] = tpmap; + fwin->languagebutton_back[state] = tpmap; #endif } } @@ -1013,9 +1020,9 @@ wFrameWindowPaint(WFrameWindow *fwin) allButtons = 0; #ifdef XKB_BUTTON_HINT - if (fwin->thai_button && !fwin->flags.hide_thai_button - && !fwin->flags.tbutton_dont_fit) - lofs += fwin->thai_button->width; + if (fwin->language_button && !fwin->flags.hide_language_button + && !fwin->flags.languagebutton_dont_fit) + lofs += fwin->language_button->width; else allButtons = 0; #endif @@ -1028,30 +1035,12 @@ wFrameWindowPaint(WFrameWindow *fwin) } #ifdef XKB_BUTTON_HINT - if (fwin->languagemode) { - fwin->tbutton_image = fwin->screen_ptr->b_pixmaps[WBUT_THAI]; - } - else fwin->tbutton_image = fwin->screen_ptr->b_pixmaps[WBUT_ENGL]; + 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); @@ -1101,8 +1090,8 @@ wFrameWindowPaint(WFrameWindow *fwin) if (fwin->left_button) handleButtonExpose(&fwin->left_button->descriptor, NULL); #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) - handleButtonExpose(&fwin->thai_button->descriptor, NULL); + if (fwin->language_button) + handleButtonExpose(&fwin->language_button->descriptor, NULL); #endif if (fwin->right_button) handleButtonExpose(&fwin->right_button->descriptor, NULL); @@ -1156,19 +1145,19 @@ reconfigure(WFrameWindow *fwin, int x, int y, int width, int height, } #ifdef XKB_BUTTON_HINT - if (fwin->thai_button) { - if (width < fwin->top_width*k && !fwin->flags.tbutton_dont_fit) { + if (fwin->language_button) { + if (width < fwin->top_width*k && !fwin->flags.languagebutton_dont_fit) { - if (!fwin->flags.hide_thai_button) { - XUnmapWindow(dpy, fwin->thai_button->window); + if (!fwin->flags.hide_language_button) { + XUnmapWindow(dpy, fwin->language_button->window); } - fwin->flags.tbutton_dont_fit = 1; - } else if (width >= fwin->top_width*k && fwin->flags.tbutton_dont_fit) { + fwin->flags.languagebutton_dont_fit = 1; + } else if (width >= fwin->top_width*k && fwin->flags.languagebutton_dont_fit) { - if (!fwin->flags.hide_thai_button) { - XMapWindow(dpy, fwin->thai_button->window); + if (!fwin->flags.hide_language_button) { + XMapWindow(dpy, fwin->language_button->window); } - fwin->flags.tbutton_dont_fit = 0; + fwin->flags.languagebutton_dont_fit = 0; } } #endif @@ -1313,9 +1302,9 @@ checkTitleSize(WFrameWindow *fwin) width -= fwin->left_button->width + 3; #ifdef XKB_BUTTON_HINT - if (fwin->thai_button && !fwin->flags.hide_thai_button - && !fwin->flags.tbutton_dont_fit) - width -= fwin->thai_button->width + 3; + 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 @@ -1431,12 +1420,12 @@ handleButtonExpose(WObjDescriptor *desc, XEvent *event) WCoreWindow *button = (WCoreWindow*)desc->self; #ifdef XKB_BUTTON_HINT - if (button == fwin->thai_button) { + if (button == fwin->language_button) { if (wPreferences.modelock){ paintButton(button, fwin->title_texture[fwin->flags.state], fwin->title_pixel[fwin->flags.state], - fwin->tbutton_image, False); + fwin->languagebutton_image, False); } } else #endif @@ -1512,9 +1501,9 @@ buttonMouseDown(WObjDescriptor *desc, XEvent *event) image = fwin->rbutton_image; } #ifdef XKB_BUTTON_HINT - if (button == fwin->thai_button) { + if (button == fwin->language_button) { if (!wPreferences.modelock) return; - image = fwin->tbutton_image; + image = fwin->languagebutton_image; } #endif @@ -1559,9 +1548,9 @@ buttonMouseDown(WObjDescriptor *desc, XEvent *event) (*fwin->on_click_right)(button, fwin->child, &ev); } #ifdef XKB_BUTTON_HINT - else if (button == fwin->thai_button) { - if (fwin->on_click_thai) - (*fwin->on_click_thai)(button, fwin->child, &ev); + 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 75a74927..4dd98f33 100644 --- a/src/framewin.h +++ b/src/framewin.h @@ -37,7 +37,7 @@ #define WFF_BORDER (1<<4) #define WFF_SINGLE_STATE (1<<5) #ifdef XKB_BUTTON_HINT -#define WFF_THAI_BUTTON (1<<6) +#define WFF_XKB_BUTTON (1<<6) #endif @@ -51,7 +51,7 @@ typedef struct WFrameWindow { WCoreWindow *titlebar; /* the titlebar */ WCoreWindow *left_button; /* miniaturize button */ #ifdef XKB_BUTTON_HINT - WCoreWindow *thai_button; + WCoreWindow *language_button; #endif WCoreWindow *right_button; /* close button */ @@ -69,13 +69,13 @@ typedef struct WFrameWindow { Pixmap lbutton_back[3]; Pixmap rbutton_back[3]; #ifdef XKB_BUTTON_HINT - Pixmap tbutton_back[3]; + Pixmap languagebutton_back[3]; #endif WPixmap *lbutton_image; WPixmap *rbutton_image; #ifdef XKB_BUTTON_HINT - WPixmap *tbutton_image; + WPixmap *languagebutton_image; #endif union WTexture **title_texture; @@ -88,6 +88,7 @@ typedef struct WFrameWindow { #ifdef KEEP_XKB_LOCK_STATUS int languagemode; + int last_languagemode; #endif /* KEEP_XKB_LOCK_STATUS */ /* thing that uses this frame. passed as data to callbacks */ @@ -96,7 +97,7 @@ typedef struct WFrameWindow { /* callbacks */ void (*on_click_left)(WCoreWindow *sender, void *data, XEvent *event); #ifdef XKB_BUTTON_HINT - void (*on_click_thai)(WCoreWindow *sender, void *data, XEvent *event); + void (*on_click_language)(WCoreWindow *sender, void *data, XEvent *event); #endif void (*on_click_right)(WCoreWindow *sender, void *data, XEvent *event); @@ -115,7 +116,7 @@ typedef struct WFrameWindow { unsigned int left_button:1; unsigned int right_button:1; #ifdef XKB_BUTTON_HINT - unsigned int thai_button:1; + unsigned int language_button:1; #endif unsigned int need_texture_remake:1; @@ -125,7 +126,7 @@ typedef struct WFrameWindow { unsigned int hide_left_button:1; unsigned int hide_right_button:1; #ifdef XKB_BUTTON_HINT - unsigned int hide_thai_button:1; + unsigned int hide_language_button:1; #endif unsigned int need_texture_change:1; @@ -133,7 +134,7 @@ typedef struct WFrameWindow { unsigned int lbutton_dont_fit:1; unsigned int rbutton_dont_fit:1; #ifdef XKB_BUTTON_HINT - unsigned int tbutton_dont_fit:1; + unsigned int languagebutton_dont_fit:1; #endif unsigned int repaint_only_titlebar:1; diff --git a/src/screen.c b/src/screen.c index ea0a083f..ee287a14 100644 --- a/src/screen.c +++ b/src/screen.c @@ -176,14 +176,22 @@ allocButtonPixmaps(WScreen *scr) pix->shared = 1; scr->b_pixmaps[WBUT_ICONIFY] = pix; #ifdef XKB_BUTTON_HINT - pix = wPixmapCreateFromXPMData(scr, PRED_THAI_XPM); + pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP1_XPM); if (pix) pix->shared = 1; - scr->b_pixmaps[WBUT_THAI] = pix; - pix = wPixmapCreateFromXPMData(scr, PRED_ENGL_XPM); + scr->b_pixmaps[WBUT_XKBGROUP1] = pix; + pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP2_XPM); if (pix) pix->shared = 1; - scr->b_pixmaps[WBUT_ENGL] = pix; + scr->b_pixmaps[WBUT_XKBGROUP2] = pix; + pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP3_XPM); + if (pix) + pix->shared = 1; + scr->b_pixmaps[WBUT_XKBGROUP3] = pix; + pix = wPixmapCreateFromXPMData(scr, PRED_XKBGROUP4_XPM); + if (pix) + pix->shared = 1; + scr->b_pixmaps[WBUT_XKBGROUP4] = pix; #endif @@ -705,8 +713,8 @@ wScreenInit(int screen_number) XSelectInput(dpy, scr->root_win, event_mask); #ifdef KEEP_XKB_LOCK_STATUS - XkbSelectEvents(dpy,XkbUseCoreKbd,XkbIndicatorStateNotifyMask, - XkbIndicatorStateNotifyMask); + XkbSelectEventDetails(dpy,XkbUseCoreKbd,XkbIndicatorStateNotify, + XkbIndicatorStateNotifyMask, XkbIndicatorStateNotifyMask); #endif /* KEEP_XKB_LOCK_STATUS */ XSync(dpy, False); diff --git a/src/screen.h b/src/screen.h index 9de3e4ee..7edaa83d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -46,10 +46,7 @@ typedef struct WFont { #define WTB_FOCUSED 0 #define WTB_UNFOCUSED 2 #define WTB_PFOCUSED 4 -#define WTB_MENU 6 -#ifdef XKB_BUTTON_HINT -#define WTB_THAI 7 -#endif +#define WTB_MENU 6 #ifdef GNOME_STUFF /* an area of the screen reserved by some window */ @@ -263,11 +260,7 @@ typedef struct _WScreen { struct WDialogData *dialog_data; #ifdef NEWSTUFF -#ifdef XKB_BUTTON_HINT - struct RImage *button_images[3][PRED_BPIXMAPS]; -#else struct RImage *button_images[2][PRED_BPIXMAPS];/* scaled tbar btn images */ -#endif #endif /* state and other informations */ diff --git a/src/window.c b/src/window.c index 00a08611..8f9436c9 100644 --- a/src/window.c +++ b/src/window.c @@ -124,7 +124,7 @@ static void windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event); static void windowIconifyClick(WCoreWindow *sender, void *data, XEvent *event); #ifdef XKB_BUTTON_HINT -static void windowThaiClick(WCoreWindow *sender, void *data, XEvent *event); +static void windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event); #endif static void titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event); @@ -893,7 +893,7 @@ wManageWindow(WScreen *scr, Window window) foo = WFF_LEFT_BUTTON | WFF_RIGHT_BUTTON; #ifdef XKB_BUTTON_HINT if (wPreferences.modelock) - foo |= WFF_THAI_BUTTON; + foo |= WFF_XKB_BUTTON; #endif if (!WFLAGP(wwin, no_titlebar)) foo |= WFF_TITLEBAR; @@ -943,8 +943,7 @@ wManageWindow(WScreen *scr, Window window) wwin->frame->on_click_left = windowIconifyClick; #ifdef XKB_BUTTON_HINT if (wPreferences.modelock) - wwin->frame->on_click_thai = windowThaiClick; - else wwin->frame->on_click_thai = NULL; + wwin->frame->on_click_language = windowLanguageClick; #endif wwin->frame->on_click_right = windowCloseClick; @@ -1255,7 +1254,7 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, foo = WFF_RIGHT_BUTTON; foo |= WFF_TITLEBAR; #ifdef XKB_BUTTON_HINT - foo |= WFF_THAI_BUTTON; + foo |= WFF_XKB_BUTTON; #endif wwin->frame = wFrameWindowCreate(scr, WMFloatingLevel, @@ -1284,10 +1283,9 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner, wwin->frame->workspace = wwin->screen_ptr->current_workspace; -#ifdef THAI +#ifdef XKB_BUTTON_HINT if (wPreferences.modelock) - wwin->frame->on_click_thai = windowThaiClick; - else wwin->frame->on_click_thai = NULL; + wwin->frame->on_click_language = windowLanguageClick; #endif wwin->frame->on_click_right = windowCloseClick; @@ -2012,11 +2010,11 @@ wWindowUpdateButtonImages(WWindow *wwin) } #ifdef XKB_BUTTON_HINT - if (!WFLAGP(wwin, no_thai_button)) { - if (fwin->tbutton_image && !fwin->tbutton_image->shared) { - wPixmapDestroy(fwin->tbutton_image); + if (!WFLAGP(wwin, no_language_button)) { + if (fwin->languagebutton_image && !fwin->languagebutton_image->shared) { + wPixmapDestroy(fwin->languagebutton_image); } - fwin->tbutton_image = scr->b_pixmaps[WBUT_ENGL]; + fwin->languagebutton_image = scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; } #endif @@ -2837,16 +2835,19 @@ windowCloseDblClick(WCoreWindow *sender, void *data, XEvent *event) #ifdef XKB_BUTTON_HINT static void -windowThaiClick(WCoreWindow *sender, void *data, XEvent *event) +windowLanguageClick(WCoreWindow *sender, void *data, XEvent *event) { WWindow *wwin = data; WFrameWindow *fwin = wwin->frame; WScreen *scr = fwin->screen_ptr; XkbStateRec staterec; + int tl; if (event->xbutton.button != Button1 && event->xbutton.button != Button3) return; - wwin->frame->languagemode = !wwin->frame->languagemode; + tl = wwin->frame->languagemode; + wwin->frame->languagemode = wwin->frame->last_languagemode; + wwin->frame->last_languagemode = tl; wFrameWindowPaint(fwin); wSetFocusTo(scr, wwin); if (event->xbutton.button == Button3) diff --git a/src/window.h b/src/window.h index fa6e0c9f..d8937071 100644 --- a/src/window.h +++ b/src/window.h @@ -92,7 +92,7 @@ typedef struct { unsigned int no_closable:1; unsigned int no_miniaturizable:1; #ifdef XKB_BUTTON_HINT - unsigned int no_thai_button:1; + unsigned int no_language_button:1; #endif /* decorations */