File: xpm_view.cc

package info (click to toggle)
nighthawk 1.0-9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,420 kB
  • ctags: 18,064
  • sloc: fortran: 17,597; cpp: 4,948; makefile: 87; sh: 13
file content (72 lines) | stat: -rw-r--r-- 1,702 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***************************************************************************
*
* For viewing xpm's..
*
***************************************************************************/
extern "C" {
#include <stdio.h>
#include <unistd.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/xpm.h>
#include <X11/keysym.h>
}
#include "defs.h"
#include "misc.h"

/***************************************************************************
*
***************************************************************************/
int main(void)
{
  if(x_init())
  {
    tbm bm;

    XMapWindow(display,window);
    XSync(display,0);
    if(loadxpm("Tobruk/map.xpm",&bm))
    {
      register int running = 1;

      while(running)
      {
        drawxpm_ani(&bm,0,0,0,1);
        XCopyArea(display,render_screen,window,gc_bgblt,0,0,
          window_width,window_height,0,0);
        while(XPending(display))
        {
          XEvent event;

          XNextEvent(display,&event);
          switch(event.type)
          {
            case ButtonPress:
              int win_x_return,win_y_return;
              Window a,b;
              int c,d;
              unsigned int e;

              XQueryPointer(display,window,&a,&b,&c,&d,
                &win_x_return,&win_y_return,&e);
              printf("%d,%d\n",win_x_return,win_y_return);
              break;
            case KeyPress:
              switch(XLookupKeysym((XKeyEvent *)&event,0))
              {
                case 'q':
                  running = 0;
                  break;
              }
              break;
          }
        }
        sleep(1);
      }
      free_bm(&bm);
    }
    Xreaper();
  }
  return 1;
}