mirror of https://github.com/buggins/dlangui.git
x11
This commit is contained in:
parent
5176abcaae
commit
bbd9d365d4
|
@ -947,6 +947,13 @@ class ColorDrawBuf : ColorDrawBufBase {
|
||||||
foreach(pixel; _buf)
|
foreach(pixel; _buf)
|
||||||
pixel ^= 0xFF000000;
|
pixel ^= 0xFF000000;
|
||||||
}
|
}
|
||||||
|
void invertByteOrder() {
|
||||||
|
foreach(pixel; _buf) {
|
||||||
|
pixel = (pixel & 0xFF00FF00) |
|
||||||
|
((pixel & 0xFF0000) >> 16) |
|
||||||
|
((pixel & 0xFF) << 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
override uint * scanLine(int y) {
|
override uint * scanLine(int y) {
|
||||||
if (y >= 0 && y < _dy)
|
if (y >= 0 && y < _dy)
|
||||||
return _buf.ptr + _dx * y;
|
return _buf.ptr + _dx * y;
|
||||||
|
|
|
@ -32,14 +32,14 @@ alias DWindow = dlangui.platforms.common.platform.Window;
|
||||||
private GC createGC(Display* display, XWindow win)
|
private GC createGC(Display* display, XWindow win)
|
||||||
{
|
{
|
||||||
GC gc; /* handle of newly created GC. */
|
GC gc; /* handle of newly created GC. */
|
||||||
uint valuemask = 0; /* which values in 'values' to */
|
uint valuemask = GCFunction | GCBackground | GCForeground | GCPlaneMask; /* which values in 'values' to */
|
||||||
/* check when creating the GC. */
|
/* check when creating the GC. */
|
||||||
XGCValues values; /* initial values for the GC. */
|
XGCValues values; /* initial values for the GC. */
|
||||||
uint line_width = 2; /* line width for the GC. */
|
values.plane_mask = AllPlanes;
|
||||||
int line_style = LineSolid; /* style for lines drawing and */
|
|
||||||
int cap_style = CapButt; /* style of the line's edje and */
|
|
||||||
int join_style = JoinBevel; /* joined lines. */
|
|
||||||
int screen_num = DefaultScreen(display);
|
int screen_num = DefaultScreen(display);
|
||||||
|
values.function_ = GXcopy;
|
||||||
|
values.background = WhitePixel(display, screen_num);
|
||||||
|
values.foreground = BlackPixel(display, screen_num);
|
||||||
|
|
||||||
gc = XCreateGC(display, win, valuemask, &values);
|
gc = XCreateGC(display, win, valuemask, &values);
|
||||||
if (!gc) {
|
if (!gc) {
|
||||||
|
@ -48,9 +48,10 @@ private GC createGC(Display* display, XWindow win)
|
||||||
//fprintf(stderr, "XCreateGC: \n");
|
//fprintf(stderr, "XCreateGC: \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate foreground and background colors for this GC. */
|
uint line_width = 2; /* line width for the GC. */
|
||||||
XSetForeground(display, gc, BlackPixel(display, screen_num));
|
int line_style = LineSolid; /* style for lines drawing and */
|
||||||
XSetBackground(display, gc, WhitePixel(display, screen_num));
|
int cap_style = CapButt; /* style of the line's edje and */
|
||||||
|
int join_style = JoinBevel; /* joined lines. */
|
||||||
|
|
||||||
/* define the style of lines that will be drawn using this GC. */
|
/* define the style of lines that will be drawn using this GC. */
|
||||||
XSetLineAttributes(display, gc,
|
XSetLineAttributes(display, gc,
|
||||||
|
@ -94,7 +95,7 @@ class X11Window : DWindow {
|
||||||
static if (true) {
|
static if (true) {
|
||||||
_win = XCreateSimpleWindow(x11display, DefaultRootWindow(x11display),
|
_win = XCreateSimpleWindow(x11display, DefaultRootWindow(x11display),
|
||||||
0, 0,
|
0, 0,
|
||||||
_dx, _dy, 1, black, white);
|
_dx, _dy, 5, black, white);
|
||||||
} else {
|
} else {
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
attr.do_not_propagate_mask = 0;
|
attr.do_not_propagate_mask = 0;
|
||||||
|
@ -115,8 +116,8 @@ class X11Window : DWindow {
|
||||||
if (!_win)
|
if (!_win)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XMapWindow(x11display, _win);
|
//XMapWindow(x11display, _win);
|
||||||
XSync(x11display, false);
|
//XSync(x11display, false);
|
||||||
|
|
||||||
//readln();
|
//readln();
|
||||||
|
|
||||||
|
@ -148,7 +149,7 @@ class X11Window : DWindow {
|
||||||
|
|
||||||
/* clear the window and bring it on top of the other windows */
|
/* clear the window and bring it on top of the other windows */
|
||||||
//XClearWindow(x11display, _win);
|
//XClearWindow(x11display, _win);
|
||||||
XFlush(x11display);
|
//XFlush(x11display);
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
|
@ -204,7 +205,32 @@ class X11Window : DWindow {
|
||||||
// draw widgets into buffer
|
// draw widgets into buffer
|
||||||
onDraw(_drawbuf);
|
onDraw(_drawbuf);
|
||||||
// draw buffer on X11 window
|
// draw buffer on X11 window
|
||||||
|
//_drawbuf.invertAlpha();
|
||||||
|
//_drawbuf.invertByteOrder();
|
||||||
|
XImage img;
|
||||||
|
img.width = _drawbuf.width;
|
||||||
|
img.height = _drawbuf.height;
|
||||||
|
img.xoffset = 0;
|
||||||
|
img.format = ZPixmap;
|
||||||
|
img.data = cast(char*)_drawbuf.scanLine(0);
|
||||||
|
img.bitmap_unit = 32;
|
||||||
|
img.bitmap_pad = 32;
|
||||||
|
img.bitmap_bit_order = LSBFirst;
|
||||||
|
img.depth = 24;
|
||||||
|
img.chars_per_line = _drawbuf.width * 4;
|
||||||
|
img.bits_per_pixel = 32;
|
||||||
|
img.red_mask = 0xFF0000;
|
||||||
|
img.green_mask = 0x00FF00;
|
||||||
|
img.blue_mask = 0x0000FF;
|
||||||
|
XInitImage(&img);
|
||||||
|
XSetClipOrigin(x11display, _gc, 0, 0);
|
||||||
|
XPutImage(x11display, _win,
|
||||||
|
_gc, //DefaultGC(x11display, DefaultScreen(x11display)),
|
||||||
|
&img,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
_drawbuf.width,
|
||||||
|
_drawbuf.height);
|
||||||
|
/*
|
||||||
XImage * image = XCreateImage(x11display,
|
XImage * image = XCreateImage(x11display,
|
||||||
DefaultVisual(x11display, DefaultScreen(x11display)),
|
DefaultVisual(x11display, DefaultScreen(x11display)),
|
||||||
24,
|
24,
|
||||||
|
@ -214,13 +240,18 @@ class X11Window : DWindow {
|
||||||
_drawbuf.width,
|
_drawbuf.width,
|
||||||
_drawbuf.height,
|
_drawbuf.height,
|
||||||
32, 0);
|
32, 0);
|
||||||
XPutImage(x11display, _win, DefaultGC(x11display, DefaultScreen(x11display)),
|
//image.bitmap_bit_order = MSBFirst;
|
||||||
|
//image.b
|
||||||
|
XPutImage(x11display, _win,
|
||||||
|
_gc, //DefaultGC(x11display, DefaultScreen(x11display)),
|
||||||
image,
|
image,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
_drawbuf.width,
|
_drawbuf.width,
|
||||||
_drawbuf.height);
|
_drawbuf.height);
|
||||||
|
*/
|
||||||
XFlush(x11display);
|
XFlush(x11display);
|
||||||
//XDestroyImage(image);
|
//XDestroyImage(image);
|
||||||
|
//XFree(image);
|
||||||
|
|
||||||
|
|
||||||
// ulong black, white;
|
// ulong black, white;
|
||||||
|
@ -244,29 +275,22 @@ class X11Window : DWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void processExpose(int width, int height) {
|
void processExpose() {
|
||||||
// XWindow root_return;
|
|
||||||
// int x_return, y_return;
|
|
||||||
// uint width_return;
|
|
||||||
// uint height_return;
|
|
||||||
// uint border_width_return;
|
|
||||||
// uint depth_return;
|
|
||||||
// XGetGeometry(x11display, _win, &root_return, &x_return, &y_return, &width_return,
|
|
||||||
// &height_return, &border_width_return, &depth_return);
|
|
||||||
// Log.d(format("XGetGeometry reported size %d, %d", width_return, height_return));
|
|
||||||
XWindowAttributes window_attributes_return;
|
XWindowAttributes window_attributes_return;
|
||||||
XGetWindowAttributes(x11display, _win, &window_attributes_return);
|
XGetWindowAttributes(x11display, _win, &window_attributes_return);
|
||||||
Log.d(format("XGetWindowAttributes reported size %d, %d", window_attributes_return.width, window_attributes_return.height));
|
Log.d(format("XGetWindowAttributes reported size %d, %d", window_attributes_return.width, window_attributes_return.height));
|
||||||
width = window_attributes_return.width;
|
int width = window_attributes_return.width;
|
||||||
height = window_attributes_return.height;
|
int height = window_attributes_return.height;
|
||||||
if (width > 0 && height > 0)
|
if (width > 0 && height > 0)
|
||||||
onResize(width, height);
|
onResize(width, height);
|
||||||
Log.d(format("processExpose(%d, %d)", width, height));
|
Log.d(format("processExpose(%d, %d)", width, height));
|
||||||
ulong black, white;
|
ulong black, white;
|
||||||
black = BlackPixel(x11display, x11screen); /* get color black */
|
black = BlackPixel(x11display, x11screen); /* get color black */
|
||||||
white = WhitePixel(x11display, x11screen); /* get color white */
|
white = WhitePixel(x11display, x11screen); /* get color white */
|
||||||
|
|
||||||
XSetBackground(x11display, _gc, white);
|
XSetBackground(x11display, _gc, white);
|
||||||
XClearWindow(x11display, _win);
|
XClearWindow(x11display, _win);
|
||||||
|
|
||||||
drawUsingBitmap();
|
drawUsingBitmap();
|
||||||
|
|
||||||
//XSetForeground( x11display, _gc, black );
|
//XSetForeground( x11display, _gc, black );
|
||||||
|
@ -348,7 +372,7 @@ class X11Platform : Platform {
|
||||||
X11Window w = findWindow(event.xexpose.window);
|
X11Window w = findWindow(event.xexpose.window);
|
||||||
if (w) {
|
if (w) {
|
||||||
|
|
||||||
w.processExpose(event.xexpose.width, event.xexpose.height);
|
w.processExpose();
|
||||||
} else {
|
} else {
|
||||||
Log.e("Window not found");
|
Log.e("Window not found");
|
||||||
}
|
}
|
||||||
|
@ -384,11 +408,11 @@ class X11Platform : Platform {
|
||||||
Log.d("You pressed a button at ",
|
Log.d("You pressed a button at ",
|
||||||
event.xbutton.x, ", ", event.xbutton.y);
|
event.xbutton.x, ", ", event.xbutton.y);
|
||||||
Log.d("...");
|
Log.d("...");
|
||||||
XClearArea(x11display, event.xbutton.window, 0, 0, 1, 1, true);
|
//XClearArea(x11display, event.xbutton.window, 0, 0, 1, 1, true);
|
||||||
X11Window w = findWindow(event.xbutton.window);
|
X11Window w = findWindow(event.xbutton.window);
|
||||||
if (w) {
|
if (w) {
|
||||||
Log.e("Calling processExpose");
|
Log.e("Calling processExpose");
|
||||||
w.processExpose(-1, -1);
|
w.processExpose();
|
||||||
} else {
|
} else {
|
||||||
Log.e("Window not found");
|
Log.e("Window not found");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue