Mono winforms app fullscreen in Ubuntu?

℡╲_俬逩灬. 提交于 2019-12-03 06:13:13

_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.

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.

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.

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.

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...

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.

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

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.

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!