static void _lib_geotagging_show_offset_window(GtkWidget *widget, dt_lib_module_t *self) { dt_lib_geotagging_t *d = self->data; gint x, y; gint px, py, center_w, center_h, window_w, window_h; GtkWidget *window = dt_ui_main_window(darktable.gui->ui); GtkWidget *center = dt_ui_center(darktable.gui->ui); gdk_window_get_origin(gtk_widget_get_window(center), &px, &py); center_w = gdk_window_get_width(gtk_widget_get_window(center)); center_h = gdk_window_get_height(gtk_widget_get_window(center)); d->floating_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_can_focus(d->floating_window, TRUE); gtk_window_set_decorated(GTK_WINDOW(d->floating_window), FALSE); gtk_window_set_type_hint(GTK_WINDOW(d->floating_window), GDK_WINDOW_TYPE_HINT_POPUP_MENU); gtk_window_set_transient_for(GTK_WINDOW(d->floating_window), GTK_WINDOW(window)); gtk_window_set_opacity(GTK_WINDOW(d->floating_window), 0.8); gtk_window_set_modal(GTK_WINDOW(d->floating_window), TRUE); GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 5, 5, 5); GtkWidget *vbox = gtk_vbox_new(TRUE, 5); gtk_container_add(GTK_CONTAINER(alignment), vbox); d->floating_window_entry = gtk_entry_new(); gtk_widget_add_events(d->floating_window_entry, GDK_FOCUS_CHANGE_MASK); g_signal_connect_swapped(d->floating_window, "focus-out-event", G_CALLBACK(gtk_widget_destroy), d->floating_window); g_object_set(G_OBJECT(d->floating_window_entry), "tooltip-text", _("enter the time shown on the selected picture\nformat: hh:mm:ss"), (char *)NULL); gtk_editable_select_region(GTK_EDITABLE(d->floating_window_entry), 0, -1); gtk_box_pack_start(GTK_BOX(vbox), d->floating_window_entry, TRUE, TRUE, 0); g_signal_connect(d->floating_window_entry, "key-press-event", G_CALLBACK(_lib_geotagging_floating_key_press), self); GtkWidget *hbox = gtk_hbox_new(TRUE, 5); GtkWidget *cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); GtkWidget *ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_box_pack_start(GTK_BOX(hbox), cancel_button, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), ok_button, TRUE, TRUE, 0); g_signal_connect_swapped(G_OBJECT(cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), d->floating_window); g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(_lib_geotagging_calculate_offset_callback), self); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(d->floating_window), alignment); gtk_widget_show_all(d->floating_window); gtk_widget_grab_focus(d->floating_window_entry); window_w = gdk_window_get_width(gtk_widget_get_window(d->floating_window)); window_h = gdk_window_get_height(gtk_widget_get_window(d->floating_window)); x = px + 0.5*(center_w-window_w); y = py + center_h - 20 - window_h; gtk_window_move(GTK_WINDOW(d->floating_window), x, y); gtk_window_present(GTK_WINDOW(d->floating_window)); }
static gboolean gtk_rotated_bin_draw (GtkWidget *widget, cairo_t *cr) { GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); GdkWindow *window; gdouble s, c; gdouble w, h; window = gtk_widget_get_window (widget); if (gtk_cairo_should_draw_window (cr, window)) { cairo_surface_t *surface; GtkAllocation child_area; if (bin->child && gtk_widget_get_visible (bin->child)) { surface = gdk_offscreen_window_get_surface (bin->offscreen_window); gtk_widget_get_allocation (bin->child, &child_area); /* transform */ s = sin (bin->angle); c = cos (bin->angle); w = c * child_area.width + s * child_area.height; h = s * child_area.width + c * child_area.height; cairo_translate (cr, (w - child_area.width) / 2, (h - child_area.height) / 2); cairo_translate (cr, child_area.width / 2, child_area.height / 2); cairo_rotate (cr, bin->angle); cairo_translate (cr, -child_area.width / 2, -child_area.height / 2); /* clip */ cairo_rectangle (cr, 0, 0, gdk_window_get_width (bin->offscreen_window), gdk_window_get_height (bin->offscreen_window)); cairo_clip (cr); /* paint */ cairo_set_source_surface (cr, surface, 0, 0); cairo_paint (cr); } } if (gtk_cairo_should_draw_window (cr, bin->offscreen_window)) { gtk_render_background (gtk_widget_get_style_context (widget), cr, 0, 0, gdk_window_get_width (bin->offscreen_window), gdk_window_get_height (bin->offscreen_window)); if (bin->child) gtk_container_propagate_draw (GTK_CONTAINER (widget), bin->child, cr); } return FALSE; }
/* private methods */ static gboolean expose_event (GtkWidget *widget, cairo_t *cr1, gpointer dara) { cairo_t *cr; gint w, h; TboDrawing *self = TBO_DRAWING (widget); cr = gdk_cairo_create(gtk_layout_get_bin_window (GTK_LAYOUT (widget))); w = gdk_window_get_width (gtk_layout_get_bin_window (GTK_LAYOUT (widget))); h = gdk_window_get_height (gtk_layout_get_bin_window (GTK_LAYOUT (widget))); cairo_set_source_rgb (cr, 0, 0, 0); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); tbo_drawing_draw (TBO_DRAWING (widget), cr); tbo_tooltip_draw (cr); // Update drawing helpers if (self->tool) self->tool->drawing (self->tool, cr); cairo_destroy(cr); return FALSE; }
static gboolean highlight_draw (GtkWidget *widget, cairo_t *cr, gpointer data) { GdkWindow *bin_window; int width; int height; GtkStyleContext *style; /* FIXMEchpe: is bin window right here??? */ bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); width = gdk_window_get_width (bin_window); height = gdk_window_get_height (bin_window); style = gtk_widget_get_style_context (widget); gtk_style_context_save (style); gtk_style_context_add_class (style, "treeview-drop-indicator"); gtk_render_focus (style, cr, 0, 0, width, height); gtk_style_context_restore (style); return FALSE; }
static void gtk_bubble_window_update_shape (GtkBubbleWindow *window) { cairo_surface_t *surface; cairo_region_t *region; GdkWindow *win; cairo_t *cr; win = gtk_widget_get_window (GTK_WIDGET (window)); surface = gdk_window_create_similar_surface (win, CAIRO_CONTENT_COLOR_ALPHA, gdk_window_get_width (win), gdk_window_get_height (win)); cr = cairo_create (surface); gtk_bubble_window_apply_border_path (window, cr); cairo_fill (cr); cairo_destroy (cr); region = gdk_cairo_region_create_from_surface (surface); cairo_surface_destroy (surface); if (!gtk_widget_is_composited (GTK_WIDGET (window))) gtk_widget_shape_combine_region (GTK_WIDGET (window), region); gtk_widget_input_shape_combine_region (GTK_WIDGET (window), region); cairo_region_destroy (region); }
static void get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2) { gint ox, oy, width, height; GtkWidget *parent = gtk_widget_get_parent(w); if (parent && gtk_widget_get_window(parent) == gtk_widget_get_window(w)) { GtkAllocation allocation; gtk_widget_get_allocation(w, &allocation); get_widget_coords(parent, &ox, &oy, NULL, NULL); height = allocation.height; width = allocation.width; } else { GdkWindow *win = gtk_widget_get_window(w); gdk_window_get_origin(win, &ox, &oy); width = gdk_window_get_width(win); height = gdk_window_get_height(win); } if (x1) *x1 = ox; if (y1) *y1 = oy; if (x2) *x2 = ox + width; if (y2) *y2 = oy + height; }
void tray_icon_added (NaTrayManager *manager, Window child, GtkWidget* container) { GdkWindow* wrapper = create_wrapper(gtk_widget_get_window(container), child); if (wrapper == NULL) return; GdkWindow* icon = get_icon_window(wrapper); g_assert(icon != NULL); gdk_window_reparent(wrapper, gtk_widget_get_window(container), 0, gdk_screen_height() - DOCK_HEIGHT); //add this mask so, gdk can handle GDK_SELECTION_CLEAR event to destroy this gdkwindow. gdk_window_set_events(icon, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK); gdk_window_add_filter(icon, (GdkFilterFunc)monitor_icon_event, wrapper); gdk_window_set_composited(wrapper, TRUE); gdk_window_show(wrapper); char *re_class = NULL; get_wmclass(icon, &re_class, NULL); if (g_strcmp0(re_class, DEEPIN_TRAY_ICON) == 0) { _deepin_tray = wrapper; _deepin_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon)); _update_deepin_try_position(); } else if (g_strcmp0(re_class, FCITX_TRAY_ICON) == 0) { _fcitx_tray = wrapper; _fcitx_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon)); _update_fcitx_try_position(); } else { int width = gdk_window_get_width(icon) * 1.0 / gdk_window_get_height(icon) * DEFAULT_HEIGHT; gdk_window_resize(icon, width, DEFAULT_HEIGHT); g_hash_table_insert(_icons, wrapper, GINT_TO_POINTER(CLAMP_WIDTH(width))); } g_free(re_class); _update_notify_area_width(); }
static gboolean button_press_callback (GtkWidget *event_box, GdkEventButton *event, gpointer data) { gint ev_width, ev_height, im_width, im_height; GdkWindow *ev_w = gtk_widget_get_parent_window(event_box); ev_width = gdk_window_get_width(ev_w); ev_height = gdk_window_get_height(ev_w); GdkPixbuf *pix = gtk_image_get_pixbuf(data); if (!pix) return TRUE; im_width = gdk_pixbuf_get_width(pix); im_height = gdk_pixbuf_get_height(pix); pic_button_x1 = event->x - (ev_width - im_width)/2; pic_button_y1 = event->y - (ev_height - im_height)/2; pic_button_x2 = pic_button_x1; pic_button_y2 = pic_button_y1; pic_button_drag = TRUE; return TRUE; }
void content_draw (GtkWidget *widget, cairo_t *cr) { PangoContext *context; PangoLayout *title_layout; PangoLayout *sub_layout; PangoFontDescription *desc; int width, height; int sub_width; width = gdk_window_get_width (gtk_widget_get_window (widget)); height = gdk_window_get_height (gtk_widget_get_window (widget)); cairo_translate (cr, width / 2, height / 2); context = gdk_pango_context_get_for_screen (gtk_widget_get_screen (widget)); title_layout = pango_layout_new (context); pango_layout_set_text (title_layout, _("This session is locked"), -1); desc = pango_font_description_from_string (TITLE_FONT); pango_layout_set_font_description (title_layout, desc); pango_font_description_free (desc); cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0); pango_cairo_update_layout (cr, title_layout); pango_layout_get_size (title_layout, &width, &height); cairo_save (cr); /* Adjust the translation to the middle left of the icon */ cairo_translate (cr, - width / PANGO_SCALE / 2 - height / PANGO_SCALE, - height / PANGO_SCALE / 2); draw_lock_icon (cr, height / PANGO_SCALE); cairo_restore (cr); cairo_move_to (cr, - width / PANGO_SCALE / 2 + height / PANGO_SCALE, - height / PANGO_SCALE); pango_cairo_show_layout (cr, title_layout); g_object_unref (title_layout); sub_layout = pango_layout_new (context); pango_layout_set_text (sub_layout, _("You'll be redirected to the unlock dialog automatically in a few seconds"), -1); pango_layout_set_wrap (sub_layout, PANGO_WRAP_WORD_CHAR); pango_layout_set_width (sub_layout, width + 2 * height); desc = pango_font_description_from_string (MESSAGE_FONT); pango_layout_set_font_description (sub_layout, desc); pango_font_description_free (desc); cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0); pango_cairo_update_layout (cr, sub_layout); pango_layout_get_size (sub_layout, &sub_width, NULL); cairo_move_to (cr, - (width + 2 * height) / PANGO_SCALE / 2, height / PANGO_SCALE); cairo_scale (cr, (width + 2 * height) / (gdouble)sub_width, (width + 2 * height) / (gdouble)sub_width); pango_cairo_show_layout (cr, sub_layout); g_object_unref (sub_layout); g_object_unref (context); }
/********************************************************************\ * gnc_window_adjust_for_screen * * adjust the window size if it is bigger than the screen size. * * * * Args: window - the window to adjust * * Returns: nothing * \********************************************************************/ void gnc_window_adjust_for_screen(GtkWindow * window) { gint screen_width; gint screen_height; gint width; gint height; if (window == NULL) return; g_return_if_fail(GTK_IS_WINDOW(window)); if (gtk_widget_get_window (GTK_WIDGET(window)) == NULL) return; screen_width = gdk_screen_width(); screen_height = gdk_screen_height(); width = gdk_window_get_width (gtk_widget_get_window (GTK_WIDGET(window))); height = gdk_window_get_height (gtk_widget_get_window (GTK_WIDGET(window))); if ((width <= screen_width) && (height <= screen_height)) return; width = MIN(width, screen_width - 10); width = MAX(width, 0); height = MIN(height, screen_height - 10); height = MAX(height, 0); gdk_window_resize(gtk_widget_get_window (GTK_WIDGET(window)), width, height); gtk_widget_queue_resize(GTK_WIDGET(window)); }
static void smaller_window_clicked (GtkWidget *button, gpointer data) { GList *selected, *l; GdkWindow *window; int w, h; selected = get_selected_windows (); for (l = selected; l != NULL; l = l->next) { window = l->data; w = gdk_window_get_width (window) - 10; h = gdk_window_get_height (window) - 10; if (w < 1) w = 1; if (h < 1) h = 1; gdk_window_resize (window, w, h); } g_list_free (selected); }
void iupDrawUpdateSize(IdrawCanvas* dc) { int w, h; #if GTK_CHECK_VERSION(2, 24, 0) w = gdk_window_get_width(dc->window); h = gdk_window_get_height(dc->window); #else gdk_drawable_get_size(dc->window, &w, &h); #endif if (w != dc->w || h != dc->h) { cairo_surface_t* surface; dc->w = w; dc->h = h; cairo_destroy(dc->image_cr); surface = cairo_surface_create_similar(cairo_get_target(dc->cr), CAIRO_CONTENT_COLOR_ALPHA, dc->w, dc->h); dc->image_cr = cairo_create(surface); cairo_surface_destroy(surface); } }
static void clutter_stage_gdk_set_gdk_geometry (ClutterStageGdk *stage) { GdkGeometry geometry; ClutterStage *wrapper = CLUTTER_STAGE_COGL (stage)->wrapper; gboolean resize = clutter_stage_get_user_resizable (wrapper); if (!resize) { geometry.min_width = geometry.max_width = gdk_window_get_width (stage->window); geometry.min_height = geometry.max_height = gdk_window_get_height (stage->window); gdk_window_set_geometry_hints (stage->window, &geometry, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); } else { clutter_stage_get_minimum_size (wrapper, (guint *)&geometry.min_width, (guint *)&geometry.min_height); gdk_window_set_geometry_hints (stage->window, &geometry, GDK_HINT_MIN_SIZE); } }
static gboolean touch_release_in_button (GtkButton *button) { GtkButtonPrivate *priv; gint width, height; GdkEvent *event; gdouble x, y; priv = button->priv; event = gtk_get_current_event (); if (!event) return FALSE; if (event->type != GDK_TOUCH_END || event->touch.window != priv->event_window) { gdk_event_free (event); return FALSE; } gdk_event_get_coords (event, &x, &y); width = gdk_window_get_width (priv->event_window); height = gdk_window_get_height (priv->event_window); gdk_event_free (event); if (x >= 0 && x <= width && y >= 0 && y <= height) return TRUE; return FALSE; }
/* preview_get_widget_size */ static void _preview_get_widget_size(Preview * preview, gint * width, gint * height) { #if GTK_CHECK_VERSION(2, 14, 0) GdkWindow * window; if((window = gtk_widget_get_window(preview->view_image)) != NULL) { # if GTK_CHECK_VERSION(2, 24, 0) *width = gdk_window_get_width(window); *height = gdk_window_get_height(window); # else gdk_drawable_get_size(GDK_DRAWABLE(window), width, height); # endif } else #endif { *width = PREVIEW_IMAGE_SIZE_DEFAULT; *height = PREVIEW_IMAGE_SIZE_DEFAULT; } #ifdef DEBUG fprintf(stderr, "DEBUG: %s() %dx%d\n", __func__, *width, *height); #endif }
static void desktop_cb (GSimpleAction *action, GVariant *parameter, gpointer callback_data) { GdkScreen *screen; GdkWindow *root; GtkWidget *window; GtkWidget *label; GdkRGBA desktop_color; screen = gdk_screen_get_default (); root = gdk_screen_get_root_window (screen); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DESKTOP"); gtk_window_set_title (GTK_WINDOW (window), "Desktop"); gtk_widget_set_size_request (window, gdk_window_get_width (root), gdk_window_get_height (root)); gtk_window_move (GTK_WINDOW (window), 0, 0); desktop_color.red = 0.32; desktop_color.green = 0.46; desktop_color.blue = 0.65; desktop_color.alpha = 1.0; override_background_color (window, &desktop_color); label = focus_label (window); gtk_container_add (GTK_CONTAINER (window), label); gtk_widget_show_all (window); }
static void drawTest(Ihandle *ih, int posx) { int w, h; GdkWindow* wnd = (GdkWindow*)IupGetAttribute(ih, "DRAWABLE"); cairo_t* cr = (cairo_t*)IupGetAttribute(ih, "CAIRO_CR"); w = gdk_window_get_width(wnd); h = gdk_window_get_height(wnd); /* white background */ cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); cairo_rectangle(cr, 0, 0, w, h); cairo_fill(cr); /* virtual size */ w = 600; /* red X */ cairo_set_source_rgba(cr, 1.0, 0, 0, 1.0); cairo_move_to(cr, -posx, 0); cairo_line_to(cr, w-posx, h); cairo_move_to(cr, -posx, h); cairo_line_to(cr, w-posx, 0); cairo_stroke(cr); }
/* Load a file image in the window. */ static void load_file () { if (background_data->background_cr) { cairo_surface_t *surface = cairo_image_surface_create_from_png (background_data->background_image); cairo_t *cr = cairo_create (surface); gtk_window_set_opacity (GTK_WINDOW (background_data->background_window), 1.0); gint new_height = 0; gint new_width = 0; new_height = gdk_window_get_height (gtk_widget_get_window (background_data->background_window)); new_width = gdk_window_get_width (gtk_widget_get_window (background_data->background_window)); cairo_surface_t *scaled_surface = scale_surface (surface, new_width, new_height ); cairo_surface_destroy (surface); cairo_destroy (cr); cairo_set_source_surface (background_data->background_cr, scaled_surface, 0.0, 0.0); cairo_paint (background_data->background_cr); cairo_stroke (background_data->background_cr); cairo_surface_destroy (scaled_surface); #ifndef _WIN32 gtk_widget_input_shape_combine_region (background_data->background_window, NULL); #endif } }
void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window) { GtkIMContextClass *klass; g_return_if_fail (GTK_IS_IM_CONTEXT (context)); klass = GTK_IM_CONTEXT_GET_CLASS (context); if (klass->set_client_window) klass->set_client_window (context, window); //below is our interposed codes to save the context to local_context. if(!GDK_IS_WINDOW (window)) return; g_object_set_data(G_OBJECT(context),"window",window); int width = gdk_window_get_width(window); int height = gdk_window_get_height(window); if(width != 0 && height !=0) { gtk_im_context_focus_in(context); local_context = context; } //only add this event_filter when using 'fcitx' immodule. //for xim immodule, this function is as same as original from gtk2. const gchar * immodule = g_getenv("GTK_IM_MODULE"); if(immodule && !strcmp(immodule, "fcitx")) { gdk_window_add_filter (window, event_filter, context); } }
JNIEXPORT jint JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1get_1height ( JNIEnv* env, jclass cls, jlong _self ) { int result; jint _result; GdkWindow* self; // convert parameter self self = (GdkWindow*) _self; // call function result = gdk_window_get_height(self); // cleanup parameter self // translate return value to JNI type _result = (jint) result; // and finally return _result; }
void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); GdkWindow *window; int ww, wh; if (!vc->gfx.scanout_mode) { return; } if (!vc->gfx.guest_fb.framebuffer) { return; } eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); window = gtk_widget_get_window(vc->gfx.drawing_area); ww = gdk_window_get_width(window); wh = gdk_window_get_height(window); egl_fb_setup_default(&vc->gfx.win_fb, ww, wh); if (vc->gfx.cursor_fb.texture) { egl_texture_blit(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.guest_fb, vc->gfx.y0_top); egl_texture_blend(vc->gfx.gls, &vc->gfx.win_fb, &vc->gfx.cursor_fb, vc->gfx.y0_top, vc->gfx.cursor_x, vc->gfx.cursor_y, vc->gfx.scale_x, vc->gfx.scale_y); } else { egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top); } eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); }
void gd_egl_draw(VirtualConsole *vc) { GdkWindow *window; int ww, wh; if (!vc->gfx.gls) { return; } window = gtk_widget_get_window(vc->gfx.drawing_area); ww = gdk_window_get_width(window); wh = gdk_window_get_height(window); if (vc->gfx.scanout_mode) { gd_egl_scanout_flush(&vc->gfx.dcl, 0, 0, vc->gfx.w, vc->gfx.h); vc->gfx.scale_x = (double)ww / vc->gfx.w; vc->gfx.scale_y = (double)wh / vc->gfx.h; } else { if (!vc->gfx.ds) { return; } eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); eglSwapBuffers(qemu_egl_display, vc->gfx.esurface); vc->gfx.scale_x = (double)ww / surface_width(vc->gfx.ds); vc->gfx.scale_y = (double)wh / surface_height(vc->gfx.ds); } }
static gboolean drag_highlight_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { gint width, height; GdkWindow *window; GtkStyleContext *style; window = gtk_widget_get_window (widget); width = gdk_window_get_width (window); height = gdk_window_get_height (window); style = gtk_widget_get_style_context (widget); gtk_style_context_save (style); gtk_style_context_add_class (style, GTK_STYLE_CLASS_DND); gtk_style_context_set_state (style, GTK_STATE_FLAG_FOCUSED); gtk_render_frame (style, cr, 0, 0, width, height); gtk_style_context_restore (style); return FALSE; }
static void selection_render_mask (Selection *selection) { GdkWindow *window; cairo_surface_t *surface; cairo_t *cr; window = gtk_widget_get_window (selection->shell->canvas); surface = gdk_window_create_similar_surface (window, CAIRO_CONTENT_ALPHA, gdk_window_get_width (window), gdk_window_get_height (window)); cr = cairo_create (surface); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); cairo_set_line_width (cr, 1.0); if (selection->shell->rotate_transform) cairo_transform (cr, selection->shell->rotate_transform); gimp_cairo_add_segments (cr, selection->segs_in, selection->n_segs_in); cairo_stroke (cr); selection->segs_in_mask = cairo_pattern_create_for_surface (surface); cairo_destroy (cr); cairo_surface_destroy (surface); }
/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { GdkWindow *win, *parentWin; GtkWidget *widget=(GtkWidget *)draw; win = gtk_widget_get_window(widget); parentWin = gtk_widget_get_parent_window(widget); #ifdef _WIN32 xinfo->display = (void*)GDK_WINDOW_HWND(win); #elif defined(__APPLE__) xinfo->display = 0; xinfo->window = getMainNSWindow(); #else xinfo->systemWindowId = GDK_WINDOW_XID(win); xinfo->display = GDK_WINDOW_XDISPLAY(parentWin); #endif int windowWidth, windowHeight; int x, y; windowWidth = gdk_window_get_width(parentWin); windowHeight = gdk_window_get_height(parentWin); gdk_window_get_position(win, &x, &y); xinfo->x = x; xinfo->y = windowHeight - (y + lastH); xinfo->width = lastW; xinfo->height = lastH; }
static void size_allocate(GtkWidget* widget, GtkAllocation* alloc) { wxPizza* pizza = WX_PIZZA(widget); int border_x, border_y; pizza->get_border_widths(border_x, border_y); int w = alloc->width - 2 * border_x; if (w < 0) w = 0; if (gtk_widget_get_realized(widget)) { int h = alloc->height - 2 * border_y; if (h < 0) h = 0; const int x = alloc->x + border_x; const int y = alloc->y + border_y; GdkWindow* window = gtk_widget_get_window(widget); int old_x, old_y; gdk_window_get_position(window, &old_x, &old_y); if (x != old_x || y != old_y || w != gdk_window_get_width(window) || h != gdk_window_get_height(window)) { gdk_window_move_resize(window, x, y, w, h); if (border_x + border_y) { // old and new border areas need to be invalidated, // otherwise they will not be erased/redrawn properly GdkWindow* parent = gtk_widget_get_parent_window(widget); gdk_window_invalidate_rect(parent, &widget->allocation, false); gdk_window_invalidate_rect(parent, alloc, false); } } } widget->allocation = *alloc; // adjust child positions for (const GList* list = pizza->m_fixed.children; list; list = list->next) { const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data); if (gtk_widget_get_visible(child->widget)) { GtkAllocation child_alloc; // note that child positions do not take border into // account, they need to be relative to widget->window, // which has already been adjusted child_alloc.x = child->x - pizza->m_scroll_x; child_alloc.y = child->y - pizza->m_scroll_y; GtkRequisition req; gtk_widget_get_child_requisition(child->widget, &req); child_alloc.width = req.width; child_alloc.height = req.height; if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) child_alloc.x = w - child_alloc.x - child_alloc.width; gtk_widget_size_allocate(child->widget, &child_alloc); } } }
static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc) { wxPizza* pizza = WX_PIZZA(widget); GtkBorder border; pizza->get_border(border); int w = alloc->width - border.left - border.right; if (w < 0) w = 0; if (gtk_widget_get_realized(widget)) { int h = alloc->height - border.top - border.bottom; if (h < 0) h = 0; const int x = alloc->x + border.left; const int y = alloc->y + border.top; GdkWindow* window = gtk_widget_get_window(widget); int old_x, old_y; gdk_window_get_position(window, &old_x, &old_y); if (x != old_x || y != old_y || w != gdk_window_get_width(window) || h != gdk_window_get_height(window)) { gdk_window_move_resize(window, x, y, w, h); if (border.left + border.right + border.top + border.bottom) { // old and new border areas need to be invalidated, // otherwise they will not be erased/redrawn properly GtkAllocation old_alloc; gtk_widget_get_allocation(widget, &old_alloc); GdkWindow* parent = gtk_widget_get_parent_window(widget); gdk_window_invalidate_rect(parent, &old_alloc, false); gdk_window_invalidate_rect(parent, alloc, false); } } } gtk_widget_set_allocation(widget, alloc); // adjust child positions for (const GList* p = pizza->m_children; p; p = p->next) { const wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data); if (gtk_widget_get_visible(child->widget)) { GtkAllocation child_alloc; // note that child positions do not take border into // account, they need to be relative to widget->window, // which has already been adjusted child_alloc.x = child->x - pizza->m_scroll_x; child_alloc.y = child->y - pizza->m_scroll_y; child_alloc.width = child->width; child_alloc.height = child->height; if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) child_alloc.x = w - child_alloc.x - child_alloc.width; gtk_widget_size_allocate(child->widget, &child_alloc); } } }
static gboolean is_in_viewport (GtkWindow *window, GdkScreen *screen, gint workspace, gint viewport_x, gint viewport_y) { GdkScreen *s; GdkDisplay *display; GdkWindow *gdkwindow; const gchar *cur_name; const gchar *name; gint cur_n; gint n; gint ws; gint sc_width, sc_height; gint x, y, width, height; gint vp_x, vp_y; /* Check for screen and display match */ display = gdk_screen_get_display (screen); cur_name = gdk_display_get_name (display); cur_n = gdk_screen_get_number (screen); s = gtk_window_get_screen (window); display = gdk_screen_get_display (s); name = gdk_display_get_name (display); n = gdk_screen_get_number (s); if (strcmp (cur_name, name) != 0 || cur_n != n) { return FALSE; } /* Check for workspace match */ ws = gedit_utils_get_window_workspace (window); if (ws != workspace && ws != GEDIT_ALL_WORKSPACES) { return FALSE; } /* Check for viewport match */ gdkwindow = gtk_widget_get_window (GTK_WIDGET (window)); gdk_window_get_position (gdkwindow, &x, &y); width = gdk_window_get_width (gdkwindow); height = gdk_window_get_height (gdkwindow); gedit_utils_get_current_viewport (screen, &vp_x, &vp_y); x += vp_x; y += vp_y; sc_width = gdk_screen_get_width (screen); sc_height = gdk_screen_get_height (screen); return x + width * .25 >= viewport_x && x + width * .75 <= viewport_x + sc_width && y >= viewport_y && y + height <= viewport_y + sc_height; }
static void gtk_xtbin_realize (GtkWidget *widget) { GtkXtBin *xtbin; GtkAllocation allocation = { 0, 0, 200, 200 }; #if GTK_CHECK_VERSION(2, 18, 0) GtkAllocation widget_allocation; #endif #ifdef DEBUG_XTBIN printf("gtk_xtbin_realize()\n"); #endif g_return_if_fail (GTK_IS_XTBIN (widget)); xtbin = GTK_XTBIN (widget); /* caculate the allocation before realize */ #if GTK_CHECK_VERSION(2, 24, 0) allocation.width = gdk_window_get_width(xtbin->parent_window); allocation.height = gdk_window_get_height(xtbin->parent_window); #else gint x, y, w, h, d; /* geometry of window */ gdk_window_get_geometry(xtbin->parent_window, &x, &y, &w, &h, &d); allocation.width = w; allocation.height = h; #endif gtk_widget_size_allocate (widget, &allocation); #ifdef DEBUG_XTBIN printf("initial allocation %d %d %d %d\n", x, y, w, h); #endif #if GTK_CHECK_VERSION(2, 18, 0) gtk_widget_get_allocation(widget, &widget_allocation); xtbin->width = widget_allocation.width; xtbin->height = widget_allocation.height; #else xtbin->width = widget->allocation.width; xtbin->height = widget->allocation.height; #endif /* use GtkSocket's realize */ (*GTK_WIDGET_CLASS(parent_class)->realize)(widget); /* create the Xt client widget */ xt_client_create(&(xtbin->xtclient), gtk_socket_get_id(GTK_SOCKET(xtbin)), xtbin->height, xtbin->width); xtbin->xtwindow = XtWindow(xtbin->xtclient.child_widget); gdk_flush(); /* now that we have created the xt client, add it to the socket. */ gtk_socket_add_id(GTK_SOCKET(widget), xtbin->xtwindow); }
wxScreenDCImpl::wxScreenDCImpl(wxScreenDC* owner) : base_type(owner) { GdkWindow* window = gdk_get_default_root_window(); m_width = gdk_window_get_width(window); m_height = gdk_window_get_height(window); cairo_t* cr = gdk_cairo_create(window); SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr)); }