void startGraphicsXYZ() { dpy = XOpenDisplay(display); if (dpy == NULL) printf("Can't open the display.\n"); //assert(dpy); window = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, wsize_x, wsize_y, 0,0,0); XSelectInput(dpy, window, (StructureNotifyMask|ExposureMask|ButtonPressMask|ButtonReleaseMask)); XMapWindow(dpy, window); context = XCreateGC(dpy, window, GCForeground | GCBackground, &gcvalues); XStoreName(dpy, window, display_name_1); XSetIconName(dpy, window, display_name_2); if (side_view) { window2 = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), wsize_x, 0, wsize_z, wsize_y, 0,0,0); XSelectInput(dpy, window2, (StructureNotifyMask|ExposureMask|ButtonPressMask|ButtonReleaseMask)); XMapWindow(dpy, window2); context2 = XCreateGC(dpy, window2, GCForeground | GCBackground, &gcvalues); XStoreName(dpy, window2, display_name_2); XSetIconName(dpy, window2, display_name_2); } check4event(); gcvalues.background = 0; }
static void set_name_and_icon(void) { char *icon_name = "HyperDoc"; char *s; Pixmap icon_pixmap; XWMHints wmhints; XClassHint ch; ch.res_name = "HyperDoc"; ch.res_class = gArgv[0]; for (s = gArgv[0] + strlen(gArgv[0]) - 1; s != gArgv[0]; s--) { if (*s == '/') { ch.res_class = s + 1; break; } } XSetClassHint(gXDisplay, gWindow->fMainWindow, &ch); XStoreName(gXDisplay, gWindow->fMainWindow, "HyperDoc"); /* define and assign the pixmap for the icon */ icon_pixmap = XCreateBitmapFromData(gXDisplay, gWindow->fMainWindow, ucharp_to_charp(ht_icon_bits), ht_icon_width, ht_icon_height); wmhints.icon_pixmap = icon_pixmap; wmhints.flags = IconPixmapHint; XSetWMHints(gXDisplay, gWindow->fMainWindow, &wmhints); /* name the icon */ XSetIconName(gXDisplay, gWindow->fMainWindow, icon_name); }
void initscreen(void) { d1=XOpenDisplay(0); if (d1==NULL) { printf("Can't open display.\n"); exit(0); } /*Aufbau der XWindowsAttribStr*/ w0 = DefaultRootWindow(d1); winatt1.background_pixel = BlackPixel(d1,0); winatt1.backing_store = WhenMapped; winatt1.event_mask = KeyPressMask|StructureNotifyMask; w1 = XCreateWindow(d1,w0,w1_x,w1_y,w1_w,w1_h,w1_border,CopyFromParent,InputOutput, CopyFromParent,CWBackPixel|CWBackingStore|CWEventMask,&winatt1); XStoreName(d1,w1,w1_wname); XSetIconName(d1,w1,w1_iname); XMapWindow(d1,w1); cm1=DefaultColormap(d1,0); if (!XAllocNamedColor(d1,cm1,"blue",&xc1,&xc2)) printf("coudn't allocate blue color\n"); f1_str=XLoadQueryFont(d1,font1_name); if (f1_str==NULL) printf("could't load font\n"); gcval1.foreground = xc1.pixel; gcval1.font = f1_str -> fid; gcval1.line_style = LineSolid; gc1 = XCreateGC(d1,w1, GCForeground|GCLineStyle, &gcval1); gcval1.foreground = WhitePixel(d1,0); gc2 = XCreateGC(d1,w1, GCForeground|GCLineStyle|GCFont, &gcval1); }
void ui_create_window(int x, int y, int w, int h) { ui->w[ui->cur].swa.override_redirect = True; ui->w[ui->cur].swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ButtonPressMask; ui->w[ui->cur].swa.colormap = XCreateColormap(ui->dpy, DefaultRootWindow(ui->dpy), ui->vinfo.visual, AllocNone); ui->w[ui->cur].swa.background_pixel = 0; ui->w[ui->cur].swa.border_pixel = 0; ui->w[ui->cur].win = XCreateWindow(ui->dpy, ui->root, x, y, w, h, 0, ui->vinfo.depth, CopyFromParent, ui->vinfo.visual, CWOverrideRedirect | CWColormap | CWBackPixel | CWEventMask | CWBorderPixel, &ui->w[ui->cur].swa); ui->w[ui->cur].xic = XCreateIC(ui->xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, ui->w[ui->cur].win, XNFocusWindow, ui->w[ui->cur].win, NULL); ui->w[ui->cur].gc = XCreateGC(ui->dpy, ui->w[ui->cur].win, 0, NULL); XStoreName(ui->dpy, ui->w[ui->cur].win, "jgmenu"); XSetIconName(ui->dpy, ui->w[ui->cur].win, "jgmenu"); set_wm_class(); /* * XDefineCursor required to prevent blindly inheriting cursor from parent * (e.g. hour-glass pointer set by tint2) * Check this URL for cursor styles: * http://tronche.com/gui/x/xlib/appendix/b/ */ XDefineCursor(ui->dpy, ui->w[ui->cur].win, XCreateFontCursor(ui->dpy, 68)); }
void initXWin(int argc, char **argv) { int pos; XWMHints wmhints; XSizeHints shints; winsize=astep ? ASTEPSIZE : NORMSIZE; if((d_display=XOpenDisplay(display))==NULL) { fprintf(stderr,"%s : Unable to open X display '%s'.\n", NAME, XDisplayName(display)); exit(1); } _XA_GNUSTEP_WM_FUNC=XInternAtom(d_display, "_GNUSTEP_WM_FUNCTION", 0); deleteWin=XInternAtom(d_display, "WM_DELETE_WINDOW", 0); w_root=DefaultRootWindow(d_display); shints.x=0; shints.y=0; shints.flags=0; pos=(XWMGeometry(d_display, DefaultScreen(d_display), position, NULL, 0, &shints, &shints.x, &shints.y, &shints.width, &shints.height, &shints.win_gravity) & (XValue | YValue)); shints.min_width=winsize; shints.min_height=winsize; shints.max_width=winsize; shints.max_height=winsize; shints.base_width=winsize; shints.base_height=winsize; shints.flags=PMinSize | PMaxSize | PBaseSize; createWin(&w_main, shints.x, shints.y); if(wmaker || astep || pos) shints.flags |= USPosition; if(wmaker) { wmhints.initial_state=WithdrawnState; wmhints.flags=WindowGroupHint | StateHint | IconWindowHint; createWin(&w_icon, shints.x, shints.y); w_activewin=w_icon; wmhints.icon_window=w_icon; } else { wmhints.initial_state=NormalState; wmhints.flags=WindowGroupHint | StateHint; w_activewin=w_main; } wmhints.window_group=w_main; XSetWMHints(d_display, w_main, &wmhints); XSetWMNormalHints(d_display, w_main, &shints); XSetCommand(d_display, w_main, argv, argc); XStoreName(d_display, w_main, NAME); XSetIconName(d_display, w_main, NAME); XSetWMProtocols(d_display, w_activewin, &deleteWin, 1); }
static void Init_disp_prop(Display *d, Window win, unsigned w, unsigned h, int x, int y, int flags) { XClassHint xclh; XWMHints xwmh; XSizeHints xsh; xwmh.flags = InputHint|StateHint|IconPixmapHint; xwmh.input = True; xwmh.initial_state = NormalState; xwmh.icon_pixmap = XCreateBitmapFromData(d, win, (char *)icon_bits, icon_width, icon_height); xsh.flags = (flags|PMinSize|PMaxSize|PBaseSize|PResizeInc); xsh.width = w; xsh.base_width = xsh.min_width = MIN_TOP_WIDTH; xsh.max_width = MAX_TOP_WIDTH; xsh.width_inc = 1; xsh.height = h; xsh.base_height = xsh.min_height = MIN_TOP_HEIGHT; xsh.max_height = MAX_TOP_HEIGHT; xsh.height_inc = 1; xsh.x = x; xsh.y = y; xclh.res_name = NULL; /* NULL: Automatically uses Argv[0], */ xclh.res_class = myClass; /* stripped of directory prefixes. */ /* * Set the above properties. */ XSetWMProperties(d, win, NULL, NULL, Argv, Argc, &xsh, &xwmh, &xclh); /* * Now initialize icon and window title name. */ XStoreName(d, win, TITLE); XSetIconName(d, win, TITLE); if (d != dpy) return; /* * Specify IO error handler and the WM_DELETE_WINDOW atom in * an attempt to catch 'nasty' quits. */ ProtocolAtom = XInternAtom(d, "WM_PROTOCOLS", False); KillAtom = XInternAtom(d, "WM_DELETE_WINDOW", False); XSetWMProtocols(d, win, &KillAtom, 1); XSetIOErrorHandler(FatalError); }
void x_window_rep::set_name (string name) { if (the_name != name) { c_string s (name); XStoreName (dpy, win, s); XSetIconName (dpy, win, s); the_name= name; mod_name= name; } }
void x_window_rep::set_modified (bool flag) { string name= (flag? (the_name * " *"): the_name); if (mod_name != name) { c_string s (name); XStoreName (dpy, win, s); XSetIconName (dpy, win, s); mod_name= name; } }
void wm_set_name(Display *display, Window shell_window, string title, string icon) { strip_space(title); strip_space(icon); if (!title.empty()) XStoreName(display, shell_window, title.chars()); if (!icon.empty()) XSetIconName(display, shell_window, icon.chars()); }
void wxTopLevelWindowX11::SetTitle(const wxString& title) { m_title = title; if (X11GetMainWindow()) { #if wxUSE_UNICODE // I wonder of e.g. Metacity takes UTF-8 here XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title.ToAscii() ); #else XStoreName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title); XSetIconName(wxGlobalDisplay(), (Window) X11GetMainWindow(), (const char*) title); #endif } }
static void set_iconName (const char *str) { char *name; if (XGetIconName (Xdisplay, TermWin.parent, &name)) name = NULL; if (name == NULL || strcmp (name, str)) XSetIconName (Xdisplay, TermWin.parent, str); if (name) XFree (name); }
value caml_gr_set_window_title(value n) { if (window_name != NULL) stat_free(window_name); window_name = stat_alloc(strlen(String_val(n))+1); strcpy(window_name, String_val(n)); if (caml_gr_initialized) { XStoreName(caml_gr_display, caml_gr_window.win, window_name); XSetIconName(caml_gr_display, caml_gr_window.win, window_name); XFlush(caml_gr_display); } return Val_unit; }
void win_set_title(win_t *win, const char *title) { XStoreName(win->env.dpy, win->xwin, title); XSetIconName(win->env.dpy, win->xwin, title); XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_NAME], XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *) title, strlen(title)); XChangeProperty(win->env.dpy, win->xwin, atoms[ATOM__NET_WM_ICON_NAME], XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *) title, strlen(title)); }
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); }
/*******************************************************************************\ |* SetWindowName *| \*******************************************************************************/ void SetWindowName(char *name) { char *fullname = NULL; if (strcmp(name, wname)) { fullname = (char *)malloc(strlen(name) + strlen(wname) + 3); if (fullname != NULL) { sprintf(fullname, "%s:%s", wname, name); XStoreName(display, win, fullname); XSetIconName(display, win, fullname); free(fullname); } else { XStoreName(display, win, wname); XSetIconName(display, win, wname); } } XMapWindow(display, win); /* XStoreName(display, win, wname); XSetIconName(display, win, wname);*/ }
void open_soundspec(void) { int scr; XGCValues gcv; if(disp != NULL) { XMapWindow(disp, win); XSync(disp, False); view_soundspec_flag = 1; return; } if((disp = XOpenDisplay(NULL)) == NULL) { ctl->cmsg(CMSG_FATAL, VERB_NORMAL, "Can't open display"); ctl->close(); exit(1); } set_color_ring(); scr = DefaultScreen(disp); depth = DefaultDepth(disp, scr); win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT, 0, 0, BlackPixel(disp, scr)); wm_delete_window = XInternAtom(disp, "WM_DELETE_WINDOW", False); XSetWMProtocols(disp, win, &wm_delete_window, 1); XSelectInput(disp, win, ExposureMask | KeyPressMask); XStoreName(disp, win, "Sound Spectrogram"); XSetIconName(disp, win, "Sound Spectrogram"); gcv.graphics_exposures = False; gc = XCreateGC(disp, win, GCGraphicsExposures, &gcv); offscr = XCreatePixmap(disp, win, SCOPE_WIDTH, SCOPE_HEIGHT, depth); XSetForeground(disp, gc, BlackPixel(disp, scr)); XFillRectangle(disp, offscr, gc, 0, 0, SCOPE_WIDTH, SCOPE_HEIGHT); img = XCreateImage(disp, DefaultVisual(disp, scr), depth, ZPixmap, 0, 0, 1, SCOPE_HEIGHT, 8, 0); XMapWindow(disp, win); XSync(disp, False); view_soundspec_flag = 1; }
void startgraphics(int wsize) { dpy = XOpenDisplay(display); if (dpy == NULL) printf("Can't open the display.\n"); //assert(dpy); window = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, wsize, wsize, 0,0,0); XSelectInput(dpy, window, (StructureNotifyMask|ExposureMask|ButtonPressMask|ButtonReleaseMask)); XMapWindow(dpy, window); context = XCreateGC(dpy, window, GCForeground | GCBackground, &gcvalues); XStoreName(dpy, window, displayname); XSetIconName(dpy, window, displayname); check4event(); gcvalues.background = 0; }
bool GLWindow::DisplayWindow(int _width, int _height) { backbuffer.w = _width; backbuffer.h = _height; if (!CreateVisual()) return false; /* create a color map */ attr.colormap = XCreateColormap(glDisplay, RootWindow(glDisplay, vi->screen), vi->visual, AllocNone); attr.border_pixel = 0; attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask ; // Create a window at the last position/size glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen), conf.x , conf.y , _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attr); /* Allow to kill properly the window */ Atom wmDelete = XInternAtom(glDisplay, "WM_DELETE_WINDOW", True); XSetWMProtocols(glDisplay, glWindow, &wmDelete, 1); // Set icon name XSetIconName(glDisplay, glWindow, "ZZogl-pg"); // Draw the window XMapRaised(glDisplay, glWindow); XSync(glDisplay, false); // connect the glx-context to the window CreateContextGL(); glXMakeCurrent(glDisplay, glWindow, context); GetGLXVersion(); // Always start in window mode fullScreen = 0; GetWindowSize(); return true; }
void TopWindow::DefSyncTitle() { GuiLock __; if(title2 == title) return; title2 = title; if(IsOpen() && GetWindow()) { Window w = GetWindow(); XStoreName(Xdisplay, w, title.ToString()); XSetIconName(Xdisplay, w, title.ToString()); String utf8title = FromUnicode(title, CHARSET_UTF8); XChangeProperty(Xdisplay, w, XAtom("_NET_WM_NAME"), XAtom("UTF8_STRING"), 8, PropModeReplace, (const unsigned char *)~utf8title, utf8title.GetLength()); XChangeProperty(Xdisplay, w, XAtom("_NET_WM_ICON_NAME"), XAtom("UTF8_STRING"), 8, PropModeReplace, (const unsigned char *)~utf8title, utf8title.GetLength()); } }
void win_set_title(win_t *win, const char *title) { if (!win || !win->xwin) return; if (!title) title = "sxiv"; XStoreName(win->env.dpy, win->xwin, title); XSetIconName(win->env.dpy, win->xwin, title); XChangeProperty(win->env.dpy, win->xwin, XInternAtom(win->env.dpy, "_NET_WM_NAME", False), XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *) title, strlen(title)); XChangeProperty(win->env.dpy, win->xwin, XInternAtom(win->env.dpy, "_NET_WM_ICON_NAME", False), XInternAtom(win->env.dpy, "UTF8_STRING", False), 8, PropModeReplace, (unsigned char *) title, strlen(title)); }
void winwidget_update_title(winwidget ret) { char *name; Atom prop_name = XInternAtom(disp, "_NET_WM_NAME", False); Atom prop_icon = XInternAtom(disp, "_NET_WM_ICON_NAME", False); Atom prop_utf8 = XInternAtom(disp, "UTF8_STRING", False); D(("winwid->name = %s\n", ret->name)); name = ret->name ? ret->name : "feh"; XStoreName(disp, ret->win, name); XSetIconName(disp, ret->win, name); XChangeProperty(disp, ret->win, prop_name, prop_utf8, 8, PropModeReplace, (const unsigned char *)name, strlen(name)); XChangeProperty(disp, ret->win, prop_icon, prop_utf8, 8, PropModeReplace, (const unsigned char *)name, strlen(name)); return; }
/*ARGSUSED*/ static void x_set_icccm_hints(Display *dpy, Window w, char *name, char *wm_icon_name, XSizeHints *psizehints, XWMHints *pwmhints, Window main_window) { XStoreName(dpy,w,name); XSetIconName(dpy,w,wm_icon_name); XSetWMNormalHints(dpy,w,psizehints); XSetWMHints(dpy,w,pwmhints); XSetClassHint(dpy,w,&classhint); /* in order for some wm's to iconify, the window shouldn't be transient. e.g. Motif wm */ if (main_window != None) { if (set_transient) XSetTransientForHint(dpy,w,main_window); } if (enable_delete) XSetWMProtocols(dpy,w,&XA_WM_DELETE_WINDOW,1); }
DockWnd::DockWnd(QWidget *main) : QWidget(NULL, "dock", WType_TopLevel | WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop) { setMouseTracking(true); connect(this, SIGNAL(toggleWin()), main, SLOT(toggleShow())); connect(this, SIGNAL(showPopup(QPoint)), main, SLOT(showDockPopup(QPoint))); connect(this, SIGNAL(doubleClicked()), main, SLOT(dockDblClicked())); connect(pClient, SIGNAL(event(ICQEvent*)), this, SLOT(processEvent(ICQEvent*))); connect(pMain, SIGNAL(iconChanged()), this, SLOT(reset())); connect(pMain, SIGNAL(msgChanged()), this, SLOT(reset())); m_state = 0; showIcon = State; QTimer *t = new QTimer(this); connect(t, SIGNAL(timeout()), this, SLOT(timer())); t->start(800); bNoToggle = false; #ifdef WIN32 QWidget::hide(); QWidget::setIcon(Pict(pClient->getStatusIcon())); gDock = this; oldDockProc = (WNDPROC)SetWindowLongW(winId(), GWL_WNDPROC, (LONG)DockWindowProc); if (oldDockProc == 0) oldDockProc = (WNDPROC)SetWindowLongA(winId(), GWL_WNDPROC, (LONG)DockWindowProc); NOTIFYICONDATAA notifyIconData; notifyIconData.cbSize = sizeof(notifyIconData); notifyIconData.hIcon = topData()->winIcon; notifyIconData.hWnd = winId(); notifyIconData.szTip[0] = 0; notifyIconData.uCallbackMessage = WM_DOCK; notifyIconData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; notifyIconData.uID = 0; Shell_NotifyIconA(NIM_ADD, ¬ifyIconData); #else setMinimumSize(22, 22); resize(22, 22); bInit = false; inTray = false; inNetTray = false; Display *dsp = x11Display(); WId win = winId(); if (bEnlightenment){ wharfIcon = NULL; bInit = true; resize(48, 48); setFocusPolicy(NoFocus); move(pMain->getDockX(), pMain->getDockY()); reset(); MWMHints mwm; mwm.flags = MWM_HINTS_DECORATIONS; mwm.functions = 0; mwm.decorations = 0; mwm.inputMode = 0; mwm.status = 0; Atom a = XInternAtom(dsp, "_MOTIF_WM_HINTS", False); XChangeProperty(dsp, win, a, a, 32, PropModeReplace, (unsigned char *)&mwm, sizeof(MWMHints) / 4); XStoreName(dsp, win, "SIM"); XClassHint *xch = XAllocClassHint(); xch->res_name = (char*)"SIM"; xch->res_class = (char*)"Epplet"; XSetClassHint(dsp, win, xch); XFree(xch); XSetIconName(dsp, win, "SIM"); unsigned long val = (1 << 0) /* | (1 << 9) */ ; a = XInternAtom(dsp, "_WIN_STATE", False); XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); val = 2; a = XInternAtom(dsp, "_WIN_LAYER", False); XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); val = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 5); a = XInternAtom(dsp, "_WIN_HINTS", False); XChangeProperty(dsp, win, a, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); win_name = "SIM"; win_version = VERSION; win_info = ""; while (!comms_win) { ECommsSetup(dsp); sleep(1); } char s[256]; snprintf(s, sizeof(s), "set clientname %s", win_name); ECommsSend(s); snprintf(s, sizeof(s), "set version %s", win_version); ECommsSend(s); snprintf(s, sizeof(s), "set info %s", win_info); ECommsSend(s); ESYNC; set_background_properties(this); show(); return; } wharfIcon = new WharfIcon(this); setBackgroundMode(X11ParentRelative); const QPixmap &pict = Pict(pClient->getStatusIcon()); setIcon(pict); XClassHint classhint; classhint.res_name = (char*)"sim"; classhint.res_class = (char*)"Wharf"; XSetClassHint(dsp, win, &classhint); Screen *screen = XDefaultScreenOfDisplay(dsp); int screen_id = XScreenNumberOfScreen(screen); char buf[32]; snprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", screen_id); Atom selection_atom = XInternAtom(dsp, buf, false); XGrabServer(dsp); Window manager_window = XGetSelectionOwner(dsp, selection_atom); if (manager_window != None) XSelectInput(dsp, manager_window, StructureNotifyMask); XUngrabServer(dsp); XFlush(dsp); if (manager_window != None){ inNetTray = true; if (!send_message(dsp, manager_window, SYSTEM_TRAY_REQUEST_DOCK, win, 0, 0)){ inNetTray = false; } } Atom kde_net_system_tray_window_for_atom = XInternAtom(dsp, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", false); long data[1]; data[0] = 0; XChangeProperty(dsp, win, kde_net_system_tray_window_for_atom, XA_WINDOW, 32, PropModeReplace, (unsigned char*)data, 1); XWMHints *hints; hints = XGetWMHints(dsp, win); hints->initial_state = WithdrawnState; hints->icon_x = 0; hints->icon_y = 0; hints->icon_window = wharfIcon->winId(); hints->window_group = win; hints->flags = WindowGroupHint | IconWindowHint | IconPositionHint | StateHint; XSetWMHints(dsp, win, hints); XFree( hints ); XSetCommand(dsp, win, _argv, _argc); if (!inNetTray){ move(-21, -21); resize(22, 22); } show(); #endif reset(); }
void setWindowTitle() { XStoreName(Xdpy, Xwin, getWindowTitle()); XSetIconName(Xdpy, Xwin, getWindowTitle()); }
int main (int argc, char* argv[]) { int yuv_width = 1024; int yuv_height = 768; int xv_port = -1; int adaptor, encodings, attributes, formats; int i, j, ret, p, _d, _w, _h; long secsb, secsa, frames; XvAdaptorInfo *ai; XvEncodingInfo *ei; XvAttribute *at; XvImageFormatValues *fo; XvImage *yuv_image; #define GUID_YUV12_PLANAR 0x32315659 unsigned int p_version, p_release, p_request_base, p_event_base, p_error_base; int p_num_adaptors; Display *dpy; Window window, _dw; XSizeHints hint; XSetWindowAttributes xswa; XVisualInfo vinfo; int screen; unsigned long mask; XEvent event; GC gc; /** for shm */ int shmem_flag = 0; XShmSegmentInfo yuv_shminfo; int CompletionType; printf("starting up video testapp...\n\n"); adaptor = -1; dpy = XOpenDisplay(NULL); if (dpy == NULL) { printf("Cannot open Display.\n"); exit (-1); } screen = DefaultScreen(dpy); /** find best display */ if (XMatchVisualInfo(dpy, screen, 24, TrueColor, &vinfo)) { printf(" found 24bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 16, TrueColor, &vinfo)) { printf(" found 16bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 15, TrueColor, &vinfo)) { printf(" found 15bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 8, PseudoColor, &vinfo)) { printf(" found 8bit PseudoColor\n"); } else if (XMatchVisualInfo(dpy, screen, 8, GrayScale, &vinfo)) { printf(" found 8bit GrayScale\n"); } else if (XMatchVisualInfo(dpy, screen, 8, StaticGray, &vinfo)) { printf(" found 8bit StaticGray\n"); } else if (XMatchVisualInfo(dpy, screen, 1, StaticGray, &vinfo)) { printf(" found 1bit StaticGray\n"); } else { printf("requires 16 bit display\n"); exit (-1); } CompletionType = -1; hint.x = 1; hint.y = 1; hint.width = yuv_width; hint.height = yuv_height; hint.flags = PPosition | PSize; xswa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vinfo.visual, AllocNone); xswa.event_mask = StructureNotifyMask | ExposureMask; xswa.background_pixel = 0; xswa.border_pixel = 0; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; window = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, yuv_width, yuv_height, 0, vinfo.depth, InputOutput, vinfo.visual, mask, &xswa); XStoreName(dpy, window, "XV"); XSetIconName(dpy, window, "XV"); XSelectInput(dpy, window, StructureNotifyMask); /** Map window */ XMapWindow(dpy, window); /** Wait for map. */ do { XNextEvent(dpy, &event); } while (event.type != MapNotify || event.xmap.event != window); if (XShmQueryExtension(dpy)) shmem_flag = 1; if (!shmem_flag) { printf("no shmem available.\n"); exit (-1); } if (shmem_flag==1) CompletionType = XShmGetEventBase(dpy) + ShmCompletion; /**--------------------------------- XV ------------------------------------*/ printf("beginning to parse the Xvideo extension...\n\n"); /** query and print Xvideo properties */ ret = XvQueryExtension(dpy, &p_version, &p_release, &p_request_base, &p_event_base, &p_error_base); if (ret != Success) { if (ret == XvBadExtension) printf("XvBadExtension returned at XvQueryExtension.\n"); else if (ret == XvBadAlloc) printf("XvBadAlloc returned at XvQueryExtension.\n"); else printf("other error happened at XvQueryExtension.\n"); } printf("========================================\n"); printf("XvQueryExtension returned the following:\n"); printf("p_version : %u\n", p_version); printf("p_release : %u\n", p_release); printf("p_request_base : %u\n", p_request_base); printf("p_event_base : %u\n", p_event_base); printf("p_error_base : %u\n", p_error_base); printf("========================================\n"); ret = XvQueryAdaptors(dpy, DefaultRootWindow(dpy), &p_num_adaptors, &ai); if (ret != Success) { if (ret == XvBadExtension) printf("XvBadExtension returned at XvQueryExtension.\n"); else if (ret == XvBadAlloc) printf("XvBadAlloc returned at XvQueryExtension.\n"); else printf("other error happaned at XvQueryAdaptors.\n"); } printf("=======================================\n"); printf("XvQueryAdaptors returned the following:\n"); printf("%d adaptors available.\n", p_num_adaptors); for (i = 0; i < p_num_adaptors; i++) { printf(" name: %s\n" " type: %s%s%s%s%s\n" " ports: %ld\n" " first port: %ld\n", ai[i].name, (ai[i].type & XvInputMask) ? "input | " : "", (ai[i].type & XvOutputMask) ? "output | " : "", (ai[i].type & XvVideoMask) ? "video | " : "", (ai[i].type & XvStillMask) ? "still | " : "", (ai[i].type & XvImageMask) ? "image | " : "", ai[i].num_ports, ai[i].base_id); xv_port = ai[i].base_id; printf("adaptor %d ; format list:\n", i); for (j = 0; j < ai[i].num_formats; j++) { printf(" depth=%d, visual=%ld\n", ai[i].formats[j].depth, ai[i].formats[j].visual_id); } for (p = ai[i].base_id; p < ai[i].base_id+ai[i].num_ports; p++) { printf(" encoding list for port %d\n", p); if (XvQueryEncodings(dpy, p, &encodings, &ei) != Success) { printf("XvQueryEncodings failed.\n"); continue; } for (j = 0; j < encodings; j++) { printf(" id=%ld, name=%s, size=%ldx%ld, numerator=%d, denominator=%d\n", ei[j].encoding_id, ei[j].name, ei[j].width, ei[j].height, ei[j].rate.numerator, ei[j].rate.denominator); } XvFreeEncodingInfo(ei); printf(" attribute list for port %d\n", p); at = XvQueryPortAttributes(dpy, p, &attributes); for (j = 0; j < attributes; j++) { printf(" name: %s\n" " flags: %s%s\n" " min_color: %i\n" " max_color: %i\n", at[j].name, (at[j].flags & XvGettable) ? " get" : "", (at[j].flags & XvSettable) ? " set" : "", at[j].min_value, at[j].max_value); } if (at) XFree(at); printf(" image format list for port %d\n", p); fo = XvListImageFormats(dpy, p, &formats); for (j = 0; j < formats; j++) { printf(" 0x%x (%4.4s) %s\n", fo[j].id, (char *)&fo[j].id, (fo[j].format == XvPacked) ? "packed" : "planar"); } if (fo) XFree(fo); } printf("\n"); } if (p_num_adaptors > 0) XvFreeAdaptorInfo(ai); if (xv_port == -1) exit (0); gc = XCreateGC(dpy, window, 0, 0); yuv_image = XvShmCreateImage(dpy, xv_port, GUID_YUV12_PLANAR, 0, yuv_width, yuv_height, &yuv_shminfo); yuv_shminfo.shmid = shmget(IPC_PRIVATE, yuv_image->data_size, IPC_CREAT | 0777); yuv_shminfo.shmaddr = yuv_image->data = shmat(yuv_shminfo.shmid, 0, 0); yuv_shminfo.readOnly = False; if (!XShmAttach(dpy, &yuv_shminfo)) { printf("XShmAttach failed !\n"); exit (-1); } for (i = 0; i < yuv_image->height; i++) { for (j = 0; j < yuv_image->width; j++) { yuv_image->data[yuv_image->width*i + j] = i*j; } } printf("%d\n", yuv_image->data_size); int joe = 0; while (1) { frames = secsa = secsb = 0; time(&secsa); while (frames < 200) { XGetGeometry(dpy, window, &_dw, &_d, &_d, &_w, &_h, &_d, &_d); for (i = 0; i < yuv_image->height * 1.5; i++) { for (j = 0; j < yuv_image->width; j++) { yuv_image->data[yuv_image->width*i + j] = (i + j + joe / 5); } } XvShmPutImage(dpy, xv_port, window, gc, yuv_image, 0, 0, yuv_image->width, yuv_image->height, 0, 0, _w, _h, True); /* XFlush(dpy); */ joe++; frames++; } time(&secsb); printf("%ld frames in %ld seconds; %.4f fps\n", frames, secsb-secsa, (double) frames/(secsb-secsa)); } return 0; }
void X11Window::_impl_setTitle(const ansichar * title) { XStoreName(m_Display, m_Window, title); XSetIconName(m_Display, m_Window, title); }
void win::title(char *title) { XStoreName(disp,w,title); XSetIconName(disp,w,title); }
void winwidget_create_window(winwidget ret, int w, int h) { XSetWindowAttributes attr; XEvent ev; XClassHint *xch; MWMHints mwmhints; Atom prop = None; int x = 0; int y = 0; char *tmpname; D(("winwidget_create_window %dx%d\n", w, h)); if (ret->full_screen) { w = scr->width; h = scr->height; #ifdef HAVE_LIBXINERAMA if (opt.xinerama && xinerama_screens) { w = xinerama_screens[xinerama_screen].width; h = xinerama_screens[xinerama_screen].height; x = xinerama_screens[xinerama_screen].x_org; y = xinerama_screens[xinerama_screen].y_org; } #endif /* HAVE_LIBXINERAMA */ } else if (opt.geom_flags) { if (opt.geom_flags & WidthValue) { w = opt.geom_w; } if (opt.geom_flags & HeightValue) { h = opt.geom_h; } if (opt.geom_flags & XValue) { if (opt.geom_flags & XNegative) { x = scr->width - opt.geom_x; } else { x = opt.geom_x; } } if (opt.geom_flags & YValue) { if (opt.geom_flags & YNegative) { y = scr->height - opt.geom_y; } else { y = opt.geom_y; } } } else if (opt.screen_clip) { if (w > scr->width) w = scr->width; if (h > scr->height) h = scr->height; #ifdef HAVE_LIBXINERAMA if (opt.xinerama && xinerama_screens) { if (w > xinerama_screens[xinerama_screen].width) w = xinerama_screens[xinerama_screen].width; if (h > xinerama_screens[xinerama_screen].height) h = xinerama_screens[xinerama_screen].height; } #endif /* HAVE_LIBXINERAMA */ } if (opt.paused) { printf("name %s\n", ret->name); tmpname = estrjoin(" ", ret->name, "[Paused]", NULL); free(ret->name); ret->name = tmpname; } ret->x = x; ret->y = y; ret->w = w; ret->h = h; ret->visible = False; attr.backing_store = NotUseful; attr.override_redirect = False; attr.colormap = cm; attr.border_pixel = 0; attr.background_pixel = 0; attr.save_under = False; attr.event_mask = StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask | ExposureMask | FocusChangeMask | PropertyChangeMask | VisibilityChangeMask; if (opt.borderless || ret->full_screen) { prop = XInternAtom(disp, "_MOTIF_WM_HINTS", True); if (prop == None) { weprintf ("Window Manager does not support MWM hints. " "To get a borderless window I have to bypass your wm."); attr.override_redirect = True; mwmhints.flags = 0; } else { mwmhints.flags = MWM_HINTS_DECORATIONS; mwmhints.decorations = 0; } } else mwmhints.flags = 0; ret->win = XCreateWindow(disp, DefaultRootWindow(disp), x, y, w, h, 0, depth, InputOutput, vis, CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWColormap | CWBackPixel | CWBorderPixel | CWEventMask, &attr); if (mwmhints.flags) { XChangeProperty(disp, ret->win, prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); } if (ret->full_screen) { Atom prop_fs = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); Atom prop_state = XInternAtom(disp, "_NET_WM_STATE", False); memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.message_type = prop_state; ev.xclient.display = disp; ev.xclient.window = ret->win; ev.xclient.format = 32; ev.xclient.data.l[0] = 1; ev.xclient.data.l[1] = prop_fs; XChangeProperty(disp, ret->win, prop_state, XA_ATOM, 32, PropModeReplace, (unsigned char *) &prop_fs, 1); } XSetWMProtocols(disp, ret->win, &wmDeleteWindow, 1); winwidget_update_title(ret); xch = XAllocClassHint(); xch->res_name = "feh"; xch->res_class = "feh"; XSetClassHint(disp, ret->win, xch); XFree(xch); /* Size hints */ if (ret->full_screen || opt.geom_flags) { XSizeHints xsz; xsz.flags = USPosition; xsz.x = x; xsz.y = y; XSetWMNormalHints(disp, ret->win, &xsz); XMoveWindow(disp, ret->win, x, y); } if (opt.hide_pointer) winwidget_set_pointer(ret, 0); /* set the icon name property */ XSetIconName(disp, ret->win, "feh"); /* set the command hint */ XSetCommand(disp, ret->win, cmdargv, cmdargc); winwidget_register(ret); return; }
void initx(xxfmt *xx) { int rslt; char title[64]; xx->dpy = XOpenDisplay(NULL); if (xx->dpy == NULL) { fprintf(stderr,"X Windows failure\n"); exit(1); } /* if X Windows is not active */ assert(xx->dpy); /* get dimensions of root window */ xx->rootww = XDisplayWidth(xx->dpy,0); xx->rootwh = XDisplayHeight(xx->dpy,0); /* make display window smaller than root window */ /* allow for menu bar on top */ // xx->dpywdth = xx->rootww - 80; // xx->dpyhght = xx->rootwh - 100; xx->dpywdth = 512; /* need a power of 2 */ xx->dpyhght = 512; /* need a power of 2 */ xx->whiteColor = WhitePixel(xx->dpy, DefaultScreen(xx->dpy)); xx->blackColor = BlackPixel(xx->dpy, DefaultScreen(xx->dpy)); xx->w = XCreateSimpleWindow(xx->dpy, DefaultRootWindow(xx->dpy), 0, 0, xx->dpywdth, xx->dpyhght, 0, xx->whiteColor, xx->whiteColor); XSelectInput(xx->dpy, xx->w, StructureNotifyMask); XMapWindow(xx->dpy, xx->w); xx->gc = XCreateGC(xx->dpy, xx->w, 0, NULL); xx->fontid = (Font) XLoadFont(xx->dpy,"12x24"); XSetFont(xx->dpy,xx->gc,xx->fontid); XSetForeground(xx->dpy, xx->gc, xx->blackColor); xx->dfltscr = XDefaultScreenOfDisplay(xx->dpy); if (xx->dfltscr == NULL) { fprintf(stderr,"XDefaultScreenOfDisplay failed\n"); perror("XDefaultScreenOfDisplay failed"); exit(1); } /* if error */ xx->cmap = XDefaultColormapOfScreen(xx->dfltscr); rslt = XAllocNamedColor(xx->dpy,xx->cmap,"red", &xx->scrdef,&xx->exctdef); if (rslt < 0) { fprintf(stderr,"XAllocNamedColor failed\n"); perror("XAllocNamedColor failed"); exit(1); } /* if error */ xx->red = xx->scrdef.pixel; XSetWindowBorderWidth(xx->dpy, xx->w, 40); sprintf(title,"Random Screen"); XStoreName(xx->dpy,xx->w,title); XSetIconName(xx->dpy,xx->w,title); while(1) { XEvent e; XNextEvent(xx->dpy, &e); if (e.type == MapNotify) break; } /* wait for window initialization */ } /* initx */
bool vogl_replay_window::open(int width, int height, int samples) { VOGL_FUNC_TRACER #if (VOGL_PLATFORM_HAS_GLX) close(); if (!check_glx_version()) return false; // TODO: These attribs (especially the sizes) should be passed in by the caller! int fbAttribs[64]; int *pAttribs = fbAttribs; *pAttribs++ = GLX_RENDER_TYPE; *pAttribs++ = GLX_RGBA_BIT; *pAttribs++ = GLX_X_RENDERABLE; *pAttribs++ = True; *pAttribs++ = GLX_DRAWABLE_TYPE; *pAttribs++ = GLX_WINDOW_BIT; *pAttribs++ = GLX_DOUBLEBUFFER; *pAttribs++ = True; *pAttribs++ = GLX_RED_SIZE; *pAttribs++ = 8; *pAttribs++ = GLX_BLUE_SIZE; *pAttribs++ = 8; *pAttribs++ = GLX_GREEN_SIZE; *pAttribs++ = 8; *pAttribs++ = GLX_ALPHA_SIZE; *pAttribs++ = 8; *pAttribs++ = GLX_DEPTH_SIZE; *pAttribs++ = 24; *pAttribs++ = GLX_STENCIL_SIZE; *pAttribs++ = 8; if (samples > 1) { *pAttribs++ = GLX_SAMPLE_BUFFERS; *pAttribs++ = 1; *pAttribs++ = GLX_SAMPLES; *pAttribs++ = samples; } *pAttribs++ = 0; // Tell X we are going to use the display m_dpy = XOpenDisplay(NULL); if (!m_dpy) { console::error("%s: XOpenDisplay() failed!\n", VOGL_FUNCTION_INFO_CSTR); return false; } // Get a new fb config that meets our attrib requirements m_pFB_configs = GL_ENTRYPOINT(glXChooseFBConfig)(m_dpy, DefaultScreen(m_dpy), fbAttribs, &m_num_fb_configs); if ((!m_pFB_configs) || (!m_num_fb_configs)) { console::error("%s: glXChooseFBConfig() failed!\n", VOGL_FUNCTION_INFO_CSTR); return false; } XVisualInfo *pVisual_info = GL_ENTRYPOINT(glXGetVisualFromFBConfig)(m_dpy, m_pFB_configs[0]); if (!pVisual_info) { console::error("%s: glXGetVisualFromFBConfig() failed!\n", VOGL_FUNCTION_INFO_CSTR); return false; } // Now create an X window XSetWindowAttributes winAttribs; winAttribs.event_mask = ExposureMask | VisibilityChangeMask | KeyPressMask | PointerMotionMask | StructureNotifyMask; winAttribs.border_pixel = 0; winAttribs.bit_gravity = StaticGravity; winAttribs.colormap = XCreateColormap(m_dpy, RootWindow(m_dpy, pVisual_info->screen), pVisual_info->visual, AllocNone); GLint winmask = CWBorderPixel | CWBitGravity | CWEventMask | CWColormap; m_win = XCreateWindow(m_dpy, DefaultRootWindow(m_dpy), 20, 20, width, height, 0, pVisual_info->depth, InputOutput, pVisual_info->visual, winmask, &winAttribs); const char *pWindow_name = (sizeof(void *) == sizeof(uint32)) ? "voglreplay 32-bit" : "voglreplay 64-bit"; XStoreName(m_dpy, m_win, pWindow_name); XSetIconName(m_dpy, m_win, pWindow_name); XSizeHints sh; utils::zero_object(sh); sh.x = 0; // slam position up so when/if we resize the window glReadPixels still works as expected (this may be a bug in the NV driver, I dunno yet) sh.y = 0; sh.width = sh.min_width = sh.max_width = sh.base_width = width; sh.height = sh.min_height = sh.max_height = sh.base_height = height; sh.flags = PSize | PMinSize | PMaxSize | PBaseSize | PPosition; XSetWMNormalHints(m_dpy, m_win, &sh); XResizeWindow(m_dpy, m_win, width, height); XMapWindow(m_dpy, m_win); //glXWaitX(); m_width = width; m_height = height; uint actual_width = 0, actual_height = 0; vogl_replay_window::get_actual_dimensions(actual_width, actual_height); vogl_debug_printf("%s: Created window, requested dimensions %ux%u, actual dimensions %ux%u\n", VOGL_FUNCTION_INFO_CSTR, m_width, m_height, actual_width, actual_height); return true; #else VOGL_ASSERT(!"impl"); return false; #endif }