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 ); } }
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)); } }
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; } } }
void _gfx_platform_window_set_name( GFX_PlatformWindow handle, const char* name) { XStoreName(_gfx_x11.display, GFX_VOID_TO_UINT(handle), name); }
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 ); }
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; }
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; }
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); }
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; }
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; } }