From 5185103c7acac7f6f291bbd5f7c969c8809237e7 Mon Sep 17 00:00:00 2001 From: Konstantin Pugin Date: Fri, 20 Jun 2014 00:34:43 +0700 Subject: Fix expanded panels and size allocation --- applets/notification_area/na-tray.c | 4 + libmate-panel-applet/mate-panel-applet.c | 8 +- libmate-panel-applet/mate-panel-applet.h | 3 + mate-panel/applet.c | 9 ++- mate-panel/mate-panel-applet-frame.c | 15 ++-- mate-panel/panel-toplevel.c | 124 ++++++++++++++++++++++--------- 6 files changed, 121 insertions(+), 42 deletions(-) diff --git a/applets/notification_area/na-tray.c b/applets/notification_area/na-tray.c index 83f502e1..d2bcad3b 100644 --- a/applets/notification_area/na-tray.c +++ b/applets/notification_area/na-tray.c @@ -247,13 +247,17 @@ tray_removed (NaTrayManager *manager, TraysScreen *trays_screen) { NaTray *tray; + NaTrayPrivate *priv; tray = g_hash_table_lookup (trays_screen->icon_table, icon); if (tray == NULL) return; + priv = tray->priv; g_assert (tray->priv->trays_screen == trays_screen); + gtk_container_remove (GTK_CONTAINER (priv->box), icon); + g_hash_table_remove (trays_screen->icon_table, icon); /* this will also destroy the tip associated to this icon */ g_hash_table_remove (trays_screen->tip_table, icon); diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 7a514c58..34f10a5f 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -2133,7 +2133,9 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) g_param_spec_uint ("orient", "Orient", "Panel Applet Orientation", - 0, G_MAXUINT, 0, /* FIXME */ + MATE_PANEL_APPLET_ORIENT_FIRST, + MATE_PANEL_APPLET_ORIENT_LAST, + MATE_PANEL_APPLET_ORIENT_UP, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_SIZE, @@ -2154,7 +2156,9 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) g_param_spec_uint ("flags", "Flags", "Panel Applet flags", - 0, G_MAXUINT, 0, /* FIXME */ + MATE_PANEL_APPLET_FLAGS_NONE, + MATE_PANEL_APPLET_FLAGS_ALL, + MATE_PANEL_APPLET_FLAGS_NONE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_SIZE_HINTS, diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index a5f91be2..1842164d 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -42,6 +42,8 @@ typedef enum { MATE_PANEL_APPLET_ORIENT_DOWN, MATE_PANEL_APPLET_ORIENT_LEFT, MATE_PANEL_APPLET_ORIENT_RIGHT +#define MATE_PANEL_APPLET_ORIENT_FIRST MATE_PANEL_APPLET_ORIENT_UP +#define MATE_PANEL_APPLET_ORIENT_LAST MATE_PANEL_APPLET_ORIENT_RIGHT } MatePanelAppletOrient; #define PANEL_TYPE_APPLET (mate_panel_applet_get_type ()) @@ -62,6 +64,7 @@ typedef enum { MATE_PANEL_APPLET_EXPAND_MAJOR = 1 << 0, MATE_PANEL_APPLET_EXPAND_MINOR = 1 << 1, MATE_PANEL_APPLET_HAS_HANDLE = 1 << 2 +#define MATE_PANEL_APPLET_FLAGS_ALL (MATE_PANEL_APPLET_EXPAND_MAJOR|MATE_PANEL_APPLET_EXPAND_MINOR|MATE_PANEL_APPLET_HAS_HANDLE) } MatePanelAppletFlags; typedef struct _MatePanelApplet MatePanelApplet; diff --git a/mate-panel/applet.c b/mate-panel/applet.c index 3d81eab4..fa668e89 100644 --- a/mate-panel/applet.c +++ b/mate-panel/applet.c @@ -598,6 +598,9 @@ mate_panel_applet_position_menu (GtkMenu *menu, { GtkAllocation allocation; GtkRequisition requisition; +#if GTK_CHECK_VERSION(3, 0, 0) + GdkDevice *device; +#endif GdkScreen *screen; GtkWidget *parent; int menu_x = 0; @@ -618,8 +621,12 @@ mate_panel_applet_position_menu (GtkMenu *menu, #endif gdk_window_get_origin (gtk_widget_get_window (applet), &menu_x, &menu_y); +#if GTK_CHECK_VERSION (3, 0, 0) + device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gtk_widget_get_display (applet))); + gdk_window_get_device_position(gtk_widget_get_window (applet), device, &pointer_x, &pointer_y, NULL); +#else gtk_widget_get_pointer (applet, &pointer_x, &pointer_y); - +#endif gtk_widget_get_allocation (applet, &allocation); if (!gtk_widget_get_has_window (applet)) { diff --git a/mate-panel/mate-panel-applet-frame.c b/mate-panel/mate-panel-applet-frame.c index bdabbc93..b0272590 100644 --- a/mate-panel/mate-panel-applet-frame.c +++ b/mate-panel/mate-panel-applet-frame.c @@ -135,11 +135,16 @@ mate_panel_applet_frame_draw (GtkWidget *widget, cairo_pattern_destroy (bg_pattern); } + cairo_rectangle (cr, + frame->priv->handle_rect.x, + frame->priv->handle_rect.y, + frame->priv->handle_rect.width, + frame->priv->handle_rect.height); + cairo_clip (cr); gtk_render_handle (context, cr, - frame->priv->handle_rect.x, - frame->priv->handle_rect.y, - frame->priv->handle_rect.width, - frame->priv->handle_rect.height); + 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); cairo_restore (cr); @@ -949,7 +954,7 @@ mate_panel_applet_frame_activating_free (MatePanelAppletFrameActivating *frame_a GdkScreen * panel_applet_frame_activating_get_screen (MatePanelAppletFrameActivating *frame_act) { - return gtk_widget_get_screen (frame_act->panel); + return gtk_widget_get_screen (GTK_WIDGET(frame_act->panel)); } PanelOrientation diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index 0132d436..459ec593 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -1475,8 +1475,11 @@ void panel_toplevel_update_edges(PanelToplevel* toplevel) background = &toplevel->priv->panel_widget->background; + /* We don't want any bevels with a color/image background */ +#if !GTK_CHECK_VERSION(3, 0, 0) if (panel_background_effective_type (background) == PANEL_BACK_NONE) { +#endif if (toplevel->priv->geometry.y > 0) edges |= PANEL_EDGE_TOP; @@ -1515,7 +1518,9 @@ void panel_toplevel_update_edges(PanelToplevel* toplevel) inner_frame = TRUE; edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM; } +#if !GTK_CHECK_VERSION(3, 0, 0) } +#endif if (!inner_frame) { inner_edges = PANEL_EDGE_NONE; @@ -2973,7 +2978,9 @@ static void panel_toplevel_check_resize (GtkContainer *container) { GtkAllocation allocation; +#if !GTK_CHECK_VERSION(3, 0, 0) GtkAllocation widget_allocation; +#endif GtkRequisition requisition; GtkWidget *widget; @@ -2990,13 +2997,11 @@ panel_toplevel_check_resize (GtkContainer *container) #else gtk_widget_size_request (widget, &requisition); #endif - gtk_widget_get_allocation (widget, &widget_allocation); + gtk_widget_get_allocation (widget, &allocation); - if (widget_allocation.width != requisition.width || - widget_allocation.height != requisition.height) - return; + allocation.width = requisition.width; + allocation.height = requisition.height; - allocation = widget_allocation; gtk_widget_size_allocate (widget, &allocation); } @@ -3148,13 +3153,16 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) PanelToplevel* toplevel = (PanelToplevel*) widget; PanelFrameEdge edges; gboolean retval = FALSE; - GdkWindow *window; - GtkStyle *style; - GtkStateType state; #if GTK_CHECK_VERSION (3, 0, 0) int awidth; int aheight; + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder padding; #else + GdkWindow *window; + GtkStyle *style; + GtkStateType state; GtkAllocation allocation; #endif @@ -3181,57 +3189,77 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) toplevel->priv->attached) return retval; - window = gtk_widget_get_window (widget); - style = gtk_widget_get_style (widget); - state = gtk_widget_get_state (widget); #if GTK_CHECK_VERSION (3, 0, 0) + state = gtk_widget_get_state_flags (widget); awidth = gtk_widget_get_allocated_width (widget); aheight = gtk_widget_get_allocated_height (widget); + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, state, &padding); + gtk_style_context_save (context); + gtk_style_context_set_state (context, state); #else + window = gtk_widget_get_window (widget); + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); gtk_widget_get_allocation (widget, &allocation); #endif if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) { int x, y, width, height; - int xthickness, ythickness; #if GTK_CHECK_VERSION (3, 0, 0) x = 0; y = 0; height = height; #else + int xthickness, ythickness; x = allocation.x; y = allocation.y; height = allocation.height; #endif width = HANDLE_SIZE; +#if !GTK_CHECK_VERSION(3, 0, 0) xthickness = style->xthickness; ythickness = style->ythickness; +#endif if (edges & PANEL_EDGE_TOP) { +#if GTK_CHECK_VERSION (3, 0, 0) + y += padding.top; + height -= padding.top; +#else y += ythickness; height -= ythickness; +#endif } if (edges & PANEL_EDGE_BOTTOM) +#if GTK_CHECK_VERSION (3, 0, 0) + height -= padding.bottom; +#else height -= ythickness; +#endif if (edges & PANEL_EDGE_LEFT) +#if GTK_CHECK_VERSION (3, 0, 0) + x += padding.left; +#else x += xthickness; +#endif - gtk_paint_handle (style, #if GTK_CHECK_VERSION (3, 0, 0) - cr, + cairo_save (cr); + gtk_render_handle (context, cr, x, y, width, height); + cairo_restore (cr); #else + gtk_paint_handle (style, window, -#endif state, GTK_SHADOW_OUT, -#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, -#endif widget, "handlebox", x, y, width, height, GTK_ORIENTATION_VERTICAL); +#endif #if GTK_CHECK_VERSION (3, 0, 0) x = awidth - HANDLE_SIZE; @@ -3239,63 +3267,83 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) x = allocation.width - HANDLE_SIZE; #endif if (edges & PANEL_EDGE_RIGHT) +#if GTK_CHECK_VERSION (3, 0, 0) + x -= padding.right; +#else x -= xthickness; +#endif - gtk_paint_handle (style, -#if GTK_CHECK_VERSION (3, 0, 0) - cr, +#if GTK_CHECK_VERSION(3, 0, 0) + cairo_save (cr); + gtk_render_handle (context, cr, x, y, width, height); + cairo_restore (cr); #else + gtk_paint_handle (style, window, -#endif state, GTK_SHADOW_OUT, -#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, -#endif widget, "handlebox", x, y, width, height, GTK_ORIENTATION_VERTICAL); +#endif } else { int x, y, width, height; - int xthickness, ythickness; #if GTK_CHECK_VERSION (3, 0, 0) x = 0; y = 0; width = awidth; #else + int xthickness, ythickness; + x = allocation.x; y = allocation.y; width = allocation.width; #endif height = HANDLE_SIZE; +#if !GTK_CHECK_VERSION (3, 0, 0) xthickness = style->xthickness; ythickness = style->ythickness; +#endif if (edges & PANEL_EDGE_LEFT) { +#if GTK_CHECK_VERSION (3, 0, 0) + x += padding.left; + width -= padding.left; +#else x += xthickness; width -= xthickness; +#endif } if (edges & PANEL_EDGE_RIGHT) +#if GTK_CHECK_VERSION (3, 0, 0) + width -= padding.right; +#else width -= xthickness; +#endif if (edges & PANEL_EDGE_TOP) +#if GTK_CHECK_VERSION (3, 0, 0) + y += padding.top; +#else y += ythickness; +#endif - gtk_paint_handle (style, #if GTK_CHECK_VERSION (3, 0, 0) - cr, + cairo_save (cr); + gtk_render_handle (context, cr, x, y, width, height); + cairo_restore (cr); #else + gtk_paint_handle (style, window, -#endif state, GTK_SHADOW_OUT, -#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, -#endif widget, "handlebox", x, y, width, height, GTK_ORIENTATION_HORIZONTAL); +#endif #if GTK_CHECK_VERSION (3, 0, 0) y = aheight - HANDLE_SIZE; @@ -3303,24 +3351,32 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) y = allocation.height - HANDLE_SIZE; #endif if (edges & PANEL_EDGE_BOTTOM) +#if GTK_CHECK_VERSION (3, 0, 0) + y -= padding.bottom; +#else y -= ythickness; +#endif - gtk_paint_handle (style, #if GTK_CHECK_VERSION (3, 0, 0) - cr, + cairo_save (cr); + gtk_render_handle (context, cr, x, y, width, height); + cairo_restore (cr); #else + gtk_paint_handle (style, window, -#endif state, GTK_SHADOW_OUT, -#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, -#endif widget, "handlebox", x, y, width, height, GTK_ORIENTATION_HORIZONTAL); +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_style_context_restore (context); +#endif + return retval; } -- cgit v1.2.1