Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 487786

Summary: [GTK] Shell.setFullScreen broken
Product: [Eclipse Project] Platform Reporter: Marco Hunsicker <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: abuzila, akurtakov, alhashash, eclipse, ericwill, lunxian, OSKozlov
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=445456
https://bugs.eclipse.org/bugs/show_bug.cgi?id=493685
https://bugs.eclipse.org/bugs/show_bug.cgi?id=496639
https://bugs.eclipse.org/bugs/show_bug.cgi?id=536017
Whiteboard:

Description Marco Hunsicker CLA 2016-02-13 09:53:58 EST
In order to be able to maximize screen real estate while on the road using a notebook with a small screen, I've created a simple plugin that allows one to toggle full screen mode for the workbench.


public void setMode(IWorkbenchWindow window, Mode mode) {
    Shell shell = window.getShell();
    ...
    if (shell.getFullScreen() != mode.isFullScreen()) {
        shell.setFullScreen(mode.isFullScreen());
    }
}

This worked fine with Eclipse Luna, but is broken since Eclipse Mars in that dialogs are no longer displayed. Or at least they are not visible when full screen mode is enabled. Presumably because of the changes introduced with fix #445456.

Setting 

    OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);

seems to be required in full screen mode to have dialogs appear above the full screen window.


In order to cater for this use case, I'd suggest that a check is introduced to test whether a parent shell is in full screen mode and if that is the case, set the necessary hint.

Shell.java:716
if (!isUndecorated() && isFullScreenParent()) {
    OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
}

private boolean isFullScreenParent() {
    for (Control p = this.parent; p != null; p = p.getParent()) {
        if (p instanceof Shell) {
            Shell window = (Shell) p;
            if (window.getFullScreen()) {
                return true;
            }
        }
    }
    return false;
}

I've you can agree on this, I could submit a patch when desired. Thank you.
Comment 1 Alexander Kurtakov CLA 2016-09-26 13:50:22 EDT
I missed this bug sorry for that. Please provide a patch.
Comment 2 Marco Hunsicker CLA 2016-09-26 14:44:03 EDT
There has been another ticket opened for this issue, https://bugs.eclipse.org/bugs/show_bug.cgi?id=496639, and a patch has already been committed.

I can't check myself right away, but it should be save to close this ticket as well.

We might only argue about whether the additional check should be applied constantly in #setVisible() or whether it would be enough to do it once in #createHandle()
Comment 3 Xia Lunxian CLA 2016-10-09 23:41:00 EDT
Is there a hotfix to resolve it. I can fix the bug as now.

and can fix it in  ver4.6.1 ?
Comment 4 Marco Hunsicker CLA 2016-10-13 12:45:09 EDT
This bug has been fixed with the following commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=dc22e68f11f287a803f19c58505ae7441a5aa459
Comment 5 Xia Lunxian CLA 2016-10-20 03:47:22 EDT
How can I get a patch?
Comment 6 Alexander Kurtakov CLA 2016-10-20 04:38:16 EDT
(In reply to Xia Lunxian from comment #5)
> How can I get a patch?

cgit gives you a patch link. But for your convenience here is the direct link http://git.eclipse.org/c/platform/eclipse.platform.swt.git/patch/?id=dc22e68f11f287a803f19c58505ae7441a5aa459
Comment 7 Oleksandr Kozlov CLA 2018-06-15 08:40:34 EDT
We faced with a new issue related to "Full Screen" mode. When user switch to "Full Screen" mode and try to open "modeless dialog" this approach doesn't work. So as workaround I append additional condition  


Shell.java

int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+	int maskModeless = SWT.CLOSE | SWT.MODELESS| SWT.BORDER | SWT.TITLE;
if ((style & mask) != 0) {
 		if (visible) {
 			display.setModalShell (this);
@@ -2353,16 +2354,10 @@
 			display.clearModal (this);
 			OS.gtk_window_set_modal (shellHandle, false);
 		}
+		 popupDialogToFront();
+	} if ((style & maskModeless) != 0) {
+	   popupDialogToFront();
+  } else {
 		updateModal ();
 	}

+
+    /**
+     * 
+     * When in full-screen mode, the OS will always consider it to be the top of the display stack unless it is a
+     * dialog. This fix will give modal windows dialog-type priority if the parent is in full-screen, allowing it to be
+     * popped up in front of the full-screen window.
+     */
+    private void popupDialogToFront() {
+        if (parent != null && parent.getShell().getFullScreen()) {faced
+            OS.gtk_window_set_type_hint(shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
+        }
+    }
+
Comment 8 Oleksandr Kozlov CLA 2018-06-15 08:41:26 EDT
Could you please verify this changes?
Comment 9 Eric Williams CLA 2018-06-15 09:40:46 EDT
(In reply to Oleksandr Kozlov from comment #8)
> Could you please verify this changes?

Is this related to bug 535906? Or are they separate issues?
Comment 10 Oleksandr Kozlov CLA 2018-06-15 09:50:27 EDT
No, this problem happen when user first time open modeless dialog.
Comment 11 Oleksandr Kozlov CLA 2018-06-15 09:51:28 EDT
This is a separate issues
Comment 12 Eric Williams CLA 2018-06-15 11:11:36 EDT
(In reply to Oleksandr Kozlov from comment #11)
> This is a separate issues

Alright, please file a new bug ticket with a snippet to reproduce this issue, and upload your patch to gerrit so I can review it. Thanks!
Comment 13 Oleksandr Kozlov CLA 2018-06-18 13:31:32 EDT
Done. 
Bug 536017 - [GTK] Shell.setFullScreen broken for Modeless window 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=536017. 
Patch in attachment.