[teklib-general] teklib: tek/mod/visual.h: added tags TVisual_Center, TVisual_Ful...

Timm S. Mueller tmueller at neoscientists.org
Tue May 6 15:33:02 CEST 2008


details:   http://hg.teklib.org/teklib/rev/03b622e1c4b6
changeset: 184:03b622e1c4b6
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Tue May 06 15:31:58 2008 +0200
description:
tek/mod/visual.h: added tags TVisual_Center, TVisual_Fullscreen,
TVisual_Borderless, added UTF-8 keyboard event representation in TIMSG;
display_x11: implemented new tags, initial window position/size/minmax
calculation rewritten; display_x11_inst.c: XEvents no longer casted, but
accessed via union members

diffs (truncated from 357 to 100 lines):

diff -r 88b55fbf34b2 -r 03b622e1c4b6 src/display_x11/display_x11_api.c
--- a/src/display_x11/display_x11_api.c	Sat Apr 26 10:13:19 2008 +0200
+++ b/src/display_x11/display_x11_api.c	Tue May 06 15:31:58 2008 +0200
@@ -2,6 +2,9 @@
 #include "display_x11_mod.h"
 
 static void freepen(TMOD_X11 *mod, VISUAL *v, struct X11Pen *pen);
+
+#define DEF_WINWIDTH 600
+#define DEF_WINHEIGHT 400
 
 /*****************************************************************************/
 
@@ -20,12 +23,16 @@ x11_openvisual(TMOD_X11 *mod, struct TVR
 
 	for (;;)
 	{
-		TBOOL popup = TFALSE;
 		XSetWindowAttributes swa;
 		TUINT swa_mask;
 		XGCValues gcv;
 		TUINT gcv_mask;
 		struct FontNode *fn;
+		XWindowAttributes rootwa;
+
+		/* gain access to root window properties: */
+		XGetWindowAttributes(mod->x11_Display,
+			DefaultRootWindow(mod->x11_Display), &rootwa);
 
 		swa_mask = CWColormap | CWEventMask;
 
@@ -41,43 +48,44 @@ x11_openvisual(TMOD_X11 *mod, struct TVR
 		v->sizehints = XAllocSizeHints();
 		if (v->sizehints == TNULL)
 			break;
-
-		v->winwidth = (TINT)
-			TGetTag(tags, TVisual_PixWidth, (TTAG) -1);
-		v->winheight = (TINT)
-			TGetTag(tags, TVisual_PixHeight, (TTAG) -1);
-
-		v->winwidth = v->winwidth >= 0 ? v->winwidth : 600;
-		v->winheight = v->winheight >= 0 ? v->winheight : 400;
-
-		v->winleft = (TINT) TGetTag(tags, TVisual_WinLeft, -1);
-		v->wintop = (TINT) TGetTag(tags, TVisual_WinTop, -1);
-		if (v->winleft >= 0 || v->wintop >= 0)
-		{
-			v->winleft = TMAX(v->winleft, 0);
-			v->wintop = TMAX(v->wintop, 0);
+		v->sizehints->flags = 0;
+
+		v->title = (TSTRPTR)
+			TGetTag(tags, TVisual_Title, (TTAG) "TEKlib visual");
+
+		/* size/position calculation: */
+
+		v->winwidth = (TINT) TGetTag(tags,
+			TVisual_PixWidth,
+			(TTAG) TMIN(WidthOfScreen(rootwa.screen), DEF_WINWIDTH));
+		v->winheight = (TINT) TGetTag(tags,
+			TVisual_PixHeight,
+			(TTAG) TMIN(HeightOfScreen(rootwa.screen), DEF_WINHEIGHT));
+
+		if (TGetTag(tags, TVisual_Center, TFALSE))
+		{
+			v->winleft = (WidthOfScreen(rootwa.screen) - v->winwidth) / 2;
+			v->wintop = (HeightOfScreen(rootwa.screen) - v->winheight) / 2;
+		}
+		else if (TGetTag(tags, TVisual_Fullscreen, TFALSE))
+		{
+			v->winwidth = WidthOfScreen(rootwa.screen);
+			v->winheight = HeightOfScreen(rootwa.screen);
+			v->winleft = 0;
+			v->wintop = 0;
 			swa_mask |= CWOverrideRedirect;
 			swa.override_redirect = True;
-			popup = TTRUE;
-		}
-
-		v->title = (TSTRPTR)
-			TGetTag(tags, TVisual_Title, (TTAG) "TEKlib visual");
-
-/*		v->colormap = XCreateColormap(mod->x11_Display,
-			RootWindow(mod->x11_Display, mod->x11_Screen),
-			mod->x11_Visual, AllocNone);*/
-
-		v->colormap = DefaultColormap(mod->x11_Display, mod->x11_Screen);
-		if (v->colormap == TNULL)
-			break;
-
-		swa.colormap = v->colormap;
-		swa.event_mask = StructureNotifyMask | ExposureMask;
-
-		v->sizehints->flags = 0;
-
-		if (v->winleft < 0 || v->wintop < 0)
+		}
+		else
+		{


More information about the teklib-general mailing list