FreeCalypso > hg > freecalypso-sw
comparison lcdemu/window.c @ 903:312778104f54
lcdemu started, compiles and runs w/o actual functionality
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 07 Sep 2015 08:34:37 +0000 |
parents | |
children | e54abee27e8f |
comparison
equal
deleted
inserted
replaced
902:4423039aeb4b | 903:312778104f54 |
---|---|
1 /* | |
2 * LCDemu based on HECterm by the same author | |
3 * X11 window creation functions | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <X11/Xlib.h> | |
9 #include <X11/Xresource.h> | |
10 #include <X11/Xutil.h> | |
11 #include "globals.h" | |
12 | |
13 extern char *xrm_lookup(); | |
14 | |
15 create_our_window() | |
16 { | |
17 XrmQuark instquarks[3], classquarks[3]; | |
18 register char *cp; | |
19 register int i, geomask; | |
20 int pixwidth, pixheight, xpos, ypos; | |
21 XSetWindowAttributes xswa; | |
22 u_long xswamask; | |
23 XColor bdcolor; | |
24 XClassHint xclasshint; | |
25 XWMHints wmhints; | |
26 | |
27 /* Determine our geometry */ | |
28 instquarks[0] = xrmquark_topinstance; | |
29 classquarks[0] = xrmquark_topclass; | |
30 classquarks[1] = instquarks[1] = XrmStringToQuark("geometry"); | |
31 instquarks[2] = classquarks[2] = NULLQUARK; | |
32 cp = xrm_lookup(instquarks, classquarks); | |
33 if (cp) { | |
34 geomask = XParseGeometry(cp, &xpos, &ypos, &pixwidth, | |
35 &pixheight); | |
36 free(cp); | |
37 } else | |
38 geomask = 0; | |
39 if (!(geomask & WidthValue)) | |
40 pixwidth = 176; | |
41 if (!(geomask & HeightValue)) | |
42 pixheight = 220; | |
43 if (!(geomask & XValue)) | |
44 xpos = 0; | |
45 else if (geomask & XNegative) | |
46 xpos += DisplayWidth(mydisplay, DefaultScreen(mydisplay)) - | |
47 pixwidth; | |
48 if (!(geomask & YValue)) | |
49 ypos = 0; | |
50 else if (geomask & YNegative) | |
51 ypos += DisplayHeight(mydisplay, DefaultScreen(mydisplay)) - | |
52 pixheight; | |
53 /* fill out XSetWindowAttributes */ | |
54 xswa.event_mask = 0; /* not interested in any events */ | |
55 xswamask = CWEventMask; | |
56 /* border color */ | |
57 classquarks[1] = instquarks[1] = XrmStringToQuark("borderColor"); | |
58 cp = xrm_lookup(instquarks, classquarks); | |
59 if (cp) { | |
60 i = XParseColor(mydisplay, DefaultColormap(mydisplay, | |
61 DefaultScreen(mydisplay)), cp, &bdcolor); | |
62 free(cp); | |
63 if (i) { | |
64 i = XAllocColor(mydisplay, DefaultColormap(mydisplay, | |
65 DefaultScreen(mydisplay)), &bdcolor); | |
66 if (i) { | |
67 xswa.border_pixel = bdcolor.pixel; | |
68 xswamask |= CWBorderPixel; | |
69 } | |
70 } | |
71 } | |
72 /* border width */ | |
73 classquarks[1] = instquarks[1] = XrmStringToQuark("borderWidth"); | |
74 cp = xrm_lookup(instquarks, classquarks); | |
75 if (cp) { | |
76 i = atoi(cp); | |
77 free(cp); | |
78 } else | |
79 i = 2; | |
80 /* go for it! */ | |
81 mainwindow = XCreateWindow(mydisplay, DefaultRootWindow(mydisplay), | |
82 xpos, ypos, pixwidth, pixheight, i, CopyFromParent, | |
83 InputOutput, CopyFromParent, xswamask, &xswa); | |
84 /* set window manager properties */ | |
85 xclasshint.res_name = proginstancename; | |
86 xclasshint.res_class = "LEDemu"; | |
87 XSetClassHint(mydisplay, mainwindow, &xclasshint); | |
88 wmhints.flags = InputHint | StateHint; | |
89 wmhints.input = False; | |
90 classquarks[1] = instquarks[1] = XrmStringToQuark("iconic"); | |
91 cp = xrm_lookup(instquarks, classquarks); | |
92 if (cp) { | |
93 i = parse_boolean_resource(cp); | |
94 free(cp); | |
95 } else | |
96 i = 0; | |
97 wmhints.initial_state = i ? IconicState : NormalState; | |
98 XSetWMHints(mydisplay, mainwindow, &wmhints); | |
99 #if 0 | |
100 if (geomask & (WidthValue|HeightValue)) | |
101 wm_normal_hints.flags = USSize; | |
102 else | |
103 wm_normal_hints.flags = PSize; | |
104 if (geomask & (XValue|YValue)) | |
105 wm_normal_hints.flags |= USPosition; | |
106 set_wm_normal_hints(); | |
107 #endif | |
108 } | |
109 | |
110 #if 0 | |
111 set_wm_normal_hints() | |
112 { | |
113 wm_normal_hints.min_width = MIN_COLUMNS * charcell_width; | |
114 wm_normal_hints.min_height = MIN_LINES * charcell_height; | |
115 wm_normal_hints.max_width = MAX_COLUMNS * charcell_width; | |
116 wm_normal_hints.max_height = MAX_LINES * charcell_height; | |
117 wm_normal_hints.width_inc = charcell_width; | |
118 wm_normal_hints.height_inc = charcell_height; | |
119 wm_normal_hints.base_width = 0; | |
120 wm_normal_hints.base_height = 0; | |
121 wm_normal_hints.flags |= PMinSize | PMaxSize | PResizeInc | PBaseSize; | |
122 XSetWMNormalHints(mydisplay, mainwindow, &wm_normal_hints); | |
123 } | |
124 #endif | |
125 | |
126 set_initial_window_title() | |
127 { | |
128 XrmQuark instquarks[3], classquarks[3]; | |
129 register char *cp; | |
130 char buf[256]; | |
131 | |
132 instquarks[0] = xrmquark_topinstance; | |
133 classquarks[0] = xrmquark_topclass; | |
134 instquarks[1] = XrmStringToQuark("title"); | |
135 classquarks[1] = XrmStringToQuark("Title"); | |
136 instquarks[2] = classquarks[2] = NULLQUARK; | |
137 cp = xrm_lookup(instquarks, classquarks); | |
138 if (cp) { | |
139 XStoreName(mydisplay, mainwindow, cp); | |
140 free(cp); | |
141 return; | |
142 } | |
143 XStoreName(mydisplay, mainwindow, "Emulated LCD"); | |
144 } | |
145 | |
146 set_initial_icon_name() | |
147 { | |
148 XrmQuark instquarks[3], classquarks[3]; | |
149 register char *cp; | |
150 | |
151 instquarks[0] = xrmquark_topinstance; | |
152 classquarks[0] = xrmquark_topclass; | |
153 instquarks[1] = XrmStringToQuark("iconName"); | |
154 classquarks[1] = XrmStringToQuark("IconName"); | |
155 instquarks[2] = classquarks[2] = NULLQUARK; | |
156 cp = xrm_lookup(instquarks, classquarks); | |
157 if (cp) { | |
158 XSetIconName(mydisplay, mainwindow, cp); | |
159 free(cp); | |
160 return; | |
161 } | |
162 XSetIconName(mydisplay, mainwindow, proginstancename); | |
163 } | |
164 | |
165 create_mainwin_gc() | |
166 { | |
167 XGCValues xgcval; | |
168 | |
169 xgcval.graphics_exposures = False; | |
170 mainwingc = XCreateGC(mydisplay, mainwindow, GCGraphicsExposures, | |
171 &xgcval); | |
172 } |