void client_resize(Client* client, XRectangle rect) { Monitor* m; if (client->fullscreen && (m = find_monitor_with_tag(client->tag))) { XSetWindowBorderWidth(gDisplay, client->window, 0); client->last_size = m->rect; XMoveResizeWindow(gDisplay, client->window, m->rect.x, m->rect.y, m->rect.width, m->rect.height); } else if (!client->floating) { // apply border width rect.width -= (window_border_width*2); rect.height -= (window_border_width*2); // ensure minimum size if (rect.width < WIN_MIN_WIDTH) rect.width = WIN_MIN_WIDTH; if (rect.height < WIN_MIN_HEIGHT) rect.height = WIN_MIN_HEIGHT; if (!client) return; Window win = client->window; if (client) { if (RECTANGLE_EQUALS(client->last_size, rect)) return; client->last_size = rect; } XSetWindowBorderWidth(gDisplay, win, window_border_width); XMoveResizeWindow(gDisplay, win, rect.x, rect.y, rect.width, rect.height); } }
void flushclients() { unsigned int i, nwins; Window dw1, dw2, *wins; Client *c; #ifdef ASSIMILATE_WINDOWS Scrn *scr2; #endif if((scr = front)) do { scr = scr->upfront; XQueryTree(dpy, scr->back, &dw1, &dw2, &wins, &nwins); for(i=0; i<nwins; i++) if((!XFindContext(dpy, wins[i], client_context, (XPointer *)&c))&&wins[i]==c->parent) { int x,y; grav_map_frame_to_win(c, c->x, c->y, &x, &y); XReparentWindow(dpy, c->window, scr->root, x, y); XSetWindowBorderWidth(dpy, c->window, c->old_bw); XRemoveFromSaveSet(dpy, c->window); wins[i]=c->window; rmclient(c); } #ifdef ASSIMILATE_WINDOWS else if((!XFindContext(dpy, wins[i], screen_context, (XPointer *)&scr2)) && scr2==scr) { XWindowAttributes attr; XSetWindowAttributes xsa; XGetWindowAttributes(dpy, wins[i], &attr); XReparentWindow(dpy, wins[i], scr->root, attr.x, attr.y); xsa.override_redirect = True; XChangeWindowAttributes(dpy, wins[i], CWOverrideRedirect, &xsa); XDeleteContext(dpy, wins[i], screen_context); XRemoveFromSaveSet(dpy, wins[i]); } #endif /* if(nwins) { for(i=0; i<(nwins>>1); i++) { Window w=wins[i]; wins[i]=wins[nwins-1-i]; wins[nwins-1-i]=w; } XRestackWindows(dpy, wins, nwins); } */ XFree((void *) wins); } while(scr!=front); while((c=clients)) { if(c->parent != c->scr->root) { int x,y; grav_map_frame_to_win(c, c->x, c->y, &x, &y); XReparentWindow(dpy, c->window, c->scr->root, x, y); XSetWindowBorderWidth(dpy, c->window, c->old_bw); XRemoveFromSaveSet(dpy, c->window); } rmclient(c); } }
void respond_box(const char *button, const char *message) { int l1 = strlen(message); int l2 = strlen(button); int width; int height; int done = 0; XEvent ev; Window wmain, wb, wm; width = l1; if (l1 < l2) width = l2; width = width + 4; height = 5 * DCURY; wmain = make_plain_window(RootWindow(display, screen), DisplayWidth / 2, DisplayHeight / 2, width * DCURX, height, 4); make_icon((char *)alert_bits, alert_width, alert_height, wmain); wm = make_plain_window(wmain, ((width - l1) * DCURX) / 2, DCURY / 2, l1 * DCURX, DCURY, 0); wb = make_window(wmain, ((width - l2) * DCURX) / 2, 2 * DCURY, l2 * DCURX, DCURY, 1); ping(); set_window_title(wmain, "!!"); XSelectInput(display, wb, BUT_MASK); while (!done) { XNextEvent(display, &ev); switch (ev.type) { case Expose: case MapNotify: do_expose(ev); expose_resp_box(button, message, wb, wm, ev.xexpose.window); break; case KeyPress: done = 1; break; case ButtonPress: if (ev.xbutton.window == wb) done = 1; break; case EnterNotify: if (ev.xcrossing.window == wb) XSetWindowBorderWidth(display, wb, 2); break; case LeaveNotify: if (ev.xcrossing.window == wb) XSetWindowBorderWidth(display, wb, 1); break; } } XSelectInput(display, wb, EV_MASK); waitasec(ClickTime); XDestroySubwindows(display, wmain); XDestroyWindow(display, wmain); }
void mainLoop() { while(1) { //Process event XNextEvent(display, &event); if(event.type == KeyPress && event.xkey.subwindow != None) { XRaiseWindow(display, event.xkey.subwindow); } else if(event.type == ButtonPress && event.xbutton.subwindow != None) { printf("subwindow: %lu\n", event.xbutton.subwindow); XGetWindowAttributes(display, event.xbutton.subwindow, &attr1); btnEvnt = event.xbutton; } else if(event.type == MotionNotify && btnEvnt.subwindow != None) { XSetWindowBorderWidth(display, btnEvnt.subwindow, 3); int xdiff = event.xbutton.x_root - btnEvnt.x_root; int ydiff = event.xbutton.y_root - btnEvnt.y_root; if(btnEvnt.button == 1) { XGetWindowAttributes(display, btnEvnt.subwindow, &attr); if(attr.y <= 1 && !loosing) { lastWidth = attr.width; lastHeight = attr.height; XMoveResizeWindow(display, btnEvnt.subwindow, 0, 0, screen->width, screen->height); } else { //TODO workaroung if(lastWidth == 0) { lastWidth = attr.width; lastHeight = attr.height; } XMoveResizeWindow(display, btnEvnt.subwindow, MAX(1, attr1.x + xdiff), MAX(1, attr1.y + ydiff), lastWidth, lastHeight); //Move and loose from Top loosing = 1; } } else if(btnEvnt.button == 3) { //Resize lastWidth = MAX(1, attr1.width + xdiff); lastHeight = MAX(1, attr1.height + ydiff); XMoveResizeWindow(display, btnEvnt.subwindow, attr1.x, attr1.y, lastWidth, lastHeight); } } else if(event.type == ButtonRelease) { XSetWindowBorderWidth(display, btnEvnt.subwindow, 0); btnEvnt.subwindow = None; loosing = 1; } } }
void x11_menu_event(X11Menu *m, const XEvent *ev) { int key; switch (ev->type) { case Expose: case MapNotify: x11_menu_draw(m); break; case KeyPress: key = get_key_press(ev); if (key == '\r') key = m->descr.def_key; if (key) m->select_func(m->cookie, key); break; case ButtonRelease: for (int i = 0; i < m->entry_wins.len; i++) { if (ev->xbutton.window == m->entry_wins.elems[i]) { m->select_func(m->cookie, m->descr.entries[i].key); break; } } break; case EnterNotify: for (int i = 0; i < m->entry_wins.len; i++) { if (ev->xcrossing.window == m->entry_wins.elems[i]) { XSetWindowBorderWidth(display, m->entry_wins.elems[i], 1); if (TipsFlag) x11_status_bar_set_text(m->sb, m->descr.entries[i].hint); break; } } break; case LeaveNotify: for (int i = 0; i < m->entry_wins.len; i++) { if (ev->xcrossing.window == m->entry_wins.elems[i]) { XSetWindowBorderWidth(display, m->entry_wins.elems[i], 0); break; } } break; } }
Bool container_client_add(container_t *container, client_t *client) { XWindowAttributes attr; int ret; container_t *tmp = NULL; ret = XFindContext(container->wm->dpy, client->window, container_context, (XPointer*)&tmp); if (ret != XCNOENT) { wm_log(container->wm, LOG_INFO, "%s: ignoring attempt to add container as a client: %d", __func__, client->window); return False; } /* Ignore the add if this window already belongs to a container */ ret = XFindContext(container->wm->dpy, client->window, client_container_context, (XPointer*)&tmp); if (ret != XCNOENT) { wm_log(container->wm, LOG_INFO, "%s: window %d already in a container, ignoring mapnotify", __func__, client->window); return False; } wm_log(container->wm, LOG_INFO, "%s: client add window %d", __func__, client->window); XAddToSaveSet(container->wm->dpy, client->window); XGetWindowAttributes(container->wm->dpy, container->frame, &attr); XSetWindowBorderWidth(container->wm->dpy, client->window, 0); XSelectInput(container->wm->dpy, client->window, CLIENT_EVENT_MASK); XReparentWindow(container->wm->dpy, client->window, container->frame, 0, TITLE_HEIGHT); XResizeWindow(container->wm->dpy, client->window, attr.width, attr.height - TITLE_HEIGHT); XSaveContext(container->wm->dpy, client->window, client_container_context, (XPointer)container); //container_paint(container); container_client_show(container, client); return True; }
static void reparent(client_t *c, strut_t *s) { XSetWindowAttributes pattr; geom_t f; f = frame_geom(c); pattr.override_redirect = True; pattr.background_pixel = bg.pixel; pattr.border_pixel = bd.pixel; pattr.event_mask = SubMask|ButtonPressMask|ExposureMask|EnterWindowMask; c->frame = XCreateWindow(dpy, root, f.x, f.y, f.w, f.h, BW(c), DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr); #ifdef SHAPE if (shape) { XShapeSelectInput(dpy, c->win, ShapeNotifyMask); set_shape(c); } #endif #ifdef XFT c->xftdraw = XftDrawCreate(dpy, (Drawable)c->frame, DefaultVisual(dpy, DefaultScreen(dpy)), DefaultColormap(dpy, DefaultScreen(dpy))); #endif XAddToSaveSet(dpy, c->win); XSelectInput(dpy, c->win, ColormapChangeMask|PropertyChangeMask); XSetWindowBorderWidth(dpy, c->win, 0); XResizeWindow(dpy, c->win, c->geom.w, c->geom.h); XReparentWindow(dpy, c->win, c->frame, 0, frame_height(c)); send_config(c); }
void init_xterm(int move) { XEvent ev; system(command); while (1) { XMaskEvent(dpy, SubstructureNotifyMask, &ev); if (ev.type == CreateNotify || ev.type == MapNotify) { termwin = ev.xcreatewindow.window; break; } } XSetWindowBorderWidth(dpy, termwin, 0); if (move) { resize_inc = get_height_inc(); height = get_optimal_height(resize_inc * opt_height); resize_term(opt_width, height); XMoveWindow(dpy, win, opt_x, -(height + opt_bw)); XSync(dpy, False); } XSetInputFocus(dpy, termwin, RevertToPointerRoot, CurrentTime); XSync(dpy, False); }
void clientwin_move(ClientWin *cw, float f, int x, int y) { /* int border = MAX(1, (double)DISTANCE(cw->mainwin) * f * 0.25); */ int border = 0; XSetWindowBorderWidth(cw->mainwin->dpy, cw->mini.window, border); cw->factor = f; cw->mini.x = x + (int)cw->x * f; cw->mini.y = y + (int)cw->y * f; if(cw->mainwin->lazy_trans) { cw->mini.x += cw->mainwin->x; cw->mini.y += cw->mainwin->y; } cw->mini.width = MAX(1, (int)cw->client.width * f); cw->mini.height = MAX(1, (int)cw->client.height * f); XMoveResizeWindow(cw->mainwin->dpy, cw->mini.window, cw->mini.x - border, cw->mini.y - border, cw->mini.width, cw->mini.height); if(cw->pixmap) XFreePixmap(cw->mainwin->dpy, cw->pixmap); if(cw->destination) XRenderFreePicture(cw->mainwin->dpy, cw->destination); cw->pixmap = XCreatePixmap(cw->mainwin->dpy, cw->mini.window, cw->mini.width, cw->mini.height, cw->mainwin->depth); XSetWindowBackgroundPixmap(cw->mainwin->dpy, cw->mini.window, cw->pixmap); cw->destination = XRenderCreatePicture(cw->mainwin->dpy, cw->pixmap, cw->mini.format, 0, 0); }
/*************************************************************************** * * * Looks for an application supplied icon window * *************************************************************************** */ void GetIconWindow(struct icon_info *item) { int x, y; unsigned int bw; Window Junkroot; if(!XGetGeometry(dpy, item->wmhints->icon_window, &Junkroot, &x, &y, (unsigned int *)&item->icon_w, (unsigned int *)&item->icon_h, &bw, (unsigned int *)&item->icon_depth)) { /* disable the icon window hint */ item->wmhints->icon_window = None; item->wmhints->flags &= ~IconWindowHint; return; } item->icon_pixmap_w = item->wmhints->icon_window; if (FShapesSupported && (item->wmhints->flags & IconMaskHint)) { SET_ICON_SHAPED(item, True); item->icon_maskPixmap = item->wmhints->icon_mask; } item->icon_w = min(max_icon_width + icon_relief, item->icon_w); item->icon_h = min(max_icon_height + icon_relief, item->icon_h); XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0); XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0); SET_ICON_OURS(item, False); SET_PIXMAP_OURS(item, False); }
static xwin*xwinget(Window w){ int n; xwin*xw=NULL; int firstavail=-1; for(n=0;n<xwinsct;n++){ if(wins[n].bits&1){//? magicnum1 if(wins[n].w==w){ return &wins[n]; } }else{ if(firstavail==-1){ firstavail=n; } } } if(firstavail==-1){ fprintf(flog,"!!! no free windows\n"); fflush(flog); sleep(5); return xwinget(w); } xw=&wins[firstavail]; xw->bits|=1;//allocated wincount++; fprintf(flog," wincount: %d\n",wincount); fflush(flog); xw->w=w; xw->vh=0; xw->desk=dsk; XSetWindowBorderWidth(dpy,w,border_width); return xw; }
ObPopup *popup_new(void) { XSetWindowAttributes attrib; ObPopup *self = g_slice_new0(ObPopup); self->obwin.type = OB_WINDOW_CLASS_INTERNAL; self->gravity = NorthWestGravity; self->x = self->y = self->textw = self->h = 0; self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_bg); self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); self->iconwm = self->iconhm = 1; attrib.override_redirect = True; self->bg = XCreateWindow(obt_display, obt_root(ob_screen), 0, 0, 1, 1, 0, RrDepth(ob_rr_inst), InputOutput, RrVisual(ob_rr_inst), CWOverrideRedirect, &attrib); self->text = XCreateWindow(obt_display, self->bg, 0, 0, 1, 1, 0, RrDepth(ob_rr_inst), InputOutput, RrVisual(ob_rr_inst), 0, NULL); XSetWindowBorderWidth(obt_display, self->bg, ob_rr_theme->obwidth); XSetWindowBorder(obt_display, self->bg, RrColorPixel(ob_rr_theme->osd_border_color)); XMapWindow(obt_display, self->text); stacking_add(INTERNAL_AS_WINDOW(self)); window_add(&self->bg, INTERNAL_AS_WINDOW(self)); return self; }
ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client) { ObMenuFrame *self; XSetWindowAttributes attr; self = g_slice_new0(ObMenuFrame); self->obwin.type = OB_WINDOW_CLASS_MENUFRAME; self->menu = menu; self->selected = NULL; self->client = client; self->direction_right = TRUE; self->show_from = show_from; attr.event_mask = FRAME_EVENTMASK; self->window = createWindow(obt_root(ob_screen), CWEventMask, &attr); /* make it a popup menu type window */ OBT_PROP_SET32(self->window, NET_WM_WINDOW_TYPE, ATOM, OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_POPUP_MENU)); XSetWindowBorderWidth(obt_display, self->window, ob_rr_theme->mbwidth); XSetWindowBorder(obt_display, self->window, RrColorPixel(ob_rr_theme->menu_border_color)); self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu); window_add(&self->window, MENUFRAME_AS_WINDOW(self)); stacking_add(MENUFRAME_AS_WINDOW(self)); return self; }
void remove_client(Client *c) { Client *p; LOG_DEBUG("remove_client() : Removing...\n"); if (!c || !c->xstuff) return; XGrabServer(dpy); ignore_xerror = 1; /* ICCCM 4.1.3.1 * "When the window is withdrawn, the window manager will either * change the state field's value to WithdrawnState or it will * remove the WM_STATE property entirely." * EWMH 1.3 * "The Window Manager should remove the property whenever a * window is withdrawn but it should leave the property in * place when it is shutting down." (both _NET_WM_DESKTOP and * _NET_WM_STATE) */ if (c->remove) { LOG_DEBUG("\tremove_client() : setting WithdrawnState\n"); set_wm_state(c, WithdrawnState); XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_desktop); XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_state); } ungravitate(c); if (c->xstuff->screen) XReparentWindow(dpy, c->xstuff->window, c->xstuff->screen->root, c->x, c->y); XSetWindowBorderWidth(dpy, c->xstuff->window, c->old_border); XRemoveFromSaveSet(dpy, c->xstuff->window); if (c->xstuff->parent) XDestroyWindow(dpy, c->xstuff->parent); if (head_client == c) head_client = c->next; else for (p = head_client; p && p->next; p = p->next) if (p->next == c) p->next = c->next; if (current == c) current = NULL; /* an enter event should set this up again */ free(c->xstuff); free(c); #ifdef DEBUG { Client *pp; int i = 0; for (pp = head_client; pp; pp = pp->next) i++; LOG_DEBUG("\tremove_client() : free(), window count now %d\n", i); } #endif XUngrabServer(dpy); XFlush(dpy); ignore_xerror = 0; LOG_DEBUG("remove_client() returning\n"); }
void client_decorate(Client* c) { XSetWindowBorderWidth(display, c->win, BORDER_WIDTH); if (c->focus) XSetWindowBorder(display, c->win, color_focus); else XSetWindowBorder(display, c->win, color_unfocus); }
void user_button_cross(Window w,int b) { int i; for(i=0;i<nuserbut;i++) if(w==userbut[i].w){ XSetWindowBorderWidth(display,w,b); return; } }
static void crossing_scroll_box(Window w, int c, SCROLLBOX sb) { int i; for (i = 0; i < sb.nw; i++) { if (w == sb.w[i]) { XSetWindowBorderWidth(display, w, c); return; } } }
static void maximise(struct WM_t *W, struct wmclient *C) { msg("client_MAX: %s\n", C->name); C->fullscreen = 1; XSetWindowBorderWidth(W->XDisplay, C->win, 0); XMoveResizeWindow(W->XDisplay, C->win, curr_head_x(W), curr_head_y(W), curr_width(W), curr_height(W)); set_net_wm_status(W, C); }
void message(const char *text, ...) { char tmp[256]; va_list vl; va_start(vl, text); vsprintf(tmp, text, vl); va_end(vl); tmp[strlen(tmp)] = 0; int th = TextHeight(fontstruct); int char_width = TextWidth(fontstruct, " "); int win_width = (strlen(tmp) * char_width) + (WLISTPADDING * 2); int win_height = th; int win_x, win_y; switch(WLISTPOS) { case 0: win_x = PADDING_WEST; win_y = PADDING_NORTH; break; case 1: win_x = SCREEN_WIDTH - PADDING_EAST - win_width - (BORDER * 2); win_y = PADDING_NORTH; break; case 2: win_x = 0 + SCREEN_WIDTH - PADDING_EAST - win_width; win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height; break; case 3: win_x = PADDING_WEST; win_y = 0 + SCREEN_HEIGHT - PADDING_SOUTH - win_height; break; case 4: win_x = (SCREEN_WIDTH / 2) - (win_width / 2); win_y = (SCREEN_HEIGHT / 2) - (win_height / 2); break; default: win_x = PADDING_WEST; win_y = PADDING_NORTH; break; } Window message_window = XCreateSimpleWindow(display, root, win_x, win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR)); XSetWindowBorderWidth(display, message_window, BORDER); XSetWindowBorder(display, message_window, name2color(SELBGCOLOR)); XMapRaised(display, message_window); XDrawString(display, message_window, BARE_GC, WLISTPADDING, 0 + th - fontstruct->max_bounds.descent, tmp, strlen(tmp)); XFlush(display); sleep(TIMEOUT); XFlush(display); if(message_window) { XDestroyWindow(display, message_window); } }
/** * Sets the width of the border of the given window. * @param win The given window. * @param width The new border width. * @ingroup Ecore_X_Window_Geometry_Group */ EAPI void ecore_x_window_border_width_set(Ecore_X_Window win, int width) { LOGFN(__FILE__, __LINE__, __FUNCTION__); /* doesn't make sense to call this on a root window */ if (!win) return; XSetWindowBorderWidth (_ecore_x_disp, win, width); }
static void calc_event(void *cookie, const XEvent *ev) { Calc *calc = cookie; int done = 0; edit_command_string(*ev, calc->name, calc->value, &done, &calc->pos, &calc->col); if (done == 1) { double z = 0; int flag = do_calc(calc->value, &z); if (flag != -1) { calc->last_val = z; draw_calc(calc->answer); } ini_calc_string(calc); } else if (done == -1) { quit_calc(calc); return; } switch (ev->type) { case Expose: draw_calc(ev->xexpose.window); break; case ButtonRelease: if (ev->xbutton.window == calc->quit) quit_calc(calc); break; case EnterNotify: if (ev->xcrossing.window == calc->quit) XSetWindowBorderWidth(display, ev->xcrossing.window, 2); break; case LeaveNotify: if (ev->xcrossing.window == calc->quit) XSetWindowBorderWidth(display, ev->xcrossing.window, 1); break; } }
void client_resize_fullscreen(HSClient* client, HSMonitor* m) { if (!client || !m) { HSDebug("client_resize_fullscreen() got invalid parameters\n"); return; } XSetWindowBorderWidth(g_display, client->window, 0); client->last_size = m->rect; client->last_border_width = 0; XMoveResizeWindow(g_display, client->window, m->rect.x, m->rect.y, m->rect.width, m->rect.height); }
void client_center(Client* client, Monitor *m) { if(!client || !m) return; if(client->fullscreen) return; XRectangle size = client->float_size; size.x = m->rect.x + m->rect.width/2 - client->float_size.width/2; size.y = m->rect.y + m->rect.height/2 - client->float_size.height/2 + bar_height; client->float_size = size; client->last_size = size; XSetWindowBorderWidth(gDisplay, client->window, window_border_width); XMoveResizeWindow(gDisplay, client->window, size.x, size.y, size.width, size.height); }
void client_resize_floating(HSClient* client, HSMonitor* m) { if (!client || !m) return; if (client->fullscreen) { client_resize_fullscreen(client, m); return; } // ensure minimal size if (client->float_size.width < WINDOW_MIN_WIDTH) client->float_size.width = WINDOW_MIN_WIDTH; if (client->float_size.height < WINDOW_MIN_HEIGHT) client->float_size.height = WINDOW_MIN_HEIGHT; bool border_changed = false; if (client->last_border_width != *g_window_border_width) { client->last_border_width = *g_window_border_width; border_changed = true; } client->last_size = client->float_size; client->last_size.x += m->rect.x + m->pad_left; client->last_size.y += m->rect.y + m->pad_up; // ensure position is on monitor int space = g_monitor_float_treshold; client->last_size.x = CLAMP(client->last_size.x, m->rect.x + m->pad_left - client->last_size.width + space, m->rect.x + m->rect.width - m->pad_left - m->pad_right - space); client->last_size.y = CLAMP(client->last_size.y, m->rect.y + m->pad_up - client->last_size.height + space, m->rect.y + m->rect.height - m->pad_up - m->pad_down - space); XRectangle rect = client->last_size; // add window border to last_size client->last_size.width += 2 * client->last_border_width; client->last_size.height += 2 * client->last_border_width; if (border_changed) { XSetWindowBorderWidth(g_display, client->window, *g_window_border_width); } XMoveResizeWindow(g_display, client->window, rect.x, rect.y, rect.width, rect.height); if (*g_window_border_inner_width > 0 && *g_window_border_inner_width < *g_window_border_width) { unsigned long current_border_color = get_window_border_color(client); HSDebug("client_resize %s\n", current_border_color == g_window_border_active_color ? "ACTIVE" : "NORMAL"); set_window_double_border(g_display, client->window, *g_window_border_inner_width, g_window_border_inner_color, current_border_color); } }
int main() { printf("opening display\n"); Display *d = XOpenDisplay(NULL); printf("grabbing default screen\n"); int screen = DefaultScreen(d); printf("default screen = %d\n", screen); printf("grabbing root window\n"); Window root = DefaultRootWindow(d); // tell root window you'll be capturing it's events XSetWindowAttributes a; a.event_mask = StructureNotifyMask|SubstructureNotifyMask|EnterWindowMask|LeaveWindowMask; // root + child (sub) windows created, window-in, window-out XSelectInput(d, root, a.event_mask); // handle errors XSetErrorHandler(handle_xerror); // capture those events XEvent e; // main event loop for (;;) { XNextEvent(d, &e); if (e.type == CreateNotify) { printf("Event: create\n"); XSelectInput(e.xcreatewindow.display, e.xcreatewindow.window, a.event_mask); XSetWindowBorderWidth(e.xcreatewindow.display, e.xcreatewindow.window, 1); // always set border to 1px } else if (e.type == ConfigureNotify) { printf("EVENT: configure\n"); } else if (e.type == EnterNotify) { printf("EVENT: focus-in\n"); focused_win = e.xcrossing.window; a.border_pixel = WhitePixel(e.xcrossing.display, screen); XChangeWindowAttributes(e.xcrossing.display, focused_win, CWBorderPixel, &a); } else if (e.type == LeaveNotify) { printf("EVENT: focus-out\n"); a.border_pixel = BlackPixel(e.xcrossing.display, screen); XChangeWindowAttributes(e.xcrossing.display, e.xcrossing.window, CWBorderPixel, &a); } } return 0; }
void del_client(client_t *c, int mode) { client_t *p; XGrabServer(dpy); XSetErrorHandler(ignore_xerror); #ifdef DEBUG dump_name(c, "removing", 'r'); dump_removal(c, mode); #endif if (mode == DEL_WITHDRAW) { set_wm_state(c, WithdrawnState); } else /* mode == DEL_REMAP */ { if (c->zoomed) { c->geom.x = c->save.x; c->geom.y = c->save.y; c->geom.w = c->save.w; c->geom.h = c->save.h; XResizeWindow(dpy, c->win, c->geom.w, c->geom.h); } XMapWindow(dpy, c->win); } remove_atom(root, net_client_list, XA_WINDOW, c->win); remove_atom(root, net_client_stack, XA_WINDOW, c->win); XSetWindowBorderWidth(dpy, c->win, c->old_bw); #ifdef XFT if (c->xftdraw) XftDrawDestroy(c->xftdraw); #endif XReparentWindow(dpy, c->win, root, c->geom.x, c->geom.y); XRemoveFromSaveSet(dpy, c->win); XDestroyWindow(dpy, c->frame); if (head == c) head = c->next; else for (p = head; p && p->next; p = p->next) if (p->next == c) p->next = c->next; if (c->name) XFree(c->name); free(c); XSync(dpy, False); XSetErrorHandler(handle_xerror); XUngrabServer(dpy); }
void cfg_reinitialize(void) { int i; #ifdef USE_XFT int xft = xftfont ? 1 : 0; #endif /* free things from old configuration */ XFreeGC(dpy, gc); XFreeGC(dpy, igc); XFreeGC(dpy, bgc); XFreeGC(dpy, ibgc); keys_free(); /* read config again */ cfg_read(0); /* update some things */ p_attr.background_pixel = fg.pixel; p_attr.border_pixel = ibfg.pixel; select_root_events(); /* update clients */ for(i = 0; i < cn; i++) { #ifdef USE_XFT if(xftfont && !xft) clients[i]->wlist_draw = XftDrawCreate(dpy, clients[i]->wlist_item, visual, colormap); if(!xftfont && xft) { XftDrawDestroy(clients[i]->title_draw); XftDrawDestroy(clients[i]->wlist_draw); } #endif XDestroyWindow(dpy, clients[i]->button_parent_left); XDestroyWindow(dpy, clients[i]->button_parent_right); free((void *) clients[i]->buttons); clients[i]->flags ^= clients[i]->flags & HAS_BUTTONS; buttons_create(clients[i]); /* buttons are now on top of the client window */ XRaiseWindow(dpy, clients[i]->window); /* hence this line */ client_update(clients[i]); client_update_name(clients[i]); (clients[i] == current) ? client_set_bg(clients[i], bg, fg) : client_set_bg(clients[i], ibg, ifg); if(clients[i]->flags & IS_TASKBAR) client_set_layer(clients[i], taskbar_ontop ? TOP : NORMAL); XUngrabButton(dpy, AnyButton, AnyModifier, clients[i]->parent); client_grab_buttons(clients[i]); if(clients[i]->flags & FULLSCREEN && clients[i]->layer <= NORMAL && fullscreen_stacking != FS_NORMAL) client_update_layer(clients[i], (fullscreen_stacking == FS_ALWAYS_ONTOP) ? NORMAL : TOP); if(clients[i]->flags & HAS_BORDER) XSetWindowBorderWidth(dpy, clients[i]->parent, border_width); ewmh_update_extents(clients[i]); } ewmh_update_number_of_desktops(); ewmh_update_geometry(); ewmh_update_strut(); }
Client* manage_client(Window win) { if (get_client_from_window(win)) return NULL; // init client Client* client = create_client(); Monitor* m = get_current_monitor(); // set to window properties client->window = win; client_update_title(client); // apply rules int manage = 1; rules_apply(client, &manage); if (!manage) { destroy_client(client); // map it... just to be sure XMapWindow(gDisplay, win); return NULL; } unsigned int border, depth; Window root_win; int x, y; unsigned int w, h; XGetGeometry(gDisplay, win, &root_win, &x, &y, &w, &h, &border, &depth); // treat wanted coordinates as floating coords XRectangle size = client->float_size; size.width = w; size.height = h; size.x = m->rect.x + m->rect.width/2 - size.width/2; size.y = m->rect.y + m->rect.height/2 - size.height/2 + bar_height; client->float_size = size; client->last_size = size; XMoveResizeWindow(gDisplay, client->window, size.x, size.y, size.width, size.height); // actually manage it g_array_append_val(g_clients, client); XSetWindowBorderWidth(gDisplay, win, window_border_width); // insert to layout if (!client->tag) client->tag = m->tag; // get events from window client_update_wm_hints(client); XSelectInput(gDisplay, win, CLIENT_EVENT_MASK); window_grab_button(win); frame_insert_window(client->tag->frame, win); monitor_apply_layout(find_monitor_with_tag(client->tag)); return client; }
winfo::winfo(QWidget *parent) : QWidget(parent) { client = NULL; XSetWindowBorderWidth(QX11Info::display(), winId(), 1); setFont(defaults::borderfont); left = new QLabel(this); Q_CHECK_PTR(left); right = new QLabel(this); Q_CHECK_PTR(right); int i; QVBoxLayout *vl = new QVBoxLayout(this); vl->setMargin(2); static const char *qcs[] = { "Sticky","Skip windowlist","Small frame","No resize","No tiling", "Skip keyboard access","Skip in screenmode","Apply to all in class" }; for(i=0; i < 8; i++) { qcbox[i] = new QCheckBox(qcs[i], this); vl->addWidget(qcbox[i]); } left->setText(QString(" Title\n Name\n Class\n Location\n Invocation\n Geometry\n")); QHBoxLayout *hl1 = new QHBoxLayout(); hl1->addWidget(left); hl1->addWidget(right); hl1->addStretch(); vl->addSpacing(4); QHBoxLayout *hl2 = new QHBoxLayout(); qb1 = new QPushButton("Permanent", this); qb2 = new QPushButton("Temporary", this); qb3 = new QPushButton(" Cancel ", this); hl2->addWidget(qb1); hl2->addStretch(); hl2->addWidget(qb2); hl2->addStretch(); hl2->addWidget(qb3); setLayout(vl); vl->addLayout(hl1); vl->addLayout(hl2); connect(qb1, SIGNAL(pressed()), this, SLOT(release_permanent())); connect(qb2, SIGNAL(pressed()), this, SLOT(release_temporary())); connect(qb3, SIGNAL(pressed()), this, SLOT(release_cancel())); }
/* Set a 1-pixel border and position it at the size/pos in C */ static void set_size_pos_border(struct WM_t *W, struct wmclient *C) { /* Add a border */ XSetWindowBorderWidth(W->XDisplay, C->win, W->prefs.bw); /* Set the colour differently if it's at the top of the focus stack */ if (W->clients[0] == C) set_border_colour(W, C, 1); else set_border_colour(W, C, 0); XMoveResizeWindow(W->XDisplay, C->win, C->x, C->y, C->w, C->h); /* XChangeProperty? */ }