diff --git a/lib/modules/Protocols.pmod/X.pmod/Requests.pmod b/lib/modules/Protocols.pmod/X.pmod/Requests.pmod index 51c4da4f9e3272fc1c070a4c12cde4c6f6df9332..045dcbec8a379805b73011037186b6df3a0a87ae 100644 --- a/lib/modules/Protocols.pmod/X.pmod/Requests.pmod +++ b/lib/modules/Protocols.pmod/X.pmod/Requests.pmod @@ -19,7 +19,7 @@ class request { if (!zero_type(m[f])) { - v += ({ m[f] }); + v += ({ objectp(m[f]) ? m[f]->id : m[f] }); mask |= bit; werror(sprintf("Request->build_value_list: field %s, mask = %x\n", f, mask)); @@ -112,18 +112,53 @@ class CreateGC inherit request; constant type = 55; - int gid; + int gc; int drawable; mapping attributes = ([ ]); string to_string() { - return build_request(sprintf("%4c%4c%s", gid, drawable, + return build_request(sprintf("%4c%4c%s", gc, drawable, build_value_list(attributes, _Xlib.gc_attributes))); } } +class ChangeGC +{ + inherit request; + constant type = 56; + + int gc; + mapping attributes; + + string to_string() + { + return build_request(sprintf("%4c%s", gc, + build_value_list(attributes, + _Xlib.gc_attributes))); + } +} + +class FillPoly +{ + inherit request; + constant type = 69; + + int drawable; + int gc; + int shape; + int coordMode; + + array points; + + string to_string() + { + return build_request(sprintf("%4c%4c%c%c%2c%@s", + drawable, gc, shape, coordMode, 0, + points->to_string())); + } +} class PolyFillRectangle { @@ -131,13 +166,13 @@ class PolyFillRectangle constant type = 70; int drawable; - int gid; + int gc; array rectangles; string to_string() { - return build_request(sprintf("%4c%4c%@s", drawable, gid, + return build_request(sprintf("%4c%4c%@s", drawable, gc, rectangles->to_string())); } } diff --git a/lib/modules/Protocols.pmod/X.pmod/Types.pmod b/lib/modules/Protocols.pmod/X.pmod/Types.pmod index f1bb7024769053e057fbbe53597485c6c90412f4..279bccf6077c4e2080d81942bc92812fedf4ded0 100644 --- a/lib/modules/Protocols.pmod/X.pmod/Types.pmod +++ b/lib/modules/Protocols.pmod/X.pmod/Types.pmod @@ -33,6 +33,20 @@ class Visual class GC { inherit XResource; + + object ChangeGC_req(mapping attributes) + { + object req = Requests.ChangeGC(); + req->gc = id; + req->attributes = attributes; + return req; + } + + void ChangeGC(mapping attributes) + { + object req = ChangeGC_req(attributes); + display->send_request(req); + } } class Rectangle @@ -64,6 +78,32 @@ class Rectangle } } +class Point +{ + int x, y; + + void create(int ... args) + { + switch(sizeof(args)) + { + case 0: + x = y = 0; + break; + case 2: + x = args[0]; + y = args[1]; + break; + default: + error("Types.Point(): To many arguments.\n"); + } + } + + string to_string() + { + return sprintf("%2c%2c", x, y); + } +} + class Drawable { inherit XResource; @@ -73,7 +113,7 @@ class Drawable object req = Requests.CreateGC(); req->drawable = id; - req->gid = display->alloc_id(); + req->gc = display->alloc_id(); return req; } @@ -85,14 +125,31 @@ class Drawable req->attributes = attributes; display->send_request(req); - return GC(display, req->gid); + return GC(display, req->gc); } + object FillPoly_req(int gc, int shape, int coordMode, array(object) p) + { + object req = Requests.FillPoly(); + req->drawable = id; + req->gc = gc; + req->shape = shape; + req->coordMode = coordMode; + req->points = p; + return req; + } + + void FillPoly(object gc, int shape, int coordMode, array(object) points) + { + object req = FillPoly_req(gc->id, shape, coordMode, points); + display->send_request(req); + } + object FillRectangles_req(int gc, array(object) r) { object req = Requests.PolyFillRectangle(); req->drawable = id; - req->gid = gc; + req->gc = gc; req->rectangles = r; return req; } @@ -112,8 +169,8 @@ class Window mapping(string:function) event_callbacks = ([ ]); - object CreateSimpleWindow_req(int x, int y, int width, int height, - int border_width, int border, int background) + object CreateWindow_req(int x, int y, int width, int height, + int border_width) { object req = Requests.CreateWindow(); req->depth = 0; /* CopyFromParent */ @@ -126,8 +183,6 @@ class Window req->borderWidth = border_width; req->c_class = 0 ; /* CopyFromParent */ req->visual = 0; /* CopyFromParent */ - req->attributes->BackPixel = background; - req->attributes->BorderPixel = border; return req; } @@ -135,10 +190,34 @@ class Window { return object_program(this_object())(@args); } - - object CreateSimpleWindow(int ... args) + + /* FIXME: Supports only visual CopyFromParent */ + object CreateWindow(int x, int y, int width, int height, + int border_width, mapping attributes) + { + object req = CreateWindow_req(x, y, width, height, + border_width); + if (attributes) + req->attributes = attributes; + display->send_request(req); + + // object w = Window(display, req->wid); + object w = new(display, req->wid); + + w->visual = visual; + w->currentInputMask = req->attributes->EventMask; + return w; + } + + object CreateSimpleWindow(int x, int y, int width, int height, + int border_width, + int border, int background) { - object req = CreateSimpleWindow_req(@args); + object req = CreateWindow_req(x, y, width, height, + border_width); + req->attributes->BackPixel = background; + req->attributes->BorderPixel = border; + display->send_request(req); // object w = Window(display, req->wid); diff --git a/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod b/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod index 5f65b7f258f0e659afa5b944b981476331d1347c..c149e5ebb93fa418b6ccf6a82e6e29e1394cdc00 100644 --- a/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod +++ b/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod @@ -441,14 +441,36 @@ class Display ...; case "UnmapNotify": ...; +#endif case "MapNotify": - ...; + { + int window; + sscanf(msg, "%*4c%4c%4c%c", + event->wid, window, event->override); + event->event = lookup_id(event->wid); + event->window = lookup_id(window) || window; + break; + } +#if 0 case "MapRequest": ...; case "ReparentNotify": ...; +#endif case "ConfigureNotify": - ...; + { + int window, aboveSibling; + sscanf(msg, "%*4c%4c%4c%4c" "%2c%2c" "%2c%2c%2c" "%c", + event->wid, window, aboveSibling, + event->x, event->y, + event->width, event->height, event->borderWidth, + event->override); + event->window = lookup_id(window) || window; + event->aboveSibling = lookup_id(aboveSibling) + || aboveSibling; + break; + } +#if 0 case "ConfigureRequest": ...; case "GravityNotify":