// Copyright status: this file is in the public domain. #include #include #include "lx.h" #include "internal.h" int lx_icccm_wm_properties( LX_CONN *xc, LX_XID win, const char *wname, const char *iname, int argc, const char * const *argv, LX_SIZE_HINTS *normal_hints, LX_WM_HINTS *wm_hints, LX_CLASS_HINTS *class_hints ) { unsigned int wmh[9]; unsigned char *ch; int chl; unsigned int nh[18]; unsigned int f; if ( ( normal_hints && ( (normal_hints->lx__version != ICCCM_INTF_VERSION_1) || (normal_hints->flags & ~( LX_S_HINT_MINSIZE | LX_S_HINT_MAXSIZE | LX_S_HINT_INC | LX_S_HINT_ASPECT | LX_S_HINT_BASE | LX_S_HINT_GRAVITY | LX_S_HINT_UPOS | LX_S_HINT_USIZE | LX_S_HINT_PPOS | LX_S_HINT_PSIZE )) || ((normal_hints->flags & (LX_S_HINT_UPOS | LX_S_HINT_PPOS)) == (LX_S_HINT_UPOS | LX_S_HINT_PPOS)) || ((normal_hints->flags & (LX_S_HINT_USIZE | LX_S_HINT_PSIZE)) == (LX_S_HINT_USIZE | LX_S_HINT_PSIZE)) ) ) || ( wm_hints && ( (wm_hints->lx__version != ICCCM_INTF_VERSION_1) || (wm_hints->flags & ~( LX_WM_HINT_STATE | LX_WM_HINT_INPUT | LX_WM_HINT_ICONPIXMAP | LX_WM_HINT_ICONMASK | LX_WM_HINT_ICONWIN | LX_WM_HINT_ICONPOS | LX_WM_HINT_GROUP )) ) ) || (class_hints && (class_hints->lx__version != ICCCM_INTF_VERSION_1)) ) { return(-1); } if (class_hints) { int nl; int cl; nl = class_hints->name ? strlen(class_hints->name)+1 : 1; cl = class_hints->class ? strlen(class_hints->class)+1 : 1; chl = nl + cl; ch = malloc(chl); if (class_hints->name) { bcopy(class_hints->name,ch,nl); } else { ch[0] = '\0'; } if (class_hints->class) { bcopy(class_hints->class,ch+nl,cl); } else { ch[nl] = '\0'; } } if (normal_hints) { f = 0; if (normal_hints->flags & LX_S_HINT_MINSIZE) { f |= 16; nh[5] = (unsigned int)normal_hints->min_w; nh[6] = (unsigned int)normal_hints->min_h; } if (normal_hints->flags & LX_S_HINT_MAXSIZE) { f |= 32; nh[7] = (unsigned int)normal_hints->max_w; nh[8] = (unsigned int)normal_hints->max_h; } if (normal_hints->flags & LX_S_HINT_INC) { f |= 64; nh[9] = (unsigned int)normal_hints->inc_w; nh[10] = (unsigned int)normal_hints->inc_h; } if (normal_hints->flags & LX_S_HINT_ASPECT) { f |= 128; nh[11] = (unsigned int)normal_hints->min_a_n; nh[12] = (unsigned int)normal_hints->min_a_d; nh[13] = (unsigned int)normal_hints->max_a_n; nh[14] = (unsigned int)normal_hints->max_a_d; } if (normal_hints->flags & LX_S_HINT_BASE) { f |= 256; nh[15] = (unsigned int)normal_hints->base_w; nh[16] = (unsigned int)normal_hints->base_h; } if (normal_hints->flags & LX_S_HINT_GRAVITY) { f |= 512; switch (normal_hints->gravity) { case LX_GRAVITY_NorthWest: case LX_GRAVITY_North: case LX_GRAVITY_NorthEast: case LX_GRAVITY_West: case LX_GRAVITY_Center: case LX_GRAVITY_East: case LX_GRAVITY_SouthWest: case LX_GRAVITY_South: case LX_GRAVITY_SouthEast: nh[17] = (unsigned int)lx__bitgravity_to_proto(normal_hints->gravity); break; default: return(-1); break; } } if (normal_hints->flags & LX_S_HINT_UPOS) { f |= 1; } else if (normal_hints->flags & LX_S_HINT_PPOS) { f |= 4; } if (normal_hints->flags & LX_S_HINT_USIZE) { f |= 2; } else if (normal_hints->flags & LX_S_HINT_PSIZE) { f |= 8; } nh[0] = f; nh[1] = 0; nh[2] = 0; nh[3] = 0; nh[4] = 0; } if (wm_hints) { f = 0; switch (wm_hints->flags & LX_WM_HINT_INPUT) { case LX_WM_HINT_INPUT_UNSET: break; case LX_WM_HINT_INPUT_FALSE: f |= 1; wmh[1] = 0; break; case LX_WM_HINT_INPUT_TRUE: f |= 1; wmh[1] = 1; break; default: return(-1); break; } switch (wm_hints->flags & LX_WM_HINT_STATE) { case LX_WM_HINT_STATE_UNSET: break; case LX_WM_HINT_STATE_NORMAL: f |= 2; wmh[2] = 1; break; case LX_WM_HINT_STATE_ICONIC: f |= 2; wmh[2] = 3; break; default: return(-1); break; } if (wm_hints->flags & LX_WM_HINT_ICONPIXMAP) { f |= 4; wmh[3] = wm_hints->icon_pix; } if (wm_hints->flags & LX_WM_HINT_ICONMASK) { f |= 32; wmh[7] = wm_hints->icon_mask; } if (wm_hints->flags & LX_WM_HINT_ICONWIN) { f |= 8; wmh[4] = wm_hints->icon_win; } if (wm_hints->flags & LX_WM_HINT_ICONPOS) { f |= 16; wmh[5] = (unsigned int)wm_hints->icon_x; wmh[6] = (unsigned int)wm_hints->icon_y; } if (wm_hints->flags & LX_WM_HINT_GROUP) { f |= 64; wmh[8] = wm_hints->group; } wmh[0] = f; } if (wname) lx_ChangeProperty(xc,win,LX_ATOM_WM_NAME,LX_ATOM_STRING,8,LX_PROPERTYMODE_Replace,wname,strlen(wname)); if (iname) lx_ChangeProperty(xc,win,LX_ATOM_WM_ICON_NAME,LX_ATOM_STRING,8,LX_PROPERTYMODE_Replace,iname,strlen(iname)); if ((argc >= 0) && argv) { int l; char *b; int i; int o; l = 0; for (i=0;i 0) { b = malloc(l); o = 0; for (i=0;i