Zenity windows appear underneath others

Bug #272083 reported by Ian Redfern on 2008-09-19
This bug affects 14 people
Affects Status Importance Assigned to Milestone
Fix Released
Won't Fix
zenity (Ubuntu)
Ubuntu Desktop Bugs
Nominated for Intrepid by Wouter Stomp

Bug Description

Binary package hint: zenity

Current Intrepid, zenity

Happens with Compiz or Metacity as window manager.

zenity --title "Title" --entry --text "Message"

The popup appears below all my other windows, rather than on top. It worked fine in Hardy.

Related branches

Pedro Villavicencio (pedro) wrote :

there's exactly the other way report here: http://bugzilla.gnome.org/show_bug.cgi?id=448946

Changed in zenity:
importance: Undecided → Low
Steve Beattie (sbeattie) wrote :

I can confirm that the gnome bug (448946) represents the state of things as of Hardy/8.04 (zenity 2.22.1-1), but that zenity in intrepid (zenity 2.24.0-0ubuntu1) behaves as the reporter describes, which seems to me to be an even worse over-correction.

Changed in zenity:
status: New → Confirmed
Changed in zenity:
status: Confirmed → Triaged
Changed in zenity:
status: Unknown → Confirmed
jcinacio (jcinacio) wrote :

Im not sure why zenity shouldn't steal focus, because imho most of the times that's the whole purpose of using zenity.

Waiting for feedback from a script for a whole minute and then realising there's a hidden dialog waiting for input is NOT a good thing...

jcinacio (jcinacio) wrote :

For reference, the focus handling can be changed by a simple property in the zenity glade file

Attaching patch, can be applied directly to /usr/share/zenity/zenity.glade

Durand D'souza (durand1) wrote :

Thanks! That patch worked.

adpads (spam-liberte) wrote :

I made an account here especially so I could thank you for that patch. Worked a charm! You the man!

Fisslefink (erin-simonds) wrote :

Thanks jcinacio! Works perfectly now.

This is truly a bug, I agree with the comment above that the desired behavior of Zenity is to steal focus and demand user interaction. Either this should be configurable as a command line argument in the zenity program, or the default setting should be changed back to the way in was in Hardy. For notifications without stealing focus, I'd suggest people use something like Growl.

For any rusty hackers that forgot how to apply patches (like me), and want to fix their zenity behavior, it's easy. Just download jcinacio's file above, and run the following command:

sudo patch -p0 /usr/share/zenity/zenity.glade < /PATH/TO/DOWNLOADED/PATCH/zenity-2.24.0-focus.patch

Thanks again.

Thanks for the patch.

Whats the point of zenity if everything it does is hidden behind other windows. Theres the --notification to use if we don't want to steal focus

The top reason to use zenity is to get a pop-up box on top of everything.
Behind all the other open applications negates all of its use for me.

Many many thanks for the patch and many thanks for helping out another rusty hacker for the line to apply it.
Patch works well.


My english is bad and i copy/paste the adpads comment's : ;)

I made an account here especially so I could thank you for that patch. Worked a charm! You the man!


zettabyte (dougvanhorn) wrote :

I modified the source to provide a --focus argument.

I couldn't get it to focus when using the --scale dialog for some reason. It's been years since I coded in C so the patch should be considered a "leg up" in getting the real work done.

Hope it helps!

Ladies and gentlemen, instead of adding an argument, --focus, to cause
the Zenity dialog to steal the focus, I believe that stealing the
focus should be the default behavior. Instead, please add an optional
argument, only for use when there is a need to prevent the Zenity
dialog from stealing the focus. This will prevent all who have come
to depend on a Zenity dialog appearing on top of all other windows
from having to rewrite all of their scripts. It seems that the vast
majority of users want Zenity dialogs to appear on top of all other
windows by default. The need for an extra argument should only apply
to the minority of users--those who don't want the Zenity dialog to
steal the focus. Perhaps this argument should be --subdue.

Thank you to everyone who is working on this, for my hat is off to you.

On 12/3/08, zettabyte <email address hidden> wrote:
> I modified the source to provide a --focus argument.
> I couldn't get it to focus when using the --scale dialog for some
> reason. It's been years since I coded in C so the patch should be
> considered a "leg up" in getting the real work done.
> Hope it helps!
> ** Attachment added: "Modifies the source code to provide a --focus
> argument."
> http://launchpadlibrarian.net/20187192/zenity-focus.patch
> --
> Zenity windows appear underneath others
> https://bugs.launchpad.net/bugs/272083
> You received this bug notification because you are a direct subscriber
> of the bug.

ajeffri (ajeffri) wrote :

Thanks for the patch! This has been bugging me for a while.

I agree that the default behavior should be to grab the focus and demand attention. If I was a C programmer, I'd fix it myself.

libertyernie (libertyernie) wrote :

I would love to see this fixed for Jaunty. Every other app seems to pop up in front (except maybe kget, but that's a different story.)

deanm (cubeist) wrote :

Great work jcinacio, this has been bugging me for awhile now. Also thanks to Fisslefink, because, yes, I had forgotten how to patch properly!

patch worked for me on:
X86_64 Ubuntu Intrepid 8.10 kernel 2.6.27-11-generic / zenity version 2.24.0

nicomen (mendoza-pvv) wrote :

Any reason this hasn't been fixed yet? Are there any valid arguments that it should open in the back?

Pedro Villavicencio (pedro) wrote :

nicomen what do you mean? the bug is still open here and in the upstream tracker but no one has submitted a patch yet to fix it. And yes patches are welcome.

Changed in zenity:
assignee: nobody → desktop-bugs
Forlong (forlong) wrote :

jcinacio provided a patch.
It's simply a matter of changing the proper values in the glade file.

Pedro Villavicencio (pedro) wrote :

I've commented on the upstream bug and linked the patch there, but there's probably a side effect as Lucas stated on the upstream report, let's wait for comments there, thanks.

Juan Simón (simonbcn) wrote :

This problem has reappeared:

Description: Ubuntu jaunty (development branch)
Release: 9.04
Linux ubuntu-desktop 2.6.28-11-server
Compiz enabled
NonfreeKernelModules: nvidia
  Instalados: 2.26.0-0ubuntu1
  Candidato: 2.26.0-0ubuntu1
  Tabla de versión:
 *** 2.26.0-0ubuntu1 0
        500 http://archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

fduppa (fduppa) wrote :

thanks a lot for this patch.

it solved the problem.

now it focus.

thanks (again)

Mario Limonciello (superm1) wrote :

setting to High on Mythbuntu task as mythtv-setup uses zenity and can cause weird behaviors when setting up a box otherwise.

Changed in mythbuntu:
importance: Undecided → High
milestone: none → jaunty-release
status: New → Confirmed
Juan Simón (simonbcn) wrote :

What patch!? This: zenity-2.24.0-focus.patch??
It's for 2.24 version, is it also valid for 2.26.0-0ubuntu1 version?
Why this problem appear again?

JDS (jsilveronnelly) wrote :

This bug still exists in Jaunty Beta as of April 16, 2009. I ran 'apt-get upgrade' just five minutes ago.

jeff@jeff-laptop:~$ cat /etc/lsb-release

jeff@jeff-laptop:~$ apt-cache showpkg zenity
Package: zenity
2.26.0-0ubuntu1 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty_main_binary-i386_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty_main_binary-i386_Packages
                  MD5: 0eaa042a6247aca86bac2f94a69fc906

The patch file did not work for me so I am attaching one that did, that I created after manually patching the glade file.

Use it as follows:

(Remember to back up the original zenity.glade file first!!!!!!!!!!!! "sudo cp -p /usr/share/zenity/zenity.glade /usr/share/zenity/zenity.glade.dist")

sudo patch -p0 /usr/share/zenity/zenity.glade < zenity-2.26.0-focus.patch

I hope this helps. Seeya...

Juan Simón (simonbcn) wrote :

Jeffrey Silverman , thank you very much!
It works for me.

Mario Limonciello (superm1) wrote :

Adding a milestone for ubuntu-9.04

Changed in zenity (Ubuntu):
milestone: none → ubuntu-9.04
Mario Limonciello (superm1) wrote :

A fixed zenity package has been uploaded, but a release team member will need to ack it.

Changed in zenity (Ubuntu):
status: Triaged → Fix Committed
FaberfoX (faberfox) wrote :

Thanks Jeffrey, patch works fine, hope to see it commited before release.

Steve Langasek (vorlon) wrote :

This patch seems to be rather large for the change in question, I wonder if each of the changes is necessary or if this change is overreaching?

The upstream bug linked here points out that having the pop-ups steal the focus, which I believe is the result of this change, will /also/ make people unhappy; I think what you ideally want here is for the window to open on top, but to not steal the focus? But neither the existing behavior, nor this change, give you that.

I'm concerned about changing the behavior of this program so blatantly, so shortly before release. Mario, would it still meet your needs for mythbuntu if this change landed as an SRU instead, to give it more time to bake?

Juan Simón (simonbcn) wrote :

I don't agree.
Let's not forget that Zenity is used to display GTK+ dialogs in shell scripts.
If I execute a shell script with zenity pop-ups, they ALWAYS appear under any other window. This is the right thing?

Mario Limonciello (superm1) wrote :

If you look at zenity.glade more closely, it defines each possible top level widget on its own (eg Calendar, Question, Info dialog etc). So this bug affects all widget types, and they need to be individually fixed.

The existing behavior (in intrepid and earlier releases) was that zenity would take focus - due to how the window manager was handling things. In jaunty, window managers are finally respecting options like that properly, which is how this came up.

Additionally, i've reviewed upstream's change history. This bug was introduced in 2.23.1 in the middle of making a new release changelog. Looking at that, it really looks like it was an oversight to me. Here's when the changeset was introduced:


Launchpad Janitor (janitor) wrote :

This bug was fixed in the package zenity - 2.26.0-0ubuntu2

zenity (2.26.0-0ubuntu2) jaunty; urgency=low

  * debian/patches/zenity-2.26.0-focus.patch: Fixes focus issues when zenity
    opens. Thanks Jeffrey Silverman. (LP: #272083)
  * debian/rules: Enable simple patch system.

 -- Mario Limonciello <email address hidden> Thu, 16 Apr 2009 11:27:16 -0500

Changed in zenity (Ubuntu):
status: Fix Committed → Fix Released
Changed in mythbuntu:
status: Confirmed → Fix Released
tags: added: iso-testing
Andras Horvath (log69) wrote :

Saying it's "Fix Released", I guess it should work just fine under Ubuntu 10.04, but it doesn't. When i run this from a terminal and open an other window after it quickly:

sleep 3; zenity --info --text hello

...then zenity appears only under my newly opened window and stays in the background. It doesn't steal focus either. (zenity version 2.28.0)

However, it works under my debian stable system (zenity 2.22.1).

Can anyone confirm that zenity's still having the bug in Ubuntu 10.04 ?

Jacob Peddicord (jpeddicord) wrote :


It's likely a problem with your window manager or its focus-stealing prevention level. Running what you provided opens a Zenity dialog above the current terminal (and it even appears to stay on top of the terminal as a modal dialog).

Jacob Peddicord (jpeddicord) wrote :

Also, the Zenity version in 10.04 is 2.30.0; please make sure you're up-to-date and try again.

Andras Horvath (log69) wrote :

My version of zenity is also 2.30.0, i mistyped it before, cause i was testing it on 9.10 too.

Lately i realised that this behavior is a matter of the window manager. Running zenity from a terminal, its window doesn't go to the top in Gnome when i have other window active. It does, when running it by clicking on an icon. So the wm probably prevents the popups getting focus that are run from an inactive terminal.

This is not an issue with Xfce's wm or other wm though that i tested on the same system. So it's probably the way metacity behaves by default.

I tried to set the focus from smart to strict as the only option here with gconf-editor in /apps/metacity/general/focus_new_windows, but it doesn't help either.

Seeing that the file /usr/share/zenity/zenity.ui has all its focus settings set to True by default (what the patch did provided in upper comments), i might say that it's not a zenity problem anymore, and it depends on the focus policy of the wm.

Changed in zenity:
importance: Unknown → Medium
status: Confirmed → Won't Fix
Arno Teigseth (arnotixe) wrote :

Hi all

The zenity man page says that "zenity tries to find the terminal window it was launched from, and stays on top of that. You can disable it by unsetting the WINDOWID variable."

I tried and this works fine for me:

eog -f background.jpg &
# (to let eog find time to show the background image)

# yes: = and then nothing

zenity <something>

This makes zenity appear "on top" of the background image.

You may have other issues, but this works for me :D

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.