| 185 | } |
| 186 | |
| 187 | void EventLoop() |
| 188 | { |
| 189 | XEvent e; |
| 190 | for(;;) { |
| 191 | XNextEvent(dpy, &e); |
| 192 | switch( e.type ) |
| 193 | { |
| 194 | case Expose: |
| 195 | { |
| 196 | if (!e.xexpose.count) |
| 197 | Paint(); |
| 198 | } |
| 199 | break; |
| 200 | case ConfigureNotify: |
| 201 | { |
| 202 | if (e.xconfigure.window == w) |
| 203 | Resize( e.xconfigure.width, e.xconfigure.height ); |
| 204 | break; |
| 205 | } |
| 206 | case KeyPress: |
| 207 | if (e.xkey.window == w) |
| 208 | { |
| 209 | char buffer[20]; |
| 210 | int bufsize = 20; |
| 211 | KeySym keysym; |
| 212 | XComposeStatus compose; |
| 213 | int charcount = XLookupString(&e.xkey, buffer, bufsize, &keysym, |
| 214 | &compose); |
| 215 | //printf("keypress(0x%04x)\n", keysym); |
| 216 | OnKeyPress( keysym ); |
| 217 | } |
| 218 | break; |
| 219 | case ButtonPress: |
| 220 | if (e.xbutton.window == w) |
| 221 | { |
| 222 | //printf("buttonpress(0x%04x)\n", e.xbutton.button ); |
| 223 | switch( e.xbutton.button ) |
| 224 | { |
| 225 | case Button4: |
| 226 | doCommand( DCMD_LINEUP, 3 ); |
| 227 | break; |
| 228 | case Button5: |
| 229 | doCommand( DCMD_LINEDOWN, 3 ); |
| 230 | break; |
| 231 | } |
| 232 | } |
| 233 | break; |
| 234 | } |
| 235 | |
| 236 | if (e.type == ButtonRelease) |
| 237 | break; |
| 238 | } |
| 239 | } |
| 240 | }; |
| 241 | |
| 242 | void initHyph(const char * fname) |