# Plot window appears in background

**URL:** <https://discourse.julialang.org/t/plot-window-appears-in-background/82293>\
**Category:** General Usage\
**Tags:** question, package, inspectdr\
**Created:** [June 6, 2022, 6:49am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293 "2022-06-06T06:49:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 6, 2022, 6:49am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/1 "2022-06-06T06:49:48Z")

</div>

I am already pretty happy with InspectDR. Can be tuned to be beautiful. One more question:

If I run the following script once all works fine:

```julia
using Plots; inspectdr()
InspectDR.defaults.xaxiscontrol_visible = false

x = 0:0.05:100
y = sin.(x)

p1 = plot(x, y, width=2, xtickfontsize=12, ytickfontsize=12, legendfontsize=12, legend=false)
pIDR = display(p1) # Display with InspectDR and keep plot object
resize!(pIDR.wnd, 1200, 700) # Resize GTK window directly

```

But if I run it a second time with the command:

```julia
include("plot.jl")

```

the window pops up in the background.

Is there anything I can do about it?

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [June 7, 2022, 1:26am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/2 "2022-06-07T01:26:50Z")

</div>

I use Ubuntu 18.04 (I believe you use the same). I have never seen that behaviour of windows popping up in the background.

That said, I have used Linux installations that popped up pretty much ALL new windows of an application in the background. I am unsure what setting causes Linux to do this (maybe it is a Gtk thing?).

### Workaround

Since InspectDR is Gtk-based, you can try forcing the new window to the foreground using:

```julia
Gtk.present(pIDR.wnd) #Move window to foreground.

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 7, 2022, 3:09am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/3 "2022-06-07T03:09:48Z")

</div>

I tried your suggestion, but it doesn’t work. Is there a way to translate this call to Julia:

```julia
gtk_window_set_keep_above(GTK_WINDOW(window), TRUE) brings the window on top, but without focus.

```

By the way, I am using both Ubuntu 18.04 and 20.04.

And perhaps the problem is that it appears minimized?

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [June 7, 2022, 8:01am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/4 "2022-06-07T08:01:55Z")

</div>

From the description of this call in the gtk docu:

“Asks to keep `window` above, so that it stays on top. Note that you shouldn’t assume the window is definitely above afterward, because other entities (e.g. the user or [window manager][gtk-X11-arch]) could not keep it above, and not all window managers support keeping windows above.”

And the call itself should be a reasonable simple ccall like you find in gtk.jl/src/windows.jl

---

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [June 8, 2022, 1:57am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/5 "2022-06-08T01:57:32Z")

</div>

> [@ufechner7](#):
>
> And perhaps the problem is that it appears minimized?

I personally would investigate this problem first myself. Seems to me like something is wrong with your environment – causing strange behaviours with Gtk.

> [@ufechner7](#):
>
> `gtk_window_set_keep_above`

That function does not appear to be ported over to the Gtk.jl package. Like @lobingera suggested, you would have to wrap the C-call it yourself if you want that functionality.

Though I’m pretty certain you should be looking into your Linux window manager (and/or Gtk installation). Looks like your problem resides there somewhere.

---

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [June 8, 2022, 7:11am UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/6 "2022-06-08T07:11:32Z")

</div>

I can verify that the window appears on top as it should in Ubuntu 20.04 (lightdm&gnome) and Julia 1.7.2. I assume none of the other windows are set ‘always on top’?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 14, 2022, 2:58pm UTC](https://discourse.julialang.org/t/plot-window-appears-in-background/82293/7 "2022-08-14T14:58:08Z")

</div>

Well, for me it does not appear on top as it should. But when I add the following call it works as expected:

```julia
using Gtk.ShortNames
G_.keep_above(pIDR.wnd, true)

```
