/* * Free the atom. */ extern void _XmFreeMotifAtom(Widget shell, Atom atom) { XmDndAtomsTable atoms; Display *dpy = XtDisplay(shell); int i; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:_XmFreeMotifAtom(%d)\n", __FILE__, __LINE__)); if (atom == None) { return; } if ((atoms = get_atoms_table(dpy)) == NULL) { _XmInitTargetsTable(dpy); atoms = get_atoms_table(dpy); } XGrabServer(dpy); if (!read_atoms_table(dpy, atoms)) { XUngrabServer(dpy); _XmInitTargetsTable(dpy); XGrabServer(dpy); atoms = get_atoms_table(dpy); } if (atoms->num_entries != 0) { for (i = 0; i < atoms->num_entries; i++) { if (atoms->entries[i].atom == atom) { atoms->entries[i].time = CurrentTime; break; } } } write_atoms_table(dpy, atoms); XUngrabServer(dpy); XFlush(dpy); }
/* * fetch and/or set the ATOM_PAIRS. This is triggered at least once * by the first call to XmInternAtom(). */ extern void _XmInitAtomPairs(Display *display) { Window win; char *dstr; Display *d; DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:_XmInitAtomPairs(%d)\n", __FILE__, __LINE__)); if ((win = read_drag_window(display)) == None) { dstr = XDisplayString(display); d = XOpenDisplay(dstr); if (d == NULL) { _XmWarning((Widget)XmGetXmDisplay(display), "Where's your display?"); return; } XGrabServer(d); if ((win = read_drag_window(d)) == None) { XSetCloseDownMode(d, RetainPermanent); win = create_drag_window(d); write_drag_window(d, &win); } XCloseDisplay(d); } set_drag_window(display, win); if (!read_atom_pairs(display)) { XGrabServer(display); if (!read_atom_pairs(display)) { write_atom_pairs(display); } XUngrabServer(display); XFlush(display); } }
static void drw_selection_negotiate (DrwSelection *drw_selection) { Display *xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); gboolean found = FALSE; /* We don't need both the XGrabServer() and the loop here; * the XGrabServer() should make sure that we only go through * the loop once. It also works if you remove the XGrabServer() * and just have the loop, but then the selection ownership * can get transfered a bunch of times before things * settle down. */ while (!found) { XGrabServer (xdisplay); if (drw_selection_find_existing (drw_selection)) found = TRUE; else if (drw_selection_claim (drw_selection)) found = TRUE; XUngrabServer (xdisplay); } }
PlexyWindows::PlexyWindows(Display* dsp, Window win, XWindowAttributes* attr, QWidget *parent, Qt::WindowFlags f ) :QWidget(parent, f) { qDebug()<<"Creating PlexyWindow"<<endl; XSelectInput(dsp, win, (PropertyChangeMask | EnterWindowMask | FocusChangeMask)); XGrabServer(dsp); XReparentWindow(dsp, win, winId(), 20, 20); XAddToSaveSet(dsp, win); Atom _net_active_window = XInternAtom(dsp , "_NET_ACTIVE_WINDOW", false); XClientMessageEvent xev; xev.type = ClientMessage; xev.window = win; xev.message_type = _net_active_window; xev.format = 32; xev.data.l[0] = 1; xev.data.l[1] = CurrentTime; xev.data.l[2] = 0; XSendEvent(dsp, QApplication::desktop()->winId(), False, StructureNotifyMask, (XEvent *)&xev); XMapWindow(dsp, win); XSync(dsp, false); XUngrabServer(dsp); show(); }
static Window awt_mgrsel_select_per_screen(Atom selection, long extra_mask) { Display *dpy = awt_display; Window owner; XGrabServer(dpy); owner = XGetSelectionOwner(dpy, selection); if (owner == None) { /* we'll get notified later if one arrives */ XUngrabServer(dpy); /* Workaround for bug 5039226 */ XSync(dpy, False); return (None); } /* * Select for StructureNotifyMask to get DestroyNotify when owner * is gone. Also select for any additional events caller is * interested in (e.g. PropertyChangeMask). Caller will be * notifed of these events via ... XXX ... */ XSelectInput(dpy, owner, StructureNotifyMask | extra_mask); XUngrabServer(dpy); /* Workaround for bug 5039226 */ XSync(dpy, False); return (owner); }
int main (int argc, char **argv){ char query[128]; int nombre_lignes = 2; char *color = "darkgrey"; // --> Couleur à chercher dans la base Window w; Display *dpy = XOpenDisplay(NULL); Atom xhextris_atom = XInternAtom(dpy, "xhextris_query_string", False); strcat(query, QUERY_STRING); strcat(query, " "); strcat(query, USER_ID); XGrabServer(dpy); w = XGetSelectionOwner(dpy, xhextris_atom); XSetSelectionOwner(dpy, w, xhextris_atom, CurrentTime); XUngrabServer(dpy); fprintf(stderr, "Sending atom to %i\n", (int)w); XChangeProperty(dpy, w, xhextris_atom, XA_STRING, 8, PropModeReplace, query, strlen(query)); XFlush(dpy); return 0; }
static void draw_background (MateBGCrossfade *fade) { if (fade->priv->widget != NULL) { gtk_widget_queue_draw (fade->priv->widget); } else if (gdk_window_get_window_type (fade->priv->window) != GDK_WINDOW_ROOT) { cairo_t *cr; cairo_region_t *region; GdkDrawingContext *draw_context; region = gdk_window_get_visible_region (fade->priv->window); draw_context = gdk_window_begin_draw_frame (fade->priv->window, region); cr = gdk_drawing_context_get_cairo_context (draw_context); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_source_surface (cr, fade->priv->fading_surface, 0, 0); cairo_paint (cr); gdk_window_end_draw_frame (fade->priv->window, draw_context); cairo_region_destroy (region); } else { Display *xdisplay = GDK_WINDOW_XDISPLAY (fade->priv->window); GdkDisplay *display; display = gdk_display_get_default (); gdk_x11_display_error_trap_push (display); XGrabServer (xdisplay); XClearWindow (xdisplay, GDK_WINDOW_XID (fade->priv->window)); send_root_property_change_notification (fade); XFlush (xdisplay); XUngrabServer (xdisplay); gdk_x11_display_error_trap_pop_ignored (display); } }
static int VimRemotingClient_init_internal(VimRemotingClient *client) { prologue(client); client->commProperty = XInternAtom(client->dpy, "Comm", False); client->vimProperty = XInternAtom(client->dpy, "Vim", False); client->registryProperty = XInternAtom(client->dpy, "VimRegistry", False); client->window = XCreateSimpleWindow( client->dpy, XDefaultRootWindow(client->dpy), getpid(), 0, 10, 10, 0, WhitePixel(client->dpy, DefaultScreen(client->dpy)), WhitePixel(client->dpy, DefaultScreen(client->dpy))); XSelectInput(client->dpy, client->window, PropertyChangeMask); /* WARNING: Do not step through this while debugging, it will hangup * the X server! */ XGrabServer(client->dpy); deleteAnyLingerer(client); XUngrabServer(client->dpy); /* Make window recognizable as a vim window */ XChangeProperty( client->dpy, client->window, client->vimProperty, XA_STRING, 8, PropModeReplace, (char *)client->vim_version, (int)strlen(client->vim_version) + 1); XSync(client->dpy, False); epilogue(client); return client->got_x_error; }
void Reborder(void) { FvwmWindow *tmp; /* temp fvwm window structure */ /* put a border back around all windows */ XGrabServer(dpy); InstallWindowColormaps(&Scr.FvwmRoot); /* force reinstall */ /* RBW - 05/15/1998 Grab the last window and work backwards: preserve stacking order on restart. */ for (tmp = Scr.FvwmRoot.stack_prev; tmp != &Scr.FvwmRoot; tmp = tmp->stack_prev) { RestoreWithdrawnLocation(tmp, True); XUnmapWindow(dpy, tmp->frame); XDestroyWindow(dpy, tmp->frame); } XUngrabServer(dpy); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, 0); }
static void xx_crosshair(int id, int x, int y) { XGrabServer(INTERNAL_display); xwini[id].xx_draw_cursor_func(id,x,y); XUngrabServer(INTERNAL_display); XFlush(INTERNAL_display); }
static void egg_tray_icon_update_manager_window(EggTrayIcon * icon) { Display *xdisplay; xdisplay = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(GTK_WIDGET(icon))); if (icon->manager_window != None) { GdkWindow *gdkwin; gdkwin = gdk_window_lookup_for_display(gtk_widget_get_display(GTK_WIDGET(icon)), icon->manager_window); gdk_window_remove_filter(gdkwin, egg_tray_icon_manager_filter, icon); } XGrabServer(xdisplay); icon->manager_window = XGetSelectionOwner(xdisplay, icon->selection_atom); if (icon->manager_window != None) XSelectInput(xdisplay, icon->manager_window, StructureNotifyMask); XUngrabServer(xdisplay); XFlush(xdisplay); if (icon->manager_window != None) { GdkWindow *gdkwin; gdkwin = gdk_window_lookup_for_display(gtk_widget_get_display(GTK_WIDGET(icon)), icon->manager_window); gdk_window_add_filter(gdkwin, egg_tray_icon_manager_filter, icon); /* Send a request that we'd like to dock */ egg_tray_icon_send_dock_request(icon); } }
QPixmap WindowGrabber::grabCurrent( bool includeDecorations ) { int x, y; #ifdef Q_WS_X11 Window root; uint w, h, border, depth; XGrabServer( QX11Info::display() ); Window child = windowUnderCursor( includeDecorations ); XGetGeometry( QX11Info::display(), child, &root, &x, &y, &w, &h, &border, &depth ); Window parent; Window* children; unsigned int nchildren; if( XQueryTree( QX11Info::display(), child, &root, &parent, &children, &nchildren ) != 0 ) { if( children != NULL ) { XFree( children ); } int newx, newy; Window dummy; if( XTranslateCoordinates( QX11Info::display(), parent, QX11Info::appRootWindow(), x, y, &newx, &newy, &dummy )) { x = newx; y = newy; } } windowPosition = QPoint(x,y); QPixmap pm( grabWindow( child, x, y, w, h, border, &title, &windowClass ) ); XUngrabServer( QX11Info::display() ); return pm; #elif defined(Q_WS_WIN) HWND hWindow; hWindow = windowUnderCursor(includeDecorations); Q_ASSERT(hWindow); HWND hParent; // Now find the top-most window do { hParent = hWindow; } while( (hWindow = GetParent(hWindow)) != NULL ); Q_ASSERT(hParent); RECT r; GetWindowRect(hParent, &r); x = r.left; y = r.top; windowPosition = QPoint(x,y); QPixmap pm( grabWindow( hParent, &title, &windowClass) ); return pm; #endif // Q_WS_X11 return QPixmap(); }
void XRRConfiguration::ToggleDisplayMode(bool bFullscreen) { if (!bValid || !screenResources || !outputInfo || !crtcInfo || !fullMode) return; if (bFullscreen == bIsFullscreen) return; XGrabServer(dpy); if (bFullscreen) { XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, crtcInfo->x, crtcInfo->y, fullMode, crtcInfo->rotation, crtcInfo->outputs, crtcInfo->noutput); XRRSetScreenSize(dpy, win, fs_fb_width, fs_fb_height, fs_fb_width_mm, fs_fb_height_mm); bIsFullscreen = true; } else { XRRSetCrtcConfig(dpy, screenResources, outputInfo->crtc, CurrentTime, crtcInfo->x, crtcInfo->y, crtcInfo->mode, crtcInfo->rotation, crtcInfo->outputs, crtcInfo->noutput); XRRSetScreenSize(dpy, win, fb_width, fb_height, fb_width_mm, fb_height_mm); bIsFullscreen = false; } XUngrabServer(dpy); XSync(dpy, false); }
static Window windowUnderCursor( bool includeDecorations = true ) { Window root; Window child; uint mask; int rootX, rootY, winX, winY; XGrabServer( QX11Info::display() ); XQueryPointer( QX11Info::display(), QX11Info::appRootWindow(), &root, &child, &rootX, &rootY, &winX, &winY, &mask ); if( child == None ) { child = QX11Info::appRootWindow(); } if( !includeDecorations ) { Window real_child = findRealWindow( child ); if( real_child != None ) { // test just in case child = real_child; } } return child; }
int TrayFindDock(Display *dpy, TrayWindow* tray) { if (tray->window == None) { tray->bTrayMapped = False; return 0; } XGrabServer(dpy); tray->dockWindow = XGetSelectionOwner(dpy, tray->atoms[ATOM_SELECTION]); if (tray->dockWindow != None) XSelectInput(dpy, tray->dockWindow, StructureNotifyMask | PropertyChangeMask); XUngrabServer(dpy); XFlush(dpy); if (tray->dockWindow != None) { TraySendOpcode(dpy, tray->dockWindow, tray, SYSTEM_TRAY_REQUEST_DOCK, tray->window, 0, 0); tray->bTrayMapped = True; return 1; } else { tray->bTrayMapped = False; ReleaseTrayWindow(tray); } return 0; }
int check_tray_manager(void) { if (tray_init) return True; xembed_atom = XInternAtom(gui->display, "_XEMBED", False); system_tray_opcode_atom = XInternAtom(gui->display, "_NET_SYSTEM_TRAY_OPCODE", False); orientation_atom = XInternAtom(gui->display, "_NET_SYSTEM_TRAY_ORIENTATION", False); manager_window = ManagerWindow(gui->display, gui->screen); XGrabServer(gui->display); if (manager_window != None) { XSelectInput(gui->display, manager_window, StructureNotifyMask|PropertyChangeMask); send_message(gui->display, manager_window, SYSTEM_TRAY_REQUEST_DOCK, gui->tray_win->window, 0, 0); aw = gui->tray_win->window; /* XftDrawDestroy(gui->tray_win->draw); //XDestroyWindow(gui->display, gui->tray_win->window); //XUnmapWindow(gui->display, gui->tray_win->window); gui->tray_win = NULL; gui_tray_init();*/ // send_message(gui->display, manager_window, SYSTEM_TRAY_REQUEST_DOCK, gui->tray_win->window, 0, 0); tray_init = True; } XUngrabServer(gui->display); XFlush(gui->display); return tray_init; }
Workspace::Workspace() : mDamage( None ), mWaitForClients( false ), mInitialRepaint( true ) { Extensions::initialize(); XGrabServer( dpy ); // Redirect all toplevel window contents to offscreen storage XCompositeRedirectSubwindows( dpy, rootId(), CompositeRedirectManual ); initClientList(); // Request notification about toplevel window state changes XSelectInput( dpy, rootId(), SubstructureNotifyMask | ExposureMask | StructureNotifyMask | PropertyChangeMask ); XUngrabServer( dpy ); // Get the picture format for the root window mFormat = XRenderFindVisualFormat( dpy, visual() ); // Create an unclipped picture for drawing on the root window XRenderPictureAttributes pa; pa.subwindow_mode = IncludeInferiors; mFrontbuffer = XRenderCreatePicture( dpy, rootId(), format(), CPSubwindowMode, &pa ); createBackbuffer(); XSync( dpy, false ); }
static void tray_widget_update_manager_window(struct _tray_widget_icon *widget_icon, gboolean dock_if_realized) { if (widget_icon->manager_window != None) return; Display *display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(GTK_WIDGET(widget_icon))); XGrabServer(display); widget_icon->manager_window = XGetSelectionOwner(display, widget_icon->selection_atom); if (widget_icon->manager_window != None) XSelectInput(display, widget_icon->manager_window, StructureNotifyMask | PropertyChangeMask); XUngrabServer(display); XFlush(display); if (widget_icon->manager_window == None) return; GdkWindow *gdk_window = gdk_window_lookup_for_display(gtk_widget_get_display(GTK_WIDGET(widget_icon)), widget_icon->manager_window); gdk_window_add_filter(gdk_window, tray_widget_filter, widget_icon); if (dock_if_realized && GTK_WIDGET_REALIZED(widget_icon)) tray_widget_send_dock_request(widget_icon); tray_widget_get_orientation_property(widget_icon); }
static void setTrayIcon(QWidget &widget) { /* System Tray Protocol Specification. */ Display *dpy = qt_xdisplay(); Screen *screen = XDefaultScreenOfDisplay(dpy); int iScreen = XScreenNumberOfScreen(screen); char szAtom[32]; snprintf(szAtom, sizeof(szAtom), "_NET_SYSTEM_TRAY_S%d", iScreen); Atom selectionAtom = XInternAtom(dpy, szAtom, False); XGrabServer(dpy); Window managerWin = XGetSelectionOwner(dpy, selectionAtom); if (managerWin != None) XSelectInput(dpy, managerWin, StructureNotifyMask); XUngrabServer(dpy); XFlush(dpy); if (managerWin != None) { XEvent ev; memset(&ev, 0, sizeof(ev)); ev.xclient.type = ClientMessage; ev.xclient.window = managerWin; ev.xclient.message_type = XInternAtom(dpy, "_NET_SYSTEM_TRAY_OPCODE", False); ev.xclient.format = 32; ev.xclient.data.l[0] = CurrentTime; ev.xclient.data.l[1] = SYSTEM_TRAY_REQUEST_DOCK; ev.xclient.data.l[2] = widget.winId(); ev.xclient.data.l[3] = 0; ev.xclient.data.l[4] = 0; XSendEvent(dpy, managerWin, False, NoEventMask, &ev); XSync(dpy, False); } }
BZclient::BZclient( Display* dpy, Window w ) { XWindowAttributes attr; long dummy ; XWMHints *hints ; XGrabServer(dpy); XGetTransientForHint(dpy, w, &transient); XFetchName(dpy, w, &name); XGetWindowAttributes(dpy, w, &attr); window = w ; ignore_unmap = 0 ; x = attr.x ; y = attr.y ; width = attr.width ; height = attr.height ; cmap = attr.colormap ; size = XAllocSizeHints() ; XGetWMNormalHints(dpy, window, size, &dummy); XSync(dpy, False); XUngrabServer(dpy); }
static void scan_windows(riftwm_t *wm) { Window root, parent, *children; XWindowAttributes attr; unsigned count, i; riftwin_t * win; XGrabServer(wm->dpy); if (XQueryTree(wm->dpy, wm->root, &root, &parent, &children, &count)) { for (i = 0; i < count; ++i) { win = add_window(wm, children[i]); if (!XGetWindowAttributes(wm->dpy, win->window, &attr)) { riftwm_error(wm, "Cannot retrieve window attributes"); } win->mapped = attr.map_state == IsViewable; } if (children) { XFree(children); } } XUngrabServer(wm->dpy); }
/* * detect_get_clipboard - try and get the CLIPBOARD_NAME clipboard * * Returns TRUE if successfully retrieved and FALSE otherwise. */ gboolean detect_get_clipboard() { static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} }; gboolean retval = FALSE; GtkClipboard *clipboard; Atom atom; atom = gdk_x11_get_xatom_by_name(CLIPBOARD_NAME); XGrabServer(GDK_DISPLAY()); if (XGetSelectionOwner(GDK_DISPLAY(), atom) != None) goto out; clipboard = gtk_clipboard_get(gdk_atom_intern(CLIPBOARD_NAME, FALSE)); if (gtk_clipboard_set_with_data( clipboard, targets, G_N_ELEMENTS (targets), clipboard_get_func, clipboard_clear_func, NULL)) retval = TRUE; out: XUngrabServer (GDK_DISPLAY ()); gdk_flush (); return retval; }
void SecureDisplay (struct display *d, Display *dpy) { Debug ("SecureDisplay %s\n", d->name); (void) Signal (SIGALRM, syncTimeout); if (Setjmp (syncJump)) { LogError ("WARNING: display %s could not be secured\n", d->name); SessionExit (d, RESERVER_DISPLAY, FALSE); } (void) alarm ((unsigned) d->grabTimeout); Debug ("Before XGrabServer %s\n", d->name); XGrabServer (dpy); if (XGrabKeyboard (dpy, DefaultRootWindow (dpy), True, GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) { (void) alarm (0); (void) Signal (SIGALRM, SIG_DFL); LogError ("WARNING: keyboard on display %s could not be secured\n", d->name); SessionExit (d, RESERVER_DISPLAY, FALSE); } Debug ("XGrabKeyboard succeeded %s\n", d->name); (void) alarm (0); (void) Signal (SIGALRM, SIG_DFL); pseudoReset (dpy); if (!d->grabServer) { XUngrabServer (dpy); XSync (dpy, 0); } Debug ("done secure %s\n", d->name); }
void sweep(Client *c) { XEvent ev; int old_cx = c->x; int old_cy = c->y; if (!grab_pointer(c->screen->root, MouseMask, resize_curs)) return; client_raise(c); #ifdef INFOBANNER_MOVERESIZE create_info_window(c); #endif XGrabServer(dpy); draw_outline(c); setmouse(c->window, c->width, c->height); for (;;) { XMaskEvent(dpy, MouseMask, &ev); switch (ev.type) { case MotionNotify: if (ev.xmotion.root != c->screen->root) break; draw_outline(c); /* clear */ XUngrabServer(dpy); recalculate_sweep(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y, ev.xmotion.state & altmask); #ifdef INFOBANNER_MOVERESIZE update_info_window(c); #endif XSync(dpy, False); XGrabServer(dpy); draw_outline(c); break; case ButtonRelease: draw_outline(c); /* clear */ XUngrabServer(dpy); #ifdef INFOBANNER_MOVERESIZE remove_info_window(); #endif XUngrabPointer(dpy, CurrentTime); moveresize(c); /* In case maximise state has changed: */ ewmh_set_net_wm_state(c); return; default: break; } } }
void getOpenwindows(void) { Window rootWindow; Atom actualType; int format; unsigned long numItems,bytesAfter; XWindowAttributes attr; unsigned long *array; Window w; unsigned char *data; Atom *atoms; int status, real_format; Atom real_type; unsigned long items_read, items_left, i; Atom _NET_WM_WINDOW_TYPE=XInternAtom(display,"_NET_WM_WINDOW_TYPE",False); Atom _NET_WM_WINDOW_TYPE_NORMAL=XInternAtom(display,"_NET_WM_WINDOW_TYPE_NORMAL",False); XGrabServer(display); skipErrors(true); rootWindow=RootWindow(display,screen); Atom _NET_CLIENT_LIST=XInternAtom(display,"_NET_CLIENT_LIST" , true); status=XGetWindowProperty(display,rootWindow,_NET_CLIENT_LIST,0L,(~0L),false,AnyPropertyType,&actualType,&format,&numItems,&bytesAfter,&data); if((status==Success) && (numItems>0)) { array=(unsigned long*)data; for(unsigned long g=0;g<numItems;g++) { for(int j=0;j<MAXWINDOWS;j++) windowSnow[j].showing=false; for(int j=0; j<MAXWINDOWS; j++) if(windowSnow[j].wid==array[g]) windowSnow[j].showing=true; } for(unsigned long k=0; k<numItems; k++) { w=(Window)array[k]; status=XGetWindowProperty(display,w,_NET_WM_WINDOW_TYPE,0L,1L,False,XA_ATOM,&real_type,&real_format,&items_read,&items_left,&data); atoms=(Atom *)data; for(i=0;i<items_read;i++) { if(atoms[i]==_NET_WM_WINDOW_TYPE_NORMAL) { skipErrors(true); XGetWindowAttributes(display,w,&attr); checkForWindowChange(w,&attr); skipErrors(false); } } } XFree(data); } skipErrors(true); XUngrabServer(display); }
void remove_client(Client *c) { Client *p; LOG_DEBUG("remove_client() : Removing...\n"); if (!c || !c->xstuff) return; XGrabServer(dpy); ignore_xerror = 1; /* ICCCM 4.1.3.1 * "When the window is withdrawn, the window manager will either * change the state field's value to WithdrawnState or it will * remove the WM_STATE property entirely." * EWMH 1.3 * "The Window Manager should remove the property whenever a * window is withdrawn but it should leave the property in * place when it is shutting down." (both _NET_WM_DESKTOP and * _NET_WM_STATE) */ if (c->remove) { LOG_DEBUG("\tremove_client() : setting WithdrawnState\n"); set_wm_state(c, WithdrawnState); XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_desktop); XDeleteProperty(dpy, c->xstuff->window, xa_net_wm_state); } ungravitate(c); if (c->xstuff->screen) XReparentWindow(dpy, c->xstuff->window, c->xstuff->screen->root, c->x, c->y); XSetWindowBorderWidth(dpy, c->xstuff->window, c->old_border); XRemoveFromSaveSet(dpy, c->xstuff->window); if (c->xstuff->parent) XDestroyWindow(dpy, c->xstuff->parent); if (head_client == c) head_client = c->next; else for (p = head_client; p && p->next; p = p->next) if (p->next == c) p->next = c->next; if (current == c) current = NULL; /* an enter event should set this up again */ free(c->xstuff); free(c); #ifdef DEBUG { Client *pp; int i = 0; for (pp = head_client; pp; pp = pp->next) i++; LOG_DEBUG("\tremove_client() : free(), window count now %d\n", i); } #endif XUngrabServer(dpy); XFlush(dpy); ignore_xerror = 0; LOG_DEBUG("remove_client() returning\n"); }
// Constructor. qsynthApplication(int& argc, char **argv) : QApplication(argc, argv), m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0) { // Load translation support. QLocale loc; if (loc.language() != QLocale::C) { // Try own Qt translation... m_pQtTranslator = new QTranslator(this); QString sLocName = "qt_" + loc.name(); QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { delete m_pQtTranslator; m_pQtTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toLocal8Bit().data(), sLocPath.toLocal8Bit().data(), sLocName.toLocal8Bit().data()); #endif } // Try own application translation... m_pMyTranslator = new QTranslator(this); sLocName = "qsynth_" + loc.name(); if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { sLocPath = CONFIG_DATADIR "/qsynth/translations"; if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { delete m_pMyTranslator; m_pMyTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toLocal8Bit().data(), sLocPath.toLocal8Bit().data(), sLocName.toLocal8Bit().data()); #endif } } } #ifdef CONFIG_X11 #ifdef CONFIG_XUNIQUE // Instance uniqueness initialization... m_pDisplay = QX11Info::display(); m_aUnique = XInternAtom(m_pDisplay, QSYNTH_XUNIQUE, false); XGrabServer(m_pDisplay); m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique); XUngrabServer(m_pDisplay); #if QT_VERSION >= 0x050100 m_pXcbEventFilter = new qsynthXcbEventFilter(this); installNativeEventFilter(m_pXcbEventFilter); #endif #endif // CONFIG_XUNIQUE #endif // CONFIG_X11 }
void StackDebugger::loadStack (CompWindowList &serverWindows, bool wait) { Window rootRet, parentRet; if (mServerChildren) XFree (mServerChildren); XSync (mDpy, FALSE); XGrabServer (mDpy); XQueryTree (mDpy, mRoot, &rootRet, &parentRet, &mServerChildren, &mServerNChildren); unsigned int n = XEventsQueued (mDpy, QueuedAfterFlush); mEvents.clear (); mEvents.resize (n); std::list <XEvent>::iterator it = mEvents.begin (); while (it != mEvents.end ()) { mFetchXEvent->getNextXEvent ((*it)); ++it; } XSync (mDpy, FALSE); /* It is possible that X might not be keeping up with us, so * we should give it about 300 ms in case the stacks are out of sync * in order to deliver any more events that might be pending */ mTimeoutRequired = false; mLastServerWindows = serverWindows; if (mServerNChildren != serverWindows.size () && wait) { struct pollfd pfd; pfd.events = POLLIN; pfd.revents = 0; pfd.fd = ConnectionNumber (mDpy); poll (&pfd, 1, 300); XEvent e; while (mFetchXEvent->getNextXEvent (e)) mEvents.push_back (e); mTimeoutRequired = true; } mDestroyedFrames.clear (); XUngrabServer (mDpy); XSync (mDpy, FALSE); }
void mdm_wm_save_wm_order (void) { Window *children = NULL; Window xparent, xroot; guint size = 0; int dlen = 0; unsigned long *data; gdk_flush (); XSync (wm_disp, False); trap_push (); XGrabServer (wm_disp); if (XQueryTree (wm_disp, wm_root, &xroot, &xparent, &children, &size)) { int i; Atom atom; data = g_new0 (unsigned long, size); for (i = 0; i < size; i++) { MdmWindow *gw = find_window (children[i], TRUE); /* Ignore unknowns and shadows */ if (gw == NULL || gw->shadow == children[i]) continue; if (gw->win == wm_login_window) { /* Empty spot in the list signifies the * login window */ data [dlen++] = None; } else { data [dlen++] = gw->win; } } atom = XInternAtom (wm_disp, "MDMWM_WINDOW_ORDER", False); XChangeProperty (wm_disp, wm_root, atom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, dlen); if (children != NULL) XFree (children); g_free (data); }
void window_set_visible(Window win, bool visible) { XGrabServer(gDisplay); XSelectInput(gDisplay, win, CLIENT_EVENT_MASK & ~StructureNotifyMask); XSelectInput(gDisplay, gRoot, ROOT_EVENT_MASK & ~SubstructureNotifyMask); if(visible) XMapWindow(gDisplay, win); else XUnmapWindow(gDisplay, win); XSelectInput(gDisplay, win, CLIENT_EVENT_MASK); XSelectInput(gDisplay, gRoot, ROOT_EVENT_MASK); XUngrabServer(gDisplay); }