void redraw_labels (GtkWidget *widget, GtkStyle *previous_style) { GtkScrollbox *self = GTK_SCROLLBOX(widget); int i; if (self->labels->len < 1) return; stop_callback(self); gtk_widget_set_size_request(GTK_WIDGET(self), 0, 0); self->draw_middle = 0; self->draw_maxmiddle = 0; for (i = 0; i < self->labels->len; i++) { GdkPixmap *newpixmap; struct label *lbl = (struct label*)g_ptr_array_index(self->labels, i); if (!lbl->msg) continue; newpixmap = make_pixmap(self, lbl->msg); if (lbl->pixmap) g_free(lbl->pixmap); lbl->pixmap = newpixmap; } start_callback(self); }
int main( int argc, char *argv[] ) { Display *dpy; Window win; Pixmap pm; GLXPixmap glxpm; dpy = XOpenDisplay(NULL); win = make_rgb_window( dpy, 300, 300 ); glxpm = make_pixmap( dpy, win, 300, 300, &pm ); glXMakeCurrent( dpy, glxpm, ctx ); printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); /* Render an image into the pixmap */ glShadeModel( GL_FLAT ); glClearColor( 0.5, 0.5, 0.5, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); glViewport( 0, 0, 300, 300 ); glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); glColor3f( 0.0, 1.0, 1.0 ); glRectf( -0.75, -0.75, 0.75, 0.75 ); glFlush(); XMapWindow( dpy, win ); event_loop( dpy, pm ); return 0; }
void gtk_scrollbox_set_label(GtkScrollbox *self, gint n, gchar *value) { gboolean append = TRUE; GdkPixmap *newpixmap; struct label *newlbl; if (n != -1) append = FALSE; if (!append) { struct label *lbl = (struct label*)g_ptr_array_index(self->labels, n); if (lbl) free_label(lbl); newlbl = lbl; } else { newlbl = g_new0(struct label, 1); g_ptr_array_add(self->labels, newlbl); } newpixmap = make_pixmap(self, value); newlbl->pixmap = newpixmap; newlbl->msg = g_strdup(value); }
void start_draw_up(GtkScrollbox *self) { gint width, height; struct label *lbl; static int i = 0; GtkWidget *widget = (GtkWidget *)self; XFCE_PANEL_LOCK(); if (self->labels->len == 0) { XFCE_PANEL_UNLOCK(); return; } if (i >= self->labels->len) i = 0; lbl = (struct label*)g_ptr_array_index(self->labels, i); self->pixmap = lbl->pixmap; /* If we failed to create a proper pixmap, try again now */ if (!lbl->pixmap) { lbl->pixmap = make_pixmap(self, lbl->msg); if (!lbl->pixmap) { /* Still no pixmap. We need to restart the timer */ if (self->draw_timeout) stop_callback(self); self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)start_draw_up, self); XFCE_PANEL_UNLOCK(); return; } } if (self->labels->len == 1) { GdkRectangle update_rect = {0, 0, GTK_WIDGET(self)->allocation.width, GTK_WIDGET(self)->allocation.height}; self->pixmap = lbl->pixmap; self->draw_offset = 0; gtk_widget_draw(GTK_WIDGET(self), &update_rect); XFCE_PANEL_UNLOCK(); return; } gdk_drawable_get_size(GDK_DRAWABLE(self->pixmap), &width, &height); self->draw_middle = self->draw_maxmiddle - width / 2; self->draw_timeout = g_timeout_add(LABEL_SPEED, (GSourceFunc)draw_up, self); i++; XFCE_PANEL_UNLOCK(); }
int main( int argc, char *argv[] ) { Display *dpy; Window win; Pixmap pm; GLXPixmap glxpm; int eventbase, errorbase; dpy = XOpenDisplay(NULL); if(NULL == dpy) { fprintf(stderr, "error: opening display\n"); return EXIT_FAILURE; } if(!glXQueryExtension(dpy, &eventbase, &errorbase)) { fprintf(stderr, "GLX is not available!\n"); return EXIT_FAILURE; } win = make_rgb_window( dpy, 300, 300 ); glxpm = make_pixmap( dpy, win, 300, 300, &pm ); printf("glxpm 0x%lx\n", glxpm); if(!glXMakeCurrent(dpy, glxpm, ctx)) { fprintf(stderr, "glXMakeCurrent failed!\n"); return EXIT_FAILURE; } printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); /* Render an image into the pixmap */ glShadeModel( GL_FLAT ); glClearColor( 0.5, 0.5, 0.5, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); glViewport( 0, 0, 300, 300 ); glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); glColor3f( 0.0, 0.0, 1.0 ); glRectf( -0.75, -0.75, 0.75, 0.75 ); glFlush(); XMapWindow( dpy, win ); event_loop( dpy, pm ); return 0; }