Mono winforms app fullscreen in Ubuntu?
Asked Answered
A

10

10

Just wondering if there's a known way of getting a Mono System.Windows.Forms application to go fullscreen on Ubuntu/Gnome.

Mono is 2.4.2.3 Ubuntu is 9.10

Doing it on Windows requires a pinvoke, clearly not going to work here.

This is what I get setting window border to none, window position to centre, and state to maximised:

alt text http://dl.dropbox.com/u/116092/misc/permalink/joggler/screenshot01.png

Update.

Have also tried:

  • this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
    this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

  • CTRL-F11

  • Text = string.Empty; // No caption
    MaximizeBox = false;
    MinimizeBox = false;
    ControlBox = false;
    FormBorderStyle = None;
    WindowState = Maximized;

  • FormBorderStyle = FormBorderStyle.None;
    Location = new Point(0, 0);
    Size = Screen.PrimaryScreen.Bounds.Size;

All of which I end up with the same result.

I have come across a lead which involves a pinvoke involving _NET_WM_STATE_FULLSCREEN but that's as far as I've got with it. Any pointers on that would be appreciated.

Audie answered 12/5, 2010 at 22:46 Comment(3)
this is an edge case, good luck.Saddle
Yup, that's kind of why I'm asking :-)Audie
See my answer below if you end up pursuing the _NET_WM_STATE_FULLSCREEN route.Beebe
B
3

_NET_WM_STATE_FULLSCREEN will just get rid of the borders. The GNOME panel will still appear.

According to the following post, the secret is to get rid of the minimum/maximum sizes so that the window manager does the resizing itself:

http://linux.derkeiler.com/Mailing-Lists/GNOME/2010-01/msg00035.html

Here is some documentation on the native spec:

http://standards.freedesktop.org/wm-spec/wm-spec-latest.html

http://www.x.org/docs/ICCCM/icccm.pdf

To talk directly to the X Window System you have to pinvoke into XLib. In order to send something like _NET_WM_STATE_FULLSCREEN you have to have a pointer to the window and also to the display.

I am not sure how to find the display but I can help with a pointer to the window. When running on X, the property Form.Handle should be a pointer to the X window.

Beebe answered 24/6, 2010 at 18:31 Comment(1)
I did a little search through the Mono source and nothing calls _NET_WM_STATE_FULLSCREEN. I am pretty comfortable saying that there is not fully managed way to send the right window hint to the window manager using Mono. You could use GTK# of course as it uses GTK+ underneath and gtk_window_fullscreen() does what you want.Beebe
B
2

Not sure what you mean by "Full Screen" - but I've written several Windows.Forms applications that take over the screen, and without a single PInvoke.

Here's how I configure my main form ...

Text = string.Empty; // No caption
MaximizeBox = false;
MinimizeBox = false;
ControlBox = false;
FormBorderStyle = None;
WindowState = Maximized;

Optionally,

TopMost = true;

Hope this helps.

Brunson answered 21/6, 2010 at 1:52 Comment(1)
That works really well on Windows, which is great, because I didn't know you could do this without a pinvoke to hide the taskbar. However no such luck on Mono: dl.dropbox.com/u/116092/misc/permalink/joggler/screenshot02.pngAudie
B
1

You need to disable visual effects in ubuntu.

edit: And make sure your form size is at least screen resolution without borders. If borders are on design time and you are removing them in code you will need something like 1030x796 for a 1024x768 display.

Banerjee answered 24/6, 2010 at 12:33 Comment(0)
C
1

I have been suffered by this problem 2 days and finally i got the solution: click the 1st icon on left tool bar and search compizconfig program. Go to preference-> unity and you will see there is a tick for unity plugin on the left side. Remove that tick and you will see the top menu bar disappeared. Though this thread is very old but I still hope I can help anyone who gets this problem and seek for help.

Crandell answered 18/7, 2013 at 2:52 Comment(0)
S
0

Have you tried this?

  this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;             
    this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

Unfortunately I have no Ubuntu available right now, but I can see old patches for this in old mono versions...

Slang answered 17/5, 2010 at 11:20 Comment(4)
Unfortunately that doesn't go over the task bar at the top of the screen (updated post with screenshot)Audie
Ok - then try to find the relevant C call to go full-screen. Calling native C functions does also work under Mono. Let me know if you have problems there, but I have done this in the past.Slang
Hmmm, a Google brings back _NET_WM_STATE_FULLSCREEN. Does that look useful?Audie
yes - but I do not find the other parameters which are necessary for the function call.Slang
I
0

It should be possible to display every app running inside gnome in fullscreen mode with the "CTRL+F11" hotkey.

Maybe you could try

System.Windows.Forms.SendKeys.Send();

but that is just a guess, I haven't got a Linux running atm to try this. But maybe this helps.

Indue answered 20/5, 2010 at 20:21 Comment(0)
E
0

I can't test it at the moment, but have you tried a simple resize?

form.FormBorderStyle = FormBorderStyle.None
form.Location = Point(0, 0)
form.Size = Screen.PrimaryScreen.Bounds.Size
Endodontics answered 22/5, 2010 at 14:40 Comment(1)
Another one that works well on Windows but same result as the second screenshot above.Audie
A
0

I have worked around this for now by setting the autohide property of the panel.

Not ideal because it depends on the user changing their environment to use my application, but better than nothing.

Audie answered 22/6, 2010 at 18:15 Comment(1)
Are you doing this manually or in code? If the latter, I suppose you could always toggle it when your app gets focus. That way, you get the whole screen but every other app behaves as expected and the system is left as it was when you are done. Of course, you would need to check the initial state to make sure it was not already auto-hide. This should work like you want even if it feels icky.Beebe
H
0

The following worked:

(Inspiration was taken from here: https://bugzilla.xamarin.com/show_bug.cgi?id=40997)

1) sudo apt-get install wmctrl

2) In your code:

Form form = new MainWindow();
form.FormBorderStyle = FormBorderStyle.None;
form.WindowState = FormWindowState.Maximized;

form.Load += (s, e) => {
    Process process = new Process {
        StartInfo = new ProcessStartInfo {
            FileName = "wmctrl",
            Arguments = $"-r :ACTIVE: -b add,fullscreen",
            CreateNoWindow = true
        }
    };
    process.Start();
    process.WaitForExit();
};

Application.Run(form);
Habilitate answered 29/8, 2018 at 0:0 Comment(2)
While :ACTIVE: worked for me on VirtualBox, it did not work on a Ubuntu tablet. I replaced :ACTIVE: with the window title (Text property of the Form) and that worked.Habilitate
Thanks! If only I still owned the hardware from 8 years ago ;-)Audie

© 2022 - 2024 — McMap. All rights reserved.