source: golgotha/src/i4/video/x11/x11devs.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.6 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef __X11_DEVICES_HPP_
10#define __X11_DEVICES_HPP_
11
12#include <X11/Xlib.h>
13#include <X11/Xutil.h>
14#include <X11/keysym.h>
15
16#include "image/depth.hh"
17#include "image/image8.hh"
18#include "image/image16.hh"
19#include "image/image32.hh"
20#include "video/display.hh"
21#include "video/x11/mitshm.hh"
22#include "time/time.hh"
23
24class x11_display_class : public i4_display_class
25
26private:
27  i4_bool open_display();
28  void close_display();
29
30  // assumes that the display has already been grabbed
31  i4_bool open_X_window(w32 width, w32 height, i4_display_class::mode *mode);
32  void    create_X_image(w32 width, w32 height);
33  void    destroy_X_image();
34  void    close_X_window();
35
36  // returns false if an error occured
37  i4_bool copy_part_to_vram(i4_coord x, i4_coord y,
38                            i4_coord x1, i4_coord y1,
39                            i4_coord x2, i4_coord y2);
40
41  class x11_mode : public mode
42  {
43  public:
44    i4_display_class *assoc;     // pointer to use, so we can confirm we created this mode
45  };
46    x11_mode amode, cur_mode;
47
48  // generic image which will take the type of the screen when we copy the save portion
49  i4_image_class *mouse_pict;   
50
51  I4_SCREEN_TYPE *mouse_save,
52                 *screen;
53
54  i4_coord mouse_x,mouse_y;
55
56
57 
58protected:
59  class x11_device_manager : public i4_device_class     // maintains the mouse & keyboard
60    {
61  private:
62      void get_x_time(w32 xtick, i4_time_class &t);
63      i4_time_class i4_start_time;
64      i4_bool need_first_time;
65      sw32 x11_start_time, x11_start_time_best_diff, first_time;
66      x11_display_class *parent;
67      w16 modifier_state;            // keyboard shift state
68  public:
69      char *name() { return "x11 device manager"; }
70      virtual i4_bool process_events();       // returns true if an event was dispatched
71      x11_device_manager();
72     
73      virtual device_flags reports_events()
74    {
75      return FLAG_MOUSE_MOVE|
76        FLAG_MOUSE_BUTTON_DOWN|
77        FLAG_MOUSE_BUTTON_UP|
78        FLAG_KEY_PRESS|
79        FLAG_KEY_RELEASE|
80        FLAG_DISPLAY_CHANGE;
81    }
82
83  };
84    x11_device_manager devs;
85
86  i4_draw_context_class *context;
87
88public:
89  i4_bool mouse_locked;
90  i4_coord                 mouse_hot_x,mouse_hot_y;
91  i4_pal_handle_class      mouse_pal;
92  i4_color                 mouse_trans;
93  x11_shm_extension_class *shm_extension;
94  x11_shm_image_class     *shm_image;
95  XImage                  *ximage;
96  Colormap                 xcolor_map;
97  XVisualInfo             *my_visual;
98  int                      screen_num;
99  Display                 *display;
100  Window                   mainwin;
101  GC                       gc;
102 
103  virtual i4_bool set_mouse_shape(i4_cursor_class *cursor);
104
105  virtual i4_image_class *get_screen();
106
107  virtual w16 width() const { return screen->width(); }
108  virtual w16 height() const { return screen->height(); }
109
110  // makes the physical display consistant with previous gfx calls
111  // either through page flipping or copying dirty rects from an
112  // off-screen buffer
113  virtual void flush();
114
115  // returns some descriptive name for this display
116  virtual char *name();
117
118  virtual i4_draw_context_class *get_context() { return context; }
119  x11_display_class();
120
121  virtual mode *current_mode() { return &cur_mode; }
122  virtual mode *get_first_mode();
123  virtual mode *get_next_mode(mode *last_mode);
124
125
126  // initialize_mode need not call close() to switch to another mode
127  virtual i4_bool initialize_mode(mode *which_one);
128
129  // should be called before a program quits
130  virtual i4_bool close();
131  virtual i4_bool available();
132
133  // loads palette into hardware registers, return i4_F if pal_id is wrong color depth for display
134  virtual i4_bool realize_palette(i4_pal_handle_class pal_id);
135
136  virtual i4_bool lock_mouse_in_place(i4_bool yes_no)
137  {
138    mouse_locked=yes_no;
139    return i4_T;
140  }
141
142  virtual i4_bool display_busy() const
143    {
144    //    if (shm_extension && shm_extension->need_sync_event)
145    //      return i4_T;
146    //    else
147    return i4_F;
148  }
149  };
150
151extern x11_display_class x11_display_instance;
152
153#endif
154
155
156
Note: See TracBrowser for help on using the repository browser.