void moz_drawingarea_resize (MozDrawingarea *drawingarea, gint width, gint height) { gdk_window_resize(drawingarea->clip_window, width, height); gdk_window_resize(drawingarea->inner_window, width, height); }
void gdk_superwin_resize (GdkSuperWin *superwin, gint width, gint height) { gdk_window_resize (superwin->bin_window, width, height); gdk_window_resize (superwin->shell_window, width, height); }
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 on_mygtk_clicked( GtkWidget *widget, GdkEventButton *event ) { if (event->button == 1 ) { gdk_window_resize(gwindow->window,movie_width,movie_height); } else { unsigned int my_Width,my_Height; getsize_gtk(&my_Width,&my_Height); if(event->button == 4) { float step=sqrt((float)my_Height); my_Width-=floor(step*((float)movie_width/(float)movie_height)); my_Height-=step; } if(event->button == 5) { float step=sqrt((float)my_Height); my_Width+=floor(step*((float)movie_width/(float)movie_height)); my_Height+=step; } // resize to match movie aspect ratio if( ((float)movie_width/(float)movie_height) < ((float)my_Width/(float)my_Height) ) my_Width=floor((float)my_Height * (float)movie_width / (float)movie_height); else my_Height=floor((float)my_Width * (float)movie_height / (float)movie_width); resize_gtk(my_Width,my_Height); } #if 0 // To be continued... else if (event->button == 4 ) {
/********************************************************************\ * 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 gtk_combo_popup_list (GtkCombo * combo) { gint height, width, x, y; gint old_width, old_height; old_width = combo->popwin->allocation.width; old_height = combo->popwin->allocation.height; gtk_combo_get_pos (combo, &x, &y, &height, &width); /* workaround for gtk_scrolled_window_size_allocate bug */ if (old_width != width || old_height != height) { gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar); gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar); } gtk_widget_set_uposition (combo->popwin, x, y); gtk_widget_set_usize (combo->popwin, width, height); gtk_widget_realize (combo->popwin); gdk_window_resize (combo->popwin->window, width, height); gtk_widget_show (combo->popwin); gtk_widget_grab_focus (combo->popwin); }
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(); }
JNIEXPORT void JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1resize ( JNIEnv* env, jclass cls, jlong _self, jint _width, jint _height ) { GdkWindow* self; gint width; gint height; // convert parameter self self = (GdkWindow*) _self; // convert parameter width width = (gint) _width; // convert parameter height height = (gint) _height; // call function gdk_window_resize(self, width, height); // cleanup parameter self // cleanup parameter width // cleanup parameter height }
void safe_window_move_resize(GdkWindow* wrapper, int x, int y, int w, int h) { XSelectInput(gdk_x11_get_default_xdisplay(), GDK_WINDOW_XID(wrapper), ExposureMask | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask); gdk_window_move_resize(wrapper, x, y, w, h); GdkWindow* icon = g_object_get_data(G_OBJECT(wrapper), "wrapper_child"); if (icon) { gdk_window_resize(icon, w, h); } gdk_window_set_events(wrapper, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK); }
static void handle_allocate(GtkWidget *widget, GdkRectangle *allocation, gpointer user_data) { gdk_window_resize(g_GdkWindow, allocation->width, allocation->height); g_Callbacks->resize(g_GdkWindow, COGL_ONSCREEN(g_Framebuffer), allocation->width, allocation->height, allocation->x, allocation->y); }
void show_message(char *from, char *content) { debug("show_message(%s, %s)\n", from, content); if (strlen(from) == 0 && strlen(content) == 0 ) { gdk_window_resize(window->window, 1, 1); return; } //初始化cairo环境 paint_message (cr, from, content); cairo_surface_flush(sf); //复制生成位图 copy_surface_to_pixmap (sf, pixmap); copy_surface_to_pixmap (sf, pixmap_mask); //刷新显示 gtk_window_set_title(GTK_WINDOW(window), content); gdk_window_set_back_pixmap (window->window, pixmap, FALSE); gtk_widget_shape_combine_mask (window, pixmap_mask, 0, 0); gtk_widget_queue_draw(window); gdk_window_resize(window->window, window_width, window_height); }
static void gtkCanvasLayoutUpdateMethod(Ihandle *ih) { iupdrvBaseLayoutUpdateMethod(ih); /* Force GdkWindow size update when not visible, so when mapped before show GDK returns the correct value. */ if (!iupdrvIsVisible(ih)) { GdkWindow* window = iupgtkGetWindow(ih->handle); gdk_window_resize(window, ih->currentwidth, ih->currentheight); } gtkCanvasUpdateChildLayout(ih); }
static void realize(GtkWidget* widget) { parent_class->realize(widget); wxPizza* pizza = WX_PIZZA(widget); if (pizza->m_border_style || pizza->m_is_scrollable) { int border_x, border_y; pizza->get_border_widths(border_x, border_y); int x = widget->allocation.x + border_x; int y = widget->allocation.y + border_y; int w = widget->allocation.width - 2 * border_x; int h = widget->allocation.height - 2 * border_y; if (w < 0) w = 0; if (h < 0) h = 0; if (pizza->m_is_scrollable) { // second window is created if wxWindow is scrollable GdkWindowAttr attr; attr.event_mask = 0; attr.x = x; attr.y = y; attr.width = w; attr.height = h; attr.wclass = GDK_INPUT_OUTPUT; attr.visual = gtk_widget_get_visual(widget); attr.colormap = gtk_widget_get_colormap(widget); attr.window_type = GDK_WINDOW_CHILD; pizza->m_backing_window = gdk_window_new( gdk_window_get_parent(widget->window), &attr, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); gdk_window_set_user_data(pizza->m_backing_window, widget); gdk_window_reparent(widget->window, pizza->m_backing_window, 0, 0); gdk_window_resize(widget->window, w, h); // Parts of m_backing_window may be exposed temporarily while // resizing. Setting the backing pixmap to None prevents those // areas from being briefly painted black. gdk_window_set_back_pixmap(pizza->m_backing_window, NULL, false); } else gdk_window_move_resize(widget->window, x, y, w, h); } }
void set_widget_size(GtkWidget *w, guint16 width, guint16 height) { #if 1 /* This one resizes the window. */ gdk_window_resize(w->window, width, height); #else /* This one doesn't seem to do anything, but the function name seems at least to be quite similar to set_widget_size. */ GtkRequisition r; r.width = width; r.height = height; gtk_widget_size_request(w, &r); #endif #if 0 /* This one doesn't do anything, and prints out errors. */ gtk_window_resize(GTK_WINDOW(w), width, height); #endif }
/********************************************************************\ * 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) { #if GTK_CHECK_VERSION(3,22,0) GdkWindow *win; GdkMonitor *mon; GdkRectangle monitor_size; #endif 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; #if GTK_CHECK_VERSION(3,22,0) win = gdk_screen_get_root_window (gtk_window_get_screen (window)); mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(window)), win); gdk_monitor_get_geometry (mon, &monitor_size); screen_width = monitor_size.width; screen_height = monitor_size.height; #else screen_width = gdk_screen_width(); screen_height = gdk_screen_height(); #endif 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 GdkWindow* get_dnd_window() { if (dnd_window == NULL) { GdkWindowAttr attr; memset(&attr, 0, sizeof (GdkWindowAttr)); attr.override_redirect = TRUE; attr.window_type = GDK_WINDOW_TEMP; attr.type_hint = GDK_WINDOW_TYPE_HINT_UTILITY; attr.wclass = GDK_INPUT_OUTPUT; attr.event_mask = GDK_ALL_EVENTS_MASK; dnd_window = gdk_window_new(NULL, &attr, GDK_WA_NOREDIR | GDK_WA_TYPE_HINT); gdk_window_move(dnd_window, -100, -100); gdk_window_resize(dnd_window, 1, 1); gdk_window_show(dnd_window); } return dnd_window; }
static void setup_win(qiv_image *q) { GdkWindowAttr attr; GdkPixmap *cursor_pixmap; if (!fullscreen) { attr.window_type=GDK_WINDOW_TOPLEVEL; attr.wclass=GDK_INPUT_OUTPUT; attr.event_mask=GDK_ALL_EVENTS_MASK; attr.x = center ? q->win_x : 0; attr.y = center ? q->win_y : 0; attr.width = q->win_w; attr.height = q->win_h; q->win = gdk_window_new(NULL, &attr, GDK_WA_X|GDK_WA_Y); if (center) { GdkGeometry geometry = { .min_width = q->win_w, .min_height = q->win_h, .max_width = q->win_w, .max_height = q->win_h, .win_gravity = GDK_GRAVITY_STATIC }; gdk_window_set_geometry_hints(q->win, &geometry, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_WIN_GRAVITY); gdk_window_move_resize(q->win, q->win_x, q->win_y, q->win_w, q->win_h); } else { GdkGeometry geometry = { .min_width = q->win_w, .min_height = q->win_h, .max_width = q->win_w, .max_height = q->win_h, }; gdk_window_set_geometry_hints(q->win, &geometry, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); gdk_window_resize(q->win, q->win_w, q->win_h); } gdk_window_show(q->win); } else { /* fullscreen */
static void clutter_stage_gdk_resize (ClutterStageWindow *stage_window, gint width, gint height) { ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window); if (width == 0 || height == 0) { /* Should not happen, if this turns up we need to debug it and * determine the cleanest way to fix. */ g_warning ("GDK stage not allowed to have 0 width or height"); width = 1; height = 1; } CLUTTER_NOTE (BACKEND, "New size received: (%d, %d)", width, height); gdk_window_resize (stage_gdk->window, width, height); }
static void gtkCanvasLayoutUpdateMethod(Ihandle *ih) { GdkWindow* window = iupgtkGetWindow(ih->handle); iupdrvBaseLayoutUpdateMethod(ih); /* Force GdkWindow size update when not visible, so when mapped before show the function gdk_drawable_get_size returns the correct value. */ if (!iupdrvIsVisible(ih)) gdk_window_resize(window, ih->currentwidth, ih->currentheight); if (iupAttribGetStr(ih, "_IUP_GTK_FIRST_RESIZE")) { /* GTK is nor calling gtkCanvasConfigureEvent on the first resize */ IFnii cb = (IFnii)IupGetCallback(ih,"RESIZE_CB"); iupAttribSetStr(ih, "_IUP_GTK_FIRST_RESIZE", NULL); if (cb) { int sb_w = 0, sb_h = 0; if (ih->data->sb) { int sb_size = iupdrvGetScrollbarSize(); if (ih->data->sb & IUP_SB_HORIZ) sb_h += sb_size; /* sb horizontal affects vertical size */ if (ih->data->sb & IUP_SB_VERT) sb_w += sb_size; /* sb vertical affects horizontal size */ } if (iupAttribGetBoolean(ih, "BORDER")) { sb_w += 4; sb_h += 4; } cb(ih, ih->currentwidth-sb_w, ih->currentheight-sb_h); } } }
/** * gtk_layout_set_size: * @layout: a #GtkLayout * @width: width of entire scrollable area * @height: height of entire scrollable area * * Sets the size of the scrollable area of the layout. * **/ void gtk_layout_set_size (GtkLayout *layout, guint width, guint height) { GtkLayoutPrivate *priv; GtkWidget *widget; g_return_if_fail (GTK_IS_LAYOUT (layout)); priv = layout->priv; widget = GTK_WIDGET (layout); g_object_freeze_notify (G_OBJECT (layout)); if (width != priv->width) { priv->width = width; g_object_notify (G_OBJECT (layout), "width"); } if (height != priv->height) { priv->height = height; g_object_notify (G_OBJECT (layout), "height"); } g_object_thaw_notify (G_OBJECT (layout)); if (gtk_widget_get_realized (widget)) { GtkAllocation allocation; gtk_widget_get_allocation (widget, &allocation); width = MAX (width, allocation.width); height = MAX (height, allocation.height); gdk_window_resize (priv->bin_window, width, height); } gtk_layout_set_hadjustment_values (layout); gtk_layout_set_vadjustment_values (layout); }
void cairo_dock_place_desklet (CairoDesklet *pDesklet, CairoDockMinimalAppletConfig *pMinimalConfig) { cd_message ("%s (%dx%d ; (%d,%d) ; %d,%d,%d)", __func__, pMinimalConfig->iDeskletWidth, pMinimalConfig->iDeskletHeight, pMinimalConfig->iDeskletPositionX, pMinimalConfig->iDeskletPositionY, pMinimalConfig->bKeepBelow, pMinimalConfig->bKeepAbove, pMinimalConfig->bOnWidgetLayer); if (pMinimalConfig->bDeskletUseSize) gdk_window_resize (pDesklet->pWidget->window, pMinimalConfig->iDeskletWidth, pMinimalConfig->iDeskletHeight); gdk_window_move(pDesklet->pWidget->window, pMinimalConfig->iDeskletPositionX, pMinimalConfig->iDeskletPositionY); gtk_window_set_keep_below (GTK_WINDOW (pDesklet->pWidget), pMinimalConfig->bKeepBelow); gtk_window_set_keep_above (GTK_WINDOW (pDesklet->pWidget), pMinimalConfig->bKeepAbove); Window Xid = GDK_WINDOW_XID (pDesklet->pWidget->window); if (pMinimalConfig->bOnWidgetLayer) cairo_dock_set_xwindow_type_hint (Xid, "_NET_WM_WINDOW_TYPE_UTILITY"); // le hide-show le fait deconner completement, il perd son skip_task_bar ! au moins sous KDE. else cairo_dock_set_xwindow_type_hint (Xid, "_NET_WM_WINDOW_TYPE_NORMAL"); pDesklet->bPositionLocked = pMinimalConfig->bPositionLocked; }
/* copied from panel-toplevel.c */ static void _window_move_resize_window (CsmFailWhaleDialog *window, gboolean move, gboolean resize) { GtkWidget *widget; widget = GTK_WIDGET (window); g_assert (gtk_widget_get_realized (widget)); if (window->priv->debug_mode) return; g_debug ("Move and/or resize window x=%d y=%d w=%d h=%d", window->priv->geometry.x, window->priv->geometry.y, window->priv->geometry.width, window->priv->geometry.height); if (move && resize) { gdk_window_move_resize (gtk_widget_get_window (widget), window->priv->geometry.x, window->priv->geometry.y, window->priv->geometry.width, window->priv->geometry.height); } else if (move) { gdk_window_move (gtk_widget_get_window (widget), window->priv->geometry.x, window->priv->geometry.y); } else if (resize) { gdk_window_resize (gtk_widget_get_window (widget), window->priv->geometry.width, window->priv->geometry.height); } }
/** * gtk_layout_set_size: * @layout: a #GtkLayout * @width: width of entire scrollable area * @height: height of entire scrollable area * * Sets the size of the scrollable area of the layout. * **/ void gtk_layout_set_size (GtkLayout *layout, guint width, guint height) { GtkWidget *widget; g_return_if_fail (GTK_IS_LAYOUT (layout)); widget = GTK_WIDGET (layout); g_object_freeze_notify (G_OBJECT (layout)); if (width != layout->width) { layout->width = width; g_object_notify (G_OBJECT (layout), "width"); } if (height != layout->height) { layout->height = height; g_object_notify (G_OBJECT (layout), "height"); } g_object_thaw_notify (G_OBJECT (layout)); if (layout->hadjustment) gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE); if (layout->vadjustment) gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE); if (gtk_widget_get_realized (widget)) { width = MAX (width, widget->allocation.width); height = MAX (height, widget->allocation.height); gdk_window_resize (layout->bin_window, width, height); } }
void gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) { GtkWidget *widget; XEvent xevent; XID win; gint x,y,w,h,border; widget = GTK_WIDGET (pizza); pizza->xoffset += dx; pizza->yoffset += dy; if (!GTK_WIDGET_MAPPED (pizza)) { gtk_pizza_position_children (pizza); return; } gtk_pizza_adjust_allocations (pizza, -dx, -dy); if (pizza->shadow_type == GTK_MYSHADOW_NONE) border = 0; else if (pizza->shadow_type == GTK_MYSHADOW_THIN) border = 1; else border = 2; x = 0; y = 0; w = widget->allocation.width - 2*border; h = widget->allocation.height - 2*border; if (dx > 0) { if (gravity_works) { gdk_window_resize (pizza->bin_window, w + dx, h); gdk_window_move (pizza->bin_window, x-dx, y); gdk_window_move_resize (pizza->bin_window, x, y, w, h ); } else { /* FIXME */ } } else if (dx < 0) { if (gravity_works) { gdk_window_move_resize (pizza->bin_window, x + dx, y, w - dx, h); gdk_window_move (pizza->bin_window, x, y); gdk_window_resize (pizza->bin_window, w, h ); } else { /* FIXME */ } } if (dy > 0) { if (gravity_works) { gdk_window_resize (pizza->bin_window, w, h + dy); gdk_window_move (pizza->bin_window, x, y-dy); gdk_window_move_resize (pizza->bin_window, x, y, w, h ); } else { /* FIXME */ } } else if (dy < 0) { if (gravity_works) { gdk_window_move_resize (pizza->bin_window, x, y+dy, w, h - dy ); gdk_window_move (pizza->bin_window, x, y); gdk_window_resize (pizza->bin_window, w, h ); } else { /* FIXME */ } } gtk_pizza_position_children (pizza); gdk_flush(); win = GDK_WINDOW_XWINDOW (pizza->bin_window); while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window), &xevent, gtk_pizza_expose_predicate, (XPointer)&win)) { GdkEvent event; GtkWidget *event_widget; if ((xevent.xany.window == GDK_WINDOW_XWINDOW (pizza->bin_window)) ) gtk_pizza_filter (&xevent, &event, pizza); if (xevent.type == Expose) { event.expose.window = gdk_window_lookup (xevent.xany.window); gdk_window_get_user_data (event.expose.window, (gpointer *)&event_widget); if (event_widget) { event.expose.type = GDK_EXPOSE; event.expose.area.x = xevent.xexpose.x; event.expose.area.y = xevent.xexpose.y; event.expose.area.width = xevent.xexpose.width; event.expose.area.height = xevent.xexpose.height; event.expose.count = xevent.xexpose.count; gdk_window_ref (event.expose.window); gtk_widget_event (event_widget, &event); gdk_window_unref (event.expose.window); } } } }
static VALUE gdkwin_resize(VALUE self, VALUE w, VALUE h) { gdk_window_resize(_SELF(self), NUM2INT(w), NUM2INT(h)); return self; }
void gldi_desklet_configure (CairoDesklet *pDesklet, CairoDeskletAttr *pAttribute) { //g_print ("%s (%dx%d ; (%d,%d) ; %d)\n", __func__, pAttribute->iDeskletWidth, pAttribute->iDeskletHeight, pAttribute->iDeskletPositionX, pAttribute->iDeskletPositionY, pAttribute->iVisibility); if (pAttribute->bDeskletUseSize && (pAttribute->iDeskletWidth != pDesklet->container.iWidth || pAttribute->iDeskletHeight != pDesklet->container.iHeight)) { pDesklet->iDesiredWidth = pAttribute->iDeskletWidth; pDesklet->iDesiredHeight = pAttribute->iDeskletHeight; gdk_window_resize (gldi_container_get_gdk_window (CAIRO_CONTAINER (pDesklet)), pAttribute->iDeskletWidth, pAttribute->iDeskletHeight); } if (! pAttribute->bDeskletUseSize) { gtk_container_set_border_width (GTK_CONTAINER (pDesklet->container.pWidget), 0); gtk_window_set_resizable (GTK_WINDOW(pDesklet->container.pWidget), FALSE); } int iAbsolutePositionX = (pAttribute->iDeskletPositionX < 0 ? gldi_desktop_get_width() + pAttribute->iDeskletPositionX : pAttribute->iDeskletPositionX); iAbsolutePositionX = MAX (0, MIN (gldi_desktop_get_width() - pAttribute->iDeskletWidth, iAbsolutePositionX)); int iAbsolutePositionY = (pAttribute->iDeskletPositionY < 0 ? gldi_desktop_get_height() + pAttribute->iDeskletPositionY : pAttribute->iDeskletPositionY); iAbsolutePositionY = MAX (0, MIN (gldi_desktop_get_height() - pAttribute->iDeskletHeight, iAbsolutePositionY)); //g_print (" let's place the deklet at (%d;%d)", iAbsolutePositionX, iAbsolutePositionY); if (pAttribute->bOnAllDesktops) { gtk_window_stick (GTK_WINDOW (pDesklet->container.pWidget)); gdk_window_move (gldi_container_get_gdk_window (CAIRO_CONTAINER (pDesklet)), iAbsolutePositionX, iAbsolutePositionY); } else { gtk_window_unstick (GTK_WINDOW (pDesklet->container.pWidget)); if (g_desktopGeometry.iNbViewportX > 0 && g_desktopGeometry.iNbViewportY > 0) { int iNumDesktop, iNumViewportX, iNumViewportY; iNumDesktop = pAttribute->iNumDesktop / (g_desktopGeometry.iNbViewportX * g_desktopGeometry.iNbViewportY); int index2 = pAttribute->iNumDesktop % (g_desktopGeometry.iNbViewportX * g_desktopGeometry.iNbViewportY); iNumViewportX = index2 / g_desktopGeometry.iNbViewportY; iNumViewportY = index2 % g_desktopGeometry.iNbViewportY; int iCurrentDesktop, iCurrentViewportX, iCurrentViewportY; gldi_desktop_get_current (&iCurrentDesktop, &iCurrentViewportX, &iCurrentViewportY); cd_debug (">>> on fixe le desklet sur le bureau (%d,%d,%d) (cur : %d,%d,%d)", iNumDesktop, iNumViewportX, iNumViewportY, iCurrentDesktop, iCurrentViewportX, iCurrentViewportY); iNumViewportX -= iCurrentViewportX; iNumViewportY -= iCurrentViewportY; cd_debug ("on le place en %d + %d", iNumViewportX * gldi_desktop_get_width(), iAbsolutePositionX); gldi_container_move (CAIRO_CONTAINER (pDesklet), iNumDesktop, iNumViewportX * gldi_desktop_get_width() + iAbsolutePositionX, iNumViewportY * gldi_desktop_get_height() + iAbsolutePositionY); } } pDesklet->bPositionLocked = pAttribute->bPositionLocked; pDesklet->bNoInput = pAttribute->bNoInput; pDesklet->fRotation = pAttribute->iRotation / 180. * G_PI ; pDesklet->fDepthRotationY = pAttribute->iDepthRotationY / 180. * G_PI ; pDesklet->fDepthRotationX = pAttribute->iDepthRotationX / 180. * G_PI ; g_free (pDesklet->cDecorationTheme); pDesklet->cDecorationTheme = pAttribute->cDecorationTheme; pAttribute->cDecorationTheme = NULL; gldi_desklet_decoration_free (pDesklet->pUserDecoration); pDesklet->pUserDecoration = pAttribute->pUserDecoration; pAttribute->pUserDecoration = NULL; gldi_desklet_set_accessibility (pDesklet, pAttribute->iVisibility, FALSE); //cd_debug ("%s (%dx%d ; %d)", __func__, pDesklet->iDesiredWidth, pDesklet->iDesiredHeight, pDesklet->iSidWriteSize); if (pDesklet->iDesiredWidth == 0 && pDesklet->iDesiredHeight == 0 && pDesklet->iSidWriteSize == 0) { gldi_desklet_load_desklet_decorations (pDesklet); } }
static gboolean on_configure_desklet (G_GNUC_UNUSED GtkWidget* pWidget, GdkEventConfigure* pEvent, CairoDesklet *pDesklet) { //g_print (" >>>>>>>>> %s (%dx%d, %d;%d)", __func__, pEvent->width, pEvent->height, pEvent->x, pEvent->y); if (pDesklet->container.iWidth != pEvent->width || pDesklet->container.iHeight != pEvent->height) { if ((pEvent->width < pDesklet->container.iWidth || pEvent->height < pDesklet->container.iHeight) && (pDesklet->iDesiredWidth != 0 && pDesklet->iDesiredHeight != 0)) { gdk_window_resize (gldi_container_get_gdk_window (CAIRO_CONTAINER (pDesklet)), pDesklet->iDesiredWidth, pDesklet->iDesiredHeight); } pDesklet->container.iWidth = pEvent->width; pDesklet->container.iHeight = pEvent->height; if (g_bUseOpenGL) { if (! gldi_gl_container_make_current (CAIRO_CONTAINER (pDesklet))) return FALSE; gldi_gl_container_set_perspective_view (CAIRO_CONTAINER (pDesklet)); } if (pDesklet->bNoInput) _cairo_dock_set_desklet_input_shape (pDesklet); if (pDesklet->iSidWriteSize != 0) { g_source_remove (pDesklet->iSidWriteSize); } pDesklet->iSidWriteSize = g_timeout_add (CD_WRITE_DELAY, (GSourceFunc) _cairo_dock_write_desklet_size, (gpointer) pDesklet); } int x = pEvent->x, y = pEvent->y; //g_print ("new desklet position : (%d;%d)", x, y); while (x < 0) // on passe au referentiel du viewport de la fenetre; inutile de connaitre sa position, puisqu'ils ont tous la meme taille. x += gldi_desktop_get_width(); while (x >= gldi_desktop_get_width()) x -= gldi_desktop_get_width(); while (y < 0) y += gldi_desktop_get_height(); while (y >= gldi_desktop_get_height()) y -= gldi_desktop_get_height(); //g_print (" => (%d;%d)\n", x, y); if (pDesklet->container.iWindowPositionX != x || pDesklet->container.iWindowPositionY != y) { pDesklet->container.iWindowPositionX = x; pDesklet->container.iWindowPositionY = y; if (gldi_desklet_manager_is_ready ()) { if (pDesklet->iSidWritePosition != 0) { g_source_remove (pDesklet->iSidWritePosition); } pDesklet->iSidWritePosition = g_timeout_add (CD_WRITE_DELAY, (GSourceFunc) _cairo_dock_write_desklet_position, (gpointer) pDesklet); } } pDesklet->moving = FALSE; return FALSE; }
GtkWidget *snd_as_widget(int argc, char **argv, GtkWidget *parent, void (*error_func)(const char *msg)) { #else void snd_doit(int argc, char **argv) { #endif GtkWidget *shell; int i; #ifdef SND_AS_WIDGET set_error_display(error_func); ss = snd_main(argc, argv); #else gtk_init(&argc, &argv); #if (!HAVE_GTK_3) #ifndef HAVE_OSX gdk_set_locale(); #endif #endif #endif ss->channel_min_height = CHANNEL_MIN_HEIGHT; ss->Graph_Cursor = DEFAULT_GRAPH_CURSOR; #ifndef SND_AS_WIDGET shell = gtk_window_new(GTK_WINDOW_TOPLEVEL); sg_make_resizable(shell); #endif auto_open_files = argc-1; if (argc > 1) auto_open_file_names = (char **)(argv + 1); ss->startup_title = mus_strdup("snd"); set_sound_style(SOUNDS_VERTICAL); for (i = 1; i < argc; i++) if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-horizontal") == 0) || (strcmp(argv[i], "--horizontal") == 0)) set_sound_style(SOUNDS_HORIZONTAL); else if ((strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "-vertical") == 0) || (strcmp(argv[i], "--vertical") == 0)) set_sound_style(SOUNDS_VERTICAL); else if ((strcmp(argv[i], "-notebook") == 0) || (strcmp(argv[i], "--notebook") == 0)) set_sound_style(SOUNDS_IN_NOTEBOOK); else if ((strcmp(argv[i], "-separate") == 0) || (strcmp(argv[i], "--separate") == 0)) set_sound_style(SOUNDS_IN_SEPARATE_WINDOWS); else if (strcmp(argv[i], "-noglob") == 0) noglob = true; else if (strcmp(argv[i], "-noinit") == 0) noinit = true; else if (strcmp(argv[i], "-nostdin") == 0) nostdin = true; else if ((strcmp(argv[i], "-b") == 0) || (strcmp(argv[i], "-batch") == 0) || (strcmp(argv[i], "--batch") == 0)) batch = true; else if (strcmp(argv[i], "--features") == 0) /* testing (compsnd) */ check_features_list(argv[i + 1]); ss->batch_mode = batch; set_auto_resize(AUTO_RESIZE_DEFAULT); ss->zoom_slider_width = ZOOM_SLIDER_WIDTH; ss->position_slider_width = POSITION_SLIDER_WIDTH; ss->channel_sash_indent = CHANNEL_SASH_INDENT; /* not currently used */ ss->channel_sash_size = CHANNEL_SASH_SIZE; ss->sash_size = SASH_SIZE; ss->sash_indent = SASH_INDENT; ss->toggle_size = TOGGLE_SIZE; ss->graph_is_active = false; ss->bg_gradient = 0.05; ss->white = WHITE_COLOR; ss->black = BLACK_COLOR; ss->light_blue = LIGHT_BLUE_COLOR; ss->lighter_blue = LIGHTER_BLUE_COLOR; ss->red = RED_COLOR; ss->green = GREEN_COLOR; ss->blue = BLUE_COLOR; ss->yellow = YELLOW_COLOR; ss->highlight_color = HIGHLIGHT_COLOR; ss->basic_color = BASIC_COLOR; ss->position_color = POSITION_COLOR; ss->zoom_color = ZOOM_COLOR; ss->cursor_color = CURSOR_COLOR; ss->selection_color = SELECTION_COLOR; ss->mix_color = MIX_COLOR; ss->enved_waveform_color = ENVED_WAVEFORM_COLOR; ss->filter_control_waveform_color = FILTER_CONTROL_WAVEFORM_COLOR; ss->listener_color = LISTENER_COLOR; ss->listener_text_color = LISTENER_TEXT_COLOR; ss->graph_color = GRAPH_COLOR; ss->selected_graph_color = SELECTED_GRAPH_COLOR; ss->data_color = DATA_COLOR; ss->selected_data_color = SELECTED_DATA_COLOR; ss->mark_color = MARK_COLOR; ss->sash_color = SASH_COLOR; ss->text_focus_color = TEXT_FOCUS_COLOR; ss->grid_color = get_in_between_color(ss->data_color, ss->graph_color); ss->selected_grid_color = get_in_between_color(ss->selected_data_color, ss->selected_graph_color); ss->axis_color_set = false; ss->orig_data_color = ss->data_color; ss->orig_selected_data_color = ss->selected_data_color; ss->orig_mark_color = ss->mark_color; ss->orig_mix_color = ss->mix_color; ss->orig_graph_color = ss->graph_color; ss->orig_selected_graph_color = ss->selected_graph_color; ss->orig_listener_color = ss->listener_color; ss->orig_listener_text_color = ss->listener_text_color; ss->orig_cursor_color = ss->cursor_color; ss->orig_basic_color = ss->basic_color; ss->orig_selection_color = ss->selection_color; ss->orig_zoom_color = ss->zoom_color; ss->orig_position_color = ss->position_color; ss->orig_highlight_color = ss->highlight_color; if ((!(set_tiny_font(DEFAULT_TINY_FONT))) && (!(set_tiny_font(FALLBACK_FONT)))) fprintf(stderr, "can't find tiny font: %s", DEFAULT_TINY_FONT); if ((!(set_axis_label_font(DEFAULT_AXIS_LABEL_FONT))) && (!(set_axis_label_font(FALLBACK_FONT)))) fprintf(stderr, "can't find axis label font: %s", DEFAULT_AXIS_LABEL_FONT); if ((!(set_axis_numbers_font(DEFAULT_AXIS_NUMBERS_FONT))) && (!(set_axis_numbers_font(FALLBACK_FONT)))) fprintf(stderr, "can't find axis numbers font: %s", DEFAULT_AXIS_NUMBERS_FONT); if ((!(set_peaks_font(DEFAULT_PEAKS_FONT))) && (!(set_peaks_font(FALLBACK_FONT)))) fprintf(stderr, "can't find peaks font: %s", DEFAULT_PEAKS_FONT); if ((!(set_bold_peaks_font(DEFAULT_BOLD_PEAKS_FONT))) && (!(set_bold_peaks_font(FALLBACK_FONT)))) fprintf(stderr, "can't find bold peaks font: %s", DEFAULT_BOLD_PEAKS_FONT); if (!(set_listener_font(FALLBACK_FONT))) fprintf(stderr, "can't find listener font: %s", FALLBACK_FONT); ss->orig_axis_label_font = mus_strdup(axis_label_font(ss)); ss->orig_axis_numbers_font = mus_strdup(axis_numbers_font(ss)); ss->orig_peaks_font = mus_strdup(peaks_font(ss)); ss->orig_bold_peaks_font = mus_strdup(bold_peaks_font(ss)); ss->orig_listener_font = mus_strdup(listener_font(ss)); ss->orig_tiny_font = mus_strdup(tiny_font(ss)); #if (!HAVE_GTK_3) init_gtk(); #endif MAIN_PANE(ss) = gtk_vbox_new(false, 0); /* not homogenous, spacing 0 */ #if (HAVE_GTK_3) init_gtk(); #endif #ifdef SND_AS_WIDGET MAIN_SHELL(ss) = parent; shell = MAIN_PANE(ss); #else MAIN_SHELL(ss) = shell; gtk_container_add(GTK_CONTAINER(MAIN_SHELL(ss)), MAIN_PANE(ss)); #endif add_menu(); /* adds menubar to MAIN_PANE (via box_pack_start) */ if (with_toolbar(ss)) show_toolbar(); if (sound_style(ss) != SOUNDS_IN_SEPARATE_WINDOWS) { SOUND_PANE(ss) = gtk_vpaned_new(); gtk_container_set_border_width(GTK_CONTAINER(SOUND_PANE(ss)), 0); gtk_container_add(GTK_CONTAINER(MAIN_PANE(ss)), SOUND_PANE(ss)); if (sound_style(ss) == SOUNDS_IN_NOTEBOOK) { SOUND_PANE_BOX(ss) = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(SOUND_PANE_BOX(ss)), GTK_POS_TOP); SG_SIGNAL_CONNECT(SOUND_PANE_BOX(ss), "switch_page", notebook_switch_page, NULL); } else { if (sound_style(ss) == SOUNDS_HORIZONTAL) SOUND_PANE_BOX(ss) = gtk_hbox_new(false, 0); else SOUND_PANE_BOX(ss) = gtk_vbox_new(false, 0); } gtk_paned_add1(GTK_PANED(SOUND_PANE(ss)), SOUND_PANE_BOX(ss)); gtk_widget_show(SOUND_PANE_BOX(ss)); gtk_widget_show(SOUND_PANE(ss)); } gtk_widget_show(MAIN_PANE(ss)); gtk_widget_show(MAIN_SHELL(ss)); #ifndef SND_AS_WIDGET #if HAVE_GTK_ADJUSTMENT_GET_UPPER MAIN_WINDOW(ss) = gtk_widget_get_window(MAIN_SHELL(ss)); #else MAIN_WINDOW(ss) = MAIN_SHELL(ss)->window; #endif #else MAIN_WINDOW(ss) = gtk_widget_get_parent_window(MAIN_SHELL(ss)); #endif setup_gcs(); if (batch) gtk_widget_hide(MAIN_SHELL(ss)); else gdk_window_resize(WIDGET_TO_WINDOW(MAIN_SHELL(ss)), INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT); startup_funcs(); #if HAVE_SETJMP_H #if MUS_TRAP_SEGFAULT if (sigsetjmp(envHandleEventsLoop, 1)) { if (!(ss->exiting)) snd_error_without_format("Caught seg fault (will try to continue):\n"); else { snd_error_without_format("Caught seg fault while trying to exit.\n"); exit(0); } } #endif if (setjmp(top_level_jump)) { if (!(ss->jump_ok)) snd_error_without_format("Caught top level error (will try to continue):\n"); else ss->jump_ok = false; } #endif if (ss->startup_errors) { post_it("Error in initialization", ss->startup_errors); free(ss->startup_errors); ss->startup_errors = NULL; } #if HAVE_GTK_3 set_basic_color(ss->basic_color); color_listener(ss->listener_color); color_chan_components(ss->zoom_color, COLOR_ZOOM); color_chan_components(ss->position_color, COLOR_POSITION); #endif #ifndef SND_AS_WIDGET set_up_icon(); gtk_main(); #else return(shell); #endif }
static void draw (GtkWidget *hand, cairo_t *cr) { int x, y; HandDisplay *handdisp = HAND_DISPLAY(hand); cairo_text_extents_t extents; cairo_font_extents_t fextents; GtkAllocation allocation; gtk_widget_get_allocation (hand, &allocation); cairo_select_font_face (cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); /* "card" mode for drap&drop icon */ if (handdisp->mode == HAND_DISPLAY_MODE_CARD) { if (handdisp->style == HAND_DISPLAY_STYLE_CARDS) { if (card_width != handdisp->want_width) { /* adjust window */ handdisp->want_width = card_width; gdk_window_resize (gtk_widget_get_parent_window (hand), card_width, card_height); /* shaped drag icon * credits to Mirco "MacSlow" Mueller <*****@*****.**> * http://macslow.thepimp.net/?p=26 */ GdkBitmap *pShapeBitmap = (GdkBitmap*) gdk_pixmap_new (NULL, card_width, card_height, 1); assert (pShapeBitmap); cairo_t *pCairoContext = gdk_cairo_create (pShapeBitmap); assert (cairo_status (pCairoContext) == CAIRO_STATUS_SUCCESS); render_card (pCairoContext, 0, 0, handdisp->table_card[0], HAND_DISPLAY_CARD); cairo_destroy (pCairoContext); gdk_window_shape_combine_mask (gtk_widget_get_parent_window (hand), pShapeBitmap, 0, 0); g_object_unref ((gpointer) pShapeBitmap); } render_card (cr, 0, 0, handdisp->table_card[0], HAND_DISPLAY_CARD); return; } char cs[6]; int c = handdisp->table_card[0]; int suit = c / 13; int rank = c % 13; snprintf (cs, 6, "%s%s", suit_str[suit], rank_str[rank]); cairo_set_font_size (cr, 20); cairo_text_extents (cr, cs, &extents); #define XPAD 4 #define YPAD 2 int w = extents.width + 2 * XPAD + 5; int h = extents.height + 2 * YPAD; cairo_set_source_rgb (cr, HAND_DISPLAY_FOCUS_BG); cairo_rectangle (cr, 1, 1, w, h); cairo_fill (cr); cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); cairo_rectangle (cr, 1, 1, w, h); cairo_stroke (cr); cairo_move_to (cr, XPAD - extents.x_bearing + 1, YPAD - extents.y_bearing + 2); cairo_set_source_rgb (cr, suit_color[suit][0], suit_color[suit][1], suit_color[suit][2]); cairo_show_text (cr, suit_str[suit]); cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); cairo_show_text (cr, rank_str[rank]); if (w + 2 != handdisp->want_width) { /* adjust window */ handdisp->want_width = w + 2; gdk_window_resize (gtk_widget_get_parent_window (hand), w + 2, h + 2); } return; } cairo_set_source_rgb (cr, HAND_DISPLAY_TABLE_BG); cairo_rectangle (cr, 0, 0, allocation.width, allocation.height); cairo_fill (cr); /* "table" mode for displaying the already played cards in the middle of the screen */ if (handdisp->mode == HAND_DISPLAY_MODE_TABLE && handdisp->style == HAND_DISPLAY_STYLE_CARDS) { int i; for (i = 0; i < 4; i++) { switch (handdisp->table_seat[i]) { case 1: x = allocation.width / 2 - card_width + 5; /*W*/ y = (allocation.height - card_height) / 2 + 5; break; case 2: x = (allocation.width - card_width) / 2 - 2; /*N*/ y = MAX (allocation.height / 2 - card_height + 10, 0); break; case 3: x = allocation.width / 2 - 5; /*E*/ y = (allocation.height - card_height) / 2 - 5; break; case 4: x = (allocation.width - card_width) / 2 + 2; /*S*/ y = MIN (allocation.height / 2 - 10, allocation.height - card_height); break; default: return; /* stop here */ } render_card (cr, x, y, handdisp->table_card[i], HAND_DISPLAY_CARD); } return; } if (handdisp->mode == HAND_DISPLAY_MODE_TABLE) { /* text */ cairo_set_font_size (cr, 20); int i; for (i = 0; i < 4; i++) { char cs[6]; if (!handdisp->table_seat[i]) return; int c = handdisp->table_card[i]; int suit = c / 13; int rank = c % 13; snprintf (cs, 6, "%s%s", suit_str[suit], rank_str[rank]); cairo_text_extents (cr, cs, &extents); #define XOFF 38 #define YOFF 23 #define WIDTH 52 #define HEIGHT 28 #define RAD 5 switch (handdisp->table_seat[i]) { /* middle point */ case 1: x = allocation.width / 2 - XOFF; /*W*/ y = allocation.height / 2; break; case 2: x = allocation.width / 2; /*N*/ y = allocation.height / 2 - YOFF; break; case 3: x = allocation.width / 2 + XOFF; /*E*/ y = allocation.height / 2; break; case 4: x = allocation.width / 2; /*S*/ y = allocation.height / 2 + YOFF; break; default: return; /* stop here */ } cairo_new_path (cr); cairo_arc_negative (cr, x-WIDTH/2+RAD, y+HEIGHT/2 - RAD, RAD, M_PI, M_PI_2); cairo_arc_negative (cr, x+WIDTH/2-RAD, y+HEIGHT/2 - RAD, RAD, M_PI_2, 0.0); cairo_arc_negative (cr, x+WIDTH/2-RAD, y-HEIGHT/2 + RAD, RAD, 0.0, -M_PI_2); cairo_arc_negative (cr, x-WIDTH/2+RAD, y-HEIGHT/2 + RAD, RAD, -M_PI_2, M_PI); cairo_close_path (cr); cairo_set_source_rgb (cr, HAND_DISPLAY_FOCUS_BG); cairo_fill_preserve (cr); cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); cairo_stroke (cr); cairo_move_to (cr, x - extents.width / 2 - 3, y + extents.height / 2 - 3); cairo_set_source_rgb (cr, suit_color[suit][0], suit_color[suit][1], suit_color[suit][2]); cairo_show_text (cr, suit_str[suit]); cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); cairo_show_text (cr, rank_str[rank]); } return; } /* normal hands display */ /* compute cached best card score for this hand */ if (handdisp->best_card_score == HAND_DISPLAY_NO_SCORE) { int c; handdisp->best_card_score = handdisp->card_score_neg ? 14 : -14; for (c = 0; c < 52; c++) { if (handdisp->card_score_neg ? (handdisp->card_score[c] < handdisp->best_card_score) : (handdisp->card_score[c] > handdisp->best_card_score)) handdisp->best_card_score = handdisp->card_score[c]; } } /* "cards" style */ if (handdisp->style == HAND_DISPLAY_STYLE_CARDS && handdisp->mode != HAND_DISPLAY_MODE_HAND_X) { /* we do not support MODE_X here, yet we still allow setting * STYLE_CARDS there to have the right drag icon */ y = MAX (allocation.height - card_height - 5, 15); int n = 0; int suit; for (suit = 0; suit < 4; suit++) { int c; for (c = 13 * (handdisp->suits[suit] + 1) - 1; c >= 13 * handdisp->suits[suit]; c--) { if (handdisp->cards[c]) { x = floor (n++ * (allocation.width - card_width) / 12.0); int sc = handdisp->card_score[c]; int yy = c == handdisp->cur_focus ? y - 15 : (sc != HAND_DISPLAY_NO_SCORE && handdisp->best_card_score == sc ? y - 5 : y); yy = MAX (yy, 0); handdisp->l[c] = x; handdisp->r[c] = x + card_width; handdisp->t[c] = y - 15; handdisp->b[c] = y + card_height; if (handdisp->cards[c] & HAND_DISPLAY_INVISIBLE_CARD) continue; render_card (cr, x, yy, c, handdisp->cards[c]); if (handdisp->cards[c] == HAND_DISPLAY_HILIGHT_CARD) { /* draw triangular arrow */ cairo_set_source_rgb (cr, HAND_DISPLAY_HILIGHT_FONT); cairo_move_to (cr, x + 3 + (allocation.width - card_width - 10) / 24.0, yy); cairo_rel_line_to (cr, -5, -5); cairo_rel_line_to (cr, 10, 0); cairo_fill (cr); } /* show card score */ if (handdisp->card_score[c] == HAND_DISPLAY_NO_SCORE) continue; char *buf = overtricks (handdisp->card_score[c]); static int text_h = 0; if (!text_h) { cairo_font_extents (cr, &fextents); text_h = fextents.ascent; } cairo_text_extents (cr, buf, &extents); cairo_move_to (cr, x + 1 + text_h, yy + 30 + extents.width); cairo_set_source_rgb (cr, HAND_DISPLAY_DD_FONT); cairo_save (cr); cairo_rotate (cr, -G_PI_2); cairo_show_text (cr, buf); cairo_restore (cr); } } } return; } /* "text" style */ /* draw suit symbols */ cairo_set_font_size (cr, 20); int suit_width = 0; int suit; for (suit = 0; suit < 4; suit++) { x = 0; y = floor ((double) allocation.height * (3.8 - suit) / 4.0); cairo_move_to (cr, x, y); cairo_text_extents (cr, suit_str[suit], &extents); if (extents.x_advance > suit_width) suit_width = extents.x_advance; cairo_set_source_rgb (cr, suit_color[suit][0], suit_color[suit][1], suit_color[suit][2]); cairo_show_text (cr, suit_str[suit]); } /* draw cards */ for (suit = 0; suit < 4; suit++) { x = 4 + suit_width; y = floor ((double) allocation.height * (3.8 - suit) / 4.0); cairo_move_to (cr, x, y); int c; for (c = 13 * suit + 12; c >= 13 * suit; c--) { if (handdisp->cards[c]) { cairo_text_extents (cr, rank_str[c % 13], &extents); handdisp->l[c] = x + extents.x_bearing; handdisp->r[c] = x + extents.x_bearing + extents.width; handdisp->t[c] = y + extents.y_bearing; handdisp->b[c] = y + extents.y_bearing + extents.height; if (!(handdisp->cards[c] & HAND_DISPLAY_INVISIBLE_CARD)) { if (c == handdisp->cur_focus) { cairo_set_source_rgb (cr, HAND_DISPLAY_FOCUS_BG); cairo_rectangle (cr, handdisp->l[c] - 1, handdisp->t[c] - 1, extents.width + 2, extents.height + 2); cairo_fill (cr); } if (handdisp->card_score[c] == HAND_DISPLAY_NO_SCORE) { if (handdisp->cards[c] == HAND_DISPLAY_CARD) cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); else if (handdisp->cards[c] == HAND_DISPLAY_GREY_CARD) cairo_set_source_rgb (cr, HAND_DISPLAY_GREY_FONT); else if (handdisp->cards[c] == HAND_DISPLAY_OLD_CARD) cairo_set_source_rgb (cr, HAND_DISPLAY_OLD_FONT); else if (handdisp->cards[c] == HAND_DISPLAY_HILIGHT_CARD) cairo_set_source_rgb (cr, HAND_DISPLAY_HILIGHT_FONT); } else { /* invert colors if the score is for the opps */ if (handdisp->card_score_neg ^ (handdisp->card_score[c] >= 0)) if (handdisp->best_card_score == handdisp->card_score[c]) cairo_set_source_rgb (cr, HAND_DISPLAY_BEST_POS_FONT); else cairo_set_source_rgb (cr, HAND_DISPLAY_POS_FONT); else if (handdisp->best_card_score == handdisp->card_score[c]) cairo_set_source_rgb (cr, HAND_DISPLAY_BEST_NEG_FONT); else cairo_set_source_rgb (cr, HAND_DISPLAY_NEG_FONT); } cairo_move_to (cr, x, y); cairo_show_text (cr, rank_str[c % 13]); } x += extents.x_advance; y += extents.y_advance; } else { handdisp->l[c] = handdisp->r[c] = handdisp->t[c] = handdisp->b[c] = 0; } } /* MODE_X */ if (handdisp->mode == HAND_DISPLAY_MODE_HAND_X) { c = 52 + suit; x += 3; cairo_text_extents (cr, "x", &extents); handdisp->l[c] = x + extents.x_bearing; handdisp->r[c] = x + extents.x_bearing + extents.width; handdisp->t[c] = y + extents.y_bearing; handdisp->b[c] = y + extents.y_bearing + extents.height; if (c == handdisp->cur_focus) { cairo_set_source_rgb (cr, HAND_DISPLAY_FOCUS_BG); cairo_rectangle (cr, handdisp->l[c] - 1, handdisp->t[c] - 1, extents.width + 2, extents.height + 2); cairo_fill (cr); } cairo_set_source_rgb (cr, HAND_DISPLAY_FONT); cairo_move_to (cr, x, y); cairo_show_text (cr, "x"); x += extents.x_advance + 4; } if (x > handdisp->want_width) { /* grow window */ handdisp->want_width = x; gtk_widget_queue_resize (hand); } } /* show card scores */ cairo_set_font_size (cr, 10); int c; for (c = 51; c >= 0; c--) { char *buf; if (handdisp->card_score[c] != HAND_DISPLAY_NO_SCORE) { buf = overtricks (handdisp->card_score[c]); cairo_text_extents (cr, buf, &extents); cairo_move_to (cr, handdisp->r[c] - extents.x_advance, handdisp->b[c]); cairo_set_source_rgb (cr, HAND_DISPLAY_DD_FONT); cairo_show_text (cr, buf); } } }
Window meta_ui_create_frame_window (MetaUI *ui, Display *xdisplay, Visual *xvisual, gint x, gint y, gint width, gint height, gint screen_no) { GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay); GdkScreen *screen = gdk_display_get_screen (display, screen_no); GdkWindowAttr attrs; gint attributes_mask; GdkWindow *window; GdkVisual *visual; #if !GTK_CHECK_VERSION (3, 0, 0) GdkColormap *cmap = gdk_screen_get_default_colormap (screen); #endif /* Default depth/visual handles clients with weird visuals; they can * always be children of the root depth/visual obviously, but * e.g. DRI games can't be children of a parent that has the same * visual as the client. */ if (!xvisual) visual = gdk_screen_get_system_visual (screen); else { visual = gdk_x11_screen_lookup_visual (screen, XVisualIDFromVisual (xvisual)); #if !GTK_CHECK_VERSION (3, 0, 0) cmap = gdk_colormap_new (visual, FALSE); #endif } attrs.title = NULL; /* frame.c is going to replace the event mask immediately, but * we still have to set it here to let GDK know what it is. */ attrs.event_mask = GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK; attrs.x = x; attrs.y = y; attrs.wclass = GDK_INPUT_OUTPUT; attrs.visual = visual; #if !GTK_CHECK_VERSION (3, 0, 0) attrs.colormap = cmap; #endif attrs.window_type = GDK_WINDOW_CHILD; attrs.cursor = NULL; attrs.wmclass_name = NULL; attrs.wmclass_class = NULL; attrs.override_redirect = FALSE; attrs.width = width; attrs.height = height; #if GTK_CHECK_VERSION (3, 0, 0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; #else attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; #endif window = gdk_window_new (gdk_screen_get_root_window(screen), &attrs, attributes_mask); gdk_window_resize (window, width, height); meta_frames_manage_window (ui->frames, GDK_WINDOW_XID (window), window); return GDK_WINDOW_XID (window); }