/* name: stk_display.cc info: stk display routines - implementation author: Dusan Halicky (dvh.tosomja@post.sk) licence: GNU GPL history: 2005-09-27 - start of developement todo: - finish and release this bugs: - */ // system header files #include #include #include // local header files #include "stk_constants.h" // this file header #include "stk_display.h" // debugging #ifdef STK_DEBUG #define STK_DISPLAY_DEBUG #endif // implementation Display *stkdisplay; int stkdisplay_screen; int stkdisplay_width; int stkdisplay_height; Window stkdisplay_root; // open the display Display *stk_display_open(char *display_name) { // open stkdisplay and set variables #ifdef STK_DISPLAY_DEBUG printf("stk_open_display: opening display '%s' ..",display_name); #endif Display *dpy = XOpenDisplay(display_name); if (!dpy) { printf(". error, cannot open display!\n"); exit(1); } #ifdef STK_DISPLAY_DEBUG else { printf(". done\n"); } #endif // get various useful infos stkdisplay_screen = DefaultScreen(dpy); stkdisplay_width = DisplayWidth(dpy, stkdisplay_screen); stkdisplay_height = DisplayHeight(dpy, stkdisplay_screen); stkdisplay_root = DefaultRootWindow(dpy); #ifdef STK_DISPLAY_DEBUG printf("stk_display: screen=%d width=%d height=%d\n",stkdisplay_screen,stkdisplay_width,stkdisplay_height); #endif // return display return dpy; } void stk_display_init(void) { // initialize global display stkdisplay = stk_display_open(0); } void stk_display_done(void) { // release global display #ifdef STK_DISPLAY_DEBUG printf("stk_display: closing display .."); #endif XCloseDisplay(stkdisplay); #ifdef STK_DISPLAY_DEBUG printf(". done\n"); #endif } // end of file