Skip to content
Snippets Groups Projects
Commit 43fd6160 authored by deuce's avatar deuce
Browse files

Add get_window_info() function which attempts to return the size and

position of the output window.
parent 4c21c673
No related branches found
No related tags found
No related merge requests found
...@@ -108,6 +108,7 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void); ...@@ -108,6 +108,7 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_insline(void);
CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt); CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt);
CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen); CIOLIBEXPORT void CIOLIBCALL ciolib_copytext(const char *text, size_t buflen);
CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void); CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void);
CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos);
#define CIOLIB_INIT() { if(initialized != 1) initciolib(CIOLIB_MODE_AUTO); } #define CIOLIB_INIT() { if(initialized != 1) initciolib(CIOLIB_MODE_AUTO); }
...@@ -145,6 +146,7 @@ int try_sdl_init(int mode) ...@@ -145,6 +146,7 @@ int try_sdl_init(int mode)
cio_api.setfont=sdl_setfont; cio_api.setfont=sdl_setfont;
cio_api.getfont=sdl_getfont; cio_api.getfont=sdl_getfont;
cio_api.loadfont=sdl_loadfont; cio_api.loadfont=sdl_loadfont;
cio_api.get_window_info=sdl_get_window_info;
return(1); return(1);
} }
return(0); return(0);
...@@ -179,6 +181,7 @@ int try_x_init(int mode) ...@@ -179,6 +181,7 @@ int try_x_init(int mode)
cio_api.setfont=x_setfont; cio_api.setfont=x_setfont;
cio_api.getfont=x_getfont; cio_api.getfont=x_getfont;
cio_api.loadfont=x_loadfont; cio_api.loadfont=x_loadfont;
cio_api.get_window_info=x_get_window_info;
return(1); return(1);
} }
return(0); return(0);
...@@ -1035,3 +1038,12 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename) ...@@ -1035,3 +1038,12 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename)
else else
return(-1); return(-1);
} }
CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos)
{
CIOLIB_INIT();
if(cio_api.get_window_info!=NULL)
return(cio_api.get_window_info(width,height,xpos,ypos));
return(-1);
}
...@@ -250,6 +250,7 @@ typedef struct { ...@@ -250,6 +250,7 @@ typedef struct {
int (*setfont) (int font, int force); int (*setfont) (int font, int force);
int (*getfont) (void); int (*getfont) (void);
int (*loadfont) (char *filename); int (*loadfont) (char *filename);
int (*get_window_info) (int* width, int* height, int* xpos, int* ypos);
int *ESCDELAY; int *ESCDELAY;
} cioapi_t; } cioapi_t;
...@@ -309,6 +310,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void); ...@@ -309,6 +310,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getcliptext(void);
CIOLIBEXPORT int CIOLIBCALL ciolib_setfont(int font, int force); CIOLIBEXPORT int CIOLIBCALL ciolib_setfont(int font, int force);
CIOLIBEXPORT int CIOLIBCALL ciolib_getfont(void); CIOLIBEXPORT int CIOLIBCALL ciolib_getfont(void);
CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename); CIOLIBEXPORT int CIOLIBCALL ciolib_loadfont(char *filename);
CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int *xpos, int *ypos);
/* DoorWay specific stuff that's only applicable to ANSI mode. */ /* DoorWay specific stuff that's only applicable to ANSI mode. */
CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable); CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
...@@ -362,6 +364,7 @@ CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable); ...@@ -362,6 +364,7 @@ CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
#define setfont(a,b) ciolib_setfont(a,b) #define setfont(a,b) ciolib_setfont(a,b)
#define getfont() ciolib_getfont() #define getfont() ciolib_getfont()
#define loadfont(a) ciolib_loadfont(a) #define loadfont(a) ciolib_loadfont(a)
#define get_window_info(a,b,c,d) ciolib_get_window_info(a,b,c,d)
#endif #endif
#ifdef WITH_SDL #ifdef WITH_SDL
......
...@@ -183,6 +183,11 @@ int xfd; ...@@ -183,6 +183,11 @@ int xfd;
char window_title[81]; char window_title[81];
char window_name[81]; char window_name[81];
int x11_window_xpos=-1;
int x11_window_ypos=-1;
int x11_window_width=-1;
int x11_window_height=-1;
/* X functions */ /* X functions */
struct x11 { struct x11 {
int (*XChangeGC) (Display*, GC, unsigned long, XGCValues*); int (*XChangeGC) (Display*, GC, unsigned long, XGCValues*);
...@@ -631,6 +636,10 @@ video_event(XEvent *ev) ...@@ -631,6 +636,10 @@ video_event(XEvent *ev)
int r; int r;
oldFS=FontScale; oldFS=FontScale;
x11_window_xpos=ev->xconfigure.x;
x11_window_ypos=ev->xconfigure.y;
x11_window_width=ev->xconfigure.width+ev->xconfigure.border_width*2;
x11_window_height=ev->xconfigure.height+ev->xconfigure.border_width*2;
if((ev->xconfigure.width == FW * DpyCols + 4) if((ev->xconfigure.width == FW * DpyCols + 4)
&& (ev->xconfigure.height == FH * (DpyRows+1) + 4)) && (ev->xconfigure.height == FH * (DpyRows+1) + 4))
break; break;
......
...@@ -78,6 +78,11 @@ extern int x_nextchar; ...@@ -78,6 +78,11 @@ extern int x_nextchar;
extern int console_new_mode; extern int console_new_mode;
extern int x11_window_xpos;
extern int x11_window_ypos;
extern int x11_window_width;
extern int x11_window_height;
int init_window(); int init_window();
int video_init(); int video_init();
int init_mode(int mode); int init_mode(int mode);
......
...@@ -973,6 +973,20 @@ int sdl_getfont(void) ...@@ -973,6 +973,20 @@ int sdl_getfont(void)
return(sdl_current_font); return(sdl_current_font);
} }
int sdl_get_window_info(int *width, int *height, int *xpos, int *ypos)
{
if(width)
*width=vstat.charwidth*vstat.cols*vstat.scaling;
if(height)
*height=vstat.charwidth*vstat.cols*vstat.scaling;
if(xpos)
*xpos=-1;
if(ypos)
*ypos=-1;
return(0);
}
/* Called from event thread only */ /* Called from event thread only */
void sdl_add_key(unsigned int keyval) void sdl_add_key(unsigned int keyval)
{ {
......
...@@ -40,6 +40,7 @@ int sdl_setfont(int font, int force); ...@@ -40,6 +40,7 @@ int sdl_setfont(int font, int force);
int sdl_getfont(void); int sdl_getfont(void);
int sdl_loadfont(char *filename); int sdl_loadfont(char *filename);
int sdl_video_event_thread(void *data); int sdl_video_event_thread(void *data);
int sdl_get_window_info(int *width, int *height, int *xpos, int *ypos);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -337,3 +337,17 @@ int x_loadfont(char *filename) ...@@ -337,3 +337,17 @@ int x_loadfont(char *filename)
{ {
return(x_load_font(filename)); return(x_load_font(filename));
} }
int x_get_window_info(int *width, int *height, int *xpos, int *ypos)
{
if(width)
*width=x11_window_width;
if(height)
*height=x11_window_height;
if(xpos)
*xpos=x11_window_xpos;
if(ypos)
*ypos=x11_window_ypos;
return(0);
}
...@@ -68,6 +68,7 @@ char *x_getcliptext(void); ...@@ -68,6 +68,7 @@ char *x_getcliptext(void);
int x_setfont(int font, int force); int x_setfont(int font, int force);
int x_getfont(void); int x_getfont(void);
int x_loadfont(char *filename); int x_loadfont(char *filename);
int x_get_window_info(int *width, int *height, int *xpos, int *ypos);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment