diff --git a/src/backend/backend.h b/src/backend/backend.h index 26ef205..3a53d65 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -91,6 +91,18 @@ typedef struct WMBackend { */ void (*display_close)(void); + /* + * Post-open initialization: validate the connection, set up visual IDs, + * parse display name for multi-head, set DISPLAY env var. + * Called from main.c immediately after display_open(). + * X11: checks dpy != NULL (fatal if not), sets default visual, parses + * screen number from display name, sets DISPLAY env. + * Wayland: no-op (display_open handles all setup internally). + * display_name: the user-supplied -display argument (may be NULL). + * multi_head_out: set to 0 if a specific screen was requested. + */ + void (*display_post_open)(const char *display_name, int *multi_head_out); + /* * Return the number of logical screens (X11: ScreenCount; Wayland: 1). * Called from main.c / StartUp() after display_open(). @@ -139,6 +151,16 @@ typedef struct WMBackend { */ void (*screen_open)(WScreen *scr); + /* + * Initialize the display-specific parts of the screen: RContext, + * WMScreen, color pixels. Returns 1 on success, 0 on failure. + * On success scr->rcontext, scr->wmscreen, scr->black/white/gray/ + * darkGray and the pixel values are all set. + * X11: creates RContext via wrlib, WMScreen via WINGs with dpy. + * Wayland: creates RContextWayland, WMScreen with NULL display. + */ + int (*screen_init_display)(WScreen *scr, int screen_number); + /* * Release all backend per-screen resources. * Called from wScreenFinish. @@ -1767,6 +1789,11 @@ typedef struct WMBackend { /* wrlib context creation */ RContext *(*create_rcontext)(int screen_number, RContextAttributes *attribs); + /* + * Show crash dialog. Returns WMAbort or WMStartAlternate. + */ + int (*show_crash_dialog)(int sig); + } WMBackend; /* diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 63fb5ce..a7f736d 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -2834,6 +2834,13 @@ wl_display_close(void) wl_state.started = 0; } +static void +wl_display_post_open(const char *display_name, int *multi_head_out) +{ + (void)display_name; + (void)multi_head_out; +} + static int wl_display_screen_count(void) { @@ -3592,6 +3599,40 @@ wl_screen_open(WScreen *scr) static void wl_screen_close(WScreen *scr) { (void)scr; } +static int +wl_screen_init_display(WScreen *scr, int screen_number) +{ + (void)screen_number; + scr->w_depth = 32; + scr->rcontext = RCreateContextWayland(scr->scr_width, scr->scr_height, NULL); + + scr->wmscreen = WMCreateScreenWithRContext(NULL, 0, scr->rcontext); + if (!scr->wmscreen) { + wfatal(_("could not initialize WINGs widget set")); + return 0; + } + + scr->black = WMBlackColor(scr->wmscreen); + scr->white = WMWhiteColor(scr->wmscreen); + scr->gray = WMGrayColor(scr->wmscreen); + scr->darkGray = WMDarkGrayColor(scr->wmscreen); + + scr->black_pixel = scr->black ? WMColorPixel(scr->black) : 0xFF000000; + scr->white_pixel = scr->white ? WMColorPixel(scr->white) : 0xFFFFFFFF; + scr->light_pixel = scr->gray ? WMColorPixel(scr->gray) : 0xFFAAAAAA; + scr->dark_pixel = scr->darkGray ? WMColorPixel(scr->darkGray) : 0xFF555555; + + return 1; +} + +static int +wl_show_crash_dialog(int sig) +{ + (void)sig; + werror(_("cannot open connection for crashing dialog panel. Aborting.")); + return 0; /* WMAbort */ +} + /* ------------------------------------------------------------------ */ /* Frame buffer (pixman + wlr_scene_buffer) */ /* ------------------------------------------------------------------ */ @@ -7210,6 +7251,7 @@ const WMBackend wl_backend = { .is_wayland = 1, /* Path 1: distinguishes Wayland from X11 */ .display_open = wl_display_open, .display_close = wl_display_close, + .display_post_open = wl_display_post_open, .display_screen_count = wl_display_screen_count, .display_default_screen = wl_display_default_screen, .atom_intern = wl_atom_intern, @@ -7217,7 +7259,9 @@ const WMBackend wl_backend = { .event_loop_terminate = wl_event_loop_terminate, .screen_open = wl_screen_open, + .screen_init_display = wl_screen_init_display, .screen_close = wl_screen_close, + .show_crash_dialog = wl_show_crash_dialog, .frame_create_toplevel = wl_frame_create_toplevel, .frame_create_child = wl_frame_create_child, diff --git a/src/backend/x11/x11_backend.c b/src/backend/x11/x11_backend.c index 9d9e382..0afb354 100644 --- a/src/backend/x11/x11_backend.c +++ b/src/backend/x11/x11_backend.c @@ -13,6 +13,11 @@ #include #include +#ifdef HAVE_INOTIFY +#include +#include +#include +#endif #include #include #include @@ -45,6 +50,8 @@ #include "../../window.h" /* WWindow -- for window_shape_clear/set */ #include "../../GNUstep.h" /* GNUstepWMAttributes */ #include "../../main.h" /* Exit() */ +#include "../../defaults.h" /* wDefaultsCheckDomains */ +#include "../../dialog.h" /* wShowCrashingDialogPanel */ #include "../../startup.h" /* wHackedGrabKey, wHackedGrabButton */ #include "../../def_pixmaps.h" #include "../../extend_pixmaps.h" @@ -117,6 +124,30 @@ x11_display_close(void) } } +static void +x11_display_post_open(const char *display_name, int *multi_head_out) +{ + if (dpy == NULL) { + wfatal(_("could not open display \"%s\""), XDisplayName(display_name)); + exit(1); + } + + if (getWVisualID(0) < 0) { + setWVisualID(0, (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid); + } + + if (display_name) { + const char *pos = strchr(display_name, ':'); + if (pos) { + int d, s; + if (sscanf(pos, ":%i.%i", &d, &s) == 2) + *multi_head_out = 0; + } + } + + setenv("DISPLAY", XDisplayName(display_name), 1); +} + static int x11_display_screen_count(void) { @@ -135,10 +166,90 @@ x11_atom_intern(const char *name) return (unsigned long)XInternAtom(dpy, name, False); } +#ifdef HAVE_INOTIFY +static void handle_inotify_events(void) +{ + ssize_t eventQLength; + size_t i = 0; + char buff[(sizeof(struct inotify_event) + NAME_MAX + 1) * 5]; + int oneShotFlag = 0; + + eventQLength = read(w_global.inotify.fd_event_queue, buff, sizeof(buff)); + if (eventQLength < 0) { + wwarning(_("read problem when trying to get INotify event: %s"), strerror(errno)); + return; + } + + while (i < (size_t)eventQLength) { + struct inotify_event *pevent = (struct inotify_event *)&buff[i]; + + if (pevent->mask & IN_DELETE_SELF) { + wwarning(_("the defaults database has been deleted!" + " Restart Window Maker to create the database" + " with the default settings")); + if (w_global.inotify.fd_event_queue >= 0) { + close(w_global.inotify.fd_event_queue); + w_global.inotify.fd_event_queue = -1; + } + } + if (pevent->mask & IN_UNMOUNT) { + wwarning(_("the unit containing the defaults database has" + " been unmounted. Setting --static mode." + " Any changes will not be saved.")); + if (w_global.inotify.fd_event_queue >= 0) { + close(w_global.inotify.fd_event_queue); + w_global.inotify.fd_event_queue = -1; + } + wPreferences.flags.noupdates = 1; + } + if ((pevent->mask & IN_MODIFY) && oneShotFlag == 0) { + wwarning(_("Inotify: Reading config files in defaults database.")); + wDefaultsCheckDomains(NULL); + oneShotFlag = 1; + } + i += sizeof(struct inotify_event) + pevent->len; + } +} +#endif + static void x11_event_loop_run(void) { - /* no-op: EventLoop() in event.c drives the X11/WINGs event pump */ + WMEvent event; +#ifdef HAVE_INOTIFY + struct timeval time; + fd_set rfds; + int retVal = 0; + + if (w_global.inotify.fd_event_queue < 0 || w_global.inotify.wd_defaults < 0) + retVal = -1; +#endif + + for (;;) { + WMNextEvent(wScreenWithNumber(0)->wmscreen, &event); + WMHandleEvent(&event); +#ifdef HAVE_INOTIFY + if (retVal != -1) { + time.tv_sec = 0; + time.tv_usec = 0; + FD_ZERO(&rfds); + FD_SET(w_global.inotify.fd_event_queue, &rfds); + + retVal = select(w_global.inotify.fd_event_queue + 1, &rfds, NULL, NULL, &time); + + if (retVal < 0) { + wwarning(_("select failed. The inotify instance will be closed." + " Changes to the defaults database will require" + " a restart to take effect.")); + close(w_global.inotify.fd_event_queue); + w_global.inotify.fd_event_queue = -1; + continue; + } + if (FD_ISSET(w_global.inotify.fd_event_queue, &rfds)) + handle_inotify_events(); + } +#endif + } } static void @@ -169,6 +280,67 @@ x11_screen_open(WScreen *scr) scr->scr_height = HeightOfScreen(ScreenOfDisplay(dpy, n)); } +static int +x11_screen_init_display(WScreen *scr, int screen_number) +{ + RContextAttributes rattr; + + rattr.flags = RC_RenderMode | RC_ColorsPerChannel | RC_StandardColormap; + rattr.render_mode = wPreferences.no_dithering ? RBestMatchRendering : RDitheredRendering; + rattr.colors_per_channel = wPreferences.cmap_size; + if (rattr.colors_per_channel < 2) + rattr.colors_per_channel = 2; + rattr.standard_colormap_mode = RUseStdColormap; + + if (getWVisualID(screen_number) >= 0) { + rattr.flags |= RC_VisualID; + rattr.visualid = getWVisualID(screen_number); + } + + scr->rcontext = RCreateContext(dpy, screen_number, &rattr); + if (!scr->rcontext && RErrorCode == RERR_STDCMAPFAIL) { + wwarning("%s", RMessageForError(RErrorCode)); + rattr.flags &= ~RC_StandardColormap; + rattr.standard_colormap_mode = RUseStdColormap; + scr->rcontext = RCreateContext(dpy, screen_number, &rattr); + } + if (!scr->rcontext) { + wfatal(_("can't create Context on screen %d, %s"), + screen_number, RMessageForError(RErrorCode)); + return 0; + } + + scr->w_win = scr->rcontext->drawable; + scr->w_visual = scr->rcontext->visual; + scr->w_depth = scr->rcontext->depth; + scr->w_colormap = scr->rcontext->cmap; + + scr->wmscreen = WMCreateScreenWithRContext(dpy, screen_number, scr->rcontext); + if (!scr->wmscreen) { + wfatal(_("could not initialize WINGs widget set")); + RDestroyContext(scr->rcontext); + return 0; + } + + scr->black = WMBlackColor(scr->wmscreen); + scr->white = WMWhiteColor(scr->wmscreen); + scr->gray = WMGrayColor(scr->wmscreen); + scr->darkGray = WMDarkGrayColor(scr->wmscreen); + + scr->black_pixel = WMColorPixel(scr->black); + scr->white_pixel = WMColorPixel(scr->white); + scr->light_pixel = WMColorPixel(scr->gray); + scr->dark_pixel = WMColorPixel(scr->darkGray); + + return 1; +} + +static int +x11_show_crash_dialog(int sig) +{ + return wShowCrashingDialogPanel(sig); +} + static void x11_screen_close(WScreen *scr) { @@ -4032,13 +4204,16 @@ const WMBackend x11_backend = { .is_wayland = 0, /* X11 backend: not Wayland */ .display_open = x11_display_open, .display_close = x11_display_close, + .display_post_open = x11_display_post_open, .display_screen_count = x11_display_screen_count, .display_default_screen = x11_display_default_screen, .atom_intern = x11_atom_intern, .event_loop_run = x11_event_loop_run, .event_loop_terminate = x11_event_loop_terminate, .screen_open = x11_screen_open, + .screen_init_display = x11_screen_init_display, .screen_close = x11_screen_close, + .show_crash_dialog = x11_show_crash_dialog, .frame_create_toplevel = x11_frame_create_toplevel, .frame_create_child = x11_frame_create_child, .frame_destroy = x11_frame_destroy, diff --git a/src/event.c b/src/event.c index 82ff195..06ec94f 100644 --- a/src/event.c +++ b/src/event.c @@ -90,7 +90,7 @@ static void handleKeyPress(WMEvent *event); static void handleFocusIn(WMEvent *event); static void handleMotionNotify(WMEvent *event); static void handleVisibilityNotify(WMEvent *event); -static void handle_inotify_events(void); +/* inotify handling moved to x11_backend.c (x11_event_loop_run) */ static void handle_selection_request(XSelectionRequestEvent *event); static void handle_selection_clear(XSelectionClearEvent *event); static void wdelete_death_handler(WMagicNumber id); @@ -284,84 +284,6 @@ void DispatchEvent(WMEvent * event) } } -#ifdef HAVE_INOTIFY -/* - *---------------------------------------------------------------------- - * handle_inotify_events- - * Check for inotify events - * - * Returns: - * After reading events for the given file descriptor (fd) and - * watch descriptor (wd) - * - * Side effects: - * Calls wDefaultsCheckDomains if config database is updated - *---------------------------------------------------------------------- - */ -static void handle_inotify_events(void) -{ - ssize_t eventQLength; - size_t i = 0; - /* Make room for at lease 5 simultaneous events, with path + filenames */ - char buff[ (sizeof(struct inotify_event) + NAME_MAX + 1) * 5 ]; - /* Check config only once per read of the event queue */ - int oneShotFlag = 0; - - /* - * Read off the queued events - * queue overflow is not checked (IN_Q_OVERFLOW). In practise this should - * not occur; the block is on Xevents, but a config file change will normally - * occur as a result of an Xevent - so the event queue should never have more than - * a few entries before a read(). - */ - eventQLength = read(w_global.inotify.fd_event_queue, - buff, sizeof(buff) ); - - if (eventQLength < 0) { - wwarning(_("read problem when trying to get INotify event: %s"), strerror(errno)); - return; - } - - /* check what events occurred */ - /* Should really check wd here too, but for now we only have one watch! */ - while (i < eventQLength) { - struct inotify_event *pevent = (struct inotify_event *)&buff[i]; - - /* - * see inotify.h for event types. - */ - if (pevent->mask & IN_DELETE_SELF) { - wwarning(_("the defaults database has been deleted!" - " Restart Window Maker to create the database" " with the default settings")); - - if (w_global.inotify.fd_event_queue >= 0) { - close(w_global.inotify.fd_event_queue); - w_global.inotify.fd_event_queue = -1; - } - } - if (pevent->mask & IN_UNMOUNT) { - wwarning(_("the unit containing the defaults database has" - " been unmounted. Setting --static mode." " Any changes will not be saved.")); - - if (w_global.inotify.fd_event_queue >= 0) { - close(w_global.inotify.fd_event_queue); - w_global.inotify.fd_event_queue = -1; - } - - wPreferences.flags.noupdates = 1; - } - if ((pevent->mask & IN_MODIFY) && oneShotFlag == 0) { - wwarning(_("Inotify: Reading config files in defaults database.")); - wDefaultsCheckDomains(NULL); - oneShotFlag = 1; - } - - /* move to next event in the buffer */ - i += sizeof(struct inotify_event) + pevent->len; - } -} -#endif /* HAVE_INOTIFY */ - /* *---------------------------------------------------------------------- * EventLoop- @@ -377,57 +299,8 @@ static void handle_inotify_events(void) */ noreturn void EventLoop(void) { - WMEvent event; -#ifdef HAVE_INOTIFY - struct timeval time; - fd_set rfds; - int retVal = 0; -#endif - - /* Wayland path: delegate to the backend's event loop (wl_display_run). - * When SIGTERM is received, event_loop_terminate() writes to a self-pipe - * which causes the event loop to call wl_display_terminate() from within - * loop context; wl_display_run() then returns here, and Exit(0) performs - * the final cleanup safely outside signal-handler and event-loop context. - * Path 1: use wm_backend->is_wayland rather than !dpy because dpy is set - * to the XWayland Display* even in Wayland-compositor mode. */ - if (!dpy || wm_backend->is_wayland) { - wm_backend->event_loop_run(); - Exit(0); - } - -#ifdef HAVE_INOTIFY - if (w_global.inotify.fd_event_queue < 0 || w_global.inotify.wd_defaults < 0) - retVal = -1; -#endif - - for (;;) { - - WMNextEvent(wScreenWithNumber(0)->wmscreen, &event); /* Blocks here */ - WMHandleEvent(&event); -#ifdef HAVE_INOTIFY - if (retVal != -1) { - time.tv_sec = 0; - time.tv_usec = 0; - FD_ZERO(&rfds); - FD_SET(w_global.inotify.fd_event_queue, &rfds); - - /* check for available read data from inotify - don't block! */ - retVal = select(w_global.inotify.fd_event_queue + 1, &rfds, NULL, NULL, &time); - - if (retVal < 0) { /* an error has occurred */ - wwarning(_("select failed. The inotify instance will be closed." - " Changes to the defaults database will require" - " a restart to take effect.")); - close(w_global.inotify.fd_event_queue); - w_global.inotify.fd_event_queue = -1; - continue; - } - if (FD_ISSET(w_global.inotify.fd_event_queue, &rfds)) - handle_inotify_events(); - } -#endif - } + wm_backend->event_loop_run(); + Exit(0); } /* diff --git a/src/main.c b/src/main.c index 8fb32ca..2ea4634 100644 --- a/src/main.c +++ b/src/main.c @@ -117,7 +117,7 @@ int getWVisualID(int screen) return wVisualID[screen]; } -static void setWVisualID(int screen, int val) +void setWVisualID(int screen, int val) { int i; @@ -616,8 +616,6 @@ int main(int argc, char **argv) static int real_main(int argc, char **argv) { int i; - char *pos; - int d, s; setlocale(LC_ALL, ""); wsetabort(wAbort); @@ -779,45 +777,7 @@ static int real_main(int argc, char **argv) /* open display */ dpy = (Display *)wm_backend->display_open(DisplayName); - if (!wm_backend->is_wayland && dpy == NULL) { - wfatal(_("could not open display \"%s\""), wm_backend->display_get_name(DisplayName)); - exit(1); - } - - if (!wm_backend->is_wayland) { - if (getWVisualID(0) < 0) { - /* - * If unspecified, use default visual instead of waiting - * for wrlib/context.c:bestContext() that may end up choosing - * the "fake" 24 bits added by the Composite extension. - * This is required to avoid all sort of corruptions when - * composite is enabled, and at a depth other than 24. - */ - setWVisualID(0, (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid); - } - - /* check if the user specified a complete display name (with screen). - * If so, only manage the specified screen */ - if (DisplayName) - pos = strchr(DisplayName, ':'); - else - pos = NULL; - - if (pos && sscanf(pos, ":%i.%i", &d, &s) == 2) - multiHead = False; - - DisplayName = wm_backend->display_get_name(DisplayName); - setenv("DISPLAY", DisplayName, 1); - - /* Path 1: skip XGetModifierMapping() when dpy is an XWayland - * display. XWayland can only service X11 requests when the - * Wayland event loop (wl_display_run) is running, which has not - * started yet at this point in main.c. Calling XGetModifierMapping - * before EventLoop() would deadlock waiting for a reply that - * XWayland cannot deliver. Modifier masks are handled via XKB - * in wl_backend (wSetModifierMasks), so this call is not needed. */ - /* Modifier initialization handled by extensions_init in X11 backend */ - } + wm_backend->display_post_open(DisplayName, &multiHead); StartUp(!multiHead); if (w_global.screen_count == 1) diff --git a/src/main.h b/src/main.h index cf61bc4..55c6ce6 100644 --- a/src/main.h +++ b/src/main.h @@ -36,5 +36,6 @@ Bool RelaunchWindow(WWindow *wwin); noreturn void wAbort(Bool dumpCore); void ExecExitScript(void); int getWVisualID(int screen); +void setWVisualID(int screen, int val); #endif diff --git a/src/monitor.c b/src/monitor.c index 013d48b..a40359f 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -41,13 +41,7 @@ static int showCrashDialog(int sig) { int crashAction; - if (!wm_backend->is_wayland) { - /* X11 backend handles crash dialog via separate connection */ - crashAction = wShowCrashingDialogPanel(sig); - } else { - werror(_("cannot open connection for crashing dialog panel. Aborting.")); - crashAction = WMAbort; - } + crashAction = wm_backend->show_crash_dialog(sig); if (crashAction == WMStartAlternate) { int i; diff --git a/src/screen.c b/src/screen.c index 7de94e6..dfc3076 100644 --- a/src/screen.c +++ b/src/screen.c @@ -117,7 +117,6 @@ void create_logo_image(WScreen *scr) WScreen *wScreenInit(int screen_number) { WScreen *scr; - RContextAttributes rattr = {}; int i; scr = wmalloc(sizeof(WScreen)); @@ -158,101 +157,7 @@ WScreen *wScreenInit(int screen_number) wm_backend->monitors_select_events(scr); wm_backend->screen_set_root_cursor(scr, WCUR_ROOT); - /* Wayland path: WM UI is pure Wayland (pixman + wlr_scene). - * XWayland exists only for X11 client apps, not for the WM itself. */ - if (wm_backend->is_wayland) { - scr->w_depth = 32; - scr->rcontext = RCreateContextWayland(scr->scr_width, scr->scr_height, NULL); - - /* WINGs screen — pure Wayland, no X11. */ - scr->wmscreen = WMCreateScreenWithRContext(NULL, 0, scr->rcontext); - - if (!scr->wmscreen) { - wfatal(_("could not initialize WINGs widget set")); - wfree(scr); - return NULL; - } - - scr->black = WMBlackColor(scr->wmscreen); - scr->white = WMWhiteColor(scr->wmscreen); - scr->gray = WMGrayColor(scr->wmscreen); - scr->darkGray = WMDarkGrayColor(scr->wmscreen); - - scr->black_pixel = scr->black ? WMColorPixel(scr->black) : 0xFF000000; - scr->white_pixel = scr->white ? WMColorPixel(scr->white) : 0xFFFFFFFF; - scr->light_pixel = scr->gray ? WMColorPixel(scr->gray) : 0xFFAAAAAA; - scr->dark_pixel = scr->darkGray ? WMColorPixel(scr->darkGray) : 0xFF555555; - - wm_backend->screen_alloc_gcs(scr); - wReadDefaults(scr, w_global.domain.wmaker->dictionary); - - if (scr->frame_border_color) - scr->frame_border_pixel = WMColorPixel(scr->frame_border_color); - if (scr->frame_focused_border_color) - scr->frame_focused_border_pixel = WMColorPixel(scr->frame_focused_border_color); - if (scr->frame_selected_border_color) - scr->frame_selected_border_pixel = WMColorPixel(scr->frame_selected_border_color); - - wm_backend->screen_create_internals(scr); - - scr->info_text_font = WMBoldSystemFontOfSize(scr->wmscreen, 12); - - wm_backend->netwm_init(scr); - wWorkspaceNew(scr); - wm_backend->screen_create_pixmaps(scr); - - scr->gview = WCreateGeometryView(scr->wmscreen); - if (scr->gview) - WMRealizeWidget(scr->gview); - - goto screen_done; - } - - /* screen descriptor for raster graphic library */ - rattr.flags = RC_RenderMode | RC_ColorsPerChannel | RC_StandardColormap; - rattr.render_mode = wPreferences.no_dithering ? RBestMatchRendering : RDitheredRendering; - - /* if the std colormap stuff works ok, this will be ignored */ - rattr.colors_per_channel = wPreferences.cmap_size; - if (rattr.colors_per_channel < 2) - rattr.colors_per_channel = 2; - - /* Use standard colormap */ - rattr.standard_colormap_mode = RUseStdColormap; - - if (getWVisualID(screen_number) >= 0) { - rattr.flags |= RC_VisualID; - rattr.visualid = getWVisualID(screen_number); - } - - scr->rcontext = wm_backend->create_rcontext(screen_number, &rattr); - - if (!scr->rcontext && RErrorCode == RERR_STDCMAPFAIL) { - wwarning("%s", RMessageForError(RErrorCode)); - - rattr.flags &= ~RC_StandardColormap; - rattr.standard_colormap_mode = RUseStdColormap; - - scr->rcontext = wm_backend->create_rcontext(screen_number, &rattr); - } - if (scr->rcontext == NULL) { - wfatal(_("can't create Context on screen %d, %s"), - screen_number, RMessageForError(RErrorCode)); - goto abort_no_context; - } - - scr->w_win = scr->rcontext->drawable; - scr->w_visual = scr->rcontext->visual; - scr->w_depth = scr->rcontext->depth; - scr->w_colormap = scr->rcontext->cmap; - - /* create screen descriptor for WINGs */ - scr->wmscreen = WMCreateScreenWithRContext(dpy, screen_number, scr->rcontext); - - if (!scr->wmscreen) { - wfatal(_("could not initialize WINGs widget set")); - RDestroyContext(scr->rcontext); - abort_no_context: + if (!wm_backend->screen_init_display(scr, screen_number)) { WMFreeArray(scr->fakeGroupLeaders); wfree(scr->totalUsableArea); wfree(scr->usableArea); @@ -261,25 +166,18 @@ WScreen *wScreenInit(int screen_number) return NULL; } - scr->black = WMBlackColor(scr->wmscreen); - scr->white = WMWhiteColor(scr->wmscreen); - scr->gray = WMGrayColor(scr->wmscreen); - scr->darkGray = WMDarkGrayColor(scr->wmscreen); - - scr->black_pixel = WMColorPixel(scr->black); - scr->white_pixel = WMColorPixel(scr->white); - scr->light_pixel = WMColorPixel(scr->gray); - scr->dark_pixel = WMColorPixel(scr->darkGray); - /* create GCs with default values */ wm_backend->screen_alloc_gcs(scr); /* read defaults for this screen */ wReadDefaults(scr, w_global.domain.wmaker->dictionary); - scr->frame_border_pixel = WMColorPixel(scr->frame_border_color); - scr->frame_focused_border_pixel = WMColorPixel(scr->frame_focused_border_color); - scr->frame_selected_border_pixel = WMColorPixel(scr->frame_selected_border_color); + if (scr->frame_border_color) + scr->frame_border_pixel = WMColorPixel(scr->frame_border_color); + if (scr->frame_focused_border_color) + scr->frame_focused_border_pixel = WMColorPixel(scr->frame_focused_border_color); + if (scr->frame_selected_border_color) + scr->frame_selected_border_pixel = WMColorPixel(scr->frame_selected_border_color); wm_backend->screen_create_internals(scr); @@ -315,7 +213,6 @@ WScreen *wScreenInit(int screen_number) wScreenUpdateUsableArea(scr); -screen_done: return scr; } diff --git a/src/shutdown.c b/src/shutdown.c index 9aa5cc2..c7093a7 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -72,8 +72,7 @@ void Shutdown(WShutdownMode mode) if (scr->helper_pid) kill(scr->helper_pid, SIGKILL); - if (!wm_backend->is_wayland) - wScreenSaveState(scr); + wScreenSaveState(scr); if (mode == WSKillMode) wm_backend->wipe_desktop(scr); @@ -99,8 +98,7 @@ void Shutdown(WShutdownMode mode) if (scr) { if (scr->helper_pid) kill(scr->helper_pid, SIGKILL); - if (!wm_backend->is_wayland) - wScreenSaveState(scr); + wScreenSaveState(scr); RestoreDesktop(scr); } } diff --git a/src/startup.c b/src/startup.c index e920e93..60ddfb6 100644 --- a/src/startup.c +++ b/src/startup.c @@ -452,8 +452,7 @@ void StartUp(Bool defaultScreenOnly) w_global.screen_count++; } - if (!wm_backend->is_wayland) - InitializeSwitchMenu(); + InitializeSwitchMenu(); /* initialize/restore state for the screens */ for (j = 0; j < w_global.screen_count; j++) { @@ -521,8 +520,7 @@ void StartUp(Bool defaultScreenOnly) } #ifndef HAVE_INOTIFY - /* setup defaults file polling (X11/WINGs timer only) */ - if (!wm_backend->is_wayland && !wPreferences.flags.noupdates) + if (!wPreferences.flags.noupdates) WMAddTimerHandler(3000, wDefaultsCheckDomains, NULL); #endif diff --git a/src/window.c b/src/window.c index f2aa7ed..916dba8 100644 --- a/src/window.c +++ b/src/window.c @@ -1147,13 +1147,11 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) wwin->frame->on_dblclick_titlebar = titlebarDblClick; wwin->frame->on_mousedown_resizebar = resizebarMouseDown; - if (!wm_backend->is_wayland) { - wm_backend->window_select_events(wwin->client_win, - wwin->event_mask & ~StructureNotifyMask); - wm_backend->client_reparent(wwin->client_win, wwin->frame->core->window, - 0, wwin->frame->top_width); - wm_backend->window_select_events(wwin->client_win, wwin->event_mask); - } + wm_backend->window_select_events(wwin->client_win, + wwin->event_mask & ~StructureNotifyMask); + wm_backend->client_reparent(wwin->client_win, wwin->frame->core->window, + 0, wwin->frame->top_width); + wm_backend->window_select_events(wwin->client_win, wwin->event_mask); { int gx, gy; @@ -1241,8 +1239,6 @@ WWindow *wManageWindow(WScreen *scr, WNativeWindow window) if (wwin->frame) wWindowMap(wwin); - else if (!dpy || wm_backend->is_wayland) - wwin->flags.mapped = 1; /* Wayland/XWayland: scene node visible by definition */ } /* setup stacking descriptor */