~ubuntu-branches/ubuntu/maverick/xbill/maverick

« back to all changes in this revision

Viewing changes to x11.cc

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Bridgett
  • Date: 2001-06-24 22:44:40 UTC
  • Revision ID: james.westby@ubuntu.com-20010624224440-r8kbgt5ae7q1230g
Tags: upstream-2.0
ImportĀ upstreamĀ versionĀ 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "objects.h"
 
2
#include "x11.h"
 
3
 
 
4
static int in_popup = 0;
 
5
 
 
6
/**********************/
 
7
/* Callback functions */
 
8
/**********************/
 
9
 
 
10
void new_game_cb (Widget w, XtPointer client_data, XtPointer call_data) {
 
11
        game.start(1);
 
12
}
 
13
 
 
14
void quit_game_cb (Widget w, XtPointer client_data, XtPointer call_data) {
 
15
        game.quit();
 
16
}
 
17
 
 
18
void get_coords (Position *x, Position *y) {
 
19
        XWindowAttributes wattr;
 
20
        Window junk;
 
21
        int rx, ry;
 
22
        XGetWindowAttributes (ui.display, ui.window, &wattr);
 
23
        XTranslateCoordinates (ui.display, ui.window, wattr.root,
 
24
                -wattr.border_width, -wattr.border_width, &rx, &ry, &junk);
 
25
        *x=rx+20;
 
26
        *y=ry+40;
 
27
}
 
28
 
 
29
void popup (Widget w, Widget *box, XtPointer call_data) {
 
30
        Position x, y;
 
31
        in_popup = 1;
 
32
#ifdef athena
 
33
        get_coords(&x, &y);
 
34
        XtMoveWidget(XtParent(*box), x, y);
 
35
#endif
 
36
        XtManageChild(*box);
 
37
        XtAddCallback(XtParent(*box), XtNpopdownCallback,
 
38
                (XtCallbackProc) popdown, NULL);
 
39
        XtPopup(XtParent(*box), XtGrabExclusive);
 
40
        while (in_popup || XtAppPending(ui.app))
 
41
                XtAppProcessEvent(ui.app, XtIMXEvent);
 
42
}
 
43
 
 
44
void popdown (Widget w, XtPointer client_data, XtPointer call_data) {
 
45
        in_popup = 0;
 
46
}
 
47
 
 
48
/******************/
 
49
/* Event handlers */
 
50
/******************/
 
51
 
 
52
void leave_window_eh(Widget w, XtPointer client_data, XEvent *event) {
 
53
        ui.pause_game();
 
54
}
 
55
 
 
56
void enter_window_eh(Widget w, XtPointer client_data, XEvent *event) {
 
57
        ui.resume_game();
 
58
}
 
59
 
 
60
void redraw_window_eh(Widget w, XtPointer client_data, XEvent *event) {
 
61
        ui.refresh();
 
62
}
 
63
 
 
64
void button_press_eh(Widget w, XtPointer data, XButtonEvent *event) {
 
65
        game.button_press(event->x, event->y);
 
66
}
 
67
 
 
68
void button_release_eh(Widget w, XtPointer data, XButtonEvent *event) {
 
69
        game.button_release(event->x, event->y);
 
70
}
 
71
 
 
72
void timer_eh(XtPointer client_data, XtIntervalId *timer_id) {
 
73
        ui.restart_timer();
 
74
        game.update();
 
75
}