I have a problem.
I need to draw on the widget type GtkDrawingArea
using functions Xlib (XDrawLine
I use the library, which draws with Xlib. And I need to pass any arguments (Display, Window, GC) in the rendering function drawSome (...)
. All is well. I took these arguments (gdk_x11_... () GdkDrawable
) and transferred the drawing drawSome (...)
. But there are problems - drawing is not always done. The image is not displayed when maximizing windows, dragging, resizing DrawingArea etc.. The image is displayed only under unusual manipulation of the top window .
Then I tested the function XDrawPoint/Line/Rectangle
- the same problem. If we use gdk_draw_rectangle (...)
- all is normal.
Here's the code below:
int main (int argc, char *argv)
g_signal_connect (G_OBJECT(area), "expose_event", G_CALLBACK(expose_event_callback), NULL);
gboolean expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
Display *dpy = gdk_x11_drawable_get_xdisplay(widget->window);
Window win =gdk_x11_drawable_get_xid(widget->window);
GC gc = DefaultGC(dpy, DefaultScreen(dpy));
//draw image on (0,0) in widget DrawingArea and a small black rectangle over image
drawSome(dpy, win, gc, ...);
XFillRectangle(dpy, win, gc, 0, 0, 10, 10);
Image and a small black rectangle displayed only in one case: if the window move beyond the desktop and return back to the desktop - the image appears. In other cases, it is not displayed.
The impression is that another function erases DrawingArea
Who can tell me what's the problem?
I would be grateful!