|
|
1.1 ! root 1: #include "copyright.h" ! 2: ! 3: /* $Header: XSetHints.c,v 11.18 87/09/01 15:05:37 toddb Exp $ */ ! 4: ! 5: /*********************************************************** ! 6: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, ! 7: and the Massachusetts Institute of Technology, Cambridge, Massachusetts. ! 8: ! 9: All Rights Reserved ! 10: ! 11: Permission to use, copy, modify, and distribute this software and its ! 12: documentation for any purpose and without fee is hereby granted, ! 13: provided that the above copyright notice appear in all copies and that ! 14: both that copyright notice and this permission notice appear in ! 15: supporting documentation, and that the names of Digital or MIT not be ! 16: used in advertising or publicity pertaining to distribution of the ! 17: software without specific, written prior permission. ! 18: ! 19: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ! 20: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ! 21: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ! 22: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ! 23: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ! 24: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ! 25: SOFTWARE. ! 26: ! 27: ******************************************************************/ ! 28: ! 29: #include "Xlibint.h" ! 30: #include "Xutil.h" ! 31: #include "Xatomtype.h" ! 32: #include "Xatom.h" ! 33: ! 34: XSetSizeHints(dpy, w, hints, property) ! 35: Display *dpy; ! 36: Window w; ! 37: XSizeHints *hints; ! 38: Atom property; ! 39: { ! 40: xPropSizeHints prop; ! 41: prop.flags = hints->flags; ! 42: prop.x = hints->x; ! 43: prop.y = hints->y; ! 44: prop.width = hints->width; ! 45: prop.height = hints->height; ! 46: prop.minWidth = hints->min_width; ! 47: prop.minHeight = hints->min_height; ! 48: prop.maxWidth = hints->max_width; ! 49: prop.maxHeight = hints->max_height; ! 50: prop.widthInc = hints->width_inc; ! 51: prop.heightInc = hints->height_inc; ! 52: prop.minAspectX = hints->min_aspect.x; ! 53: prop.minAspectY = hints->min_aspect.y; ! 54: prop.maxAspectX = hints->max_aspect.x; ! 55: prop.maxAspectY = hints->max_aspect.y; ! 56: XChangeProperty (dpy, w, property, XA_WM_SIZE_HINTS, 32, ! 57: PropModeReplace, (unsigned char *) &prop, NumPropSizeElements); ! 58: } ! 59: ! 60: /* ! 61: * XSetWMHints sets the property ! 62: * WM_HINTS type: WM_HINTS format:32 ! 63: */ ! 64: ! 65: XSetWMHints (dpy, w, wmhints) ! 66: Display *dpy; ! 67: Window w; ! 68: XWMHints *wmhints; ! 69: { ! 70: xPropWMHints prop; ! 71: prop.flags = wmhints->flags; ! 72: prop.input = wmhints->input; ! 73: prop.initialState = wmhints->initial_state; ! 74: prop.iconPixmap = wmhints->icon_pixmap; ! 75: prop.iconWindow = wmhints->icon_window; ! 76: prop.iconX = wmhints->icon_x; ! 77: prop.iconY = wmhints->icon_y; ! 78: prop.iconMask = wmhints->icon_mask; ! 79: prop.windowGroup = wmhints->window_group; ! 80: XChangeProperty (dpy, w, XA_WM_HINTS, XA_WM_HINTS, 32, ! 81: PropModeReplace, (unsigned char *) &prop, NumPropWMHintsElements); ! 82: } ! 83: ! 84: ! 85: ! 86: /* ! 87: * XSetZoomHints sets the property ! 88: * WM_ZOOM_HINTS type: WM_SIZE_HINTS format: 32 ! 89: */ ! 90: ! 91: XSetZoomHints (dpy, w, zhints) ! 92: Display *dpy; ! 93: Window w; ! 94: XSizeHints *zhints; ! 95: { ! 96: XSetSizeHints (dpy, w, zhints, XA_WM_ZOOM_HINTS); ! 97: } ! 98: ! 99: ! 100: /* ! 101: * XSetNormalHints sets the property ! 102: * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32 ! 103: */ ! 104: ! 105: void XSetNormalHints (dpy, w, hints) ! 106: Display *dpy; ! 107: Window w; ! 108: XSizeHints *hints; ! 109: { ! 110: XSetSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS); ! 111: } ! 112: ! 113: ! 114: XSetIconSizes (dpy, w, list, count) ! 115: Display *dpy; ! 116: Window w; /* typically, root */ ! 117: XIconSize *list; ! 118: int count; /* number of items on the list */ ! 119: { ! 120: register int i; ! 121: xPropIconSize *pp, *prop; ! 122: unsigned nbytes = count * sizeof(xPropIconSize); ! 123: prop = pp = (xPropIconSize *) Xmalloc (nbytes); ! 124: for (i = 0; i < count; i++) { ! 125: pp->minWidth = list->min_width; ! 126: pp->minHeight = list->min_height; ! 127: pp->maxWidth = list->max_width; ! 128: pp->maxHeight = list->max_height; ! 129: pp->widthInc = list->width_inc; ! 130: pp->heightInc = list->height_inc; ! 131: pp += 1; ! 132: list += 1; ! 133: } ! 134: XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32, ! 135: PropModeReplace, (unsigned char *) prop, ! 136: count * NumPropIconSizeElements); ! 137: Xfree ((char *)prop); ! 138: } ! 139: ! 140: #include <strings.h> ! 141: XSetCommand (dpy, w, argv, argc) ! 142: Display *dpy; ! 143: Window w; ! 144: char **argv; ! 145: int argc; ! 146: { ! 147: register int i; ! 148: register unsigned nbytes; ! 149: register char *buf, *bp; ! 150: for (i = 0, nbytes = 0; i < argc; i++) { ! 151: nbytes += strlen(argv[i]) + 1; ! 152: } ! 153: if (nbytes == 0) return; ! 154: bp = buf = Xmalloc(nbytes); ! 155: /* copy arguments into single buffer */ ! 156: for (i = 0; i < argc; i++) { ! 157: (void) strcpy(bp, argv[i]); ! 158: bp += strlen(argv[i]) + 1; ! 159: } ! 160: XChangeProperty (dpy, w, XA_WM_COMMAND, XA_STRING, 8, PropModeReplace, ! 161: (unsigned char *)buf, nbytes); ! 162: Xfree(buf); ! 163: } ! 164: /* ! 165: * XSetStandardProperties sets the following properties: ! 166: * WM_NAME type: STRING format: 8 ! 167: * WM_ICON_NAME type: STRING format: 8 ! 168: * WM_HINTS type: WM_HINTS format: 32 ! 169: * WM_COMMAND type: STRING ! 170: * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32 ! 171: */ ! 172: ! 173: XSetStandardProperties (dpy, w, name, icon_string, icon_pixmap, argv, argc, hints) ! 174: Display *dpy; ! 175: Window w; /* window to decorate */ ! 176: char *name; /* name of application */ ! 177: char *icon_string; /* name string for icon */ ! 178: Pixmap icon_pixmap; /* pixmap to use as icon, or None */ ! 179: char *argv[]; /* command to be used to restart application */ ! 180: int argc; /* count of arguments */ ! 181: XSizeHints *hints; /* size hints for window in its normal state */ ! 182: { ! 183: XWMHints phints; ! 184: phints.flags = 0; ! 185: ! 186: if (name != NULL) XStoreName (dpy, w, name); ! 187: ! 188: if (icon_string != NULL) { ! 189: XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8, ! 190: PropModeReplace, (unsigned char *)icon_string, strlen(icon_string)); ! 191: } ! 192: ! 193: if (icon_pixmap != None) { ! 194: phints.icon_pixmap = icon_pixmap; ! 195: phints.flags |= IconPixmapHint; ! 196: } ! 197: if (argv != NULL) XSetCommand(dpy, w, argv, argc); ! 198: ! 199: if (hints != NULL) XSetNormalHints(dpy, w, hints); ! 200: ! 201: if (phints.flags != 0) XSetWMHints(dpy, w, &phints); ! 202: } ! 203: ! 204: void ! 205: XSetTransientForHint(dpy, w, propWindow) ! 206: Display *dpy; ! 207: Window w; ! 208: Window propWindow; ! 209: { ! 210: XChangeProperty(dpy, w, XA_WM_TRANSIENT_FOR, XA_WINDOW, 32, ! 211: PropModeReplace, (char *) &propWindow, 1); ! 212: } ! 213: ! 214: void ! 215: XSetClassHint(dpy, w, classhint) ! 216: Display *dpy; ! 217: Window w; ! 218: XClassHint *classhint; ! 219: { ! 220: char *class_string = NULL; ! 221: int len_nm, len_cl; ! 222: ! 223: len_nm = strlen(classhint->res_name); ! 224: len_cl = strlen(classhint->res_class); ! 225: class_string = Xmalloc(len_nm + len_cl + 2); ! 226: strcpy(class_string, classhint->res_name); ! 227: strcpy(class_string+strlen(classhint->res_name)+1, classhint->res_class); ! 228: XChangeProperty(dpy, w, XA_WM_CLASS, XA_STRING, 8, ! 229: PropModeReplace, class_string, len_nm+len_cl+2); ! 230: Xfree(class_string); ! 231: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.