diff options
author | luigifab <[email protected]> | 2025-07-14 16:38:37 +0200 |
---|---|---|
committer | Luke from DC <[email protected]> | 2025-07-15 07:22:29 +0000 |
commit | 8cd1ba9b0b055d3d5a4e55bdb0262e7b090bd147 (patch) | |
tree | 8100e945b9be0c21b110db03e04073c2937a8bbd | |
parent | 131e9ea115fa052dc545930b10ff170fa2e140ad (diff) | |
download | mate-panel-8cd1ba9b0b055d3d5a4e55bdb0262e7b090bd147.tar.bz2 mate-panel-8cd1ba9b0b055d3d5a4e55bdb0262e7b090bd147.tar.xz |
Fix dragging panel color
-rw-r--r-- | mate-panel/panel.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mate-panel/panel.c b/mate-panel/panel.c index e854cf73..065d2090 100644 --- a/mate-panel/panel.c +++ b/mate-panel/panel.c @@ -454,7 +454,8 @@ set_background_image_from_uri (PanelToplevel *toplevel, static gboolean set_background_color (PanelToplevel *toplevel, - guint16 *dropped) + guint16 *dropped, + gint length) { GdkRGBA color; @@ -465,10 +466,11 @@ set_background_color (PanelToplevel *toplevel, ! panel_profile_background_key_is_writable (toplevel, "type")) return FALSE; - color.red = dropped [0]; - color.green = dropped [1]; - color.blue = dropped [2]; - color.alpha = 1.; + const gdouble scale = 1.0 / 65535.0; + color.red = dropped[0] * scale; + color.green = dropped[1] * scale; + color.blue = dropped[2] * scale; + color.alpha = (length > 3) ? dropped[3] * scale : 1.0; panel_profile_set_background_color (toplevel, &color); panel_profile_set_background_type (toplevel, PANEL_BACK_COLOR); @@ -1232,7 +1234,9 @@ panel_receive_dnd_data (PanelWidget *panel, success = drop_url (panel, pos, (char *)data); break; case TARGET_COLOR: - success = set_background_color (panel->toplevel, (guint16 *) data); + gint n_bytes = gtk_selection_data_get_length (selection_data); + gint length = n_bytes / sizeof (guint16); + success = set_background_color (panel->toplevel, (guint16 *) data, length); break; case TARGET_BGIMAGE: success = set_background_image_from_uri (panel->toplevel, (char *) data); |