#include "WINGsP.h" #include "wconfig.h" /* widgets.c is now backend-neutral. Every Xlib call has moved to * widgets_x11.c. WINGsP.h still pulls Xlib in transitively (will be * fixed in phase ε), so the Display * typedef in WMCreate* signatures * resolves through that. */ /********** data ************/ #define CHECK_BUTTON_ON_WIDTH 16 #define CHECK_BUTTON_ON_HEIGHT 16 static char *CHECK_BUTTON_ON[] = { " %", " .............%#", " ........... .%#", " .......... #.%#", " ......... #%.%#", " ........ #%..%#", " ... #.. #%...%#", " ... #% #%....%#", " ... % #%.....%#", " ... #%......%#", " ... #%.......%#", " ...#%........%#", " .............%#", " .............%#", " %%%%%%%%%%%%%%#", "%###############" }; #define CHECK_BUTTON_OFF_WIDTH 16 #define CHECK_BUTTON_OFF_HEIGHT 16 static char *CHECK_BUTTON_OFF[] = { " %", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " .............%#", " %%%%%%%%%%%%%%#", "%###############" }; #define RADIO_BUTTON_ON_WIDTH 15 #define RADIO_BUTTON_ON_HEIGHT 15 static char *RADIO_BUTTON_ON[] = { ".....%%%%%.....", "...%%#####%%...", "..%##.....%.%..", ".%#%.. .....", ".%#. ...", "%#.. .. ", "%#. . ", "%#. . ", "%#. . ", "%#. . ", ".%%. . .", ".%.. . .", "..%... .. ..", ".... ..... ...", "..... .....", }; #define RADIO_BUTTON_OFF_WIDTH 15 #define RADIO_BUTTON_OFF_HEIGHT 15 static char *RADIO_BUTTON_OFF[] = { ".....%%%%%.....", "...%%#####%%...", "..%##.......%..", ".%#%...........", ".%#............", "%#............ ", "%#............ ", "%#............ ", "%#............ ", "%#............ ", ".%%.......... .", ".%........... .", "..%......... ..", ".... ..... ...", "..... .....", }; #define TRISTATE_BUTTON_ON_WIDTH 15 #define TRISTATE_BUTTON_ON_HEIGHT 15 static char *TRISTATE_BUTTON_ON[] = { "%%%%%%%%%%%%%%.", "%%%%%%%%%%%%%. ", "%% . ", "%% ## ## . ", "%% ### ### . ", "%% ### ### . ", "%% ##### . ", "%% ### . ", "%% ##### . ", "%% ### ### . ", "%% ### ### . ", "%% ## ## . ", "%% . ", "%............. ", ". ", }; #define TRISTATE_BUTTON_OFF_WIDTH 15 #define TRISTATE_BUTTON_OFF_HEIGHT 15 static char *TRISTATE_BUTTON_OFF[] = { "%%%%%%%%%%%%%%.", "%%%%%%%%%%%%%. ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%% . ", "%............. ", ". ", }; #define TRISTATE_BUTTON_TRI_WIDTH 15 #define TRISTATE_BUTTON_TRI_HEIGHT 15 static char *TRISTATE_BUTTON_TRI[] = { "%%%%%%%%%%%%%%.", "%%%%%%%%%%%%%. ", "%% . ", "%% # # # # # . ", "%% # # # # . ", "%% # # # # # . ", "%% # # # # . ", "%% # # # # # . ", "%% # # # # . ", "%% # # # # # . ", "%% # # # # . ", "%% # # # # # . ", "%% . ", "%............. ", ". ", }; static char *BUTTON_ARROW[] = { "..................", "....##....#### ...", "...#.%....#... ...", "..#..%#####... ...", ".#............ ...", "#............. ...", ".#............ ...", "..#.. ...", "...#. ............", "....# ............" }; #define BUTTON_ARROW_WIDTH 18 #define BUTTON_ARROW_HEIGHT 10 static char *BUTTON_ARROW2[] = { " ", " ## ####. ", " # % # . ", " # %##### . ", " # . ", "# . ", " # . ", " # .......... ", " # . ", " #. " }; #define BUTTON_ARROW2_WIDTH 18 #define BUTTON_ARROW2_HEIGHT 10 static char *SCROLLER_DIMPLE[] = { ".%###.", "%#%%%%", "#%%...", "#%.. ", "#%. ", ".%. ." }; #define SCROLLER_DIMPLE_WIDTH 6 #define SCROLLER_DIMPLE_HEIGHT 6 static char *SCROLLER_ARROW_UP[] = { "....%....", "....#....", "...%#%...", "...###...", "..%###%..", "..#####..", ".%#####%.", ".#######.", "%#######%" }; static char *HI_SCROLLER_ARROW_UP[] = { " % ", " % ", " %%% ", " %%% ", " %%%%% ", " %%%%% ", " %%%%%%% ", " %%%%%%% ", "%%%%%%%%%" }; #define SCROLLER_ARROW_UP_WIDTH 9 #define SCROLLER_ARROW_UP_HEIGHT 9 static char *SCROLLER_ARROW_DOWN[] = { "%#######%", ".#######.", ".%#####%.", "..#####..", "..%###%..", "...###...", "...%#%...", "....#....", "....%...." }; static char *HI_SCROLLER_ARROW_DOWN[] = { "%%%%%%%%%", " %%%%%%% ", " %%%%%%% ", " %%%%% ", " %%%%% ", " %%% ", " %%% ", " % ", " % " }; #define SCROLLER_ARROW_DOWN_WIDTH 9 #define SCROLLER_ARROW_DOWN_HEIGHT 9 static char *SCROLLER_ARROW_LEFT[] = { "........%", "......%##", "....%####", "..%######", "%########", "..%######", "....%####", "......%##", "........%" }; static char *HI_SCROLLER_ARROW_LEFT[] = { " %", " %%%", " %%%%%", " %%%%%%%", "%%%%%%%%%", " %%%%%%%", " %%%%%", " %%%", " %" }; #define SCROLLER_ARROW_LEFT_WIDTH 9 #define SCROLLER_ARROW_LEFT_HEIGHT 9 static char *SCROLLER_ARROW_RIGHT[] = { "%........", "##%......", "####%....", "######%..", "########%", "######%..", "####%....", "##%......", "%........" }; static char *HI_SCROLLER_ARROW_RIGHT[] = { "% ", "%%% ", "%%%%% ", "%%%%%%% ", "%%%%%%%%%", "%%%%%%% ", "%%%%% ", "%%% ", "% " }; #define SCROLLER_ARROW_RIGHT_WIDTH 9 #define SCROLLER_ARROW_RIGHT_HEIGHT 9 static char *POPUP_INDICATOR[] = { " #==", " ......%#==", " ......%#%%", " ......%#%%", " %%%%%%%#%%", "#########%%", "==%%%%%%%%%", "==%%%%%%%%%" }; #define POPUP_INDICATOR_WIDTH 11 #define POPUP_INDICATOR_HEIGHT 8 static char *PULLDOWN_INDICATOR[] = { "=#######=", "=%===== =", "==%=== ==", "==%=== ==", "===%= ===", "===%= ===", "====%====" }; #define PULLDOWN_INDICATOR_WIDTH 9 #define PULLDOWN_INDICATOR_HEIGHT 7 #define CHECK_MARK_WIDTH 8 #define CHECK_MARK_HEIGHT 10 static char *CHECK_MARK[] = { "======== ", "======= #", "====== #%", "===== #%=", " #== #%==", " #% #%===", " % #%====", " #%=====", " #%======", "#%=======" }; #define STIPPLE_WIDTH 8 #define STIPPLE_HEIGHT 8 static char STIPPLE_BITS[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }; static int userWidgetCount = 0; /***** end data ******/ static WMPixmap *makePixmap(W_Screen * sPtr, char **data, int width, int height, int masked) { RImage *img; WMPixmap *pix; int x, y; RColor white_c = {0xff, 0xff, 0xff, 0xff}; RColor light_c = {0xae, 0xaa, 0xae, 0xff}; RColor dark_c = {0x55, 0x55, 0x55, 0xff}; RColor black_c = {0x00, 0x00, 0x00, 0xff}; RColor trans_c = {0xae, 0xaa, 0xae, 0x00}; img = RCreateImage(width, height, True); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { RColor *c; switch (data[y][x]) { case ' ': case 'w': c = &white_c; break; case '=': c = masked ? &trans_c : &light_c; break; case '.': case 'l': c = &light_c; break; case '%': case 'd': c = &dark_c; break; case '#': case 'b': default: c = &black_c; break; } RPutPixel(img, x, y, c); } } pix = WMCreatePixmapFromRImage(sPtr, img, 128); RReleaseImage(img); return pix; } #define T_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.tiff" #define X_WINGS_IMAGES_FILE RESOURCE_PATH"/Images.xpm" static Bool loadPixmaps(WMScreen * scr) { RImage *image, *tmp; RColor gray; RColor white; gray.red = 0xae; gray.green = 0xaa; gray.blue = 0xae; white.red = 0xff; white.green = 0xff; white.blue = 0xff; image = RLoadImage(scr->rcontext, T_WINGS_IMAGES_FILE, 0); if (!image) image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0); if (!image) { wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode)); return False; } /* home icon */ /* make it have a gray background */ tmp = RGetSubImage(image, 0, 0, 24, 24); RCombineImageWithColor(tmp, &gray); scr->homeIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* make it have a white background */ tmp = RGetSubImage(image, 0, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* trash can */ tmp = RGetSubImage(image, 104, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 104, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* create dir */ tmp = RGetSubImage(image, 104, 24, 24, 24); RCombineImageWithColor(tmp, &white); scr->createDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 104, 24, 24, 24); RCombineImageWithColor(tmp, &white); scr->altCreateDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* diskettes */ tmp = RGetSubImage(image, 24, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 24, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* unmount */ tmp = RGetSubImage(image, 0, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->unmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 0, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->altUnmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* Magnifying Glass Icon for ColorPanel */ tmp = RGetSubImage(image, 24, 0, 40, 32); RCombineImageWithColor(tmp, &gray); scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* ColorWheel Icon for ColorPanel */ tmp = RGetSubImage(image, 0, 25, 24, 24); scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* GrayScale Icon for ColorPanel */ tmp = RGetSubImage(image, 65, 0, 40, 24); scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* RGB Icon for ColorPanel */ tmp = RGetSubImage(image, 25, 33, 40, 24); scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* CMYK Icon for ColorPanel */ tmp = RGetSubImage(image, 65, 25, 40, 24); scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* HSB Icon for ColorPanel */ tmp = RGetSubImage(image, 0, 57, 40, 24); scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* CustomColorPalette Icon for ColorPanel */ tmp = RGetSubImage(image, 81, 57, 40, 24); scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* ColorList Icon for ColorPanel */ tmp = RGetSubImage(image, 41, 57, 40, 24); scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); RReleaseImage(image); return True; } /* * Platform backends (phase ζ). Each is a W_PlatformBackend instance * defined in its own backend file: * * W_PlatformBackendX11 — widgets_x11.c * W_PlatformBackendWLClient — wclient_wl.c (only when --enable-wayland-client) * * Referenced as weak symbols here so a build that excludes a backend * (e.g. --disable-x11-backend) links cleanly with the symbol resolving * to NULL. WMOpenScreen iterates the registry below. Order matters: * the first .detect() to return non-zero wins, so the more specific * backend (Wayland-client) is listed before the X11 fallback. */ extern const W_PlatformBackend W_PlatformBackendWLClient __attribute__((weak)); extern const W_PlatformBackend W_PlatformBackendX11 __attribute__((weak)); static const W_PlatformBackend *const wm_platform_backends[] = { &W_PlatformBackendWLClient, &W_PlatformBackendX11, NULL }; WMScreen *WMOpenScreen(const char *display) { /* First pass: ask each available backend if this display is theirs. */ for (int i = 0; wm_platform_backends[i]; i++) { const W_PlatformBackend *b = wm_platform_backends[i]; if (!b || !b->detect || !b->open) continue; /* weak-undefined: backend not linked in */ if (b->detect(display)) { WMScreen *scr = b->open(display); if (scr) return scr; wwarning(_("WINGs: %s backend failed to open display, trying next"), b->name); } } /* Second pass: nobody claimed it explicitly — try each in order. */ for (int i = 0; wm_platform_backends[i]; i++) { const W_PlatformBackend *b = wm_platform_backends[i]; if (!b || !b->open) continue; WMScreen *scr = b->open(display); if (scr) return scr; } wwarning(_("WINGs: no platform backend could open the display")); return NULL; } /* * W_screen_next_kind — communicates which widget backends the next * WMCreateScreenWithRContext call should install. Set by the platform * backend (e.g. wlclient_open in wclient_wl.c) before it calls * WMCreateScreenWithRContext. Default is X11. * * Replaces the previous WMAKER_USE_WAYLAND env-var dispatch — env * detection belongs in the platform backend's .detect() function, not * in shared code. */ static WMScreenKind wm_screen_next_kind = WM_SCREEN_KIND_X11; void W_SetNextScreenKind(WMScreenKind kind) { wm_screen_next_kind = kind; } WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * context) { W_Screen *scrPtr; static int initialized = 0; int wayland = (wm_screen_next_kind == WM_SCREEN_KIND_WAYLAND); /* Reset for the next call so leakage between WMOpenScreen invocations * can't accidentally pick the wrong backend set. */ wm_screen_next_kind = WM_SCREEN_KIND_X11; if (!initialized) { initialized = 1; W_ReadConfigurations(); assert(W_ApplicationInitialized()); } scrPtr = malloc(sizeof(W_Screen)); if (!scrPtr) return NULL; memset(scrPtr, 0, sizeof(W_Screen)); scrPtr->aflags.hasAppIcon = 1; scrPtr->display = display; scrPtr->screen = screen; scrPtr->rcontext = context; /* --- Backend selection --- */ scrPtr->depth = context ? context->depth : 32; scrPtr->visual = context ? context->visual : NULL; scrPtr->colormap = context ? context->cmap : 0; /* RContext->drawable is set to RootWindow() by RCreateContext (X11) * or 0 by RCreateContextWayland — use it directly so this file * doesn't need the X11 RootWindow() macro. */ scrPtr->rootWin = context ? context->drawable : WM_NATIVE_NONE; scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); /* * Backend selection. When --disable-x11-backend is configured the * W_*BackendX11 symbols are weak-undefined (resolve to NULL); the * Wayland path is the only valid choice in that case so we must not * land on an X11 branch. If the build did include X11 but the * caller asked for X11 mode (wayland=0) and somehow the symbols are * still missing, fall back to Wayland and warn — the screen is * unusable as X11 anyway. */ if (!wayland && &W_FontBackendX11 == NULL) { wwarning(_("WINGs: X11 backend not built; falling back to Wayland")); wayland = 1; } scrPtr->fontBackend = wayland ? &W_FontBackendWL : &W_FontBackendX11; scrPtr->fontBackendCtx = scrPtr->fontBackend->screen_init(scrPtr); scrPtr->eventBackend = wayland ? &W_EventBackendWL : &W_EventBackendX11; scrPtr->eventBackendCtx = scrPtr->eventBackend->screen_init(scrPtr); scrPtr->renderBackend = wayland ? &W_RenderBackendWL : &W_RenderBackendX11; scrPtr->renderBackendCtx = scrPtr->renderBackend->screen_init(scrPtr); scrPtr->viewBackend = wayland ? &W_ViewBackendWL : &W_ViewBackendX11; scrPtr->viewBackendCtx = scrPtr->viewBackend->screen_init(scrPtr); scrPtr->colorBackend = wayland ? &W_ColorBackendWL : &W_ColorBackendX11; scrPtr->colorBackendCtx = scrPtr->colorBackend->screen_init(scrPtr); /* --- Common init --- */ scrPtr->antialiasedText = WINGsConfiguration.antialiasedText; WMWhiteColor(scrPtr); WMBlackColor(scrPtr); WMGrayColor(scrPtr); WMDarkGrayColor(scrPtr); scrPtr->normalFont = WMSystemFontOfSize(scrPtr, 0); scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr, 0); if (!scrPtr->boldFont) scrPtr->boldFont = scrPtr->normalFont; if (!scrPtr->normalFont) { wwarning(_("could not load any fonts.")); return NULL; } /* --- Platform-specific late init (GCs, atoms, cursors, pixmaps, IM) --- */ if (scrPtr->viewBackend->platform_init) scrPtr->viewBackend->platform_init(scrPtr); /* --- Widget pixmaps (backend-neutral via RImage) --- */ scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON, CHECK_BUTTON_ON_WIDTH, CHECK_BUTTON_ON_HEIGHT, False); scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF, CHECK_BUTTON_OFF_WIDTH, CHECK_BUTTON_OFF_HEIGHT, False); scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON, RADIO_BUTTON_ON_WIDTH, RADIO_BUTTON_ON_HEIGHT, False); scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF, RADIO_BUTTON_OFF_WIDTH, RADIO_BUTTON_OFF_HEIGHT, False); scrPtr->tristateButtonImageOn = makePixmap(scrPtr, TRISTATE_BUTTON_ON, TRISTATE_BUTTON_ON_WIDTH, TRISTATE_BUTTON_ON_HEIGHT, False); scrPtr->tristateButtonImageOff = makePixmap(scrPtr, TRISTATE_BUTTON_OFF, TRISTATE_BUTTON_OFF_WIDTH, TRISTATE_BUTTON_OFF_HEIGHT, False); scrPtr->tristateButtonImageTri = makePixmap(scrPtr, TRISTATE_BUTTON_TRI, TRISTATE_BUTTON_TRI_WIDTH, TRISTATE_BUTTON_TRI_HEIGHT, False); scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW, BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT, False); scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2, BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT, False); scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE, SCROLLER_DIMPLE_WIDTH, SCROLLER_DIMPLE_HEIGHT, False); scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP, SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True); scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN, SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True); scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT, SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True); scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT, SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True); scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP, SCROLLER_ARROW_UP_WIDTH, SCROLLER_ARROW_UP_HEIGHT, True); scrPtr->hiDownArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_DOWN, SCROLLER_ARROW_DOWN_WIDTH, SCROLLER_ARROW_DOWN_HEIGHT, True); scrPtr->hiLeftArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_LEFT, SCROLLER_ARROW_LEFT_WIDTH, SCROLLER_ARROW_LEFT_HEIGHT, True); scrPtr->hiRightArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_RIGHT, SCROLLER_ARROW_RIGHT_WIDTH, SCROLLER_ARROW_RIGHT_HEIGHT, True); scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR, POPUP_INDICATOR_WIDTH, POPUP_INDICATOR_HEIGHT, True); scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR, PULLDOWN_INDICATOR_WIDTH, PULLDOWN_INDICATOR_HEIGHT, True); scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK, CHECK_MARK_WIDTH, CHECK_MARK_HEIGHT, True); loadPixmaps(scrPtr); /* --- Final common init --- */ scrPtr->rootView = W_CreateRootView(scrPtr); scrPtr->balloon = W_CreateBalloon(scrPtr); return scrPtr; } void WMSetWidgetDefaultFont(WMScreen * scr, WMFont * font) { WMReleaseFont(scr->normalFont); scr->normalFont = WMRetainFont(font); } void WMSetWidgetDefaultBoldFont(WMScreen * scr, WMFont * font) { WMReleaseFont(scr->boldFont); scr->boldFont = WMRetainFont(font); } void WMHangData(WMWidget * widget, void *data) { W_VIEW(widget)->hangedData = data; } void *WMGetHangedData(WMWidget * widget) { return W_VIEW(widget)->hangedData; } void WMDestroyWidget(WMWidget * widget) { W_UnmapView(W_VIEW(widget)); W_DestroyView(W_VIEW(widget)); } void WMSetFocusToWidget(WMWidget * widget) { W_SetFocusOfTopLevel(W_TopLevelOfView(W_VIEW(widget)), W_VIEW(widget)); } /* * WMRealizeWidget- * Realizes the widget and all its children. * */ void WMRealizeWidget(WMWidget * w) { W_RealizeView(W_VIEW(w)); } void WMMapWidget(WMWidget * w) { W_MapView(W_VIEW(w)); } void WMReparentWidget(WMWidget * w, WMWidget * newParent, int x, int y) { W_ReparentView(W_VIEW(w), W_VIEW(newParent), x, y); } static void makeChildrenAutomap(W_View * view, int flag) { view = view->childrenList; while (view) { view->flags.mapWhenRealized = flag; makeChildrenAutomap(view, flag); view = view->nextSister; } } void WMMapSubwidgets(WMWidget * w) { /* make sure that subwidgets created after the parent was realized * are mapped too */ if (!W_VIEW(w)->flags.realized) { makeChildrenAutomap(W_VIEW(w), True); } else { W_MapSubviews(W_VIEW(w)); } } void WMUnmapSubwidgets(WMWidget * w) { if (!W_VIEW(w)->flags.realized) { makeChildrenAutomap(W_VIEW(w), False); } else { W_UnmapSubviews(W_VIEW(w)); } } void WMUnmapWidget(WMWidget * w) { W_UnmapView(W_VIEW(w)); } Bool WMWidgetIsMapped(WMWidget * w) { return W_VIEW(w)->flags.mapped; } void WMSetWidgetBackgroundColor(WMWidget * w, WMColor * color) { W_SetViewBackgroundColor(W_VIEW(w), color); if (W_VIEW(w)->flags.mapped) WMRedisplayWidget(w); } WMColor *WMGetWidgetBackgroundColor(WMWidget * w) { return W_VIEW(w)->backColor; } void WMSetWidgetBackgroundPixmap(WMWidget *w, WMPixmap *pix) { if (!pix) return; W_SetViewBackgroundPixmap(W_VIEW(w), pix); if (W_VIEW(w)->flags.mapped) WMRedisplayWidget(w); } WMPixmap *WMGetWidgetBackgroundPixmap(WMWidget *w) { return W_VIEW(w)->backImage; } void WMRaiseWidget(WMWidget * w) { W_RaiseView(W_VIEW(w)); } void WMLowerWidget(WMWidget * w) { W_LowerView(W_VIEW(w)); } void WMMoveWidget(WMWidget * w, int x, int y) { W_MoveView(W_VIEW(w), x, y); } void WMResizeWidget(WMWidget * w, unsigned int width, unsigned int height) { W_ResizeView(W_VIEW(w), width, height); } W_Class W_RegisterUserWidget(void) { userWidgetCount++; return userWidgetCount + WC_UserWidget - 1; } RContext *WMScreenRContext(WMScreen * scr) { return scr->rcontext; } unsigned int WMWidgetWidth(WMWidget * w) { return W_VIEW(w)->size.width; } unsigned int WMWidgetHeight(WMWidget * w) { return W_VIEW(w)->size.height; } WNativeWindow WMWidgetXID(WMWidget * w) { return W_VIEW(w)->window; } WMScreen *WMWidgetScreen(WMWidget * w) { return W_VIEW(w)->screen; } void WMScreenMainLoop(WMScreen * scr) { WMEvent event; while (1) { WMNextEvent(scr, &event); WMHandleEvent(&event); } } void WMBreakModalLoop(WMScreen * scr) { scr->modalLoop = 0; } void WMRunModalLoop(WMScreen * scr, WMView * view) { /* why is scr passed if is determined from the view? */ /*WMScreen *scr = view->screen; */ int oldModalLoop = scr->modalLoop; WMView *oldModalView = scr->modalView; W_View *ptr; int needsRedisplay = 1; scr->modalView = view; scr->modalLoop = 1; while (scr->modalLoop) { WMEvent event; WMNextEvent(scr, &event); WMHandleEvent(&event); if (needsRedisplay) { needsRedisplay = 0; for (ptr = view->childrenList; ptr; ptr = ptr->nextSister) W_RedisplayView(ptr); } /* Wayland: re-composite and commit after each event */ if (!scr->display) { const W_ViewBackend *vb = scr->viewBackend; W_View *top = view; while (top->parent && !top->flags.topLevel) top = top->parent; vb->map(scr->viewBackendCtx, top); } } scr->modalView = oldModalView; scr->modalLoop = oldModalLoop; } Display *WMScreenDisplay(WMScreen * scr) { return scr->display; } int WMScreenDepth(WMScreen * scr) { return scr->depth; } unsigned int WMScreenWidth(WMScreen * scr) { return scr->rootView->size.width; } unsigned int WMScreenHeight(WMScreen * scr) { return scr->rootView->size.height; } void WMRedisplayWidget(WMWidget * w) { W_RedisplayView(W_VIEW(w)); }