static void xdpy_set_window_title_default(ALLEGRO_DISPLAY *display, const char *title) { ALLEGRO_SYSTEM_XGLX *system = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver(); ALLEGRO_DISPLAY_XGLX *glx = (ALLEGRO_DISPLAY_XGLX *)display; { Atom WM_NAME = XInternAtom(system->x11display, "WM_NAME", False); Atom _NET_WM_NAME = XInternAtom(system->x11display, "_NET_WM_NAME", False); char *list[1] = { (char *) title }; XTextProperty property; Xutf8TextListToTextProperty(system->x11display, list, 1, XUTF8StringStyle, &property); XSetTextProperty(system->x11display, glx->window, &property, WM_NAME); XSetTextProperty(system->x11display, glx->window, &property, _NET_WM_NAME); XSetTextProperty(system->x11display, glx->window, &property, XA_WM_NAME); XFree(property.value); } { XClassHint *hint = XAllocClassHint(); if (hint) { ALLEGRO_PATH *exepath = al_get_standard_path(ALLEGRO_EXENAME_PATH); // hint doesn't use a const char*, so we use strdup to create a non const string hint->res_name = strdup(al_get_path_basename(exepath)); hint->res_class = strdup(al_get_path_basename(exepath)); XSetClassHint(system->x11display, glx->window, hint); free(hint->res_name); free(hint->res_class); XFree(hint); al_destroy_path(exepath); } } }
void prop_string_set(const char *name, const char *value) { Display *d; Atom a_name; Atom a_UTF8; XTextProperty xtp; if (name == NULL || value == NULL || value[0] == '\0') return; d = XOpenDisplay(NULL); if (d == NULL) return; a_name = XInternAtom(d, name, False); if (a_name == None) goto exit; a_UTF8 = XInternAtom(d, "UTF8_STRING", False); if (a_UTF8 == None) goto exit; xtp.value = (unsigned char *)value; xtp.format = 8; xtp.encoding = a_UTF8; xtp.nitems = strlen(value); XSetTextProperty(d, DefaultRootWindow(d), &xtp, a_name); exit: XCloseDisplay(d); }
void XSetWMClientMachine ( Display *dpy, Window w, XTextProperty *tp) { XSetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE); }
void XSetWMIconName ( Display *dpy, Window w, XTextProperty *tp) { XSetTextProperty (dpy, w, tp, XA_WM_ICON_NAME); }
void XDesktopContainer::initXWin() { display = XOpenDisplay(NULL); if (!display){ cout << "Display is null!!\n"; _exit(1); } char *name = DisplayString(display); int screen = DefaultScreen(display); rootWindow = RootWindow(display, screen); XTextProperty prop; Atom start = XInternAtom(display,"_IDESK_START", false); cout << " Idesk starting in " << name << endl; prop.value = (unsigned char *)name; prop.encoding = XA_STRING; prop.format = 8; prop.nitems = strlen(name); XSetTextProperty(display, rootWindow, &prop, start); XSelectInput( display, rootWindow, PropertyChangeMask| SubstructureNotifyMask); XSync(display, false); }
int dwbremote_set_property_list(Display *dpy, Window win, Atom atom, char **list, int count) { XTextProperty prop; Xutf8TextListToTextProperty(dpy, list, count, XUTF8StringStyle, &prop); XSetTextProperty(dpy, win, &prop, atom); XFree(prop.value); return 0; }
/** * @brief Set a UTF-8 string property on a window. */ bool wm_wid_set_prop_utf8(session_t *ps, Window wid, Atom prop, char *text) { XTextProperty text_prop = { }; bool success = (Success == XmbTextListToTextProperty(ps->dpy, &text, 1, XUTF8StringStyle, &text_prop)); if (success) XSetTextProperty(ps->dpy, wid, &text_prop, prop); sxfree(text_prop.value); return success; }
int window_set_text_prop(Window w, Atom atom, char *txt) { XTextProperty prop; if (XStringListToTextProperty(&txt, 1, &prop)) { XSetTextProperty(display, w, &prop, atom); XFree(prop.value); } return 0; }
/* sets up the 'workspace names' property */ static void gnome_set_workspace_names (int count, char **names) { XTextProperty text; if (XStringListToTextProperty (names, count, &text)) { XSetTextProperty (dpy, root_win, &text, _XA_WIN_WORKSPACE_NAMES); XFree (text.value); } }
void ewmh_update_desktop_names() { char** names = g_new(char*, tag_get_count()); for (int i = 0; i < tag_get_count(); i++) { names[i] = get_tag_by_index(i)->name->str; } XTextProperty text_prop; Xutf8TextListToTextProperty(g_display, names, tag_get_count(), XUTF8StringStyle, &text_prop); XSetTextProperty(g_display, g_root, &text_prop, g_netatom[NetDesktopNames]); XFree(text_prop.value); g_free(names); }
static void xdpy_set_window_title(ALLEGRO_DISPLAY *display, const char *title) { ALLEGRO_SYSTEM_XGLX *system = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver(); ALLEGRO_DISPLAY_XGLX *glx = (ALLEGRO_DISPLAY_XGLX *)display; _al_mutex_lock(&system->lock); Atom WM_NAME = XInternAtom(system->x11display, "WM_NAME", False); Atom _NET_WM_NAME = XInternAtom(system->x11display, "_NET_WM_NAME", False); char *list[] = {(void *)title}; XTextProperty property; Xutf8TextListToTextProperty(system->x11display, list, 1, XUTF8StringStyle, &property); XSetTextProperty(system->x11display, glx->window, &property, WM_NAME); XSetTextProperty(system->x11display, glx->window, &property, _NET_WM_NAME); XFree(property.value); XClassHint hint; hint.res_name = strdup(title); // Leak? (below too...) hint.res_class = strdup(title); XSetClassHint(system->x11display, glx->window, &hint); _al_mutex_unlock(&system->lock); }
void ewmh_update_desktop_names() { char** names = g_new(char*, g_tags->len); for (int i = 0; i < g_tags->len; i++) { names[i] = g_array_index(g_tags, HSTag*,i)->name->str; } XTextProperty text_prop; Xutf8TextListToTextProperty(g_display, names, g_tags->len, XUTF8StringStyle, &text_prop); XSetTextProperty(g_display, g_root, &text_prop, g_netatom[NetDesktopNames]); XFree(text_prop.value); g_free(names); }
void hook_emit(int argc, const char** argv) { static int last_property_number = 0; if (argc <= 0) { // nothing to do return; } XTextProperty text_prop; static char atom_name[STRING_BUF_SIZE]; snprintf(atom_name, STRING_BUF_SIZE, HERBST_HOOK_PROPERTY_FORMAT, last_property_number); Atom atom = ATOM(atom_name); Xutf8TextListToTextProperty(g_display, (char**)argv, argc, XUTF8StringStyle, &text_prop); XSetTextProperty(g_display, g_event_window, &text_prop, atom); XFree(text_prop.value); // set counter for next property last_property_number += 1; last_property_number %= HERBST_HOOK_PROPERTY_COUNT; }
/** * Set a window string property. * @param win The window * @param type The property * @param str The string * * Set a window string property */ EAPI void ecore_x_window_prop_string_set(Ecore_X_Window win, Ecore_X_Atom type, const char *str) { XTextProperty xtp; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (win == 0) win = DefaultRootWindow(_ecore_x_disp); xtp.value = (unsigned char *)str; xtp.format = 8; xtp.encoding = ECORE_X_ATOM_UTF8_STRING; xtp.nitems = strlen(str); XSetTextProperty(_ecore_x_disp, win, &xtp, type); }
void xwindow_set_text_property(Window win, Atom a, const char **ptr, int n) { XTextProperty prop; bool ok; if(!ioncore_g.use_mb){ Status st=XStringListToTextProperty((char **)ptr, n, &prop); ok=(st!=0); }else{ int st=XmbTextListToTextProperty(ioncore_g.dpy, (char **)ptr, n, XTextStyle, &prop); ok=(st>=0); } if(!ok) return; XSetTextProperty(ioncore_g.dpy, win, &prop, a); XFree(prop.value); }
void #ifdef STANDALONE_SERVER main (int argc, char *argv[]) { unsigned window_size; string identity; /* This will be the contents of the identity_atom */ #else /* not STANDALONE_SERVER */ start_server (unsigned window_size, string identity) { #endif /* not STANDALONE_SERVER */ XTextProperty textP; Widget viewport_widget; int zero = 0; /* This routine will intercept messages we get. */ XtActionsRec actions[] = { { "MessageHandler", message_handler } }; /* Here we assume that all the characters will fit in an em square. (We make further assumptions below.) The TFM format guarantees that the design size is not negative. Values in the resource database override this. These initial values are only useful if we are not standalone, but we reassign just below if we are standalone. */ Arg geometry_args[] = { { XtNheight, window_size }, { XtNwidth, window_size }, }; #ifdef STANDALONE_SERVER if (argc == 3) { window_size = atou (argv[1]); geometry_args[0].value = geometry_args[1].value = window_size; identity = argv[2]; } else { fprintf (stderr, "Usage: %s window-size identity.\n", argv[0]); exit(0); } #endif /* STANDALONE_SERVER */ /* We have no fallback resources, and we've already parsed the args. */ top_level = XtInitialize (NULL, CLASS_NAME, NULL, 0, &zero, NULL); viewport_widget = XtCreateManagedWidget ("viewport", viewportWidgetClass, top_level, NULL, 0); canvas_widget = XtCreateManagedWidget ("canvas", labelWidgetClass, viewport_widget, geometry_args, XtNumber (geometry_args)); XtAddActions (actions, XtNumber (actions)); XtRealizeWidget (top_level); display = XtDisplay (top_level); foserver_exit_atom = XInternAtom (display, FOSERVER_EXIT_ATOM, False); foserver_update_pixmap_atom = XInternAtom (display, FOSERVER_UPDATE_PIXMAP_ATOM, False); /* Get the identity atom number. Create it if it doesn't exist. */ foserver_identity_atom = XInternAtom (display, FOSERVER_IDENTITY_ATOM, False); textP.value = (unsigned char *) identity; /* Set value. */ textP.encoding = XA_STRING; textP.format = 8; textP.nitems = strlen (identity); XSetTextProperty (display, XtWindow (canvas_widget), &textP, foserver_identity_atom); /* Process events forever. */ XtMainLoop (); }
bool hc_send_command(HCConnection* con, int argc, char* argv[], GString** ret_out, int* ret_status) { if (!hc_create_client_window(con)) { return false; } // check for running window manager instance // TODO // set arguments XTextProperty text_prop; Xutf8TextListToTextProperty(con->display, argv, argc, XUTF8StringStyle, &text_prop); XSetTextProperty(con->display, con->client_window, &text_prop, con->atom_args); XFree(text_prop.value); // get output int command_status = 0; XEvent event; GString* output = NULL; bool output_received = false, status_received = false; while (!output_received || !status_received) { XNextEvent(con->display, &event); if (event.type != PropertyNotify) { // got an event of wrong type continue; } XPropertyEvent* pe = &(event.xproperty); if (pe->window != con->client_window) { // got an event from wrong window continue; } if (!output_received && pe->atom == con->atom_output) { output = window_property_to_g_string(con->display, con->client_window, con->atom_output); if (!output) { fprintf(stderr, "could not get WindowProperty \"%s\"\n", HERBST_IPC_OUTPUT_ATOM); return false; } output_received = true; } else if (!status_received && pe->atom == con->atom_status) { int *value; Atom type; int format; unsigned long items, bytes; if (Success != XGetWindowProperty(con->display, con->client_window, XInternAtom(con->display, HERBST_IPC_STATUS_ATOM, False), 0, 1, False, XA_ATOM, &type, &format, &items, &bytes, (unsigned char**)&value)) { // if could not get window property fprintf(stderr, "could not get WindowProperty \"%s\"\n", HERBST_IPC_STATUS_ATOM); return false; } command_status = *value; XFree(value); status_received = true; } } *ret_status = command_status; *ret_out = output; return true; }
void XDesktopContainer::parseNonIconEvents() { switch (event.type) { case PropertyNotify: //char *name = XGetAtomName(display, event.xproperty.atom ); //cout << " Name " << name << endl ; static Atom atom_stop = None ; if( atom_stop == None ) atom_stop = XInternAtom(display, "_IDESK_STOP", True); if (event.xproperty.atom == atom_stop && !stop){ XTextProperty prop; int result = XGetTextProperty(display, rootWindow, &prop, atom_stop); if(result && prop.encoding != None && prop.value != NULL){ string current_display_name = DisplayString(display); string old_display_name = (char *)prop.value; string mesg = (char *)prop.value; if(current_display_name == old_display_name){ XDeleteProperty (display, rootWindow, atom_stop); cout << "Error ... Idesk is running in " << prop.value << endl; cout << "Exit." << endl; _exit(1); } } } static Atom atom_start = None ; if( atom_start == None ) atom_start = XInternAtom(display, "_IDESK_START", True); if (event.xproperty.atom == atom_start){ XTextProperty prop; int result = XGetTextProperty(display, rootWindow, &prop, atom_start); if(result && prop.encoding != None && prop.value != NULL){ string current_display_name = DisplayString(display); string old_display_name = (char *)prop.value; if(current_display_name == old_display_name){ XDeleteProperty (display, rootWindow, atom_start); stop = XInternAtom(display,"_IDESK_STOP", false); prop.value = (unsigned char *)current_display_name.c_str(); prop.encoding = XA_STRING; prop.format = 8; prop.nitems = strlen(current_display_name.c_str()); XSetTextProperty(display, rootWindow, &prop, stop); } } } static Atom atom_xroot = None ; if( atom_xroot == None ) atom_xroot = XInternAtom(display, "_XROOTPMAP_ID", True); if (event.xproperty.atom == atom_xroot) { Pixmap pmap = bg->GetRootPixmap(event.xproperty.atom); if(bg->pixmap == None){ bg->Refresh(pmap); bg->pixmap = (Pixmap)1; //For Fix }else{ bg->InitSpareRoot(event.xproperty.window); } updateIcons(); } break; } }