コード例 #1
0
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);
}
コード例 #2
0
ファイル: DragBS.c プロジェクト: att/uwin
/*
 * 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);
}
コード例 #3
0
ファイル: xevent.c プロジェクト: DannyDaemonic/lxsession
gboolean single_instance_check()
{
	/* NOTE: this is a hack to do single instance */
	XGrabServer( dpy );
	if( XGetSelectionOwner( dpy, CMD_ATOM ) )
	{
		XUngrabServer( dpy );
		XCloseDisplay( dpy );
		return FALSE;
	}
	XSetSelectionOwner( dpy, CMD_ATOM, DefaultRootWindow( dpy ), CurrentTime );
	XUngrabServer( dpy );
	return TRUE;
}
コード例 #4
0
ファイル: test.c プロジェクト: jordansissel/ifwm
Bool keydown(wm_t *wm, wm_event_t *event) {
  XKeyEvent kev = event->xevent->xkey;
  KeySym sym;

  wm_log(wm, LOG_INFO, "%s", __func__);
  sym = XKeycodeToKeysym(wm->dpy, kev.keycode, 0);
  wm_log(wm, LOG_INFO, "%s: key %d / %d", __func__, sym, XK_j);
  if (kev.state == Mod1Mask) {
    switch (sym) {
      case XK_j:
        container_split(current_container, SPLIT_VERTICAL);
        break;
      case XK_h:
        container_split(current_container, SPLIT_HORIZONTAL);
        break;
      default:
        wm_log(wm, LOG_WARN, "%s: unexpected keysym %d", __func__, sym);
    }
  }
  switch (sym) {
    case XK_Return:
      run("xterm -bg black -fg white");
      break;
  }
  XUngrabServer(wm->dpy);
  return True;
}
コード例 #5
0
static gboolean
drw_selection_find_existing (DrwSelection *drw_selection)
{
	Display *xdisplay = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
	Window old;

	gdk_error_trap_push ();
	old = XGetSelectionOwner (xdisplay,
				  gdk_x11_get_xatom_by_name (SELECTION_NAME));
	if (old) {
		XSelectInput (xdisplay, old, StructureNotifyMask);
		drw_selection->owner_window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), old);
	}
	XSync (xdisplay, False);

	if (gdk_error_trap_pop () == 0 && drw_selection->owner_window) {
		gdk_window_add_filter (drw_selection->owner_window,
				       drw_selection_filter, drw_selection);

		XUngrabServer (xdisplay);

		return TRUE;
	} else {
		if (drw_selection->owner_window) {
			g_object_unref (drw_selection->owner_window);
			drw_selection->owner_window = NULL;
		}

		return FALSE;
	}
}
コード例 #6
0
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);
	}
}
コード例 #7
0
ファイル: resize.c プロジェクト: dkogan/notion
bool moveresmode_do_end(WMoveresMode *mode, bool apply)
{
    WRegion *reg=mode->reg;

    assert(reg!=NULL);
    assert(tmpmode==mode);

    tmpmode=NULL;

    if(XOR_RESIZE){
        moveres_draw_rubberband(mode);
        if(apply){
            WRQGeomParams rq=RQGEOMPARAMS_INIT;

            rq.geom=mode->geom;
            rq.flags=mode->rqflags&~REGION_RQGEOM_TRYONLY;

            region_rqgeom(reg, &rq, &mode->geom);
        }
        XUngrabServer(ioncore_g.dpy);
    }
    if(apply)
        set_saved(mode, reg);

    if(mode->infowin!=NULL){
        mainloop_defer_destroy((Obj*)mode->infowin);
        mode->infowin=NULL;
    }
    destroy_obj((Obj*)mode);

    return TRUE;
}
コード例 #8
0
ファイル: plexywindows.cpp プロジェクト: kshamindra/plexydesk
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();
}
コード例 #9
0
ファイル: relais_ligne.c プロジェクト: robertoxmed/xhextris
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;
}
コード例 #10
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);
	}
}
コード例 #11
0
void ude_ungrab_server(UDEDesktop *desk)
{
  desk->internal.sgrabstat--;
  if(desk->internal.sgrabstat < 0)
    ude_error_exit(1,"tried to ungrab ungrabbed server.");
  if(!desk->internal.sgrabstat) XUngrabServer(desk->disp);
}
コード例 #12
0
ファイル: remote_x.c プロジェクト: moriyoshi/mod_vim
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;
}
コード例 #13
0
ファイル: workspace.cpp プロジェクト: aaronblanchard/Quantum
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 );
}
コード例 #14
0
ファイル: fvwm.c プロジェクト: rn10950/FVWM95-Updated
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);
}
コード例 #15
0
ファイル: eggtrayicon.c プロジェクト: krzyzanowskim/GNUGadu
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);
	}
}
コード例 #16
0
ファイル: clipboard.c プロジェクト: ronhuang/pcmanx-gtk2
/*
 * 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;
}
コード例 #17
0
ファイル: gui_tray.c プロジェクト: chinese-opendesktop/oxim
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;
}
コード例 #18
0
ファイル: windowgrabber.cpp プロジェクト: KDE/ksnapshot
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();
}
コード例 #19
0
ファイル: session.c プロジェクト: cz172638/wdm
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);
}
コード例 #20
0
ファイル: X11Utils.cpp プロジェクト: adit-chandra/dolphin
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);
}
コード例 #21
0
ファイル: tray.c プロジェクト: adaptee/fcitx
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;
}
コード例 #22
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);
}
コード例 #23
0
ファイル: tray_widget.c プロジェクト: voidptr/xneur-option
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);
}
コード例 #24
0
ファイル: qsystemtray.cpp プロジェクト: alick/mytunet
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);
    }
}
コード例 #25
0
ファイル: riftwm.c プロジェクト: nandor/riftwm
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);
}
コード例 #26
0
ファイル: client.cpp プロジェクト: druon/Beziers_wm
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);


}
コード例 #27
0
ファイル: screen.c プロジェクト: yugecin/evilwm
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;
        }
    }
}
コード例 #28
0
ファイル: update.cpp プロジェクト: KeithDHedger/XDecorations
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);
}
コード例 #29
0
ファイル: client.c プロジェクト: clivecrous/evilpoison
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");
}
コード例 #30
0
ファイル: session.c プロジェクト: bbidulock/wdm
void UnsecureDisplay(struct display *d, Display * dpy)
{
	WDMDebug("Unsecure display %s\n", d->name);
	if (d->grabServer) {
		XUngrabServer(dpy);
		XSync(dpy, 0);
	}
}