static gboolean on_timer_signal(CalibArea *area) { GdkWindow *win; area->time_elapsed += TIME_STEP; if (area->time_elapsed > MAX_TIME) { set_calibration_status (area); return FALSE; } /* Update clock */ win = gtk_widget_get_window (area->window); if (win) { GdkRectangle rect; rect.x = area->display_width/2 - CLOCK_RADIUS - CLOCK_LINE_WIDTH; rect.y = area->display_height/2 - CLOCK_RADIUS - CLOCK_LINE_WIDTH; rect.width = 2 * CLOCK_RADIUS + 1 + 2 * CLOCK_LINE_WIDTH; rect.height = 2 * CLOCK_RADIUS + 1 + 2 * CLOCK_LINE_WIDTH; gdk_window_invalidate_rect(win, &rect, FALSE); } return TRUE; }
/** * The method resize updates the view internal variables to the changed region * size. * * \param view view to resize * \param newRegion the size of the new region * \return OK on success */ RCode view_lsv_resize(ViewGeneric *view, GdkRectangle newRegion) { ViewListStatus* lsv_data = NULL; ASSERT( NULL != view ); lsv_data = view_lsv_get_data_pointer(view); if ( NULL == lsv_data ) { return FAIL; } // check if buffer need to be resized if ( newRegion.x == view->region.x && newRegion.width == view->region.width && newRegion.y == view->region.y && newRegion.height == view->region.height ) { return OK; } TRACE_MESSAGE(VIEW, TL_DEBUG, "Image list status resize (view=%p, [x=%d,y=%d,width=%d,height=%d]", view, newRegion.x, newRegion.y, newRegion.width, newRegion.height ); // force redraw of view if ( NULL != view->window ) { gdk_window_invalidate_rect(view->window, &(newRegion), FALSE); } return OK; }
/* * The timer-based process that operates on some variables then invalidates copter's region to trigger * an expose_event, thus invoking function "on_copter_expose_event" through the window manager. * */ static gboolean render_timer_event (gpointer theUser_data) { GdkWindow *parent; GtkWidget *theWidget = GTK_WIDGET (theUser_data); /* * Only send a redraw request if the render process is not busy. * This prevents long rendering processes from piling up. */ if (pthread_mutex_trylock (&copter_render_mutex) != EBUSY) { // Unlock the mutex before we issue the redraw. pthread_mutex_unlock (&copter_render_mutex); // Invalidate 3D copter's region to signal the window handler there needs to be an update in that area, if (parent = gtk_widget_get_parent_window (theWidget)) gdk_window_invalidate_rect (parent, &theWidget->allocation, TRUE); /* * Force an immediate update - we can omit this and leave the window manager to call the redraw when the * main loop is idle. However, we get smoother, more consistent updates this way. */ if (parent = gtk_widget_get_parent_window (theWidget)) gdk_window_process_updates (parent, TRUE); } return TRUE; }
void wxMiniFrame::SetTitle( const wxString &title ) { wxFrame::SetTitle( title ); if (GTK_PIZZA(m_mainWidget)->bin_window) gdk_window_invalidate_rect( GTK_PIZZA(m_mainWidget)->bin_window, NULL, true ); }
void on_composited_changed ( GdkScreen *screen, gpointer user_data) { GromitData *data = (GromitData *) user_data; if(data->debug) g_printerr("DEBUG: got composited-changed event\n"); data->composited = gdk_screen_is_composited (data->screen); if(data->composited) { // undo shape gtk_widget_shape_combine_region(data->win, NULL); // re-apply transparency gtk_window_set_opacity(GTK_WINDOW(data->win), 0.75); } // set anti-aliasing GHashTableIter it; gpointer value; g_hash_table_iter_init (&it, data->tool_config); while (g_hash_table_iter_next (&it, NULL, &value)) { GromitPaintContext *context = value; cairo_set_antialias(context->paint_ctx, data->composited ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE); } GdkRectangle rect = {0, 0, data->width, data->height}; gdk_window_invalidate_rect(gtk_widget_get_window(data->win), &rect, 0); }
/* Draw a rectangle on the screen */ static void draw_brush (GtkWidget *widget, gdouble x, gdouble y) { GdkRectangle update_rect; cairo_t *cr; update_rect.x = x - 3; update_rect.y = y - 3; update_rect.width = 6; update_rect.height = 6; /* Paint to the surface, where we store our state */ cr = cairo_create (surface); gdk_cairo_rectangle (cr, &update_rect); cairo_fill (cr); cairo_destroy (cr); /* Now invalidate the affected region of the drawing area. */ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &update_rect, FALSE); }
static void git_source_view_on_adj_value_changed (GtkAdjustment *adj, GitSourceView *sview) { GitSourceViewPrivate *priv = sview->priv; gint dx = 0, dy = 0; if (priv->hadjustment) { gint new_offset = (gint) priv->hadjustment->value; dx = priv->x_offset - new_offset; priv->x_offset = new_offset; } if (priv->vadjustment) { gint new_offset = (gint) priv->vadjustment->value; dy = priv->y_offset - new_offset; priv->y_offset = new_offset; } if (GTK_WIDGET_REALIZED (GTK_WIDGET (sview))) { /* If dx has changed then we have to redraw the whole window because the commit hashes on the left side shouldn't scroll */ if (dx) gdk_window_invalidate_rect (GTK_WIDGET (sview)->window, NULL, FALSE); else if (dy) gdk_window_scroll (GTK_WIDGET (sview)->window, dx, dy); } }
static void git_source_view_on_completed (GitAnnotatedSource *source, const GError *error, GitSourceView *sview) { GitSourceViewPrivate *priv = sview->priv; if (error) git_source_view_set_state (sview, GIT_SOURCE_VIEW_ERROR, error); else { /* Forget the old painting source */ if (priv->paint_source) g_object_unref (priv->paint_source); /* Use the loading source to paint with */ priv->paint_source = g_object_ref (source); /* Recalculate the line height */ priv->line_height = 0; git_source_view_calculate_line_height (sview); gdk_window_invalidate_rect (GTK_WIDGET (sview)->window, NULL, FALSE); git_source_view_update_scroll_adjustments (sview); git_source_view_set_state (sview, GIT_SOURCE_VIEW_READY, NULL); } git_source_view_unref_loading_source (sview); }
void Ctrl::WndInvalidateRect(const Rect& r) { GuiLock __; LLOG("WndInvalidateRect " << r); gdk_window_invalidate_rect(gdk(), GdkRect(r), TRUE); // gtk_widget_queue_draw_area(top->window, r.left, r.top, r.GetWidth(), r.GetHeight()); }
void ekiga_ext_window_set_size (EkigaExtWindow *ew, int width, int height) { int pw, ph; g_return_if_fail (width > 0 && height > 0); gtk_widget_get_size_request (ew->priv->event_box, &pw, &ph); /* No size requisition yet * It's our first call so we silently set the new requisition and exit... */ if (pw == -1) { gtk_widget_set_size_request (ew->priv->event_box, width, height); return; } /* Do some kind of filtering here. We often get duplicate "size-changed" events... * Note that we currently only bother about the width of the event_box. */ if (pw == width) return; gtk_widget_set_size_request (ew->priv->event_box, width, height); gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (ew)), NULL, TRUE); }
void SludgeGLApplication::on_drawingarea1_realize(GtkWidget *theWidget) { GdkGLContext *glContext; GdkGLDrawable *glDrawable; if (theWidget->window == NULL) { return; } gtk_widget_add_events(theWidget, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_SCROLL_MASK); glContext = gtk_widget_get_gl_context (theWidget); glDrawable = gtk_widget_get_gl_drawable (theWidget); // Signal to gdk the start OpenGL operations. if (!gdk_gl_drawable_gl_begin (glDrawable, glContext)) { return; } glViewport (0, 0, theWidget->allocation.width, theWidget->allocation.height); /* Your one-time OpenGL initialization code goes here */ x = y = 0; w = theWidget->allocation.width; h = theWidget->allocation.height; prepareOpenGL(); // Signal to gdk we're done with OpenGL operations. gdk_gl_drawable_gl_end (glDrawable); gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE); }
/*** *** The "motion_notify_event" signal handler. Any processing required when *** the OpenGL-capable drawing area is under drag motion should be done here. ***/ static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer data) { GtkAllocation allocation; gboolean redraw = FALSE; gtk_widget_get_allocation (widget, &allocation); if (event->state & GDK_BUTTON1_MASK) { sphi += (float)(event->x - beginX) / 4.0; stheta += (float)(beginY - event->y) / 4.0; redraw = TRUE; } if (event->state & GDK_BUTTON2_MASK) { sdepth -= ((event->y - beginY)/(allocation.height))*(MAXGRID/2); redraw = TRUE; } beginX = event->x; beginY = event->y; if (redraw && !animate) gdk_window_invalidate_rect (gtk_widget_get_window (widget), &allocation, FALSE); return TRUE; }
void background_info_set_background_by_drawable(BackgroundInfo* info, guint32 drawable) { gint x, y; guint border,depth, width=0, height=0; Display* dpy = gdk_x11_get_default_xdisplay(); gdk_error_trap_push(); //TODO: //we shoul use xatom_name window to set events instead of root window //because the monitors changed signal will came before root window rect changed //so the Xroot window rect maybe keep old rect in update_bg function and in Display DBus signal "PrimaryChanged" Window root; XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &border, &depth); g_debug("[%s] width: %d, height: %d, x: %d y: %d\n", __func__, width, height, x, y); if (gdk_error_trap_pop()) { g_warning("[%s] invalid drawable %d \n", __func__, drawable); return; } g_mutex_lock(&info->m); if (info->bg != NULL) { cairo_surface_destroy(info->bg); info->bg = NULL; } info->bg = cairo_xlib_surface_create(dpy, drawable, gdk_x11_visual_get_xvisual(gdk_visual_get_system()), width, height); g_mutex_unlock(&info->m); if (gtk_widget_get_realized(info->container)) { gdk_window_invalidate_rect(gtk_widget_get_window(info->container), NULL, TRUE); } }
void background_info_set_background_by_file(BackgroundInfo* info, const char* file) { g_message("[%s] file, :%s", __func__, file); GError* error = NULL; GdkScreen *screen; screen = gtk_window_get_screen (GTK_WINDOW (info->container)); gint w = gdk_screen_get_width(screen); gint h = gdk_screen_get_height(screen); g_message("[%s] gdk_screen_get_width:%d, height: %d\n", __func__, w, h); GdkPixbuf* pb = gdk_pixbuf_new_from_file_at_scale(file,w,h,FALSE, &error); if (error != NULL) { g_warning("[%s] failed: %s\n", __func__, error->message); g_error_free(error); return; } g_mutex_lock(&info->m); if (info->bg != NULL) { cairo_surface_destroy(info->bg); info->bg = NULL; } info->bg = gdk_cairo_surface_create_from_pixbuf(pb, 1, gtk_widget_get_window(info->container)); g_mutex_unlock(&info->m); g_object_unref(pb); if (gtk_widget_get_realized(info->container)) { gdk_window_invalidate_rect(gtk_widget_get_window(info->container), NULL, TRUE); } }
/* * The timer-based process that operates on some variables then invalidates drawingarea1's region to trigger * an expose_event, thus invoking function "on_drawingarea1_expose_event" through the window manager. * */ gboolean SludgeGLApplication::render_timer_event(gpointer theUser_data) { GtkWidget *theWidget = GTK_WIDGET (theUser_data); /* * Only send a redraw request if the render process is not busy. This prevents long rendering processes * from piling up. */ if (g_mutex_trylock(theRender_mutex)) { // Unlock the mutex before we issue the redraw. g_mutex_unlock(theRender_mutex); // Invalidate drawingarea1's region to signal the window handler there needs to be an update in that area, gdk_window_invalidate_rect (gtk_widget_get_parent_window (theWidget), &theWidget->allocation, TRUE); // gdk_window_invalidate_rect (theWidget->window, &theWidget->allocation, FALSE); /* * Force an immediate update - we can omit this and leave the window manager to call the redraw when the * main loop is idle. However, we get smoother, more consistent updates this way. */ gdk_window_process_updates (gtk_widget_get_parent_window (theWidget), TRUE); // gdk_window_process_updates (theWidget->window, FALSE); } return TRUE; }
static gboolean fade_timeout (GsdMediaKeysWindow *window) { if (window->priv->fade_out_alpha <= 0.0) { gtk_widget_hide (GTK_WIDGET (window)); /* Reset it for the next time */ window->priv->fade_out_alpha = 1.0; window->priv->fade_timeout_id = 0; return FALSE; } else { GdkRectangle rect; GtkWidget *win = GTK_WIDGET (window); GtkAllocation allocation; window->priv->fade_out_alpha -= 0.10; rect.x = 0; rect.y = 0; gtk_widget_get_allocation (win, &allocation); rect.width = allocation.width; rect.height = allocation.height; gdk_window_invalidate_rect (gtk_widget_get_window (win), &rect, FALSE); } return TRUE; }
/* Invalidate the region modified by the path */ void ramble_update_region(GList *path, GdkWindow *window) { START_FUNC GdkRectangle rect; struct ramble_point *p1, *p2; if (path) { p1=(struct ramble_point *)path->data; if (path->prev) { p2=(struct ramble_point *)path->prev->data; if (p1->p.x > p2->p.x) { rect.x=p2->p.x; rect.width=p1->p.x-p2->p.x; } else { rect.x=p1->p.x; rect.width=p2->p.x-p1->p.x; } if (p1->p.y > p2->p.y) { rect.y=p2->p.y; rect.height=p1->p.y-p2->p.y; } else { rect.y=p1->p.y; rect.height=p2->p.y-p1->p.y; } rect.x=rect.x-10; rect.y=rect.y-10; rect.width=rect.width+20; rect.height=rect.height+20; gdk_window_invalidate_rect(window, &rect, TRUE); } } END_FUNC }
static gboolean lmplayer_lyric_widget_da_add_file(LmplayerLyricWidget *lyric, const gchar *file) { g_return_val_if_fail(LMPLAYER_IS_LYRIC_WIDGET_DA(lyric), FALSE); g_return_val_if_fail(file != NULL, FALSE); LmplayerLyricWidgetDaPrivate *priv = LMPLAYER_LYRIC_WIDGET_DA(lyric)->priv; if(g_access(file, R_OK) != 0) return FALSE; if(priv->lines != NULL) { g_list_free(priv->lines); priv->lines = NULL; priv->da_height = 0; } priv->loaded = parse_lyric_file_without_check(LMPLAYER_LYRIC_WIDGET_DA(lyric), file); if(priv->loaded) { gtk_layout_move(GTK_LAYOUT(lyric), priv->alignment, 0, 0); gdk_window_invalidate_rect(priv->da->window, NULL, FALSE); } priv->changed = TRUE; priv->current_second = -1; update_pixmap(LMPLAYER_LYRIC_WIDGET_DA(lyric)); return priv->loaded; }
static void term_app_request(VteTerminal *term, gpointer user_data) { int event = GPOINTER_TO_INT(user_data); if(event == TERM_ICONIFY_WINDOW) gdk_window_iconify(GTK_WIDGET(mainwindow)->window); if(event == TERM_DEICONIFY_WINDOW) gdk_window_deiconify(GTK_WIDGET(mainwindow)->window); if(event == TERM_RAISE_WINDOW) gdk_window_raise(GTK_WIDGET(mainwindow)->window); if(event == TERM_LOWER_WINDOW) gdk_window_lower(GTK_WIDGET(mainwindow)->window); if(event == TERM_MAXIMIZE_WINDOW) gdk_window_maximize(GTK_WIDGET(mainwindow)->window); if(event == TERM_RESTORE_WINDOW) gdk_window_unmaximize(GTK_WIDGET(mainwindow)->window); if(event == TERM_REFRESH_WINDOW) { GdkRectangle rect; rect.x = rect.y = 0; rect.width = mainwindow->allocation.width; rect.height = mainwindow->allocation.height; gdk_window_invalidate_rect(GTK_WIDGET(mainwindow)->window, &rect, TRUE); } }
/* When GLArea widget size changes, viewport size is set to match the new size */ static gint reshape(GtkWidget *widget, GdkEventConfigure *event) { GdkGLContext *glcontext = gtk_widget_get_gl_context (widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (widget); if(!GTK_IS_WIDGET(widget)) return TRUE; if(!GTK_WIDGET_REALIZED(widget)) return TRUE; if (gdk_gl_drawable_gl_begin (gldrawable, glcontext)) { /* pthread_mutex_lock (&theRender_mutex);*/ glViewport(0,0, widget->allocation.width, widget->allocation.height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(perspective) mYPerspective(Zoom,(GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height,zNear,zFar); else { gdouble fw = (GLdouble)widget->allocation.width/(GLdouble)widget->allocation.height; gdouble fh = 1.0; glOrtho(-fw,fw,-fh,fh,-1,1); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gdk_gl_drawable_gl_end (gldrawable); /* pthread_mutex_unlock (&theRender_mutex);*/ gdk_window_invalidate_rect (gtk_widget_get_parent_window (widget), &widget->allocation, TRUE); gdk_window_process_updates (gtk_widget_get_parent_window (widget), TRUE); } return TRUE; }
bool WaylandEGLContext::create_context () { int scale = gdk_window_get_scale_factor (gdk_window); gdk_window_get_geometry (gdk_window, &x, &y, &width, &height); EGLint surface_attribs[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_RED_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_NONE }; EGLint context_attribs[] = { EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT, EGL_NONE }; EGLint num_configs = 0; if (!subsurface) return false; egl_display = eglGetDisplay ((EGLNativeDisplayType) display); eglInitialize (egl_display, NULL, NULL); if (!eglChooseConfig (egl_display, surface_attribs, &egl_config, 1, &num_configs)) { printf ("Couldn't find matching config.\n"); return false; } eglBindAPI (EGL_OPENGL_API); egl_window = wl_egl_window_create (child, width * scale, height * scale); if (!egl_window) { printf ("Couldn't create window.\n"); return false; } egl_surface = eglCreateWindowSurface (egl_display, egl_config, (EGLNativeWindowType) egl_window, NULL); if (!egl_surface) { printf ("Couldn't create surface.\n"); return false; } egl_context = eglCreateContext (egl_display, egl_config, EGL_NO_CONTEXT, context_attribs); if (!egl_context) { printf ("Couldn't create context.\n"); return false; } wl_surface_set_buffer_scale (child, scale); gdk_window_invalidate_rect (gdk_window, NULL, FALSE); return true; }
void meta_tile_preview_show (MetaTilePreview *preview, MetaRectangle *tile_rect) { GdkWindow *window; GdkRectangle old_rect; if (gtk_widget_get_visible (preview->preview_window) && preview->tile_rect.x == tile_rect->x && preview->tile_rect.y == tile_rect->y && preview->tile_rect.width == tile_rect->width && preview->tile_rect.height == tile_rect->height) return; /* nothing to do */ gtk_widget_show (preview->preview_window); window = gtk_widget_get_window (preview->preview_window); meta_core_lower_beneath_grab_window (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_WINDOW_XID (window), gtk_get_current_event_time ()); old_rect.x = old_rect.y = 0; old_rect.width = preview->tile_rect.width; old_rect.height = preview->tile_rect.height; gdk_window_invalidate_rect (window, &old_rect, FALSE); preview->tile_rect = *tile_rect; gdk_window_move_resize (window, preview->tile_rect.x, preview->tile_rect.y, preview->tile_rect.width, preview->tile_rect.height); if (!preview->has_alpha) { cairo_region_t *outer_region, *inner_region; GdkRectangle outer_rect, inner_rect; GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 }; gdk_window_set_background_rgba (window, &black); outer_rect.x = outer_rect.y = 0; outer_rect.width = preview->tile_rect.width; outer_rect.height = preview->tile_rect.height; inner_rect.x = OUTLINE_WIDTH; inner_rect.y = OUTLINE_WIDTH; inner_rect.width = outer_rect.width - 2 * OUTLINE_WIDTH; inner_rect.height = outer_rect.height - 2 * OUTLINE_WIDTH; outer_region = cairo_region_create_rectangle (&outer_rect); inner_region = cairo_region_create_rectangle (&inner_rect); cairo_region_subtract (outer_region, inner_region); cairo_region_destroy (inner_region); gdk_window_shape_combine_region (window, outer_region, 0, 0); cairo_region_destroy (outer_region); } }
/************************************************************************** Flush the given part of the canvas buffer (if there is one) to the screen. **************************************************************************/ void flush_mapcanvas(int canvas_x, int canvas_y, int pixel_width, int pixel_height) { GdkRectangle rectangle = {canvas_x, canvas_y, pixel_width, pixel_height}; if (gtk_widget_get_realized(map_canvas) && !mapview_is_frozen()) { gdk_window_invalidate_rect(gtk_widget_get_window(map_canvas), &rectangle, FALSE); } }
static gboolean gtk_offscreen_box_damage (GtkWidget *widget, GdkEventExpose *event) { gdk_window_invalidate_rect (widget->window, NULL, FALSE); return TRUE; }
void wxMiniFrame::SetTitle( const wxString &title ) { wxFrame::SetTitle( title ); GdkWindow* window = gtk_widget_get_window(gtk_bin_get_child(GTK_BIN(m_widget))); if (window) gdk_window_invalidate_rect(window, NULL, false); }
static gboolean widget_overlay_damage (GtkWidget *widget, G_GNUC_UNUSED GdkEventExpose *event) { gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE); return TRUE; }
void background_info_change_alpha(BackgroundInfo* info, double alpha) { info->alpha = alpha; if (gtk_widget_get_realized(info->container)) { gdk_window_invalidate_rect(gtk_widget_get_window(info->container), NULL, TRUE); } }
/************************************************************************** Mark the rectangular region as "dirty" so that we know to flush it later. **************************************************************************/ void dirty_rect(int canvas_x, int canvas_y, int pixel_width, int pixel_height) { GdkRectangle rectangle = {canvas_x, canvas_y, pixel_width, pixel_height}; if (gtk_widget_get_realized(map_canvas)) { gdk_window_invalidate_rect(gtk_widget_get_window(map_canvas), &rectangle, FALSE); } }
static gboolean gtk_mirror_bin_damage (GtkWidget *widget, GdkEventExpose *event) { gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE); return TRUE; }
void force_update(GtkWidget *wid) { if ((wid) && (wid->window)) { gdk_window_invalidate_rect(GDK_WINDOW(wid->window), NULL, true); gdk_window_process_updates(GDK_WINDOW(wid->window), true); } }