示例#1
0
void _gfx_platform_window_set_position(

		GFX_PlatformWindow  handle,
		int                 x,
		int                 y)
{
	/* Check if fullscreen */
	GFX_X11_Window* it = _gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));
	if(it && !(it->flags & GFX_X11_FULLSCREEN))
	{
		/* Get window's monitor position */
		int xM = 0;
		int yM = 0;

		if(it->monitor)
		{
			xM = it->monitor->x;
			yM = it->monitor->y;
		}

		XMoveWindow(
			_gfx_x11.display,
			GFX_VOID_TO_UINT(handle),
			x + xM,
			y + yM
		);
	}
}
示例#2
0
void _gfx_platform_window_hide(

		GFX_PlatformWindow handle)
{
	GFX_X11_Window* internal =
		_gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));

	if(internal)
	{
		internal->flags |= GFX_X11_HIDDEN;
		XUnmapWindow(_gfx_x11.display, GFX_VOID_TO_UINT(handle));
	}
}
示例#3
0
void _gfx_platform_window_get_position(

		GFX_PlatformWindow  handle,
		int*                x,
		int*                y)
{
	GFX_X11_Window* internal =
		_gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));

	if(!internal)
	{
		*x = 0;
		*y = 0;
	}
	else
	{
		*x = internal->x;
		*y = internal->y;

		/* Get window's monitor position */
		if(internal->monitor)
		{
			*x -= internal->monitor->x;
			*y -= internal->monitor->y;
		}
	}
}
示例#4
0
void _gfx_platform_window_set_name(

		GFX_PlatformWindow  handle,
		const char*         name)
{
	XStoreName(_gfx_x11.display, GFX_VOID_TO_UINT(handle), name);
}
示例#5
0
void _gfx_platform_window_set_size(

		GFX_PlatformWindow  handle,
		unsigned int        width,
		unsigned int        height)
{
	GFX_X11_Window* internal =
		_gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));

	if(internal && (internal->flags & GFX_X11_RESIZABLE))
		XResizeWindow(
			_gfx_x11.display,
			GFX_VOID_TO_UINT(handle),
			width,
			height
		);
}
示例#6
0
GFX_PlatformMonitor _gfx_platform_window_get_monitor(

		GFX_PlatformWindow handle)
{
	GFX_X11_Window* it = _gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));
	if(it) return it->monitor;

	return NULL;
}
示例#7
0
int _gfx_platform_thread_join(

		GFX_PlatformThread  thread,
		unsigned int*       ret)
{
	void* val = NULL;
	if(pthread_join(thread, &val)) return 0;

	if(ret) *ret = GFX_VOID_TO_UINT(val);

	return 1;
}
示例#8
0
void _gfx_platform_window_free(

		GFX_PlatformWindow handle)
{
	GFX_X11_Window* it =
		_gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));

	/* Get attributes */
	XWindowAttributes attr;
	XGetWindowAttributes(_gfx_x11.display, GFX_VOID_TO_UINT(handle), &attr);

	/* Make sure to undo fullscreen */
	if(it->flags & GFX_X11_FULLSCREEN)
		_gfx_x11_leave_fullscreen(it->monitor);

	/* Destroy context, the window and its colormap */
	_gfx_platform_context_clear(handle);
	XDestroyWindow(_gfx_x11.display, GFX_VOID_TO_UINT(handle));
	XFreeColormap(_gfx_x11.display, attr.colormap);

	/* Remove from vector */
	gfx_vector_erase(&_gfx_x11.windows, it);
}
示例#9
0
char* _gfx_platform_window_get_name(

		GFX_PlatformWindow handle)
{
	/* Check if it has a name */
	char* buff;
	XFetchName(_gfx_x11.display, GFX_VOID_TO_UINT(handle), &buff);
	if(!buff) return NULL;

	/* Copy to client side memory */
	char* name = malloc(strlen(buff) + 1);
	strcpy(name, buff);

	XFree(buff);

	return name;
}
示例#10
0
void _gfx_platform_window_get_size(

		GFX_PlatformWindow  handle,
		unsigned int*       width,
		unsigned int*       height)
{
	GFX_X11_Window* internal =
		_gfx_x11_get_window_from_handle(GFX_VOID_TO_UINT(handle));

	if(!internal)
	{
		*width = 0;
		*height = 0;
	}
	else
	{
		*width = internal->width;
		*height = internal->height;
	}
}