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 |
{ \ |
{ \ |
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", server_bpp, bpp, depth); |
620 |
|
|
|
|
|
|
|
|
621 |
return True; |
return True; |
622 |
} |
} |
623 |
|
|
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, &status); |
|
xevent, str, sizeof(str), &keysym, &status); |
|
806 |
if (!((status == XLookupKeySym) || (status == XLookupBoth))) |
if (!((status == XLookupKeySym) || (status == XLookupBoth))) |
807 |
{ |
{ |
808 |
error("XmbLookupString failed with status 0x%x\n", |
error("XmbLookupString failed with status 0x%x\n", |
837 |
break; |
break; |
838 |
|
|
839 |
case KeyRelease: |
case KeyRelease: |
840 |
last_gesturetime = ((XKeyEvent *) & xevent)->time; |
last_gesturetime = xevent.xkey.time; |
841 |
XLookupString((XKeyEvent *) & xevent, str, |
XLookupString((XKeyEvent *) & xevent, str, |
842 |
sizeof(str), &keysym, NULL); |
sizeof(str), &keysym, NULL); |
843 |
|
|
858 |
break; |
break; |
859 |
|
|
860 |
case ButtonPress: |
case ButtonPress: |
|
last_gesturetime = ((XButtonEvent *) & xevent)->time; |
|
861 |
flags = MOUSE_FLAG_DOWN; |
flags = MOUSE_FLAG_DOWN; |
862 |
/* fall through */ |
/* fall through */ |
863 |
|
|
864 |
case ButtonRelease: |
case ButtonRelease: |
865 |
last_gesturetime = ((XButtonEvent *) & xevent)->time; |
last_gesturetime = xevent.xbutton.time; |
866 |
button = xkeymap_translate_button(xevent.xbutton.button); |
button = xkeymap_translate_button(xevent.xbutton.button); |
867 |
if (button == 0) |
if (button == 0) |
868 |
break; |
break; |
998 |
mod_map = XGetModifierMapping(display); |
mod_map = XGetModifierMapping(display); |
999 |
} |
} |
1000 |
break; |
break; |
1001 |
/* Clipboard stuff */ |
|
1002 |
case SelectionClear: |
/* clipboard stuff */ |
|
cliprdr_handle_SelectionClear(); |
|
|
break; |
|
1003 |
case SelectionNotify: |
case SelectionNotify: |
1004 |
cliprdr_handle_SelectionNotify((XSelectionEvent *) & xevent); |
xclip_handle_SelectionNotify(&xevent.xselection); |
1005 |
break; |
break; |
1006 |
case SelectionRequest: |
case SelectionRequest: |
1007 |
cliprdr_handle_SelectionRequest((XSelectionRequestEvent *) & |
xclip_handle_SelectionRequest(&xevent.xselectionrequest); |
1008 |
xevent); |
break; |
1009 |
|
case SelectionClear: |
1010 |
|
xclip_handle_SelectionClear(); |
1011 |
break; |
break; |
|
|
|
1012 |
case PropertyNotify: |
case PropertyNotify: |
1013 |
xwin_process_propertynotify((XPropertyEvent *) & xevent); |
xclip_handle_PropertyNotify(&xevent.xproperty); |
1014 |
break; |
break; |
|
|
|
|
|
|
1015 |
} |
} |
1016 |
} |
} |
1017 |
/* Keep going */ |
/* Keep going */ |
1720 |
XFree(image); |
XFree(image); |
1721 |
} |
} |
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); |
|
|
} |
|
|
} |
|
|
} |
|