static void gtk_revealer_real_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkAllocation child_allocation; GtkWidget *child; gboolean window_visible; int bin_x, bin_y; GtkRevealerTransitionType transition; g_return_if_fail (allocation != NULL); gtk_widget_set_allocation (widget, allocation); gtk_revealer_get_child_allocation (revealer, allocation, &child_allocation); child = gtk_bin_get_child (GTK_BIN (revealer)); if (child != NULL && gtk_widget_get_visible (child)) gtk_widget_size_allocate (child, &child_allocation); if (gtk_widget_get_realized (widget)) { if (gtk_widget_get_mapped (widget)) { window_visible = allocation->width > 0 && allocation->height > 0; if (!window_visible && gdk_window_is_visible (priv->view_window)) gdk_window_hide (priv->view_window); if (window_visible && !gdk_window_is_visible (priv->view_window)) gdk_window_show (priv->view_window); } gdk_window_move_resize (priv->view_window, allocation->x, allocation->y, allocation->width, allocation->height); bin_x = 0; bin_y = 0; transition = effective_transition (revealer); if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) bin_y = allocation->height - child_allocation.height; else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) bin_x = allocation->width - child_allocation.width; gdk_window_move_resize (priv->bin_window, bin_x, bin_y, child_allocation.width, child_allocation.height); } }
JNIEXPORT jboolean JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1is_1visible ( JNIEnv* env, jclass cls, jlong _self ) { gboolean result; jboolean _result; GdkWindow* self; // convert parameter self self = (GdkWindow*) _self; // call function result = gdk_window_is_visible(self); // cleanup parameter self // translate return value to JNI type _result = (jboolean) result; // and finally return _result; }
static void test_widget_windows (gpointer data) { GType type = GPOINTER_TO_SIZE (data); GtkWidget* window = gtk_test_create_widget (GTK_TYPE_WINDOW, NULL); GtkWidget* widget = gtk_test_create_widget (type, NULL); GList * windows; gtk_container_add (GTK_CONTAINER (window), widget); gtk_widget_show_all (window); windows = g_list_prepend (NULL, gtk_widget_get_window (window)); while (windows) { gpointer user_data = NULL; GList * children = gdk_window_get_children (windows->data); if (!gdk_window_is_visible (windows->data)) { g_error ("the GdkWindow %p wasn't shown in map()", windows->data); } gdk_window_get_user_data (windows->data, &user_data); if (!user_data) { /* at some point provide a better message (e.g. with the window tree and the data) */ g_error ("the GdkWindow %p doesn't have user data set", windows->data); } windows = g_list_delete_link (windows, windows); windows = g_list_concat (windows, children); } }
static bool childrenUseEvent(GtkWidget *widget, GdkEventButton *event, bool inNoteBook) { // accept, by default bool usable = true; // get children and check GList *children = gtk_container_get_children(GTK_CONTAINER(widget)); for (GList *child = children;child && usable;child = g_list_next(child)) { // cast child to GtkWidget if (GTK_IS_WIDGET(child->data)) { GtkWidget *childWidget = GTK_WIDGET(child->data); GdkWindow *window = nullptr; // check widget state and type if (gtk_widget_get_state(childWidget) == GTK_STATE_PRELIGHT) { // if widget is prelight, we don't need to check where event // happen, any prelight widget indicate we can't do a move usable = false; continue; } window = gtk_widget_get_window(childWidget); if (!(window && gdk_window_is_visible(window))) continue; if (GTK_IS_NOTEBOOK(childWidget)) inNoteBook = true; if(!(event && withinWidget(childWidget, event))) continue; // check special cases for which grab should not be enabled if((isBlackListed(G_OBJECT(childWidget))) || (GTK_IS_NOTEBOOK(widget) && Tab::isLabel(GTK_NOTEBOOK(widget), childWidget)) || (GTK_IS_BUTTON(childWidget) && gtk_widget_get_state(childWidget) != GTK_STATE_INSENSITIVE) || (gtk_widget_get_events(childWidget) & (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)) || (GTK_IS_MENU_ITEM(childWidget)) || (GTK_IS_SCROLLED_WINDOW(childWidget) && (!inNoteBook || gtk_widget_is_focus(childWidget)))) { usable = false; } // if child is a container and event has been accepted so far, // also check it, recursively if (usable && GTK_IS_CONTAINER(childWidget)) { usable = childrenUseEvent(childWidget, event, inNoteBook); } } } if (children) { g_list_free(children); } return usable; }
/* Window is visible */ int clip_GDK_WINDOWISVISIBLE(ClipMachine * cm) { C_widget *cwin = _fetch_cw_arg(cm); GdkWindow *win = NULL; CHECKCWID(cwin,GTK_IS_WIDGET); if (cwin && cwin->widget) win = cwin->widget->window; _clip_retl(cm, gdk_window_is_visible(win)); return 0; err: return 1; }
/** * Change current cursor to default cursor. * * \param force_update Call a gtk iteration to ensure cursor * is updated. May cause trouble if * called from some signal handlers. */ void gsb_status_stop_wait ( gboolean force_update ) { if ( ! run.window ) return; gdk_window_set_cursor ( run.window -> window, NULL ); if ( tracked_window && gdk_window_is_visible ( tracked_window ) ) { gdk_window_set_cursor ( tracked_window, NULL ); tracked_window = NULL; } if ( force_update ) update_gui ( ); }
static void gb_slider_unmap (GtkWidget *widget) { GbSlider *self = (GbSlider *)widget; GbSliderPrivate *priv = gb_slider_get_instance_private (self); gsize i; g_assert (GB_IS_SLIDER (self)); for (i = 0; i < priv->children->len; i++) { GbSliderChild *child; child = g_ptr_array_index (priv->children, i); if ((child->window != NULL) && gdk_window_is_visible (child->window)) gdk_window_hide (child->window); } GTK_WIDGET_CLASS (gb_slider_parent_class)->unmap (widget); }
static void gstyle_slidein_overlay_child_allocate (GstyleSlidein *self, GtkAllocation *alloc) { GtkAllocation child_alloc = { 0, }; gboolean visible; g_assert (GSTYLE_IS_SLIDEIN (self)); g_assert (alloc != NULL); if (self->overlay_child != NULL) { visible = gtk_widget_get_visible (self->overlay_child); if (self->overlay_window != NULL && gtk_widget_get_mapped (GTK_WIDGET (self))) { if (visible) gdk_window_show (self->overlay_window); else if (gdk_window_is_visible (self->overlay_window)) gdk_window_hide (self->overlay_window); } if (!visible) return; gstyle_slidein_compute_child_allocation (self, *alloc, &child_alloc); if (self->overlay_window != NULL) gdk_window_move_resize (self->overlay_window, child_alloc.x, child_alloc.y, child_alloc.width, child_alloc.height); child_alloc.x = 0; child_alloc.y = 0; gtk_widget_size_allocate (self->overlay_child, &child_alloc); } }
static VALUE gdkwin_is_visible(VALUE self) { return CBOOL2RVAL(gdk_window_is_visible(_SELF(self))); }
static void gtk_revealer_real_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkAllocation child_allocation; GtkWidget *child; gboolean window_visible; int bin_x, bin_y; GtkRevealerTransitionType transition; GtkBorder padding; g_return_if_fail (allocation != NULL); gtk_widget_set_allocation (widget, allocation); gtk_revealer_get_child_allocation (revealer, allocation, &child_allocation); child = gtk_bin_get_child (GTK_BIN (revealer)); if (child != NULL && gtk_widget_get_visible (child)) gtk_widget_size_allocate (child, &child_allocation); if (gtk_widget_get_realized (widget)) { if (gtk_widget_get_mapped (widget)) { window_visible = allocation->width > 0 && allocation->height > 0; if (!window_visible && gdk_window_is_visible (priv->view_window)) gdk_window_hide (priv->view_window); if (window_visible && !gdk_window_is_visible (priv->view_window)) gdk_window_show (priv->view_window); } /* The view window will follow the revealer allocation, which is modified * along the animation */ gdk_window_move_resize (priv->view_window, allocation->x, allocation->y, allocation->width, allocation->height); gtk_revealer_get_padding (revealer, &padding); bin_x = 0; bin_y = 0; transition = effective_transition (revealer); /* The child allocation is fixed (it is not modified by the animation), * and it's origin is relative to the bin_window. * The bin_window has the same allocation as the child, and then the bin_window * deals with the relative positioning with respect to the revealer taking * into account the paddings of the revealer. * * For most of transitions, the bin_window moves along with the revealer, * as its allocation changes. * However for GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN * we need to first move the bin_window upwards and then slide it down in * the revealer. * Otherwise the child would appear as static and the revealer will allocate * following the animation, clipping the child. * To calculate the correct y position for this case: * allocation->height - child_allocation.height is the relative position * towards the revealer taking into account the animation progress with * both vertical paddings added, therefore we need to substract the part * that we don't want to take into account for the y position, which * in this case is the bottom padding. * * The same special treatment is needed for GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT. */ if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) { bin_y = allocation->height - child_allocation.height - padding.bottom; bin_x = padding.left; } else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) { bin_y = padding.top; bin_x = allocation->width - child_allocation.width - padding.right; } else { bin_x = padding.left; bin_y = padding.top; } gdk_window_move_resize (priv->bin_window, bin_x, bin_y, child_allocation.width, child_allocation.height); } }