Пример #1
0
QRect QxtWindowSystem::windowGeometry(WId window)
{
    int x, y;
    uint width, height, border, depth;
    Window root, child;
    Display* display = QX11Info::display();
    XGetGeometry(display, window, &root, &x, &y, &width, &height, &border, &depth);
    XTranslateCoordinates(display, window, root, x, y, &x, &y, &child);

    static Atom net_frame = 0;
    if (!net_frame)
        net_frame = XInternAtom(QX11Info::display(), "_NET_FRAME_EXTENTS", True);

    QRect rect(x, y, width, height);
    Atom type = 0;
    int format = 0;
    uchar* data = 0;
    ulong count, after;
    if (XGetWindowProperty(display, window, net_frame, 0, 4, False, AnyPropertyType,
                           &type, &format, &count, &after, &data) == Success)
    {
        // _NET_FRAME_EXTENTS, left, right, top, bottom, CARDINAL[4]/32
        if (count == 4)
        {
            long* extents = reinterpret_cast<long*>(data);
            rect.adjust(-extents[0], -extents[2], extents[1], extents[3]);
        }
        if (data)
            XFree(data);
    }
    return rect;
}
Пример #2
0
	Rect X11Window::get_screen_position() const
	{
		XLockDisplay(handle.display);

		Window  root;
		Window  parent;
		Window  child;
		Window* children;
		unsigned int children_count;

		// Get parent Window
		XQueryTree(handle.display, handle.window, &root, &parent, &children, &children_count);
		XFree(children);

		// Get this window's attributes.
		XWindowAttributes attr;
		XGetWindowAttributes(handle.display, handle.window, &attr);

		int xpos;
		int ypos;
		// Get parent window's translation coordinates to root window.
		XTranslateCoordinates(handle.display, parent, root, attr.x, attr.y, &xpos, &ypos, &child);

		return Rect::xywh(xpos, ypos, attr.width, attr.height);
	}
Пример #3
0
void
stubGetWindowGeometry(WindowInfo *window, int *x, int *y, unsigned int *w, unsigned int *h)
{
    Window root, child;
    unsigned int border, depth;
    Display *dpy;

    dpy = stubGetWindowDisplay(window);

    //@todo: Performing those checks is expensive operation, especially for simple apps with high FPS.
    //       Disabling those triples glxgears fps, thus using xevents instead of per frame polling is much more preferred.
    //@todo: Check similar on windows guests, though doubtful as there're no XSync like calls on windows.
    if (window && dpy)
    {
        XLOCK(dpy);
    }

    if (!window
        || !dpy
        || !window->drawable
        || !XGetGeometry(dpy, window->drawable, &root, x, y, w, h, &border, &depth)
        || !XTranslateCoordinates(dpy, window->drawable, root, 0, 0, x, y, &child)) 
    {
        crWarning("Failed to get windows geometry for %p, try xwininfo", window);
        *x = *y = 0;
        *w = *h = 0;
    }

    if (window && dpy)
    {
        XUNLOCK(dpy);
    }
}
Пример #4
0
/*
 * Send the mouse event back to the window manager.
 * So that 9term can tell rio to pop up its button3 menu.
 */
void
_xbouncemouse(Mouse *m)
{
	XButtonEvent e;
	XWindow dw;

	e.type = ButtonPress;
	e.state = 0;
	e.button = 0;
	if(m->buttons&1)
		e.button = 1;
	else if(m->buttons&2)
		e.button = 2;
	else if(m->buttons&4)
		e.button = 3;
	e.same_screen = 1;
	XTranslateCoordinates(_x.display, _x.drawable,
		DefaultRootWindow(_x.display),
		m->xy.x, m->xy.y, &e.x_root, &e.y_root, &dw);
	e.root = DefaultRootWindow(_x.display);
	e.window = e.root;
	e.subwindow = None;
	e.x = e.x_root;
	e.y = e.y_root;
#undef time
	e.time = CurrentTime;
	XUngrabPointer(_x.display, m->msec);
	XSendEvent(_x.display, e.root, True, ButtonPressMask, (XEvent*)&e);
	XFlush(_x.display);
}
Пример #5
0
bool GLWindow::processEvent(const XEvent& event)
	{
	bool closeRequested=false;
	switch(event.type)
		{
		case ConfigureNotify:
			{
			/* Retrieve the new window size: */
			windowPos.size[0]=event.xconfigure.width;
			windowPos.size[1]=event.xconfigure.height;
			
			/* Calculate the window's position on the screen: */
			Window child;
			XTranslateCoordinates(display,window,root,0,0,&windowPos.origin[0],&windowPos.origin[1],&child);
			break;
			}
		
		case ClientMessage:
			if(event.xclient.message_type==wmProtocolsAtom&&event.xclient.format==32&&(Atom)(event.xclient.data.l[0])==wmDeleteWindowAtom)
				closeRequested=true;
			break;
		}
	
	return closeRequested;
	}
Пример #6
0
gboolean
_gdk_x11_window_simulate_button (GdkWindow      *window,
                                 gint            x,
                                 gint            y,
                                 guint           button, /*1..3*/
                                 GdkModifierType modifiers,
                                 GdkEventType    button_pressrelease)
{
    GdkScreen *screen;
    XButtonEvent xev = {
        0,  /* type */
        0,  /* serial */
        1,  /* send_event */
    };
    gboolean success;

    g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
    g_return_val_if_fail (window != NULL, FALSE);

    if (!GDK_WINDOW_IS_MAPPED (window))
        return FALSE;

    screen = gdk_window_get_screen (window);

    if (x < 0 && y < 0)
    {
        x = window->width / 2;
        y = window->height / 2;
    }

    /* Convert to impl coordinates */
    x = x + window->abs_x;
    y = y + window->abs_y;

    xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease;
    xev.display = GDK_WINDOW_XDISPLAY (window);
    xev.window = GDK_WINDOW_XID (window);
    xev.root = RootWindow (xev.display, GDK_X11_SCREEN (screen)->screen_num);
    xev.subwindow = 0;
    xev.time = 0;
    xev.x = x;
    xev.y = y;
    xev.x_root = 0;
    xev.y_root = 0;
    xev.state = modifiers;
    xev.button = button;
    gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
    xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
                      xev.x, xev.y, &xev.x_root, &xev.y_root,
                      &xev.subwindow);
    if (!xev.subwindow)
        xev.subwindow = xev.window;
    success = xev.same_screen;
    success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
    success &= 0 != XSendEvent (xev.display, xev.window, True, button_pressrelease == GDK_BUTTON_PRESS ? ButtonPressMask : ButtonReleaseMask, (XEvent*) &xev);
    XSync (xev.display, False);
    success &= 0 == gdk_x11_display_error_trap_pop(GDK_WINDOW_DISPLAY (window));
    return success;
}
Пример #7
0
void SetTrackPos(FcitxXimFrontend* xim, FcitxInputContext* ic, IMChangeICStruct * call_data)
{
    if (ic == NULL)
        return;

    int i;
    FcitxXimIC* ximic = GetXimIC(ic);
    if (call_data) {
        XICAttribute *pre_attr = ((IMChangeICStruct *) call_data)->preedit_attr;

        for (i = 0; i < (int)((IMChangeICStruct *) call_data)->preedit_attr_num; i++, pre_attr++) {
            if (!strcmp(XNSpotLocation, pre_attr->name)) {
                ximic->bHasCursorLocation = true;
                ximic->offset_x = (*(XPoint *) pre_attr->value).x;
                ximic->offset_y = (*(XPoint *) pre_attr->value).y;
            }
        }
    }

    Window window;
    if (!(window = ximic->focus_win))
        window = ximic->client_win;

    if (window != None) {
        Window dst;
        XWindowAttributes attr;
        XGetWindowAttributes(xim->display, window, &attr);

        if (ximic->offset_x < 0 && ximic->offset_y < 0) {

            XTranslateCoordinates(xim->display, window, RootWindow(xim->display, xim->iScreen),
                                  0, attr.height,
                                  &ic->offset_x, &ic->offset_y,
                                  &dst
                                 );
        } else {
            XTranslateCoordinates(xim->display, window, RootWindow(xim->display, xim->iScreen),
                                  ximic->offset_x, ximic->offset_y,
                                  &ic->offset_x, &ic->offset_y,
                                  &dst);
        }
    }

    if (ic == FcitxInstanceGetCurrentIC(xim->owner))
        FcitxUIMoveInputWindow(xim->owner);
}
Пример #8
0
/** Get the rectangle that makes up the window area.
*/
void getWindowRect(Display *dsp, Window *win, int *x, int *y, unsigned int *w, unsigned int *h)
{
	unsigned int bw,d;
	int junkx, junky;
	Window junkroot =  RootWindow(dsp, 0);
	XGetGeometry(dsp,*win,&junkroot,&junkx,&junky,w,h,&bw,&d);
	XTranslateCoordinates(dsp, *win, junkroot, junkx, junky, x, y, &junkroot);
}
Пример #9
0
void X11Factory::getMonitorInfo( const GenericWindow &rWindow,
                                 int* p_x, int* p_y,
                                 int* p_width, int* p_height ) const
{
    // initialize to default geometry
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();

    // Use Xinerama to determine the monitor where the video
    // mostly resides (biggest surface)
    Display *pDisplay = m_pDisplay->getDisplay();
    Window wnd = (Window)rWindow.getOSHandle();
    Window root = DefaultRootWindow( pDisplay );
    Window child_wnd;

    int x, y;
    unsigned int w, h, border, depth;
    XGetGeometry( pDisplay, wnd, &root, &x, &y, &w, &h, &border, &depth );
    XTranslateCoordinates( pDisplay, wnd, root, 0, 0, &x, &y, &child_wnd );

    int num;
    XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num );
    if( info )
    {
        Region reg1 = XCreateRegion();
        XRectangle rect1 = { (short)x, (short)y, (unsigned short)w, (unsigned short)h };
        XUnionRectWithRegion( &rect1, reg1, reg1 );

        unsigned int surface = 0;
        for( int i = 0; i < num; i++ )
        {
            Region reg2 = XCreateRegion();
            XRectangle rect2 = { info[i].x_org, info[i].y_org,
                                 (unsigned short)info[i].width, (unsigned short)info[i].height };
            XUnionRectWithRegion( &rect2, reg2, reg2 );

            Region reg = XCreateRegion();
            XIntersectRegion( reg1, reg2, reg );
            XRectangle rect;
            XClipBox( reg, &rect );
            unsigned int surf = rect.width * rect.height;
            if( surf > surface )
            {
               surface = surf;
               *p_x = info[i].x_org;
               *p_y = info[i].y_org;
               *p_width = info[i].width;
               *p_height = info[i].height;
            }
            XDestroyRegion( reg );
            XDestroyRegion( reg2 );
        }
        XDestroyRegion( reg1 );
        XFree( info );
    }
}
Пример #10
0
XCTRL_API void get_window_geom(Display *disp, Window win, Geometry*geom)
{
  int x, y;
  unsigned int bw, depth;
  Window root;
  memset(geom,0,sizeof(Geometry));
  XGetGeometry(disp, win, &root, &x, &y, &geom->w, &geom->h, &bw, &depth);
  XTranslateCoordinates (disp, win, root, x, y, &geom->x, &geom->y, &root);
}
Пример #11
0
void get_window_pos_sdl (int *rx, int *ry) {
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);
	if ( SDL_GetWMInfo(&info) > 0 ) {
#ifdef PLATFORM_WINDOWS

#if 0 // legacy
	WINDOWINFO w;
	GetWindowInfo(info.window, &w);
	*x= w.rcWindow.left;
	*y= w.rcWindow.top;
	printf("%ld - %ld\n", w.rcWindow.left, w.rcWindow.top);
#endif
		RECT rect;
		//GetWindowRect() <> SetWindowPos()
		if (GetClientRect(info.window, &rect)) {
			*rx = rect.left;
			*ry = rect.top;
			return;
		}
#elif (defined HAVE_LIBXV || defined HAVE_IMLIB2)
		if (info.subsystem == SDL_SYSWM_X11 ) {
			// NB. with SDL window decorations are not taken into account :(
			Window	dummy;
			info.info.x11.lock_func();
			XTranslateCoordinates(info.info.x11.display, info.info.x11.wmwindow, DefaultRootWindow(info.info.x11.display), 0, 0, rx, ry, &dummy);
			while (dummy !=None) {
				int x = 0;
				int y = 0;
				XTranslateCoordinates(info.info.x11.display, info.info.x11.wmwindow, dummy, 0, 0, &x, &y, &dummy);
				if (dummy!=None) {
					(*rx)-=x; (*ry)-=y;
				} else {
					(*rx)+=x; (*ry)+=y;
				}
			}
			info.info.x11.unlock_func();
			return;
		}
#endif
	}
	if(rx) *rx=1;
	if(ry) *ry=1;
}
Пример #12
0
static void gfx_ctx_destroy(void)
{
   if (g_dpy && g_ctx)
   {
      glXMakeContextCurrent(g_dpy, None, None, NULL);
      glXDestroyContext(g_dpy, g_ctx);
      g_ctx = NULL;
   }

   if (g_win)
   {
      glXDestroyWindow(g_dpy, g_glx_win);
      g_glx_win = 0;

      // Save last used monitor for later.
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, DefaultRootWindow(g_dpy),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   if (g_dpy)
   {
      XCloseDisplay(g_dpy);
      g_dpy = NULL;
   }

   g_inited = false;
   g_pglSwapInterval = NULL;
}
Пример #13
0
void get_window_coordinates(Window win, int *x, int *y, int *w, int *h)
{
	int dummy_int;
	unsigned ww, wh, bw, bh;
	Window src;
	XTranslateCoordinates(server.display, win, server.root_win, 0, 0, x, y, &src);
	XGetGeometry(server.display, win, &src, &dummy_int, &dummy_int, &ww, &wh, &bw, &bh);
	*w = ww + bw;
	*h = wh + bh;
}
Пример #14
0
void TWindow::LocalToRoot(TRect& rect) const
{
	int x, y;
	Window childWindow;
	XTranslateCoordinates(sDisplay, fWindow, gApplication->GetRootWindow(),
										   0, 0, &x, &y, &childWindow);

	const TPoint& scroll = GetScroll();
	rect.Offset(x - scroll.h, y - scroll.v);
}
Пример #15
0
Point2 OS_X11::get_window_position() const {
	int x,y;
	Window child;
	XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child);

	int screen = get_current_screen();
	Point2i screen_position = get_screen_position(screen);

	return Point2i(x-screen_position.x, y-screen_position.y);
}
Пример #16
0
static void __run_complex_function_items(
	cond_rc_t *cond_rc, char cond, FvwmFunction *func,
	const exec_context_t *exc, char *args[], Bool has_ref_window_moved)
{
	char c;
	FunctionItem *fi;
	int x0, y0, x, y;
	extern Window PressedW;

	if (!(!has_ref_window_moved && PressedW && XTranslateCoordinates(
				  dpy, PressedW , Scr.Root, 0, 0, &x0, &y0,
				  &JunkChild)))
	{
		x0 = y0 = 0;
	}

	for (fi = func->first_item; fi != NULL && cond_rc->break_levels == 0; )
	{
		/* make lower case */
		c = fi->condition;
		if (isupper(c))
		{
			c = tolower(c);
		}
		if (c == cond)
		{
			__execute_function(
				cond_rc, exc, fi->action, FUNC_DONT_DEFER,
				args, has_ref_window_moved);
			if (!has_ref_window_moved && PressedW &&
			    XTranslateCoordinates(
				  dpy, PressedW , Scr.Root, 0, 0, &x, &y,
				  &JunkChild))
			{
				has_ref_window_moved =(x != x0 || y != y0);
			}
		}
		fi = fi->next_item;
	}

	return;
}
Пример #17
0
void XVWindow::toggleFullscreen() {
	int newX, newY, newWidth, newHeight;
	Window childWindow;
	XWindowAttributes xwattributes;

	if (_state.fullscreen) {
		// not needed with EWMH fs
		if ( ! (_wmType & wm_FULLSCREEN) ) {
			newX = _state.oldx;
			newY = _state.oldy;
			newWidth = _state.oldWidth;
			newHeight = _state.oldHeight;
			setDecoration(true);
		}

		// removes fullscreen state if wm supports EWMH
		setEWMHFullscreen(_NET_WM_STATE_REMOVE);
	} else {
		// sets fullscreen state if wm supports EWMH
		setEWMHFullscreen(_NET_WM_STATE_ADD);

		// not needed with EWMH fs - save window coordinates/size and discover fullscreen window size
		if ( ! (_wmType & wm_FULLSCREEN) ) {
			newX = 0;
			newY = 0;
			newWidth = DisplayWidth(_display, DefaultScreen(_display));
			newHeight = DisplayHeight(_display, DefaultScreen(_display));

			setDecoration(false);
			XFlush(_display);
			XTranslateCoordinates(_display, _XVWindow, RootWindow(_display, DefaultScreen(_display)),
						0,0,&_state.oldx,&_state.oldy, &childWindow);
			XGetWindowAttributes(_display, _XVWindow, &xwattributes);
			_state.oldWidth = xwattributes.width;
			_state.oldHeight = xwattributes.height;
		}
	}
	 // not needed with EWMH fs - create a screen-filling window on top and turn of decorations
	if (!(_wmType & wm_FULLSCREEN) ) {
		setSizeHints(newX, newY, _XVImage->width, _XVImage->height, newWidth, newHeight);
		setLayer((!_state.fullscreen) ? 0 : 1);
		XMoveResizeWindow(_display, _XVWindow, newX, newY, newWidth, newHeight);
	}

	/* some WMs lose ontop after fullscreeen */
	if ((_state.fullscreen) & _state.ontop) {
		setLayer(1);
	}

	XMapRaised(_display, _XVWindow);
	XRaiseWindow(_display, _XVWindow);
	XFlush(_display);
	_state.fullscreen=!_state.fullscreen;
}
Пример #18
0
void wxWindowX11::DoClientToScreen(int *x, int *y) const
{
    Display *display = wxGlobalDisplay();
    Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display));
    Window thisWindow = (Window) m_clientWindow;

    Window childWindow;
    int xx = *x;
    int yy = *y;
    XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow);
}
Пример #19
0
static GLboolean
getWindowGeometry(GLint *x, GLint *y, GLint *w, GLint *h)
{
	GLboolean retVal = GL_FALSE;
	ErrorFunc prev = XSetErrorHandler(handler);

	if (!windowtracker_spu.dpy) {
		windowtracker_spu.dpy = XOpenDisplay(windowtracker_spu.display);
	}
	if (windowtracker_spu.dpy) {
		Display *dpy = windowtracker_spu.dpy;
		if (!windowtracker_spu.win
				&& windowtracker_spu.window_title
				&& windowtracker_spu.window_title[0]) {
			crDebug("Window Tracker SPU: Looking for window %s",
							windowtracker_spu.window_title);
			windowtracker_spu.win = findWindowByTitle(dpy,
																								DefaultScreen(dpy),
																								DefaultRootWindow(dpy),
																								windowtracker_spu.window_title);
			if (windowtracker_spu.win) {
				crDebug("Window Tracker SPU: found window ID %u (0x%x)",
								(unsigned int) windowtracker_spu.win,
								(unsigned int) windowtracker_spu.win);
			}
		}
		if (windowtracker_spu.win) {
			Window root, child;
			unsigned int width, height, border, depth;
			if (XGetGeometry(windowtracker_spu.dpy, windowtracker_spu.win, &root,
											 x, y, &width, &height, &border, &depth)) {
				int rx, ry;
				if (XTranslateCoordinates(dpy,
																	windowtracker_spu.win,  /* from */
																	DefaultRootWindow(dpy), /* to */
																	*x, *y, &rx, &ry, &child)) {
					*x = rx;
					*y = ry;
				}
				*w = width;
				*h = height;
				retVal = GL_TRUE;
			}
		}
	}

	XSetErrorHandler(prev);

	if (ErrorCaught) {
		crError("Window Tracker SPU: invalid window handle.  Exiting.");
	}

	return retVal;
}
Пример #20
0
Файл: main.c Проект: Abioy/ibus
static void
_xim_set_cursor_location (X11IC *x11ic)
{
    g_return_if_fail (x11ic != NULL);

    GdkRectangle preedit_area = x11ic->preedit_area;

    Window w = x11ic->focus_window ?
        x11ic->focus_window :x11ic->client_window;

    if (w) {
        XWindowAttributes xwa;
        Window child;

        XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), w, &xwa);
        if (preedit_area.x <= 0 && preedit_area.y <= 0) {
             XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), w,
                xwa.root,
                0,
                xwa.height,
                &preedit_area.x,
                &preedit_area.y,
                &child);
        }
        else {
            XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), w,
                xwa.root,
                preedit_area.x,
                preedit_area.y,
                &preedit_area.x,
                &preedit_area.y,
                &child);
        }
    }

    ibus_input_context_set_cursor_location (x11ic->context,
            preedit_area.x,
            preedit_area.y,
            preedit_area.width,
            preedit_area.height);
}
Пример #21
0
static void
get_xy(Window w, unsigned short *x, unsigned short *y)
{
   Display            *d;
   int                 rx, ry;
   Window              child;

   d = Epplet_get_display();
   XTranslateCoordinates(d, w, DefaultRootWindow(d), 0, 0, &rx, &ry, &child);
   *x = rx;
   *y = ry;
}
Пример #22
0
JNIEXPORT int JNICALL Java_sun_awt_X11_XlibWrapper_XTranslateCoordinates
(JNIEnv *env, jclass clazz, jlong display, jlong src_w, jlong dest_w, 
 jlong src_x, jlong src_y, jlong dest_x_return, jlong dest_y_return, 
 jlong child_return)
{
    AWT_CHECK_HAVE_LOCK();   
    return XTranslateCoordinates( (Display *) display, src_w, dest_w,
                  src_x, src_y,
                  (int *) dest_x_return,
                  (int *) dest_y_return,
                  (Window *) child_return);
}
Пример #23
0
static void savegeom() {
        Window root;
        Window child;
        int nx, ny;
        unsigned border;
        unsigned depth;
        XGetGeometry(g_dpy, g_win, &root, 
                     &nx, &ny, &g_nw, &g_nh, 
                     &border, &depth);
        XTranslateCoordinates(g_dpy, g_win, root,
                              -nx, -ny, &g_nx, &g_ny, &child);
}
Пример #24
0
void MwDndDropCoordinates(Widget widget,XEvent *event,int *x,int *y)
{
    int root_x,root_y;
    Window child_return;
    
    MwDndDropRootCoordinates(event,&root_x,&root_y);
    XTranslateCoordinates(dpy,DefaultRootWindow(dpy),
			  XtWindow(widget),
			  root_x,root_y,
			  x,y,
			  &child_return);
}
/*
 * Procedure to make a bubble help widget
 *   Note that background, borderColor, and borderWidth are specified elsewhere
 */
static void makeBubbleHelpWidget(Widget w, char *label)
{
    Window child;
    Widget wparent=XtParent(w);
    XmString xmString;
    Position x,y;
    Dimension width,height;
    Arg args[20];
    int nargs;
    int xroot,yroot;

  /* Destroy any old one */
    if(bubbleHelpWidget) XtDestroyWidget(bubbleHelpWidget);
  /* Get location of widget relative to its parent */
    nargs=0;
    XtSetArg(args[nargs],XmNx,&x); nargs++;
    XtSetArg(args[nargs],XmNy,&y); nargs++;
    XtSetArg(args[nargs],XmNwidth,&width); nargs++;
    XtSetArg(args[nargs],XmNheight,&height); nargs++;
    XtGetValues(w,args,nargs);
  /* Translate the coordinates to the root window
   *  XmNx and XmNy are supposed to be relative to the parent, but they are not.
   *  They are relative to the root window */
    if(XTranslateCoordinates(XtDisplay(w),XtWindow(XtParent(w)),
      RootWindowOfScreen(XtScreen(w)),(int)x,(int)y,&xroot,&yroot,&child)) {
	x=xroot;
	y=yroot;
    }
  /* Create dialog shell */
    nargs=0;
    XtSetArg(args[nargs],XmNmwmDecorations,0); nargs++;
    XtSetArg(args[nargs],XmNmwmFunctions,0); nargs++;
    XtSetArg(args[nargs],XmNx,x+width/2+BUBBLE_DELTAX); nargs++;
    XtSetArg(args[nargs],XmNy,y+height+BUBBLE_DELTAY); nargs++;
    bubbleHelpWidget=XmCreateDialogShell(wparent,"bubbleHelpD",args,nargs);
  /* Create label */
    xmString=XmStringCreateLocalized(label);
    nargs=0;
    XtSetArg(args[nargs],XmNlabelString,xmString); nargs++;
    bubbleHelpWidgetLabel=XmCreateLabel(bubbleHelpWidget,"bubbleHelpDL",
      args,nargs);
    XtManageChild(bubbleHelpWidgetLabel);
    XtManageChild(bubbleHelpWidget);
    XmStringFree(xmString);
  /* Get location of widget */
    nargs=0;
    XtSetArg(args[nargs],XmNx,&x); nargs++;
    XtSetArg(args[nargs],XmNy,&y); nargs++;
    XtSetArg(args[nargs],XmNwidth,&width); nargs++;
    XtSetArg(args[nargs],XmNheight,&height); nargs++;
    XtGetValues(bubbleHelpWidget,args,nargs);
}
Пример #26
0
// origin for our coordinates is the bottom left corner
bool SpringApp::GetDisplayGeometry()
{
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);

	if (!SDL_GetWMInfo(&info)) {
		return false;
	}

#ifndef _WIN32
	info.info.x11.lock_func();
	{
		Display* display = info.info.x11.display;
		Window   window  = info.info.x11.window;

		XWindowAttributes attrs;
		XGetWindowAttributes(display, window, &attrs);
		const Screen* screen = attrs.screen;
		gu->screenSizeX = WidthOfScreen(screen);
		gu->screenSizeY = HeightOfScreen(screen);
		gu->winSizeX = attrs.width;
		gu->winSizeY = attrs.height;

		Window tmp;
		int xp, yp;
		XTranslateCoordinates(display, window, attrs.root, 0, 0, &xp, &yp, &tmp);
		gu->winPosX = xp;
		gu->winPosY = gu->screenSizeY - gu->winSizeY - yp;
	}
	info.info.x11.unlock_func();
#else
	gu->screenSizeX = GetSystemMetrics(SM_CXFULLSCREEN);
	gu->screenSizeY = GetSystemMetrics(SM_CYFULLSCREEN);

	RECT rect;
	if (!GetClientRect(info.window, &rect)) {
		return false;
	}

	if((rect.right - rect.left)==0 || (rect.bottom - rect.top)==0)
		return false;

	gu->winSizeX = rect.right - rect.left;
	gu->winSizeY = rect.bottom - rect.top;

	// translate from client coords to screen coords
	MapWindowPoints(info.window, HWND_DESKTOP, (LPPOINT)&rect, 2);
	gu->winPosX = rect.left;
	gu->winPosY = gu->screenSizeY - gu->winSizeY - rect.top;
#endif // _WIN32
	return true;
}
Пример #27
0
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
{
    Window child;
    int x, y;

    XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
                          0, 0, &x, &y, &child);

    if (xpos)
        *xpos = x;
    if (ypos)
        *ypos = y;
}
Пример #28
0
int BC_Pan::activate(int popup_x, int popup_y)
{
	int x, y;
	Window tempwin;

	active = 0;
	if (popup_x < 0 || popup_y < 0)
	{
		XTranslateCoordinates(top_level->display,
			win,
			top_level->rootwin,
			0,
			0,
			&x,
			&y,
			&tempwin);

		x -= (images[PAN_POPUP]->get_w() - get_w()) / 2;
		y -= (images[PAN_POPUP]->get_h() - get_h()) / 2;
		if (x < 0) x = 0;
	}
	else {
		XTranslateCoordinates(top_level->display,
			top_level->win, top_level->rootwin,
			popup_x, popup_y, &x, &y, &tempwin);
		x -= images[PAN_POPUP]->get_w() / 2;
		y -= images[PAN_POPUP]->get_h() / 2;
		if (x < 0) x = 0;
	}

	delete popup;
	popup = new BC_Popup(this, x, y,
				images[PAN_POPUP]->get_w(),
				images[PAN_POPUP]->get_h(),
				0, 0, images[PAN_POPUP]);
	draw_popup();
	flush();
	return 0;
}
Пример #29
0
void CWinSystemX11::UpdateCrtc()
{
  XWindowAttributes winattr;
  int posx, posy;
  float fps = 0.0f;
  Window child;
  XGetWindowAttributes(m_dpy, m_mainWindow, &winattr);
  XTranslateCoordinates(m_dpy, m_mainWindow, RootWindow(m_dpy, m_nScreen), winattr.x, winattr.y,
                        &posx, &posy, &child);

  m_crtc = g_xrandr.GetCrtc(posx+winattr.width/2, posy+winattr.height/2, fps);
  g_graphicsContext.SetFPS(fps);
}
Пример #30
0
IntPoint getX11WindowPosition(const SDL_SysWMinfo* pSDLWMInfo)
{
    int x, y;
    Window dummy;
    XWindowAttributes wAttribs;
    pSDLWMInfo->info.x11.lock_func();
    XGetWindowAttributes(pSDLWMInfo->info.x11.display, pSDLWMInfo->info.x11.window,
            &wAttribs);
    XTranslateCoordinates(pSDLWMInfo->info.x11.display, pSDLWMInfo->info.x11.window,
            wAttribs.root, 0, 0, &x, &y, &dummy);
    pSDLWMInfo->info.x11.unlock_func();
    return IntPoint(x, y);
}