void wm_redraw_ncarea(win *window) { GR_WINDOW_INFO info; GR_WM_PROPERTIES props; GR_BOOL active; Dprintf("wm_container_exposure window %d\n", window->wid); GrGetWindowInfo(window->wid, &info); GrGetWMProperties(window->clientid, &props); /* * Check for invalid window. This will be the * case if the client exited, and we're just * getting the paint notification for our parent. */ if (props.flags) { active = (window->clientid == GrGetFocus()); nxPaintNCArea(window->wid, info.width, info.height, props.title, active, props.props); } /* free title returned from GrGetWMProperties*/ if (props.title) free(props.title); }
void topbar_mousemoved(win *window, GR_EVENT_MOUSE *event) { struct position *pos; GR_WM_PROPERTIES props; Dprintf("topbar_mousemoved window %d\n", window->wid); if(!window->active) return; pos = (struct position *) window->data; /* turn off background erase draw while moving*/ GrGetWMProperties(window->pid, &props); if (props.title) free(props.title); props.flags = GR_WM_FLAGS_PROPS; props.props |= GR_WM_PROPS_NOBACKGROUND; GrSetWMProperties(window->pid, &props); GrMoveWindow(window->pid, event->rootx - pos->x, event->rooty - pos->y); props.props &= ~GR_WM_PROPS_NOBACKGROUND; GrSetWMProperties(window->pid, &props); }
void topbar_exposure(win *window, GR_EVENT_EXPOSURE *event) { win *pwin = wm_find_window(window->pid); struct clientinfo *ci = pwin->data; GR_WM_PROPERTIES prop; Dprintf("topbar_exposure window %d\n", window->wid); GrGetWMProperties(ci->cid, &prop); if (prop.title) { GrText(window->wid, buttonsgc, 0, 0, prop.title, -1, GR_TFASCII|GR_TFTOP); free(prop.title); } }
static void GrGetWMPropertiesWrapper(void *r) { nxGetWMPropertiesReq *req = r; UINT16 textlen; GR_WM_PROPERTIES props; GrGetWMProperties(req->windowid, &props); if(props.title) textlen = strlen(props.title) + 1; else textlen = 0; GsWriteType(current_fd,GrNumGetWMProperties); GsWrite(current_fd, &props, sizeof(props)); GsWrite(current_fd, &textlen, sizeof(textlen)); if(textlen) GsWrite(current_fd, props.title, textlen); }
void wm_redraw_ncarea(win *window) { GR_WINDOW_INFO info; GR_WM_PROPERTIES props; GR_BOOL active; GR_WINDOW_ID focusedwindow; Dprintf("wm_container_exposure window %d\n", window->wid); GrGetWindowInfo(window->wid, &info); GrGetWMProperties(window->clientid, &props); /* * Check for invalid window. This will be the * case if the client exited, and we're just * getting the paint notification for our parent. */ if (props.flags) { /* Get window with keyboard focus*/ focusedwindow = GrGetFocus(); /* * Check if the current window or any of its ancestors has the focus * A window is active even if any of its ancestors has focus * --Amit Kulkarni */ active = checkHasFocus(window->clientid,focusedwindow); /* * Note that we should also raise the window if its active and behind. * an active window deserves to be on the top :-) */ //if(active) //GrRaiseWindow(window->wid); // FIXME nxPaintNCArea(window->wid, info.width, info.height, props.title, active, props.props); } /* free title returned from GrGetWMProperties*/ if (props.title) free(props.title); }
static void _nxDelPropData(struct window_props *prop) { /* delete XA_WM_TRANSIENT_FOR data*/ if ((prop->property == XA_WM_TRANSIENT_FOR) && prop->data) { Window prop_window = *((Window*)prop->data); GR_WM_PROPERTIES props; GrGetWMProperties(prop_window, &props); if (props.title) free(props.title); props.flags = GR_WM_FLAGS_PROPS; props.props &= ~(GR_WM_PROPS_NORAISE | GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NOFOCUS); GrSetWMProperties(prop_window, &props); GrSetFocus(prop_window); } if (prop->data) Xfree(prop->data); Xfree(prop); }
int XChangeProperty(Display * display, Window w, Atom property, Atom type, int format, int mode, _Xconst unsigned char *data, int nelements) { struct windows *win = NULL; struct window_props *prop = NULL; Window prop_window; int hash = w % SZHASHTABLE; GR_WM_PROPERTIES props; if (!nelements || data == NULL) { DPRINTF("XChangeProperty called with NULL data [Atom:%lx,m:%x,d:%lx]\n", type, mode, (long)data); return 1; } DPRINTF("XChangeProperty called [Atom:%lx, mode:%x, data:%lx]\n", type, mode, (long)data); win = window_list[hash]; if (!win) { win = window_list[hash] = // (struct windows *) Xcalloc(sizeof(struct windows), 1); (struct windows *) Xcalloc(1, sizeof(struct windows)); } else { struct windows *t; for (t=win; ; t=t->next) { if (t->w == w) { win = t; break; } if (!t->next) break; } if (!win) { win = t->next = //(struct windows *) Xcalloc(sizeof(struct windows), 1); (struct windows *) Xcalloc(1, sizeof(struct windows)); } } win->w = w; if (!win->properties) { prop = win->properties = //(struct window_props *) Xcalloc(sizeof(struct window_props), 1); (struct window_props *) Xcalloc(1, sizeof(struct window_props)); } else { struct window_props *t; for (t=win->properties; ; t=t->next) { if (t->property == property) { prop = t; break; } if (!t->next) break; } if (!prop) { prop = t->next = //(struct window_props *) Xcalloc(sizeof(struct window_props), 1); (struct window_props *) Xcalloc(1, sizeof(struct window_props)); } } DPRINTF("XChangeProperty: win:%x prop:%x\n", (int)w, (int)prop); switch (mode) { case PropModeAppend: // 2 case PropModePrepend: // 1 if (prop->data) { int f8 = prop->format / 8; char *p; int bytes; //DPRINTF("XChangeProperty: %d,%d\n", format, bytes); if (type != prop->type || format != prop->format) return 0; bytes = (prop->nelements + nelements) * f8; p = (char *)Xmalloc(bytes+1); /* alloc + 1 for string '\0'*/ p[bytes] = '\0'; if (mode == PropModeAppend) { memcpy(p, prop->data, prop->nelements * f8); memcpy(p + (prop->nelements * f8), data, (nelements * f8)); } else { memcpy(p, data, nelements * f8); memcpy(p + (nelements * f8), prop->data, (prop->nelements * f8)); } Xfree(prop->data); prop->data = (unsigned char *)p; prop->nelements += nelements; prop->bytes = bytes; break; } /* Fall through */ case PropModeReplace: // 0 if (prop->data) Xfree(prop->data); if (format<0 || format/8 > 4) { DPRINTF("XChangeProperty: format[%d]\n", format); format = 8; } prop->bytes = nelements * (format / 8); prop->data = (unsigned char *) Xmalloc(prop->bytes+1); /* +1 for string '\0'*/ prop->data[prop->bytes] = '\0'; //DPRINTF("XChangeProperty: [%x,%d,%x]\n", prop,nelements,prop->bytes); memcpy(prop->data, data, prop->bytes); prop->property = property; prop->type = type; prop->format = format; prop->nelements = nelements; break; } switch (property) { case XA_WM_TRANSIENT_FOR: prop_window = *((Window *)data); GrGetWMProperties(prop_window, &props); if (props.title) free(props.title); props.flags = GR_WM_FLAGS_PROPS; props.props |= (GR_WM_PROPS_NORAISE | GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NOFOCUS); GrSetWMProperties(prop_window, &props); break; case XA_WM_NAME: props.flags = GR_WM_FLAGS_TITLE; props.title = (char *)prop->data; GrSetWMProperties(w, &props); break; default: break; } return 1; }