/** Get a supporting window to use. */ Window GetSupportingWindow() { if(trays) { return trays->window; } else if(supportingWindow != None) { return supportingWindow; } else { supportingWindow = JXCreateSimpleWindow(display, rootWindow, 0, 0, 1, 1, 0, 0, 0); return supportingWindow; } }
/** Load a gradient background. */ void LoadGradientBackground(BackgroundNode *bp) { XColor color1; XColor color2; char *temp; char *sep; int len; sep = strchr(bp->value, ':'); if(!sep) { bp->pixmap = None; bp->window = None; return; } /* Get the first color. */ len = (int)(sep - bp->value); temp = AllocateStack(len + 1); memcpy(temp, bp->value, len); temp[len] = 0; ParseColor(temp, &color1); ReleaseStack(temp); /* Get the second color. */ len = strlen(sep + 1); temp = AllocateStack(len + 1); memcpy(temp, sep + 1, len); temp[len] = 0; ParseColor(temp, &color2); ReleaseStack(temp); /* Create the window. */ bp->window = JXCreateSimpleWindow(display, rootWindow, 0, 0, rootWidth, rootHeight, 0, 0, 0); bp->pixmap = JXCreatePixmap(display, bp->window, rootWidth, rootHeight, rootDepth); if(color1.pixel == color2.pixel) { JXSetForeground(display, rootGC, color1.pixel); JXFillRectangle(display, bp->pixmap, rootGC, 0, 0, rootWidth, rootHeight); } else { DrawHorizontalGradient(bp->pixmap, rootGC, color1.pixel, color2.pixel, 0, 0, rootWidth, rootHeight); } }
/** Load an image background. */ void LoadImageBackground(BackgroundNode *bp) { IconNode *ip; int width, height; /* Load the icon. */ ExpandPath(&bp->value); ip = LoadNamedIcon(bp->value); if(JUNLIKELY(!ip)) { bp->pixmap = None; bp->window = None; Warning(_("background image not found: \"%s\""), bp->value); return; } /* We can't use render on these. */ ip->useRender = 0; /* Determine the size of the background pixmap. */ if(bp->type == BACKGROUND_TILE) { width = ip->image->width; height = ip->image->height; } else { width = rootWidth; height = rootHeight; } /* Create the window. */ bp->window = JXCreateSimpleWindow(display, rootWindow, 0, 0, rootWidth, rootHeight, 0, 0, 0); /* Create the pixmap. */ bp->pixmap = JXCreatePixmap(display, bp->window, width, height, rootDepth); /* Clear the pixmap in case it is too small. */ JXSetForeground(display, rootGC, 0); JXFillRectangle(display, bp->pixmap, rootGC, 0, 0, width, height); /* Draw the icon on the background pixmap. */ PutIcon(ip, bp->pixmap, 0, 0, width, height); /* We don't need the icon anymore. */ DestroyIcon(ip); }
/** Load a solid background. */ void LoadSolidBackground(BackgroundNode *bp) { XColor c; ParseColor(bp->value, &c); /* Create the window. */ bp->window = JXCreateSimpleWindow(display, rootWindow, 0, 0, rootWidth, rootHeight, 0, 0, 0); /* Create the pixmap. */ bp->pixmap = JXCreatePixmap(display, bp->window, 1, 1, rootDepth); JXSetForeground(display, rootGC, c.pixel); JXDrawPoint(display, bp->pixmap, rootGC, 0, 0); }
/** Startup the dock. */ void StartupDock(void) { char *selectionName; if(!dock) { /* No dock has been requested. */ return; } if(dock->window == None) { /* No dock yet. */ /* Get the selection atom. */ selectionName = AllocateStack(sizeof(BASE_SELECTION_NAME)); snprintf(selectionName, sizeof(BASE_SELECTION_NAME), BASE_SELECTION_NAME, rootScreen); dockAtom = JXInternAtom(display, selectionName, False); ReleaseStack(selectionName); /* The location and size of the window doesn't matter here. */ dock->window = JXCreateSimpleWindow(display, rootWindow, /* x, y, width, height */ 0, 0, 1, 1, /* border_size, border_color */ 0, 0, /* background */ colors[COLOR_TRAY_BG2]); JXSelectInput(display, dock->window, SubstructureNotifyMask | SubstructureRedirectMask | EnterWindowMask | PointerMotionMask | PointerMotionHintMask); } dock->cp->window = dock->window; }
/** Prepare the connection. */ void StartupConnection(void) { XSetWindowAttributes attr; #ifdef USE_SHAPE int shapeError; #endif #ifdef USE_XRENDER int renderEvent; int renderError; #endif struct sigaction sa; char name[32]; Window win; XEvent event; int revert; initializing = 1; OpenConnection(); #if 0 XSynchronize(display, True); #endif /* Create the supporting window used to verify JWM is running. */ supportingWindow = JXCreateSimpleWindow(display, rootWindow, 0, 0, 1, 1, 0, 0, 0); /* Get the atom used for the window manager selection. */ snprintf(name, 32, "WM_S%d", rootScreen); managerSelection = JXInternAtom(display, name, False); /* Get the current window manager and take the selection. */ GrabServer(); win = JXGetSelectionOwner(display, managerSelection); if(win != None) { JXSelectInput(display, win, StructureNotifyMask); } JXSetSelectionOwner(display, managerSelection, supportingWindow, CurrentTime); UngrabServer(); /* Wait for the current selection owner to give up the selection. */ if(win != None) { /* Note that we need to wait for the current selection owner * to exit before we can expect to select SubstructureRedirectMask. */ XIfEvent(display, &event, SelectionReleased, (XPointer)&win); JXSync(display, False); } event.xclient.display = display; event.xclient.type = ClientMessage; event.xclient.window = rootWindow; event.xclient.message_type = JXInternAtom(display, managerProperty, False); event.xclient.format = 32; event.xclient.data.l[0] = CurrentTime; event.xclient.data.l[1] = managerSelection; event.xclient.data.l[2] = supportingWindow; event.xclient.data.l[3] = 2; event.xclient.data.l[4] = 0; JXSendEvent(display, rootWindow, False, StructureNotifyMask, &event); JXSync(display, False); JXSetErrorHandler(ErrorHandler); clientContext = XUniqueContext(); frameContext = XUniqueContext(); /* Set the events we want for the root window. * Note that asking for SubstructureRedirect will fail * if another window manager is already running. */ attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | StructureNotifyMask | PropertyChangeMask | ColormapChangeMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | PointerMotionHintMask; JXChangeWindowAttributes(display, rootWindow, CWEventMask, &attr); memset(&sa, 0, sizeof(sa)); sa.sa_flags = 0; sa.sa_handler = HandleExit; sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sa.sa_flags = SA_NOCLDWAIT; sa.sa_handler = SIG_DFL; sigaction(SIGCHLD, &sa, NULL); #ifdef USE_SHAPE haveShape = JXShapeQueryExtension(display, &shapeEvent, &shapeError); if (haveShape) { Debug("shape extension enabled"); } else { Debug("shape extension disabled"); } #endif #ifdef USE_XRENDER haveRender = JXRenderQueryExtension(display, &renderEvent, &renderError); if(haveRender) { Debug("render extension enabled"); } else { Debug("render extension disabled"); } #endif /* Make sure we have input focus. */ win = None; JXGetInputFocus(display, &win, &revert); if(win == None) { JXSetInputFocus(display, rootWindow, RevertToParent, CurrentTime); } initializing = 0; }