Home | History | Annotate | Line # | Download | only in ephyr
      1 /*
      2  * Xephyr - A kdrive X server thats runs in a host X window.
      3  *          Authored by Matthew Allum <mallum (at) o-hand.com>
      4  *
      5  * Copyright  2004 Nokia
      6  *
      7  * Permission to use, copy, modify, distribute, and sell this software and its
      8  * documentation for any purpose is hereby granted without fee, provided that
      9  * the above copyright notice appear in all copies and that both that
     10  * copyright notice and this permission notice appear in supporting
     11  * documentation, and that the name of Nokia not be used in
     12  * advertising or publicity pertaining to distribution of the software without
     13  * specific, written prior permission. Nokia makes no
     14  * representations about the suitability of this software for any purpose.  It
     15  * is provided "as is" without express or implied warranty.
     16  *
     17  * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     18  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     19  * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     20  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     21  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     22  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     23  * PERFORMANCE OF THIS SOFTWARE.
     24  */
     25 
     26 #ifndef _XLIBS_STUFF_H_
     27 #define _XLIBS_STUFF_H_
     28 
     29 #include <X11/X.h>
     30 #include <X11/Xmd.h>
     31 
     32 #define EPHYR_WANT_DEBUG 0
     33 
     34 #if (EPHYR_WANT_DEBUG)
     35 #define EPHYR_DBG(x, a...) \
     36  fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
     37 #else
     38 #define EPHYR_DBG(x, a...) do {} while (0)
     39 #endif
     40 
     41 typedef struct EphyrHostXVars  EphyrHostXVars;
     42 typedef struct EphyrHostXEvent EphyrHostXEvent;
     43 typedef void* EphyrScreenInfo ;
     44 typedef enum EphyrHostXEventType
     45 {
     46   EPHYR_EV_MOUSE_MOTION,
     47   EPHYR_EV_MOUSE_PRESS,
     48   EPHYR_EV_MOUSE_RELEASE,
     49   EPHYR_EV_KEY_PRESS,
     50   EPHYR_EV_KEY_RELEASE,
     51   EPHYR_EV_EXPOSE
     52 }
     53 EphyrHostXEventType;
     54 
     55 /* I can't believe it's not a KeySymsRec. */
     56 typedef struct {
     57   int             minKeyCode;
     58   int             maxKeyCode;
     59   int             mapWidth;
     60   CARD32         *map;
     61 } EphyrKeySyms;
     62 
     63 struct EphyrHostXEvent
     64 {
     65   EphyrHostXEventType type;
     66 
     67   union
     68   {
     69     struct mouse_motion {
     70       int x;
     71       int y;
     72       int screen;
     73       int window;
     74     } mouse_motion;
     75 
     76     struct mouse_down {
     77       int button_num;
     78     } mouse_down;
     79 
     80     struct mouse_up {
     81       int button_num;
     82     } mouse_up;
     83 
     84     struct key_up {
     85       int scancode;
     86     } key_up;
     87 
     88     struct key_down {
     89       int scancode;
     90     } key_down;
     91 
     92     struct expose {
     93       int window;
     94     } expose;
     95 
     96   } data;
     97 
     98   int key_state;
     99 };
    100 
    101 typedef struct {
    102   VisualID visualid;
    103   int screen;
    104   int depth;
    105   int class;
    106   unsigned long red_mask;
    107   unsigned long green_mask;
    108   unsigned long blue_mask;
    109   int colormap_size;
    110   int bits_per_rgb;
    111 } EphyrHostVisualInfo;
    112 
    113 typedef struct {
    114     int x, y;
    115     int width, height ;
    116     int visualid ;
    117 } EphyrHostWindowAttributes;
    118 
    119 typedef struct {
    120     int x,y,width,height;
    121 } EphyrBox;
    122 
    123 typedef struct {
    124     short x1,y1,x2,y2;
    125 } EphyrRect;
    126 
    127 int
    128 hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height);
    129 
    130 int
    131 hostx_want_host_cursor(void);
    132 
    133 void
    134 hostx_use_host_cursor(void);
    135 
    136 void
    137 hostx_use_fullscreen(void);
    138 
    139 int
    140 hostx_want_fullscreen(void);
    141 
    142 int
    143 hostx_want_preexisting_window(EphyrScreenInfo screen);
    144 
    145 void
    146 hostx_use_preexisting_window(unsigned long win_id);
    147 
    148 void
    149 hostx_use_resname (char *name, int fromcmd);
    150 
    151 void
    152 hostx_set_title(char *name);
    153 
    154 void
    155 hostx_handle_signal(int signum);
    156 
    157 int
    158 hostx_init(void);
    159 
    160 void
    161 hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num);
    162 
    163 void
    164 hostx_set_display_name(char *name);
    165 
    166 void
    167 hostx_set_screen_number(EphyrScreenInfo screen, int number);
    168 
    169 void
    170 hostx_set_win_title(EphyrScreenInfo screen, char *extra_text);
    171 
    172 int
    173 hostx_get_depth (void);
    174 
    175 int
    176 hostx_get_server_depth (EphyrScreenInfo screen);
    177 
    178 void
    179 hostx_set_server_depth(EphyrScreenInfo screen, int depth);
    180 
    181 int
    182 hostx_get_bpp(void *info);
    183 
    184 void
    185 hostx_get_visual_masks (void   *info,
    186 			CARD32 *rmsk,
    187 			CARD32 *gmsk,
    188 			CARD32 *bmsk);
    189 void
    190 hostx_set_cmap_entry(unsigned char idx,
    191 		     unsigned char r,
    192 		     unsigned char g,
    193 		     unsigned char b);
    194 
    195 void*
    196 hostx_screen_init (EphyrScreenInfo screen,
    197                    int width, int height,
    198                    int buffer_height);
    199 
    200 void
    201 hostx_paint_rect(EphyrScreenInfo screen,
    202 		 int sx,    int sy,
    203 		 int dx,    int dy,
    204 		 int width, int height);
    205 
    206 
    207 void
    208 hostx_load_keymap (void);
    209 
    210 int
    211 hostx_get_event (EphyrHostXEvent *ev);
    212 
    213 void*
    214 hostx_get_display (void) ;
    215 
    216 int
    217 hostx_get_window (int a_screen_number) ;
    218 
    219 int
    220 hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attr)  ;
    221 
    222 int
    223 hostx_get_extension_info (const char *a_ext_name,
    224                           int *a_major_opcode,
    225                           int *a_first_even,
    226                           int *a_first_error) ;
    227 int
    228 hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
    229                         int *a_num_entries) ;
    230 
    231 int hostx_create_window (int a_screen_number,
    232                          EphyrBox *a_geometry,
    233                          int a_visual_id,
    234                          int *a_host_win /*out parameter*/) ;
    235 
    236 int hostx_destroy_window (int a_win) ;
    237 
    238 int hostx_set_window_geometry (int a_win, EphyrBox *a_geo) ;
    239 
    240 
    241 int hostx_set_window_bounding_rectangles (int a_window,
    242                                           EphyrRect *a_rects,
    243                                           int a_num_rects) ;
    244 
    245 int hostx_set_window_clipping_rectangles (int a_window,
    246                                           EphyrRect *a_rects,
    247                                           int a_num_rects) ;
    248 int hostx_has_xshape (void) ;
    249 
    250 #ifdef XF86DRI
    251 int hostx_lookup_peer_window (void *a_local_window,
    252                               int *a_host_peer /*out parameter*/) ;
    253 int
    254 hostx_allocate_resource_id_peer (int a_local_resource_id,
    255                                  int *a_remote_resource_id) ;
    256 int
    257 hostx_get_resource_id_peer (int a_local_resource_id,
    258                             int *a_remote_resource_id) ;
    259 int hostx_has_dri (void) ;
    260 
    261 int hostx_has_glx (void) ;
    262 #endif /* XF86DRI */
    263 
    264 #endif /*_XLIBS_STUFF_H_*/
    265