forked from pyrite-dev/milsko
stuff
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@400 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
7a531de084
commit
599b1ee0c8
11 changed files with 214 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ enum mwm_hints_enum {
|
|||
MWM_FUNC_CLOSE = (1L << 5)
|
||||
};
|
||||
|
||||
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | KeymapNotify;
|
||||
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | KeymapNotify | FocusChangeMask;
|
||||
|
||||
static void create_pixmap(MwLL handle) {
|
||||
XWindowAttributes attr;
|
||||
|
|
@ -110,6 +110,8 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
|
|||
r->width = width;
|
||||
r->height = height;
|
||||
|
||||
r->grabbed = 0;
|
||||
|
||||
r->colormap = DefaultColormap(r->display, XDefaultScreen(r->display));
|
||||
r->wm_delete = XInternAtom(r->display, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(r->display, r->window, &r->wm_delete, 1);
|
||||
|
|
@ -284,12 +286,28 @@ void MwLLNextEvent(MwLL handle) {
|
|||
if(ev.xclient.data.l[0] == (long)handle->wm_delete) {
|
||||
MwLLDispatch(handle, close, NULL);
|
||||
}
|
||||
} else if(ev.type == FocusIn){
|
||||
MwLLDispatch(handle, focus_in, NULL);
|
||||
} else if(ev.type == FocusOut){
|
||||
MwLLDispatch(handle, focus_out, NULL);
|
||||
} else if(ev.type == MotionNotify) {
|
||||
MwPoint p;
|
||||
XWindowAttributes attr;
|
||||
|
||||
XGetWindowAttributes(handle->display, handle->window, &attr);
|
||||
|
||||
p.x = ev.xmotion.x;
|
||||
p.y = ev.xmotion.y;
|
||||
|
||||
if(handle->grabbed){
|
||||
p.x -= attr.width / 2;
|
||||
p.y -= attr.height / 2;
|
||||
}
|
||||
|
||||
MwLLDispatch(handle, move, &p);
|
||||
if(handle->grabbed && (p.x != 0 || p.y != 0)){
|
||||
XWarpPointer(handle->display, None, handle->window, 0, 0, 0, 0, attr.width / 2, attr.height / 2);
|
||||
}
|
||||
} else if(ev.type == KeyPress || ev.type == KeyRelease) {
|
||||
int n = -1;
|
||||
char str[512];
|
||||
|
|
@ -325,6 +343,10 @@ void MwLLNextEvent(MwLL handle) {
|
|||
n = MwLLKeyUp;
|
||||
} else if(strcmp(str, "Down") == 0) {
|
||||
n = MwLLKeyDown;
|
||||
} else if(strcmp(str, "Return") == 0){
|
||||
n = MwLLKeyEnter;
|
||||
} else if(strcmp(str, "Escape") == 0){
|
||||
n = MwLLKeyEscape;
|
||||
}
|
||||
|
||||
if(n != -1) {
|
||||
|
|
@ -663,3 +685,21 @@ long MwLLGetTick(void) {
|
|||
|
||||
return n;
|
||||
}
|
||||
|
||||
void MwLLFocus(MwLL handle){
|
||||
XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime);
|
||||
}
|
||||
|
||||
void MwLLGrabPointer(MwLL handle, int toggle){
|
||||
XWindowAttributes attr;
|
||||
|
||||
XGetWindowAttributes(handle->display, handle->window, &attr);
|
||||
|
||||
if(toggle){
|
||||
handle->grabbed = 1;
|
||||
|
||||
XWarpPointer(handle->display, None, handle->window, 0, 0, 0, 0, attr.width / 2, attr.height / 2);
|
||||
}else{
|
||||
handle->grabbed = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue