After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695132 - gtk_widget_get_opacity should return original opacity value
gtk_widget_get_opacity should return original opacity value
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.7.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-03-04 15:48 UTC by Michael Terry
Modified: 2013-05-23 12:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Terry 2013-03-04 15:48:03 UTC
In GTK+ 3.7, window opacity handling has changed a bit.  It now goes through a generic widget opacity process and the requested opacity value gets manipulated a bit (converted to an int).

However...  when a client app requests the opacity back, it gets this manipulated number, modified back into a double.  I believe most clients expect to receive the original opacity value.

For example, the fading "camera flash" effect in gnome-screenshot and cheese both do something like the following:

static gboolean
cheese_flash_opacity_fade (gpointer data)
{
  CheeseFlash        *flash        = data;
  CheeseFlashPrivate *flash_priv   = CHEESE_FLASH_GET_PRIVATE (flash);
  GtkWindow          *flash_window = flash_priv->window;
  double              opacity      = gtk_window_get_opacity (flash_window);

  /* exponentially decrease */
  gtk_window_set_opacity (flash_window, opacity * 0.95);

  if (opacity <= 0.01)
  {
    /* the flasher has finished when we reach the quit value */
    gtk_widget_hide (GTK_WIDGET (flash_window));
    return FALSE;
  }

  return TRUE;
}

With GTK+ 3.7.10, this will get stuck forever at opacity 0.039216.  (It gets reduced to 0.037255, which gets rounded to 10, which gets returned back as 0.039216.)

This code is making the assumption that get() will return what set() was given.  Which doesn't seem like a bad assumption.

Please have GtkWidget save the original value to set() and return it in get().
Comment 1 Michael Terry 2013-03-04 15:57:03 UTC
Actually, it's not just an assumption that get() will return what set() was given.  It's explicitly mentioned in the gtk-doc comments:

/**
 * gtk_window_get_opacity:
 * @window: a #GtkWindow
 *
 * Fetches the requested opacity for this window. See
 * gtk_window_set_opacity().
 *
 * Return value: the requested opacity for this window.
 *
 * Since: 2.12
 * Deprecated: 3.8: Use gtk_widget_get_opacity instead.
 **/
Comment 2 Iain Lane 2013-05-23 12:36:06 UTC
seb128 says this is fixed in 3.8.1. Not sure which commit.