/** * @brief Set basic properties on a window. */ void wm_wid_set_info(session_t *ps, Window wid, const char *name, Atom window_type) { // Set window name { char *textcpy = mstrjoin("skippy-xd ", name); { XTextProperty text_prop = { }; if (Success == XmbTextListToTextProperty(ps->dpy, &textcpy, 1, XStdICCTextStyle, &text_prop)) XSetWMName(ps->dpy, wid, &text_prop); sxfree(text_prop.value); } wm_wid_set_prop_utf8(ps, wid, _NET_WM_NAME, textcpy); free(textcpy); } // Set window class { XClassHint *classh = allocchk(XAllocClassHint()); classh->res_name = "skippy-xd"; classh->res_class = "skippy-xd"; XSetClassHint(ps->dpy, wid, classh); XFree(classh); } // Set window type { if (!window_type) window_type = _NET_WM_WINDOW_TYPE_NORMAL; long val = window_type; XChangeProperty(ps->dpy, wid, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1); } }
int main() { char *str = "My program title"; dpy=XOpenDisplay(NULL); assert(dpy); scr=DefaultScreen(dpy); win=XCreateSimpleWindow(dpy, RootWindow(dpy,scr), 0, 0, /* coordinates */ SCREEN_WIDTH/2, SCREEN_HEIGHT/2, /* size */ 1, /* border width */ WhitePixel(dpy,scr), /* foreground */ BlackPixel(dpy,scr) /* background */ ); XMapWindow(dpy, win); XMoveWindow(dpy, win, 0, 0); XTextProperty title; XStringListToTextProperty(&str, 1, &title); XSetWMName(dpy, win, &title); XSetWMIconName(dpy, win, &title); XFlush(dpy); getchar(); return EXIT_SUCCESS; }
void set_window_name(Display *disp, Window win, char *name) { XTextProperty name_prop; XStringListToTextProperty(&name, 1, &name_prop); XSetWMName(disp, win, &name_prop); }
void wsys_set_title(const char *title) { XTextProperty tp_wname; XStringListToTextProperty((char**)&title, 1, &tp_wname); XSetWMName(dpy, win, &tp_wname); XFree(tp_wname.value); }
// Set up a window. int initWindow( long width, long height ) { int defScreen; XSetWindowAttributes wAttr; XGCValues gcValues; char buffer[64] = "Graphics"; XTextProperty xtp = {(unsigned char *)buffer, 125, 8, strlen(buffer)}; /* * connect to the X server. uses the server specified in the * DISPLAY environment variable */ curDisplay = XOpenDisplay((char *) NULL); if ((Display *) NULL == curDisplay) { fprintf(stderr, "Fish School Stats Display: could not open display.\n"); exit(-1); } /* * begin to create a window */ defdepth = DefaultDepth(curDisplay,0); bytesPerPixel = defdepth/8; bytesPerPixel = bytesPerPixel == 3 ? 4 : bytesPerPixel; defScreen = DefaultScreen(curDisplay); curWindow = XCreateWindow(curDisplay, DefaultRootWindow(curDisplay), 10, 10, width, height, 0, defdepth, InputOutput, DefaultVisual(curDisplay, defScreen), 0, &wAttr); /* * request mouse button and keypress events */ wAttr.event_mask = ButtonPressMask | KeyPressMask | ExposureMask; XChangeWindowAttributes(curDisplay, curWindow, CWEventMask, &wAttr); /* * force it to appear on the screen */ XSetWMName(curDisplay, curWindow, &xtp); XMapWindow(curDisplay, curWindow); /* * create a graphics context. this stores a drawing state; stuff like * current color and line width. this gc is for drawing into our * window. */ curGC = XCreateGC(curDisplay, curWindow, 0, &gcValues); defaultFont = XQueryFont(curDisplay, XGContextFromGC(curGC)); XSetWindowColormap( curDisplay, curWindow, DefaultColormapOfScreen(DefaultScreenOfDisplay(curDisplay))); return(bytesPerPixel); }
static void sendhints(Window w,struct hints *h) { if(h->flg&1) XSetWMName(dsp,w,&h->window_name); if(h->flg&2) XSetWMIconName(dsp,w,&h->icon_name); if(h->flg&4) XSetCommand(dsp,w,h->argv,h->argc); if(h->flg&8) XSetClassHint(dsp,w,&h->class_hints); if(h->normal_hints.flags) XSetWMNormalHints(dsp,w,&h->normal_hints); if(h->wm_hints.flags) XSetWMHints(dsp,w,&h->wm_hints); }
void CStdWindow::SetTitle(const char *Title) { #ifdef USE_X11 XTextProperty title_property; StdStrBuf tbuf(Title, true); char *tbufstr = tbuf.getMData(); XStringListToTextProperty(&tbufstr, 1, &title_property); XSetWMName(dpy, wnd, &title_property); #endif }
bool XPlatformWindow::set_name(const char* window_name) { XTextProperty windowName; if (XStringListToTextProperty((char**)&window_name, 1, &windowName) == 0) { warning("X structure allocation for window name failed--window won't work."); return false; } XSetWMName(_display, _xwindow, &windowName); return true; }
void SkOSWindow::onSetTitle(const char title[]) { if (!fUnixWindow.fDisplay) return; XTextProperty textProp; textProp.value = (unsigned char*)title; textProp.format = 8; textProp.nitems = strlen((char*)textProp.value); textProp.encoding = XA_STRING; XSetWMName(fUnixWindow.fDisplay, fUnixWindow.fWin, &textProp); }
EAPI void ecore_x_icccm_title_set(Ecore_X_Window win, const char *t) { char *list[1]; XTextProperty xprop; int ret; if (!t) return; LOGFN(__FILE__, __LINE__, __FUNCTION__); xprop.value = NULL; #ifdef X_HAVE_UTF8_STRING list[0] = strdup(t); ret = Xutf8TextListToTextProperty(_ecore_x_disp, list, 1, XUTF8StringStyle, &xprop); #else /* ifdef X_HAVE_UTF8_STRING */ list[0] = strdup(t); ret = XmbTextListToTextProperty(_ecore_x_disp, list, 1, XStdICCTextStyle, &xprop); #endif /* ifdef X_HAVE_UTF8_STRING */ if (_ecore_xlib_sync) ecore_x_sync(); if (ret >= Success) { XSetWMName(_ecore_x_disp, win, &xprop); if (_ecore_xlib_sync) ecore_x_sync(); if (xprop.value) XFree(xprop.value); } else if (XStringListToTextProperty(list, 1, &xprop) >= Success) { XSetWMName(_ecore_x_disp, win, &xprop); if (_ecore_xlib_sync) ecore_x_sync(); if (xprop.value) XFree(xprop.value); } free(list[0]); }
void QXlibWindow::setWindowTitle(const QString &title) { QByteArray ba = title.toLatin1(); //We're not making a general solution here... XTextProperty windowName; windowName.value = (unsigned char *)ba.constData(); windowName.encoding = XA_STRING; windowName.format = 8; windowName.nitems = ba.length(); XSetWMName(mScreen->display()->nativeDisplay(), x_window, &windowName); }
/* * Set the name (in the title bar) of Infowin */ static errr Infowin_set_name(cptr name) { Status st; XTextProperty tp; char buf[128]; char *bp = buf; my_strcpy(buf, name, sizeof(buf)); st = XStringListToTextProperty(&bp, 1, &tp); if (st) XSetWMName(Metadpy->dpy, Infowin->win, &tp); return (0); }
/****************************************************************************** ChangeWindowName - Self explanitory Original work from FvwmIdent: Copyright 1994, Robert Nation and Nobutaka Suzuki. ******************************************************************************/ void ChangeWindowName(char *str) { XTextProperty name; if (XStringListToTextProperty(&str,1,&name) == 0) { fprintf(stderr,"%s: cannot allocate window name.\n",Module); return; } XSetWMName(dpy,win,&name); XSetWMIconName(dpy,win,&name); XFree(name.value); }
bool CWindowUnix::SetText(const wchar_t *unicodetext) { XTextProperty title; const char *buff = axelynx::utils::WideCharToMultiByte(unicodetext); XStringListToTextProperty((char**)&buff, sizeof(char), &title ); XSetWMName(dpy_,win_,&title); delete[] buff; return 0; }
void AppX11::setWmName(QWidget *widget, const QString &name) { d->wmName = name.toUtf8(); char *utf8 = d->wmName.data(); auto wid = widget->effectiveWinId(); if (d->connection && d->display) { XTextProperty text; Xutf8TextListToTextProperty(d->display, &utf8, 1, XCompoundTextStyle, &text); XSetWMName(d->display, wid, &text); // xcb_icccm_set_wm_name(d->x.connection, d->x.window, XCB_ATOM_STRING, 8, d->wmName.size(), d->wmName.constData()); const char className[] = "cmplayer\0CMPlayer"; xcb_icccm_set_wm_class(d->connection, wid, sizeof(className), className); } }
/************************************************************************** * Change the window name displayed in the title bar. **************************************************************************/ void change_window_name(char *str) { XTextProperty name; if (XStringListToTextProperty(&str,1,&name) == 0) { fprintf(stderr,"FvwmBanner: cannot allocate window name"); return; } XSetWMName(dpy,win,&name); XSetWMIconName(dpy,win,&name); XFree(name.value); }
XWindow::XWindow(const string & title, const Rectangle & bounds) : Component(title) { this->display = XApplication::GetInstance()->GetXDisplay(); // Create the window this->window = XCreateSimpleWindow( this->display, DefaultRootWindow(this->display), bounds.x, bounds.y, bounds.width, bounds.height, 0, // Window border width. Doesn't include width by window manager XApplication::GetInstance()->GetWhiteColor(), XApplication::GetInstance()->GetBlackColor()); // Add ourselves to the mappings windowMappings[this->window] = this; windowNum = this->GetComponentNum(); intWindowMap[windowNum] = this; XTextProperty xtext; xtext.value = (unsigned char*)title.c_str(); xtext.encoding = XA_STRING; xtext.format = 8; // bits per character xtext.nitems = strlen(title.c_str()); // string length XSetWMName(this->display, this->window, &xtext); // Select input events XSelectInput( this->display, this->window, ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | ExposureMask | PointerMotionMask | ButtonMotionMask | StructureNotifyMask); GC gc = XCreateGC( display, window, 0, 0); this->graphics = new Graphics(this->display, this->window, gc); // Now set our bounds to that which we were set XWindowAttributes attr; XGetWindowAttributes(this->display, this->window, &attr); Component::SetBounds(Rectangle(attr.x, attr.y, attr.width, attr.height)); }
// set window name using text properties void SetWindowNameWithTextProps(Display *display, Window window, char *name) { XTextProperty text_property; // convert character string to text property (void) XStringListToTextProperty(&name, 1, &text_property); // set window name (void) XSetWMName(display, window, &text_property); // all done return; }
void pxWindow::setTitle(char* title) { Display* d = mDisplayRef.getDisplay(); XTextProperty tp; tp.value = (unsigned char *)title; tp.encoding = XA_WM_NAME; tp.format = 8; // 8 bit chars tp.nitems = strlen(title); XSetWMName(d, win, &tp); XStoreName(d, win, title); XSetWMIconName(d, win, &tp); XSetIconName(d, win, title); }
/* CENTRY */ void APIENTRY glutSetWindowTitle(const char *title) { XTextProperty textprop; assert(!__glutCurrentWindow->parent); textprop.value = (unsigned char *) title; textprop.encoding = XA_STRING; textprop.format = 8; textprop.nitems = strlen(title); XSetWMName(__glutDisplay, __glutCurrentWindow->win, &textprop); XFlush(__glutDisplay); }
/************************************************************************** * Change the window name displayed in the title bar. **************************************************************************/ void change_window_name(char *str) { XTextProperty name; if(str == NULL) return; if (XStringListToTextProperty(&str,1,&name) == 0) { fprintf(stderr,"%s: cannot allocate window name",MyName); return; } XSetWMName(dpy,main_win,&name); XFree(name.value); }
void XSetWMProperties(Display * display, Window w, XTextProperty * window_name, XTextProperty * icon_name, char **argv, int argc, XSizeHints * normal_hints, XWMHints * wm_hints, XClassHint *class_hints) { if (window_name) XSetWMName(display, w, window_name); if (icon_name) XSetWMIconName(display, w, icon_name); if (normal_hints) XSetWMNormalHints(display, w, normal_hints); if (wm_hints) XSetWMHints(display, w, wm_hints); if (class_hints) XSetWMClassHints(display, w, class_hints); }
/* * Set the current window's title */ void fgPlatformGlutSetWindowTitle( const char* title ) { XTextProperty text; text.value = (unsigned char *) title; text.encoding = XA_STRING; text.format = 8; text.nitems = strlen( title ); XSetWMName( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, &text ); XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */ }
void set_dialog_properties (Display *d, Window w, char *name, int width, int height) { XTextProperty nameprop; if (!XStringListToTextProperty (&name, 1, &nameprop)) { warn ("XStringListToTextProperty failed\n"); return; } XSetWMName (d, w, &nameprop); XSizeHints *sh = XAllocSizeHints (); sh->base_width = sh->min_width = sh->max_width = width; sh->base_height = sh->min_height = sh->max_height = height; sh->flags = PBaseSize | PMinSize | PMaxSize; XSetWMNormalHints (d, w, sh); XFree (sh); }
/* CENTRY */ void GLUTAPIENTRY glutSetWindowTitle(const char *title) { XTextProperty textprop; const char **pvalue = (const char**) &textprop.value; // See below for why... assert(!__glutCurrentWindow->parent); IGNORE_IN_GAME_MODE(); *pvalue = title; /* We want to write "textprop.value = (unsigned char *) title;" but gcc complains about discarding const-ness of pointer */ assert(!strcmp((const char*)textprop.value, title)); textprop.encoding = XA_STRING; textprop.format = 8; textprop.nitems = (unsigned long)strlen(title); XSetWMName(__glutDisplay, __glutCurrentWindow->win, &textprop); XFlush(__glutDisplay); }
bool GSWndOGL::SetWindowText(const char* title) { if (!m_managed) return true; XTextProperty prop; memset(&prop, 0, sizeof(prop)); char* ptitle = (char*)title; if (XStringListToTextProperty(&ptitle, 1, &prop)) { XSetWMName(m_NativeDisplay, m_NativeWindow, &prop); } XFree(prop.value); XFlush(m_NativeDisplay); return true; }
static PetscErrorCode PetscDrawSetTitle_X(PetscDraw draw,const char title[]) { PetscDraw_X *win = (PetscDraw_X*)draw->data; XTextProperty prop; PetscErrorCode ierr; size_t len; PetscFunctionBegin; if (win->win) { XGetWMName(win->disp,win->win,&prop); XFree((void*)prop.value); prop.value = (unsigned char *)title; ierr = PetscStrlen(title,&len);CHKERRQ(ierr); prop.nitems = (long) len; XSetWMName(win->disp,win->win,&prop); } PetscFunctionReturn(0); }
void BaseManager::setWindowCaption(const std::wstring& _text) { #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 ::SetWindowTextW((HWND)getWindowHandle(), _text.c_str()); #elif MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX Display* xDisplay = nullptr; unsigned long windowHandle = 0; mWindow->getCustomAttribute("XDISPLAY", &xDisplay); mWindow->getCustomAttribute("WINDOW", &windowHandle); Window win = (Window)windowHandle; XTextProperty windowName; windowName.value = (unsigned char *)(MyGUI::UString(_text).asUTF8_c_str()); windowName.encoding = XA_STRING; windowName.format = 8; windowName.nitems = strlen((char *)(windowName.value)); XSetWMName(xDisplay, win, &windowName); #endif }
static void set_window_title(ModeInfo * mi) { XTextProperty prop; char *buf; unsigned int status; buf = (char *) malloc(strlen(MI_NAME(mi)) + strlen(MI_DESC(mi)) + 3); (void) sprintf(buf, "%s: %s", MI_NAME(mi), MI_DESC(mi)); status = XStringListToTextProperty(&buf, 1, &prop); if (status != 0) { XSetWMName(MI_DISPLAY(mi), MI_WINDOW(mi), &prop); XFree((caddr_t) prop.value); } free(buf); if (MI_IS_ICONIC(mi) && description) { modeDescription(mi); } }
void GLWindow::SetTitle(char *strtitle) { #ifndef USE_GSOPEN2 if (!glDisplay or !glWindow) return; if (fullScreen) return; XTextProperty prop; memset(&prop, 0, sizeof(prop)); char* ptitle = strtitle; if (XStringListToTextProperty(&ptitle, 1, &prop)) { XLockDisplay(glDisplay); XSetWMName(glDisplay, glWindow, &prop); XUnlockDisplay(glDisplay); } XFree(prop.value); #endif }