GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 8:17 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Drawing on the GtkDrawingArea with Xlib func
PostPosted: Wed Feb 20, 2013 11:54 am 
Offline

Joined: Wed Feb 20, 2013 10:36 am
Posts: 2
Hi everyone!
I have a problem.

I need to draw on the widget type GtkDrawingArea using functions Xlib (XDrawLine etc). Why?
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, GdkGC) 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:

Code:
...
GtkDrawingArea* area;
...
int main (int argc, char *argv[])
{
   ...
   area=GTK_DRAWING_AREA(gtk_builder_get_object(builder,"area"));
   gtk_widget_realize (GTK_WIDGET(area));
   ...
   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);

   return FALSE;
}
...


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!


Top
 Profile  
 
 Post subject: Re: Drawing on the GtkDrawingArea with Xlib func
PostPosted: Sat Feb 23, 2013 2:51 pm 
Offline

Joined: Wed Feb 20, 2013 10:36 am
Posts: 2
Disabling double buffering widget DrawingArea (gtk_widget_set_double_buffered) helped to solve my problem.

Thank you for your attention!
Thread can be closed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group