32 |
extern BOOL grab_keyboard; |
extern BOOL grab_keyboard; |
33 |
extern BOOL hide_decorations; |
extern BOOL hide_decorations; |
34 |
extern char title[]; |
extern char title[]; |
35 |
extern int server_bpp; |
extern int g_server_bpp; |
36 |
extern int win_button_size; |
extern int win_button_size; |
37 |
BOOL enable_compose = False; |
BOOL enable_compose = False; |
38 |
BOOL focused; |
BOOL focused; |
52 |
static XModifierKeymap *mod_map; |
static XModifierKeymap *mod_map; |
53 |
static Cursor current_cursor; |
static Cursor current_cursor; |
54 |
static Atom protocol_atom, kill_atom; |
static Atom protocol_atom, kill_atom; |
|
static long input_mask; /* Needs to be global since we access it in |
|
|
both ui_create_window and the PropertyNotify |
|
|
callback functions */ |
|
55 |
|
|
56 |
/* endianness */ |
/* endianness */ |
57 |
static BOOL host_be; |
static BOOL host_be; |
87 |
} |
} |
88 |
PixelColour; |
PixelColour; |
89 |
|
|
|
struct _PropNotifyCb; |
|
|
|
|
|
typedef struct _PropNotifyCb |
|
|
{ |
|
|
Window wnd; |
|
|
Atom atom; |
|
|
void (*callback) (XPropertyEvent *); |
|
|
struct _PropNotifyCb *next; |
|
|
} |
|
|
PropNotifyCb; |
|
|
|
|
|
|
|
|
static PropNotifyCb *propnotify_callbacks = NULL; |
|
|
|
|
90 |
|
|
91 |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
#define FILL_RECTANGLE(x,y,cx,cy)\ |
92 |
{ \ |
{ \ |
105 |
static Colormap xcolmap; |
static Colormap xcolmap; |
106 |
static uint32 *colmap; |
static uint32 *colmap; |
107 |
|
|
108 |
#define TRANSLATE(col) ( server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) ) |
#define TRANSLATE(col) ( g_server_bpp != 8 ? translate_colour(col) : owncolmap ? col : translate_colour(colmap[col]) ) |
109 |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col)); |
110 |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col)); |
111 |
|
|
218 |
static uint32 |
static uint32 |
219 |
translate_colour(uint32 colour) |
translate_colour(uint32 colour) |
220 |
{ |
{ |
221 |
switch (server_bpp) |
switch (g_server_bpp) |
222 |
{ |
{ |
223 |
case 15: |
case 15: |
224 |
switch (bpp) |
switch (bpp) |
419 |
uint8 *out = (uint8 *) xmalloc(size); |
uint8 *out = (uint8 *) xmalloc(size); |
420 |
uint8 *end = out + size; |
uint8 *end = out + size; |
421 |
|
|
422 |
switch (server_bpp) |
switch (g_server_bpp) |
423 |
{ |
{ |
424 |
case 24: |
case 24: |
425 |
switch (bpp) |
switch (bpp) |
613 |
IM = XOpenIM(display, NULL, NULL, NULL); |
IM = XOpenIM(display, NULL, NULL, NULL); |
614 |
|
|
615 |
xkeymap_init(); |
xkeymap_init(); |
616 |
|
xclip_init(); |
617 |
|
|
618 |
/* todo take this out when high colour is done */ |
/* todo take this out when high colour is done */ |
619 |
printf("server bpp %d client bpp %d depth %d\n", server_bpp, bpp, depth); |
printf("server bpp %d client bpp %d depth %d\n", g_server_bpp, bpp, depth); |
|
|
|
|
|
|
620 |
|
|
621 |
return True; |
return True; |
622 |
} |
} |
644 |
XClassHint *classhints; |
XClassHint *classhints; |
645 |
XSizeHints *sizehints; |
XSizeHints *sizehints; |
646 |
int wndwidth, wndheight; |
int wndwidth, wndheight; |
647 |
long ic_input_mask; |
long input_mask, ic_input_mask; |
648 |
XEvent xevent; |
XEvent xevent; |
649 |
|
|
650 |
wndwidth = fullscreen ? WidthOfScreen(screen) : width; |
wndwidth = fullscreen ? WidthOfScreen(screen) : width; |
758 |
} |
} |
759 |
} |
} |
760 |
|
|
|
static void |
|
|
xwin_process_propertynotify(XPropertyEvent * xev) |
|
|
{ |
|
|
PropNotifyCb *this = propnotify_callbacks; |
|
|
while (NULL != this) |
|
|
{ |
|
|
if (xev->window == this->wnd && xev->atom == this->atom) |
|
|
{ |
|
|
this->callback(xev); |
|
|
} |
|
|
this = this->next; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
761 |
/* Process all events in Xlib queue |
/* Process all events in Xlib queue |
762 |
Returns 0 after user quit, 1 otherwise */ |
Returns 0 after user quit, 1 otherwise */ |
763 |
static int |
static int |
797 |
break; |
break; |
798 |
|
|
799 |
case KeyPress: |
case KeyPress: |
800 |
last_gesturetime = ((XKeyEvent *) & xevent)->time; |
last_gesturetime = xevent.xkey.time; |
801 |
if (IC != NULL) |
if (IC != NULL) |
802 |
/* Multi_key compatible version */ |
/* Multi_key compatible version */ |
803 |
{ |
{ |
804 |
XmbLookupString(IC, |
XmbLookupString(IC, |
805 |
(XKeyPressedEvent *) & |
&xevent.xkey, str, sizeof(str), &keysym, |
806 |
xevent, str, sizeof(str), &keysym, &status); |
&status); |
807 |
if (!((status == XLookupKeySym) || (status == XLookupBoth))) |
if (!((status == XLookupKeySym) || (status == XLookupBoth))) |
808 |
{ |
{ |
809 |
error("XmbLookupString failed with status 0x%x\n", |
error("XmbLookupString failed with status 0x%x\n", |
838 |
break; |
break; |
839 |
|
|
840 |
case KeyRelease: |
case KeyRelease: |
841 |
last_gesturetime = ((XKeyEvent *) & xevent)->time; |
last_gesturetime = xevent.xkey.time; |
842 |
XLookupString((XKeyEvent *) & xevent, str, |
XLookupString((XKeyEvent *) & xevent, str, |
843 |
sizeof(str), &keysym, NULL); |
sizeof(str), &keysym, NULL); |
844 |
|
|
859 |
break; |
break; |
860 |
|
|
861 |
case ButtonPress: |
case ButtonPress: |
|
last_gesturetime = ((XButtonEvent *) & xevent)->time; |
|
862 |
flags = MOUSE_FLAG_DOWN; |
flags = MOUSE_FLAG_DOWN; |
863 |
/* fall through */ |
/* fall through */ |
864 |
|
|
865 |
case ButtonRelease: |
case ButtonRelease: |
866 |
last_gesturetime = ((XButtonEvent *) & xevent)->time; |
last_gesturetime = xevent.xbutton.time; |
867 |
button = xkeymap_translate_button(xevent.xbutton.button); |
button = xkeymap_translate_button(xevent.xbutton.button); |
868 |
if (button == 0) |
if (button == 0) |
869 |
break; |
break; |
999 |
mod_map = XGetModifierMapping(display); |
mod_map = XGetModifierMapping(display); |
1000 |
} |
} |
1001 |
break; |
break; |
1002 |
/* Clipboard stuff */ |
|
1003 |
case SelectionClear: |
/* clipboard stuff */ |
|
cliprdr_handle_SelectionClear(); |
|
|
break; |
|
1004 |
case SelectionNotify: |
case SelectionNotify: |
1005 |
cliprdr_handle_SelectionNotify((XSelectionEvent *) & xevent); |
xclip_handle_SelectionNotify(&xevent.xselection); |
1006 |
break; |
break; |
1007 |
case SelectionRequest: |
case SelectionRequest: |
1008 |
cliprdr_handle_SelectionRequest((XSelectionRequestEvent *) & |
xclip_handle_SelectionRequest(&xevent.xselectionrequest); |
1009 |
xevent); |
break; |
1010 |
|
case SelectionClear: |
1011 |
|
xclip_handle_SelectionClear(); |
1012 |
break; |
break; |
|
|
|
1013 |
case PropertyNotify: |
case PropertyNotify: |
1014 |
xwin_process_propertynotify((XPropertyEvent *) & xevent); |
xclip_handle_PropertyNotify(&xevent.xproperty); |
1015 |
break; |
break; |
|
|
|
|
|
|
1016 |
} |
} |
1017 |
} |
} |
1018 |
/* Keep going */ |
/* Keep going */ |
1069 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
1070 |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
bitmap = XCreatePixmap(display, wnd, width, height, depth); |
1071 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
1072 |
(char *) tdata, width, height, server_bpp == 8 ? 8 : bpp, 0); |
(char *) tdata, width, height, g_server_bpp == 8 ? 8 : bpp, 0); |
1073 |
|
|
1074 |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height); |
1075 |
|
|
1086 |
uint8 *tdata; |
uint8 *tdata; |
1087 |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
tdata = (owncolmap ? data : translate_image(width, height, data)); |
1088 |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
image = XCreateImage(display, visual, depth, ZPixmap, 0, |
1089 |
(char *) tdata, width, height, server_bpp == 8 ? 8 : bpp, 0); |
(char *) tdata, width, height, g_server_bpp == 8 ? 8 : bpp, 0); |
1090 |
|
|
1091 |
if (ownbackstore) |
if (ownbackstore) |
1092 |
{ |
{ |
1720 |
|
|
1721 |
XFree(image); |
XFree(image); |
1722 |
} |
} |
|
|
|
|
|
|
|
void |
|
|
xwin_register_propertynotify(Window event_wnd, Atom atom, |
|
|
void (*propertycallback) (XPropertyEvent *)) |
|
|
{ |
|
|
PropNotifyCb *this; |
|
|
int window_already_registrered = 0; |
|
|
if (NULL != propnotify_callbacks) |
|
|
{ |
|
|
this = propnotify_callbacks; |
|
|
if (event_wnd == this->wnd) |
|
|
{ |
|
|
window_already_registrered = 1; |
|
|
if (atom == this->atom) |
|
|
return; |
|
|
} |
|
|
while (NULL != this->next) |
|
|
{ |
|
|
if (event_wnd == this->wnd) |
|
|
{ |
|
|
window_already_registrered = 1; |
|
|
if (atom == this->atom) |
|
|
return; |
|
|
/* Find last entry in list */ |
|
|
} |
|
|
this = this->next; |
|
|
} |
|
|
this->next = xmalloc(sizeof(PropNotifyCb)); |
|
|
this->next->next = NULL; |
|
|
this = this->next; |
|
|
|
|
|
} |
|
|
else |
|
|
{ |
|
|
this = xmalloc(sizeof(PropNotifyCb)); |
|
|
this->next = NULL; |
|
|
propnotify_callbacks = this; |
|
|
} |
|
|
if (!window_already_registrered) |
|
|
{ |
|
|
if (wnd == event_wnd) |
|
|
XSelectInput(display, wnd, input_mask | PropertyChangeMask); |
|
|
else |
|
|
XSelectInput(display, event_wnd, PropertyChangeMask); |
|
|
} |
|
|
this->wnd = event_wnd; |
|
|
this->atom = atom; |
|
|
this->callback = propertycallback; |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
xwin_deregister_propertynotify(Window event_wnd, Atom atom) |
|
|
{ |
|
|
PropNotifyCb *this = propnotify_callbacks; |
|
|
PropNotifyCb *prev; |
|
|
int window_needed = 0; |
|
|
prev = this; |
|
|
while (NULL != this) |
|
|
{ |
|
|
if (event_wnd == this->wnd) |
|
|
{ |
|
|
if (atom == this->atom) |
|
|
{ |
|
|
if (prev == this) |
|
|
{ |
|
|
propnotify_callbacks = this->next; |
|
|
} |
|
|
else |
|
|
{ |
|
|
prev->next = this->next; |
|
|
} |
|
|
xfree(this); |
|
|
continue; |
|
|
} |
|
|
else |
|
|
{ |
|
|
window_needed = 1; |
|
|
} |
|
|
} |
|
|
prev = this; |
|
|
this = this->next; |
|
|
} |
|
|
if (!window_needed) |
|
|
{ |
|
|
if (wnd != event_wnd) |
|
|
{ |
|
|
XSelectInput(display, event_wnd, NoEventMask); |
|
|
} |
|
|
else |
|
|
{ |
|
|
XSelectInput(display, wnd, input_mask); |
|
|
} |
|
|
} |
|
|
} |
|