void focus() { Window *children, root_ret, par_ret; unsigned int n=0; XQueryTree(dpy, root, &root_ret, &par_ret, &children, &n); printf("wimp: children: %u\ti: %d\n", n, i); if(n < 1) { return; XFree(children); } else if(i+1 >= n) { i=0; XRaiseWindow(dpy, children[i]); XSetWindowBorder(dpy, children[i], color.pixel); XSetInputFocus(dpy, children[i] , RevertToParent, CurrentTime); XFree(children); } else { i++; XRaiseWindow(dpy, children[i]); XSetWindowBorder(dpy, children[i], color.pixel); XSetInputFocus(dpy, children[i] , RevertToParent, CurrentTime); XFree(children); } }
void select_client(Client *c) { XColor border_colour_active, border_colour_inactive; XColor border_colour_float_active, border_colour_float_inactive; XColor dummy; unsigned long bpixel; if (current) { XAllocNamedColor(dpy, DefaultColormap(dpy, current->xstuff->screen->screen), settings_get( "border.colour.inactive" ), &border_colour_inactive, &dummy); XAllocNamedColor(dpy, DefaultColormap(dpy, current->xstuff->screen->screen), settings_get( "border.colour.float.inactive" ), &border_colour_float_inactive, &dummy); if (is_sticky(current)) bpixel = border_colour_float_inactive.pixel; else bpixel = border_colour_inactive.pixel; XSetWindowBorder(dpy, current->xstuff->parent, bpixel); } if (c) { XAllocNamedColor(dpy, DefaultColormap(dpy, c->xstuff->screen->screen), settings_get( "border.colour.active" ), &border_colour_active, &dummy); XAllocNamedColor(dpy, DefaultColormap(dpy, c->xstuff->screen->screen), settings_get( "border.colour.float.active" ), &border_colour_float_active, &dummy); if (is_sticky(c)) bpixel = border_colour_float_active.pixel; else bpixel = border_colour_active.pixel; XSetWindowBorder(dpy, c->xstuff->parent, bpixel); XInstallColormap(dpy, c->xstuff->cmap); XSetInputFocus(dpy, c->xstuff->window, RevertToPointerRoot, CurrentTime); } current = c; }
static void set_border_colour(struct WM_t *W, struct wmclient *C, int focus) { if (focus) XSetWindowBorder(W->XDisplay, C->win, W->focus_border_col); else XSetWindowBorder(W->XDisplay, C->win, W->unfocus_border_col); }
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); }
static Bool ChangeSensitive(Widget w) { if (XtIsRealized(w)) { if (XtIsSensitive(w)) if (w->core.border_pixmap != XtUnspecifiedPixmap) XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w), w->core.border_pixmap); else XSetWindowBorder(XtDisplay(w), XtWindow(w), w->core.border_pixel); else { if (((SimpleWidget)w)->simple.insensitive_border == None) ((SimpleWidget)w)->simple.insensitive_border = XmuCreateStippledPixmap(XtScreen(w), w->core.border_pixel, w->core.background_pixel, w->core.depth); XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w), ((SimpleWidget)w)->simple.insensitive_border); } } return (False); }
void decor_win_follow(Client *c) { int bcolor = config.xcolor_fborder; int fill = config.xcolor_fbg; int shadow = config.xcolor_fshadow; int tcolor = config.xcolor_ftitle; if(!c->hastitle){ return; } if (!c->frame) { return; } int ty = config.title_y; char n[256]; XSetWindowBackground(dpy, c->frame, fill); XSetWindowBorder(dpy, c->frame, bcolor); XSetForeground(dpy, gc, fill); XFillRectangle (dpy, c->frame, gc, 0, 0, c->w, c->h); sprintf(n, "%s %s : %s",config.viewnames[c->oldpos.view], c->key, c->name); draw_text(c, xfont, fill, tcolor, shadow, 3, ty, n); }
static Bool ChangeSensitive(Widget w) { CommandWidget cbw = (CommandWidget)w; if (XtIsRealized(w)) { if (XtIsSensitive(w)) { if (w->core.border_pixmap != XtUnspecifiedPixmap) XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w), w->core.border_pixmap); else XSetWindowBorder(XtDisplay(w), XtWindow(w), w->core.border_pixel); } else { if (cbw->simple.insensitive_border == None) cbw->simple.insensitive_border = XmuCreateStippledPixmap(XtScreen(w), w->core.border_pixel, cbw->command.set ? cbw->label.foreground : w->core.background_pixel, w->core.depth); XSetWindowBorderPixmap(XtDisplay(w), XtWindow(w), cbw->simple.insensitive_border); } } return (False); }
int gfx_init(char *title, int win_w, int win_h, char *font_path) { e = evas_new(); evas_set_output_method(e, RENDER_METHOD_ALPHA_SOFTWARE); if ((d = XOpenDisplay(NULL)) == NULL) return 0; vis = evas_get_optimal_visual(e, d); cmap = evas_get_optimal_colormap(e, d); a_win_del = XInternAtom(d, "WM_DELETE_WINDOW", False); win = XCreateSimpleWindow(d, DefaultRootWindow(d), 0, 0, win_w, win_h, 0, 0, 0); XSelectInput(d, win, ButtonPressMask | ExposureMask); XSetWindowColormap(d, win, cmap); XSetWindowBorder(d, win, 0); XStoreName(d, win, title); XSync(d, False); XMapWindow(d, win); XSetWMProtocols(d, win, &a_win_del, 1); evas_set_output(e, d, win, vis, cmap); evas_set_output_size(e, win_w, win_h); evas_set_output_viewport(e, 0, 0, win_w, win_h); evas_font_add_path(e, font_path); return 1; }
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 window_focus(Window window) { window_unfocus(lastfocus); XSetWindowBorder(gDisplay, window, wincolors[1][ColWindowBorder]); if(!get_client_from_window(window)->neverfocus) XSetInputFocus(gDisplay, window, RevertToPointerRoot, CurrentTime); lastfocus = window; }
bool WPcric( WPICON *icoptr, XCrossingEvent *croev) /* Crossing-rutin för WPICON. * * In: icoptr = C-pekare till WPICON. * croev = X-crossing event. * * Ut: Inget. * * Felkod: . * * (C)microform ab 17/1/94 J. Kjellander * * 2007-05-28 Tooltips, J.Kjellander * ******************************************************!*/ { int x,y; /* ***Enter => Highligt border. */ if ( croev->type == EnterNotify ) { XSetWindowBorder(xdisp,croev->window,WPgcol(WP_NOTI)); if ( icoptr->tt_str[0] != '\0' ) { WPgtmp(&x,&y); WPorder_tooltip(x+5,y+10,icoptr->tt_str); } } /* ***Leave => Normal border again. */ else { XSetWindowBorder(xdisp,croev->window,WPgcol(WP_BGND2)); WPclear_tooltip(); } return(TRUE); }
void setborder(Window *w, int width, Color *col) { assert(w->type == WWindow); if(width) XSetWindowBorder(display, w->xid, pixelvalue(w, col)); if(width != w->border) configwin(w, w->r, width); }
void select_client(Client *c) { if (current) XSetWindowBorder(dpy, current->parent, current->screen->bg.pixel); if (c) { unsigned long bpixel; #ifdef VWM if (is_sticky(c)) bpixel = c->screen->fc.pixel; else #endif bpixel = c->screen->fg.pixel; XSetWindowBorder(dpy, c->parent, bpixel); #ifdef COLOURMAP XInstallColormap(dpy, c->cmap); #endif XSetInputFocus(dpy, c->window, RevertToPointerRoot, CurrentTime); } current = c; }
void window_update_border(Window window, unsigned long color) { if (*g_window_border_inner_width > 0 && *g_window_border_inner_width < *g_window_border_width) { set_window_double_border(g_display, window, *g_window_border_inner_width, g_window_border_inner_color, color); } else { XSetWindowBorder(g_display, window, color); } }
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); } }
void focus(Client *c) { if(c && c->view != view) return; if(sel && sel != c) { XSetWindowBorder(dpy, sel->win, normcol); } if(c) { detachstack(c); c->snext = stack; stack = c; } sel = c; if(!selscreen) return; if(c) { XSetWindowBorder(dpy, c->win, selcol); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); } else XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); }
void manage(Window w, XWindowAttributes *wa) { Client *c, *t; Window trans; c = emallocz(sizeof(Client)); c->win = w; c->x = wa->x; c->y = wa->y; c->w = wa->width; c->h = wa->height; if(c->w == sw && c->h == sh) { c->border = 0; c->x = sx; c->y = sy; } else { c->border = BORDERPX; if(c->x + c->w + 2 * c->border > sx + sw) c->x = sx + sw - c->w - 2 * c->border; if(c->y + c->h + 2 * c->border > sy + sh) c->y = sy + sh - c->h - 2 * c->border; if(c->x < sx) c->x = sx; if(c->y < sy) c->y = sy; } updatesizehints(c); XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); XSetWindowBorder(dpy, c->win, normcol); updatetitle(c); if((t = getclient(trans))) c->view = t->view; else c->view = view; if(clients) clients->prev = c; c->next = clients; c->snext = stack; stack = clients = c; XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); XMapWindow(dpy, c->win); setclientstate(c, NormalState); if(c->view == view) focus(c); arrange(); }
Bool redecorateVolume(void *data, void *aux_data) { ASVolume *v = (ASVolume*)data; ASVolumeCanvasPlacement *placement = (ASVolumeCanvasPlacement*) aux_data; int width = placement->tileWidth; int height = placement->tileHeight; int x = 0, y = 0; if (placement->vertical) { y = placement->currPos; placement->currPos += height; } else { x = placement->currPos; placement->currPos += width; } if (v) { XSetWindowAttributes attr; // ARGB2PIXEL(Scr.asv,Config->border_color_argb,&(attr.border_pixel)); if( v->canvas == NULL ) { Window w; attr.event_mask = EnterWindowMask|PointerMotionMask|LeaveWindowMask|StructureNotifyMask|ButtonReleaseMask|ButtonPressMask ; w = create_visual_window(Scr.asv, AppState.mainWindow, x, y, width, height, 0, InputOutput, CWEventMask|CWBorderPixel, &attr ); v->canvas = create_ascanvas( w ); show_progress("creating volume canvas (%p) for \"%s\"", v->canvas, v->name); handle_canvas_config( v->canvas ); } else { XSetWindowBorder( dpy, v->canvas->w, attr.border_pixel ); moveresize_canvas (v->canvas, x, y, width, height); } updateVolumeContents (v); set_astbar_size (v->contents, width, height); /* redraw will happen on ConfigureNotify */ #if 0 render_astbar (v->contents, v->canvas ); update_canvas_display (v->canvas ); #endif } return True; }
void zwm_decor_update(Client *c) { if(super_on){ decor_win_follow(c); return; } int bcolor = c->root_user?config.xcolor_root:config.xcolor_fborder; int fill = c->root_user?config.xcolor_root:config.xcolor_fbg; int shadow = config.xcolor_fshadow; int tcolor = config.xcolor_ftitle; if(!c->hastitle){ return; } if(c->focused == False && !super_on){ bcolor = config.xcolor_nborder; fill = config.xcolor_nbg; shadow = config.xcolor_nshadow; tcolor = config.xcolor_ntitle; } if(c->isfloating){ fill = config.xcolor_flbg; bcolor = config.xcolor_flbg; } if (c->frame) { int iw= c->w - (config.button_width*config.button_count) - 4*c->border; int vx = 4*c->border; const char* vtxt = config.viewnames[c->view]; int tx = vx + config.button_width; int ty = config.title_y; char n[256]; XSetWindowBackground(dpy, c->frame, fill); XSetWindowBorder(dpy, c->frame, bcolor); XSetForeground(dpy, gc, fill); XFillRectangle (dpy, c->frame, gc, 0, 0, c->w, c->h); draw_text(c, xfont, fill, tcolor, shadow, vx, ty, vtxt); sprintf(n, "%s %s", c->isfloating?"▬":views[c->view].layout->symbol, c->name ); draw_text(c, xfont, fill, tcolor, shadow, tx, ty, n); // draw_text(c, xfont, fill, tcolor, shadow, tx + config.button_width, ty, c->name); if(c->focused){ get_status(title, 1024); char tmp[256]; char cap[32]; sprintf(tmp, "%s[%lu]",title, c->ucount/60); strcpy(title,tmp); draw_text(c, xfont, fill, tcolor, shadow, iw - date_width - 20 - char_width, ty, title); draw_text(c, ifont, fill, tcolor, shadow, iw, config.icon_y, icons); FILE *b = fopen("/sys/class/power_supply/BAT0/capacity", "r"); if(b) { fgets(cap, 32, b); cap[3] = 0; int p = atoi(cap) ; if(p != 100) { //int x = iw - date_width - 20 - char_width - 15; int x = iw - config.button_width; XSetForeground(dpy, gc, config.xcolor_ftitle); XFillRectangle (dpy, c->frame, gc, x, 2, 8, ty); XSetForeground(dpy, gc, config.xcolor_nborder); XFillRectangle (dpy, c->frame, gc, x, 2, 8, (ty) * (100-p) / 100 ); } fclose(b); } } } }
int eventFuncMenu(XEvent ev){ int i,j,k; switch(ev.type){ case ButtonPress: for ( i=0 ; i<MAX_PEN ; i++ ){ /* 太さ・色選択ウィンドウ上で押された? */ if ( ev.xany.window == pen_win[i] ){ /* ペンサイズを変更 */ for ( j=0 ; j<MAX_PEN ; j++ ){ XSetWindowBackground( dis, pen_win[j], UNSELECTED_COLOR1 ); XClearWindow(dis,pen_win[j]); } XSetWindowBackground( dis, pen_win[i], SELECTED_COLOR); XClearWindow(dis,pen_win[i]); remapFuncMenu(); current_pen = i*3+2; XSetLineAttributes(dis, gc, current_pen, current_line, current_cap, current_join); XSetLineAttributes(dis, mask_gc, current_pen, current_line, current_cap, current_join); return(0); } } for ( i=0 ; i<MAX_COLOR ; i++ ){ if ( ev.xany.window == color_win[i] ){ /* 色を変更 */ current_color = GetColor(dis, color_name[i]); XSetForeground(dis, gc, current_color); return(0); } } if ( ev.xany.window == colors_win ){ /* 色を指定して変更 */ current_color = callColorSelect(dis, current_color,canvas); XSetForeground(dis, gc, current_color); remapCanvas(); remapFuncMenu(); return(0); } for ( i=0 ; i<MAX_FUNC ; i++ ){ if ( ev.xany.window == func_win[i] ){ /* 機能を変更 */ for ( j=0 ; j<MAX_FUNC ; j++ ){ XSetWindowBackground( dis, func_win[j], UNSELECTED_COLOR1 ); XClearWindow(dis,func_win[j]); } XSetWindowBackground( dis, func_win[i], SELECTED_COLOR); XClearWindow(dis,func_win[i]); remapFuncMenu(); state=i; setFuncSubWin(); return(0); } for ( j=0 ; j<MAX_FUNC_SUB ; j++ ){ if ( ev.xany.window == func_type_win[i][j] ){ /* 補助機能を変更 */ for ( k=0 ; k<MAX_FUNC_SUB ; k++ ){ XSetWindowBackground( dis, func_type_win[i][k], UNSELECTED_COLOR1 ); XClearWindow(dis,func_type_win[i][k]); } XSetWindowBackground( dis, func_type_win[i][j], SELECTED_COLOR); XClearWindow(dis,func_type_win[i][j]); remapFuncMenu(); sub_state=j; setFuncSubWin(); return(0); } } } for ( i=0 ; i<MAX_TYPE ; i++ ){ if ( ev.xany.window == line_type_win[i] ){ /* 線種を変更 */ switch(i){ case 0: XSetWindowBackground( dis, line_type_win[0], SELECTED_COLOR); XClearWindow(dis,line_type_win[0]); XSetWindowBackground( dis, line_type_win[1], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[1]); XSetWindowBackground( dis, line_type_win[2], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[2]); current_line=LineSolid; break; case 1: XSetWindowBackground( dis, line_type_win[0], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[0]); XSetWindowBackground( dis, line_type_win[1], SELECTED_COLOR); XClearWindow(dis,line_type_win[1]); XSetWindowBackground( dis, line_type_win[2], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[2]); current_line=LineOnOffDash; break; case 2: XSetWindowBackground( dis, line_type_win[0], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[0]); XSetWindowBackground( dis, line_type_win[1], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[1]); XSetWindowBackground( dis, line_type_win[2], SELECTED_COLOR); XClearWindow(dis,line_type_win[2]); current_line=LineDoubleDash; break; case 3: XSetWindowBackground( dis, line_type_win[3], SELECTED_COLOR); XClearWindow(dis,line_type_win[3]); XSetWindowBackground( dis, line_type_win[4], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[4]); XSetWindowBackground( dis, line_type_win[5], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[5]); current_cap=CapRound; break; case 4: XSetWindowBackground( dis, line_type_win[3], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[3]); XSetWindowBackground( dis, line_type_win[4], SELECTED_COLOR); XClearWindow(dis,line_type_win[4]); XSetWindowBackground( dis, line_type_win[5], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[5]); current_cap=CapButt; break; case 5: XSetWindowBackground( dis, line_type_win[3], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[3]); XSetWindowBackground( dis, line_type_win[4], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[4]); XSetWindowBackground( dis, line_type_win[5], SELECTED_COLOR); XClearWindow(dis,line_type_win[5]); current_cap=CapProjecting; break; case 6: XSetWindowBackground( dis, line_type_win[6], SELECTED_COLOR); XClearWindow(dis,line_type_win[6]); XSetWindowBackground( dis, line_type_win[7], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[7]); XSetWindowBackground( dis, line_type_win[8], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[8]); current_join=JoinMiter; break; case 7: XSetWindowBackground( dis, line_type_win[6], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[6]); XSetWindowBackground( dis, line_type_win[7], SELECTED_COLOR); XClearWindow(dis,line_type_win[7]); XSetWindowBackground( dis, line_type_win[8], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[8]); current_join=JoinRound; break; case 8: XSetWindowBackground( dis, line_type_win[6], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[6]); XSetWindowBackground( dis, line_type_win[7], UNSELECTED_COLOR2); XClearWindow(dis,line_type_win[7]); XSetWindowBackground( dis, line_type_win[8], SELECTED_COLOR); XClearWindow(dis,line_type_win[8]); current_join=JoinBevel; break; default: break; } remapFuncMenu(); XSetLineAttributes(dis, gc, current_pen, current_line, current_cap, current_join); XSetLineAttributes(dis, mask_gc, current_pen, current_line, current_cap, current_join); } } /***************************** デバッグ用 ********************************/ if ( ev.xany.window == debug_win ){ //printf("color=%d size=%d\n",current_color,current_pen); for(i=0;i<MAX_COLOR;i++) printf("%s %x\n",color_name[i],GetColor( dis, color_name[i])); printf("%x\n",GetColor(dis,"yellow")>>8&0xff); save_png(canvas); return(0); } /***************************** デバッグ用 *********************************/ break; case EnterNotify: /* ウィンドウにポインタが入った */ for ( i=0 ; i<MAX_PEN ; i++ ){ if ( ev.xany.window == pen_win[i] ){ /* ペンサイズ */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } } for ( i=0 ; i<MAX_TYPE ; i++ ){ if ( ev.xany.window == line_type_win[i] ){ /* 線種 */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } } for ( i=0 ; i<MAX_COLOR ; i++ ){ if ( ev.xany.window == color_win[i] ){ /* 色 */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } } if ( ev.xany.window == colors_win ){ /* 色指定 */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } for ( i=0 ; i<MAX_FUNC ; i++ ){ if ( ev.xany.window == func_win[i] ){ /* 機能 */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } for ( j=0 ; j<MAX_FUNC_SUB ; j++ ){ if ( ev.xany.window == func_type_win[i][j] ){ /* 補助機能 */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } } } if ( ev.xany.window == debug_win ){ /* デバッグ */ XSetWindowBorder(dis, ev.xany.window, OVERED_BORDERLINE_COLOR); return(0); } break; case LeaveNotify: /* ウィンドウからポインタが出た */ for ( i=0 ; i<MAX_PEN ; i++ ){ if ( ev.xany.window == pen_win[i] ){ /* ペンサイズ */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } } for ( i=0 ; i<MAX_TYPE ; i++ ){ if ( ev.xany.window == line_type_win[i] ){ /* 線種 */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } } for ( i=0 ; i<MAX_COLOR ; i++ ){ if ( ev.xany.window == color_win[i] ){ /* 色 */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } } if ( ev.xany.window == colors_win ){ /* 色指定 */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } for ( i=0 ; i<MAX_FUNC ; i++ ){ if ( ev.xany.window == func_win[i] ){ /* 機能 */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } for ( j=0 ; j<MAX_FUNC_SUB ; j++ ){ if ( ev.xany.window == func_type_win[i][j] ){ /* 補助機能 */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } } } if ( ev.xany.window == debug_win ){ /* デバッグ */ XSetWindowBorder(dis, ev.xany.window, BORDERLINE_COLOR); return(0); } break; default: break; } return(1); }
void list_windows() { int th, ypos, x; th = TextHeight(fontstruct); ypos = 0 + th - fontstruct->max_bounds.descent; Window WINDOW_LIST_WINDOW = None; char *tmp; char title[256]; int number = 0; int max_title = 0; XWindowAttributes winattr; Window root_return; int char_width = TextWidth(fontstruct, " "); for (x = 0; x< max_windows; x++) { if(windows_container[x] != None) { if(!XGetWindowAttributes(display, windows_container[x], &winattr) || winattr.override_redirect || XGetTransientForHint(display, windows_container[x], &root_return)) continue; if(winattr.map_state == IsViewable) { if(XFetchName(display, windows_container[x], &tmp)) { number++; if(windows_container[x] == selected) { sprintf(title, "%d - %s", get_position(windows_container[x]), tmp); } else { sprintf(title, "%d - %s", get_position(windows_container[x]), tmp); } if(strlen(title) > max_title) max_title = strlen(title); title[0] = 0; } } } } if(number > 0) { int win_width = (max_title * char_width) + (WLISTPADDING * 2); int win_height = number * 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_LIST_WINDOW = XCreateSimpleWindow(display, root, win_x, win_y, win_width, win_height, BORDER, name2color(FGCOLOR), name2color(BGCOLOR)); XSetWindowBorderWidth(display, WINDOW_LIST_WINDOW, BORDER); XSetWindowBorder(display, WINDOW_LIST_WINDOW, name2color(SELBGCOLOR)); XMapRaised(display, WINDOW_LIST_WINDOW); for (x = 0; x< max_windows; x++) { if(windows_container[x] != None) { if(!XGetWindowAttributes(display, windows_container[x], &winattr) || winattr.override_redirect || XGetTransientForHint(display, windows_container[x], &root_return)) continue; if(winattr.map_state == IsViewable) { if(XFetchName(display, windows_container[x], &tmp)) { if(windows_container[x] == selected) { sprintf(title, "%d - %s", get_position(windows_container[x]), tmp); XFillRectangle(display, WINDOW_LIST_WINDOW, BARE_SELECTEDBG_GC, 0, ypos - th + fontstruct->max_bounds.descent, win_width, th); XDrawString(display, WINDOW_LIST_WINDOW, BARE_SELECTEDFG_GC, WLISTPADDING, ypos, title, strlen(title)); ypos+=th; } else { sprintf(title, "%d - %s", get_position(windows_container[x]), tmp); XDrawString(display, WINDOW_LIST_WINDOW, BARE_GC, WLISTPADDING, ypos, title, strlen(title)); ypos+=th; } title[0] = 0; } } } } XFlush(display); sleep(TIMEOUT); XFlush(display); if(WINDOW_LIST_WINDOW) { XDestroyWindow(display, WINDOW_LIST_WINDOW); } } else { message("No windows to list!"); } }
void client_setup_border(Client* client, bool focused) { XSetWindowBorder(gDisplay, client->window, wincolors[focused ? 1:0][ColWindowBorder]); }
void menu_frame_render(ObMenuFrame *self) { gint w = 0, h = 0; gint tw, th; /* temps */ GList *it; gboolean has_icon = FALSE; ObMenu *sub; ObMenuEntryFrame *e; /* find text dimensions */ STRUT_SET(self->item_margin, 0, 0, 0, 0); if (self->entries) { gint l, t, r, b; e = self->entries->data; ob_rr_theme->a_menu_text_normal->texture[0].data.text.string = ""; tw = RrMinWidth(ob_rr_theme->a_menu_text_normal); tw += 2*PADDING; th = ITEM_HEIGHT; RrMargins(ob_rr_theme->a_menu_normal, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_disabled, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_disabled_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); } /* render the entries */ for (it = self->entries; it; it = g_list_next(it)) { RrAppearance *text_a; e = it->data; /* if the first entry is a labeled separator, then make its border overlap with the menu's outside border */ if (it == self->entries && e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { h -= ob_rr_theme->mbwidth; } if (e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { e->border = ob_rr_theme->mbwidth; } RECT_SET_POINT(e->area, 0, h+e->border); XMoveWindow(obt_display, e->window, e->area.x-e->border, e->area.y-e->border); XSetWindowBorderWidth(obt_display, e->window, e->border); XSetWindowBorder(obt_display, e->window, RrColorPixel(ob_rr_theme->menu_border_color)); text_a = (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !e->entry->data.normal.enabled ? /* disabled */ (e == self->selected ? ob_rr_theme->a_menu_text_disabled_selected : ob_rr_theme->a_menu_text_disabled) : /* enabled */ (e == self->selected ? ob_rr_theme->a_menu_text_selected : ob_rr_theme->a_menu_text_normal)); switch (e->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: text_a->texture[0].data.text.string = e->entry->data.normal.label; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon || e->entry->data.normal.mask) has_icon = TRUE; break; case OB_MENU_ENTRY_TYPE_SUBMENU: sub = e->entry->data.submenu.submenu; text_a->texture[0].data.text.string = sub ? sub->title : ""; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon || e->entry->data.normal.mask) has_icon = TRUE; tw += ITEM_HEIGHT - PADDING; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (e->entry->data.separator.label != NULL) { ob_rr_theme->a_menu_text_title->texture[0].data.text.string = e->entry->data.separator.label; tw = RrMinWidth(ob_rr_theme->a_menu_text_title) + 2*ob_rr_theme->paddingx; tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_title_height + (ob_rr_theme->mbwidth - PADDING) *2; } else { tw = 0; th = ob_rr_theme->menu_sep_width + 2*ob_rr_theme->menu_sep_paddingy - 2*PADDING; } break; default: g_assert_not_reached(); } tw += 2*PADDING; th += 2*PADDING; w = MAX(w, tw); h += th; } /* if the last entry is a labeled separator, then make its border overlap with the menu's outside border */ it = g_list_last(self->entries); e = it ? it->data : NULL; if (e && e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { h -= ob_rr_theme->mbwidth; } self->text_x = PADDING; self->text_w = w; if (self->entries) { if (has_icon) { w += ITEM_HEIGHT + PADDING; self->text_x += ITEM_HEIGHT + PADDING; } } if (!w) w = 10; if (!h) h = 3; XResizeWindow(obt_display, self->window, w, h); self->inner_w = w; RrPaint(self->a_items, self->window, w, h); for (it = self->entries; it; it = g_list_next(it)) menu_entry_frame_render(it->data); w += ob_rr_theme->mbwidth * 2; h += ob_rr_theme->mbwidth * 2; RECT_SET_SIZE(self->area, w, h); XFlush(obt_display); }
void window_unfocus(Window window) { // grab buttons in old window again XSetWindowBorder(gDisplay, window, wincolors[0][ColWindowBorder]); window_grab_button(window); }
void make_splash_dialog (saver_info *si) { int x, y, bw; XSetWindowAttributes attrs; unsigned long attrmask = 0; splash_dialog_data *sp; saver_screen_info *ssi; Colormap cmap; char *f; if (si->sp_data) return; if (!si->prefs.splash_p || si->prefs.splash_duration <= 0) return; ssi = &si->screens[mouse_screen (si)]; if (!ssi || !ssi->screen) return; /* WTF? Trying to splash while no screens connected? */ cmap = DefaultColormapOfScreen (ssi->screen); sp = (splash_dialog_data *) calloc (1, sizeof(*sp)); sp->prompt_screen = ssi; sp->heading_label = get_string_resource (si->dpy, "splash.heading.label", "Dialog.Label.Label"); sp->body_label = get_string_resource (si->dpy, "splash.body.label", "Dialog.Label.Label"); sp->body2_label = get_string_resource (si->dpy, "splash.body2.label", "Dialog.Label.Label"); sp->demo_label = get_string_resource (si->dpy, "splash.demo.label", "Dialog.Button.Label"); #ifdef PREFS_BUTTON sp->prefs_label = get_string_resource (si->dpy, "splash.prefs.label", "Dialog.Button.Label"); #endif /* PREFS_BUTTON */ sp->help_label = get_string_resource (si->dpy, "splash.help.label", "Dialog.Button.Label"); if (!sp->heading_label) sp->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY"); if (!sp->body_label) sp->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY"); if (!sp->body2_label) sp->body2_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY"); if (!sp->demo_label) sp->demo_label = strdup("ERROR"); #ifdef PREFS_BUTTON if (!sp->prefs_label) sp->prefs_label = strdup("ERROR"); #endif /* PREFS_BUTTON */ if (!sp->help_label) sp->help_label = strdup("ERROR"); /* Put the version number in the label. */ { char *s = (char *) malloc (strlen(sp->heading_label) + 20); sprintf(s, sp->heading_label, si->version); free (sp->heading_label); sp->heading_label = s; } f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font"); sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed")); if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed"); if (f) free (f); f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font"); sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed")); if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed"); if (f) free (f); f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font"); sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed")); if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed"); if (f) free (f); sp->foreground = get_pixel_resource (si->dpy, cmap, "splash.foreground", "Dialog.Foreground"); sp->background = get_pixel_resource (si->dpy, cmap, "splash.background", "Dialog.Background"); sp->border = get_pixel_resource (si->dpy, cmap, "splash.borderColor", "Dialog.borderColor"); if (sp->foreground == sp->background) { /* Make sure the error messages show up. */ sp->foreground = BlackPixelOfScreen (ssi->screen); sp->background = WhitePixelOfScreen (ssi->screen); } sp->button_foreground = get_pixel_resource (si->dpy, cmap, "splash.Button.foreground", "Dialog.Button.Foreground"); sp->button_background = get_pixel_resource (si->dpy, cmap, "splash.Button.background", "Dialog.Button.Background"); sp->shadow_top = get_pixel_resource (si->dpy, cmap, "splash.topShadowColor", "Dialog.Foreground"); sp->shadow_bottom = get_pixel_resource (si->dpy, cmap, "splash.bottomShadowColor", "Dialog.Background"); sp->logo_width = get_integer_resource (si->dpy, "splash.logo.width", "Dialog.Logo.Width"); sp->logo_height = get_integer_resource (si->dpy, "splash.logo.height", "Dialog.Logo.Height"); sp->internal_border = get_integer_resource (si->dpy, "splash.internalBorderWidth", "Dialog.InternalBorderWidth"); sp->shadow_width = get_integer_resource (si->dpy, "splash.shadowThickness", "Dialog.ShadowThickness"); if (sp->logo_width == 0) sp->logo_width = 150; if (sp->logo_height == 0) sp->logo_height = 150; if (sp->internal_border == 0) sp->internal_border = 15; if (sp->shadow_width == 0) sp->shadow_width = 4; { int direction, ascent, descent; XCharStruct overall; sp->width = 0; sp->height = 0; /* Measure the heading_label. */ XTextExtents (sp->heading_font, sp->heading_label, strlen(sp->heading_label), &direction, &ascent, &descent, &overall); if (overall.width > sp->width) sp->width = overall.width; sp->height += ascent + descent; /* Measure the body_label. */ XTextExtents (sp->body_font, sp->body_label, strlen(sp->body_label), &direction, &ascent, &descent, &overall); if (overall.width > sp->width) sp->width = overall.width; sp->height += ascent + descent; /* Measure the body2_label. */ XTextExtents (sp->body_font, sp->body2_label, strlen(sp->body2_label), &direction, &ascent, &descent, &overall); if (overall.width > sp->width) sp->width = overall.width; sp->height += ascent + descent; { Dimension w2 = 0, w3 = 0, w4 = 0; Dimension h2 = 0, h3 = 0, h4 = 0; /* Measure the Demo button. */ XTextExtents (sp->button_font, sp->demo_label, strlen(sp->demo_label), &direction, &ascent, &descent, &overall); w2 = overall.width; h2 = ascent + descent; #ifdef PREFS_BUTTON /* Measure the Prefs button. */ XTextExtents (sp->button_font, sp->prefs_label, strlen(sp->prefs_label), &direction, &ascent, &descent, &overall); w3 = overall.width; h3 = ascent + descent; #else /* !PREFS_BUTTON */ w3 = 0; h3 = 0; #endif /* !PREFS_BUTTON */ /* Measure the Help button. */ XTextExtents (sp->button_font, sp->help_label, strlen(sp->help_label), &direction, &ascent, &descent, &overall); w4 = overall.width; h4 = ascent + descent; w2 = MAX(w2, w3); w2 = MAX(w2, w4); h2 = MAX(h2, h3); h2 = MAX(h2, h4); /* Add some horizontal padding inside the buttons. */ w2 += ascent; w2 += ((ascent + descent) / 2) + (sp->shadow_width * 2); h2 += ((ascent + descent) / 2) + (sp->shadow_width * 2); sp->button_width = w2; sp->button_height = h2; #ifdef PREFS_BUTTON w2 *= 3; #else /* !PREFS_BUTTON */ w2 *= 2; #endif /* !PREFS_BUTTON */ w2 += ((ascent + descent) * 2); /* for space between buttons */ if (w2 > sp->width) sp->width = w2; sp->height += h2; } sp->width += (sp->internal_border * 2); sp->height += (sp->internal_border * 3); if (sp->logo_height > sp->height) sp->height = sp->logo_height; else if (sp->height > sp->logo_height) sp->logo_height = sp->height; sp->logo_width = sp->logo_height; sp->width += sp->logo_width; } attrmask |= CWOverrideRedirect; attrs.override_redirect = True; attrmask |= CWEventMask; attrs.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask); { int sx = 0, sy = 0, w, h; int mouse_x = 0, mouse_y = 0; { Window pointer_root, pointer_child; int root_x, root_y, win_x, win_y; unsigned int mask; if (XQueryPointer (si->dpy, RootWindowOfScreen (ssi->screen), &pointer_root, &pointer_child, &root_x, &root_y, &win_x, &win_y, &mask)) { mouse_x = root_x; mouse_y = root_y; } } x = ssi->x; y = ssi->y; w = ssi->width; h = ssi->height; if (si->prefs.debug_p) w /= 2; x = sx + (((w + sp->width) / 2) - sp->width); y = sy + (((h + sp->height) / 2) - sp->height); if (x < sx) x = sx; if (y < sy) y = sy; } bw = get_integer_resource (si->dpy, "splash.borderWidth", "Dialog.BorderWidth"); si->splash_dialog = XCreateWindow (si->dpy, RootWindowOfScreen(ssi->screen), x, y, sp->width, sp->height, bw, DefaultDepthOfScreen (ssi->screen), InputOutput, DefaultVisualOfScreen(ssi->screen), attrmask, &attrs); XSetWindowBackground (si->dpy, si->splash_dialog, sp->background); XSetWindowBorder (si->dpy, si->splash_dialog, sp->border); sp->logo_pixmap = xscreensaver_logo (ssi->screen, /* same visual as si->splash_dialog */ DefaultVisualOfScreen (ssi->screen), si->splash_dialog, cmap, sp->background, &sp->logo_pixels, &sp->logo_npixels, &sp->logo_clipmask, True); XMapRaised (si->dpy, si->splash_dialog); XSync (si->dpy, False); si->sp_data = sp; sp->timer = XtAppAddTimeOut (si->app, si->prefs.splash_duration, unsplash_timer, (XtPointer) si); draw_splash_window (si); XSync (si->dpy, False); }
int main( int argc , char *argv[] ){ Display *display; Window window; Window pen_window[5]; Window color_window[5]; GC gc; char title[] = "Paint"; char icon_title[] = "Paint"; unsigned long background; unsigned long foreground; int button_size=40; char *colors[]={ "rgb:00/00/00", "rgb:ff/00/00", "rgb:00/ff/00", "rgb:00/00/ff", "rgb:ff/ff/00", }; int current_pen=2; unsigned long current_color=0; int x0,y0,x1,y1; int i; display = XOpenDisplay(NULL); background = WhitePixel(display,0); foreground = BlackPixel(display,0); window = XCreateSimpleWindow(display, DefaultRootWindow(display), 0,0,500,400, 0,0,background); XSetStandardProperties(display,window,title,icon_title, None,argv,argc,NULL); /* GC を生成し、各種設定を行う */ gc = XCreateGC(display,window,0,0); XSetBackground(display,gc,background); XSetForeground(display,gc,current_color); XSetLineAttributes(display,gc,current_pen, LineSolid,CapRound,JoinMiter); /* メインウィンドウのイベントマスクを設定 */ XSelectInput(display,window, ExposureMask | ButtonPressMask | ButtonMotionMask); /* ペンサイズ・色選択ウィンドウを作成 */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ pen_window[i] = XCreateSimpleWindow(display,window, 10,(button_size+10)*i+30, button_size,button_size, 1,mycolor(display,"rgb:aa/aa/aa"), mycolor(display,"rgb:ee/ee/ee")); color_window[i] = XCreateSimpleWindow(display,window, 500-10-button_size,(button_size+10)*i+30, button_size,button_size, 1,mycolor(display,"rgb:aa/aa/aa"), mycolor(display,colors[i])); XSelectInput(display,pen_window[i], ButtonPressMask | EnterWindowMask | LeaveWindowMask ); XSelectInput(display,color_window[i], ButtonPressMask | EnterWindowMask | LeaveWindowMask ); } /* 全てのウィンドウをマップ */ XMapWindow(display,window); XMapSubwindows(display,window); while (1){ XEvent event; XNextEvent(display,&event); switch ( event.type ){ case Expose: /* 再描画 */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ int pen_size = i*3+2; /* ペンサイズウィンドウを再描画 */ XSetForeground(display,gc,foreground); XFillArc(display,pen_window[i],gc, button_size/2-pen_size/2,button_size/2-pen_size/2, pen_size,pen_size,0,360*64); } break; case EnterNotify: /* ウィンドウにポインタが入った */ XSetWindowBorder(display,event.xany.window, mycolor(display,"black")); break; case LeaveNotify: /* ウィンドウからポインタが出た */ XSetWindowBorder(display,event.xany.window, mycolor(display,"rgb:aa/aa/aa")); break; case MotionNotify: /* ボタンを押しながらマウスが動いた */ x1 = event.xbutton.x; y1 = event.xbutton.y; XDrawLine(display,window,gc,x0,y0,x1,y1); x0 = x1; y0 = y1; break; case ButtonPress: /* ボタンが押された */ /* キャンバス上で押された? */ if ( event.xany.window == window ){ x0 = event.xbutton.x; y0 = event.xbutton.y; XDrawLine(display,window,gc,x0,y0,x0,y0); break; } /* ペンサイズ/色選択ウィンドウ上で押された? */ for ( i=0 ; i<sizeof(pen_window)/sizeof(pen_window[0]) ; i++ ){ /* ペンサイズを変更 */ if ( event.xany.window == pen_window[i] ){ current_pen = i*3+2; XSetLineAttributes(display,gc,current_pen, LineSolid,CapRound,JoinMiter); break; } /* 色を変更 */ if ( event.xany.window == color_window[i] ){ current_color = mycolor(display,colors[i]); XSetForeground(display,gc,current_color); break; } } break; } } }
static void __map_window(Display *dpy) { rectangle new_g; rectangle screen_g; Window dummy; fscreen_scr_arg *fsarg = NULL; /* for now no xinerama support */ ftips_placement_t placement; int x,y; static int border_width = 1; static Window win_f = None; if (border_width != current_config->border_width) { XSetWindowBorderWidth(dpy, win, current_config->border_width); border_width = current_config->border_width; } FScreenGetScrRect( fsarg, FSCREEN_GLOBAL, &screen_g.x, &screen_g.y, &screen_g.width, &screen_g.height); new_g.height = ((current_config->Ffont)? current_config->Ffont->height:0) + 1; new_g.width = 4; if (label && current_config->Ffont) { new_g.width += FlocaleTextWidth( current_config->Ffont, label, strlen(label)); } if (current_config->placement != FTIPS_PLACEMENT_AUTO_UPDOWN && current_config->placement != FTIPS_PLACEMENT_AUTO_LEFTRIGHT) { placement = current_config->placement; } else { XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), box.x, box.y, &x, &y, &dummy); if (current_config->placement == FTIPS_PLACEMENT_AUTO_UPDOWN) { if (y + box.height/2 >= screen_g.height/2) { placement = FTIPS_PLACEMENT_UP; } else { placement = FTIPS_PLACEMENT_DOWN; } } else { if (x + box.width/2 >= screen_g.width/2) { placement = FTIPS_PLACEMENT_LEFT; } else { placement = FTIPS_PLACEMENT_RIGHT; } } } if (placement == FTIPS_PLACEMENT_RIGHT || placement == FTIPS_PLACEMENT_LEFT) { if (current_config->justification == FTIPS_JUSTIFICATION_CENTER) { y = box.y + (box.height / 2) - (new_g.height / 2) - current_config->border_width; } else if (current_config->justification == FTIPS_JUSTIFICATION_RIGHT_DOWN) { y = box.y + box.height - new_g.height - (2 * current_config->border_width) - current_config->justification_offset; } else /* LEFT_UP */ { y = box.y + current_config->justification_offset; } } else /* placement == FTIPS_PLACEMENT_DOWN || placement == FTIPS_PLACEMENT_UP */ { if (current_config->justification == FTIPS_JUSTIFICATION_CENTER) { x = box.x + (box.width / 2) - (new_g.width / 2) - current_config->border_width; } else if (current_config->justification == FTIPS_JUSTIFICATION_RIGHT_DOWN) { x = box.x + box.width - new_g.width - (2 * current_config->border_width) - current_config->justification_offset; } else /* LEFT_UP */ { x = box.x + current_config->justification_offset; } } if (placement == FTIPS_PLACEMENT_RIGHT) { x = box.x + box.width + current_config->placement_offset + 1; } else if (placement == FTIPS_PLACEMENT_LEFT) { x = box.x - current_config->placement_offset - new_g.width - (2 * current_config->border_width) - 1; } else if (placement == FTIPS_PLACEMENT_DOWN) { y = box.y + box.height + current_config->placement_offset - 0; } else /* UP */ { y = box.y - current_config->placement_offset - new_g.height + 0 - (2 * current_config->border_width); } XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), x, y, &new_g.x, &new_g.y, &dummy); if (placement == FTIPS_PLACEMENT_RIGHT || placement == FTIPS_PLACEMENT_LEFT) { int x1,y1,l1,l2; if (new_g.x < 2) { x = box.x + box.width + current_config->placement_offset + 1; XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), x, y, &x1, &y1, &dummy); /* */ l1 = new_g.width + new_g.x - 2; l2 = screen_g.width - (x1 + new_g.width) - current_config->border_width - 2; if (l2 > l1) { new_g.x = x1; } } else if (new_g.x + new_g.width > screen_g.width - (2 * current_config->border_width) - 2) { x = box.x - current_config->placement_offset - new_g.width - (2 * current_config->border_width) - 1; XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), x, y, &x1, &y1, &dummy); /* */ l1 = new_g.width + x1 - 2; l2 = screen_g.width - (new_g.x + new_g.width) - (2 * current_config->border_width) - 2; if (l1 > l2) { new_g.x = x1; } } if ( new_g.y < 2 ) { new_g.y = 2; } else if (new_g.y + new_g.height > screen_g.height - (2 * current_config->border_width) - 2) { new_g.y = screen_g.height - new_g.height - (2 * current_config->border_width) - 2; } } else /* placement == FTIPS_PLACEMENT_DOWN || placement == FTIPS_PLACEMENT_UP */ { if (new_g.y < 2) { y = box.y + box.height + current_config->placement_offset - 0; XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), x, y, &new_g.x, &new_g.y, &dummy); } else if (new_g.y + new_g.height > screen_g.height - (2 * current_config->border_width) - 2) { y = box.y - current_config->placement_offset - new_g.height + 0 - (2 * current_config->border_width); XTranslateCoordinates( dpy, win_for, DefaultRootWindow(dpy), x, y, &new_g.x, &new_g.y, &dummy); } if ( new_g.x < 2 ) { new_g.x = 2; } else if (new_g.x + new_g.width > screen_g.width - (2 * current_config->border_width) - 2) { new_g.x = screen_g.width - new_g.width - (2 * current_config->border_width) - 2; } } /* make changes to window */ XMoveResizeWindow( dpy, win, new_g.x, new_g.y, new_g.width, new_g.height); __setup_gc(dpy); if (current_config->colorset > -1) { SetWindowBackground( dpy, win, new_g.width, new_g.height, &Colorset[current_config->colorset], Pdepth, gc, True); } else { XSetWindowBackground (dpy, win, current_config->bg); } if (current_config->border_width > 0) { XSetWindowBorder( dpy, win, Colorset[current_config->colorset].fg); } if (state != FVWM_TIPS_MAPPED && win_f != win_for) { long l_win_for; l_win_for = win_for; XChangeProperty( dpy, win, _net_um_for, XA_WINDOW, 32, PropModeReplace, (unsigned char *) &l_win_for, 1); win_f = win_for; } XMapRaised(dpy, win); state = FVWM_TIPS_MAPPED; return; }
bool WPcrbu( WPBUTT *butptr, bool enter) /* Crossing handler for WPBUTT. * * In: butptr = C ptr to WPBUTT. * enter = TRUE => Enter. * FALSE => Leave. * * Return: Always = TRUE. * * (C)microform ab 6/12/93 J. Kjellander * * 2007-03-08 Tooltips, J.Kjellander * 2007-10-22 Button types, J.Kjellander * ******************************************************!*/ { int x,y,orgcol; /* ***LABELBUTTON's dont react on crossing events. */ if ( butptr->type == LABELBUTTON ) return(TRUE); /* ***All others do. ***Enter => Change color of window border to WP_NOTI. */ if ( enter == TRUE && !butptr->hlight ) { switch ( butptr->type ) { case TEXTBUTTON: orgcol = butptr->color.bckgnd; butptr->color.bckgnd = WP_NOTI; XSetWindowBackground(xdisp,butptr->id.x_id,WPgcol(WP_NOTI)); WPxpbu(butptr); XFlush(xdisp); butptr->color.bckgnd = orgcol; break; case PUSHBUTTON: case STATEBUTTON: case FUNCBUTTON: XSetWindowBorder(xdisp,butptr->id.x_id,WPgcbu(butptr->id.p_id,WP_NOTI)); break; } /* ***Button is now highlighted. */ butptr->hlight = TRUE; /* ***Order a tooltip in a few seconds if there is one to display. */ if ( butptr->tt_str[0] != '\0' ) { WPgtmp(&x,&y); WPorder_tooltip(x+5,y+10,butptr->tt_str); } } /* ***Leave => Reset window border color. */ else if ( butptr->hlight ) { switch ( butptr->type ) { case TEXTBUTTON: XSetWindowBackground(xdisp,butptr->id.x_id,WPgcol(butptr->color.bckgnd)); WPxpbu(butptr); XFlush(xdisp); break; case PUSHBUTTON: case STATEBUTTON: case FUNCBUTTON: XSetWindowBorder(xdisp,butptr->id.x_id,WPgcbu(butptr->id.p_id,WP_BGND1)); break; } /* ***Button is no longer highlighted. */ butptr->hlight = FALSE; /* ***Remove ordered or active tooltip. */ WPclear_tooltip(); } return(TRUE); }
void win::setborder(unsigned long color) { XSetWindowBorder(disp, w, color); }