Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8267307: Introduce new client property for XAWT: xawt.mwm_decor_title #4113

Closed
wants to merge 3 commits into from

Conversation

mkartashev
Copy link
Member

@mkartashev mkartashev commented May 19, 2021

This commit introduces a new client property xawt.mwm_decor_title implementing JDK-8267307. The property can be set prior to showing a window or after the window has been displayed, in which case the window will have to be hidden/shown (re-mapped) for the property to take effect.

The general idea is to provide control over the "decorations" part of the X11 window property called _MOTIF_WM_HINTS. Those "decoration" bits are set to 1 (XWindowAttributesData.AWT_DECOR_ALL) to show all the decorations or 0 (XWindowAttributesData.AWT_DECOR_NONE) to ask the window manager (WM) not to decorate with anything, even borders or resize handles. With xawt.mwm_decor_title property set to "true", this commit adds the ability to set the bits to 2 (XWindowAttributesData.AWT_DECOR_BORDER), which some WMs take as "decorate with only a border", thus effectively removing the window's title bar, but still leaving the resize capability.

This feature was tested and works correctly on "vanilla" Ubuntu 20.04 with the "GNOME Shell" window manager. It was also tested with Xfwm4 and KDE, where it did not have any effect; these two WMs have limited respected for the "decorations" bits of the _MOTIF_WM_HINTS window property.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8267307: Introduce new client property for XAWT: xawt.mwm_decor_title

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4113/head:pull/4113
$ git checkout pull/4113

Update a local copy of the PR:
$ git checkout pull/4113
$ git pull https://git.openjdk.java.net/jdk pull/4113/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4113

View PR using the GUI difftool:
$ git pr show -t 4113

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4113.diff

@mkartashev
Copy link
Member Author

mkartashev commented May 19, 2021

/covered

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label May 19, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented May 19, 2021

Hi @mkartashev, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user mkartashev" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label May 19, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented May 19, 2021

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@openjdk
Copy link

openjdk bot commented May 19, 2021

@mkartashev The following label will be automatically applied to this pull request:

  • awt

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the awt client-libs-dev@openjdk.org label May 19, 2021
@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels May 19, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label May 19, 2021
@mlbridge
Copy link

mlbridge bot commented May 19, 2021

Webrevs

@mrserb
Copy link
Member

mrserb commented May 20, 2021

Hello, thank you for your contribution, One initial question: what the name "mwm_" of this property actually means?

@mlbridge
Copy link

mlbridge bot commented May 21, 2021

Mailing list message from Maxim Kartashev on awt-dev:

On Fri, May 21, 2021 at 12:33 AM Sergey Bylokhov <serb at openjdk.java.net>
wrote:

On Wed, 19 May 2021 10:23:01 GMT, Maxim Kartashev <github.com+
28651297+mkartashev at openjdk.org> wrote:

This commit introduces a new client property xawt.mwm_decor_title
implementing JDK-8267307. The property can be set prior to showing a window
or after the window has been displayed, in which case the window will have
to be hidden/shown (re-mapped) for the property to take effect.

The general idea is to provide control over the "decorations" part of
the X11 window property called _MOTIF_WM_HINTS. Those "decoration" bits are
set to 1 (XWindowAttributesData.AWT_DECOR_ALL) to show all the decorations
or 0 (XWindowAttributesData.AWT_DECOR_NONE) to ask the window manager (WM)
not to decorate with anything, even borders or resize handles. With
xawt.mwm_decor_title property set to "true", this commit adds the ability
to set the bits to 2 (XWindowAttributesData.AWT_DECOR_BORDER), which some
WMs take as "decorate with only a border", thus effectively removing the
window's title bar, but still leaving the resize capability.

This feature was tested and works correctly on "vanilla" Ubuntu 20.04
with the "GNOME Shell" window manager. It was also tested with Xfwm4 and
KDE, where it did not have any effect; these two WMs have limited respected
for the "decorations" bits of the _MOTIF_WM_HINTS window property.

Hello, thank you for your contribution, One initial question: what the
name "mwm_" of this property actually means?

The name's historical: it's from the _MOTIF_WM_HINTS property of X11 that
has "decorations" bits in it (the 3rd word of the structure). For instance,
this is from a Firefox window in GNOME that does not have a title bar:

$ xprop -id 0x2600003 | grep -i MOTIF_WM_HINTS
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0

Despite the name ("motif"), this property has apparently become a de-facto
standard way to communicate client wishes about its window decoration to
any window manager currently in charge.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210521/f196d645/attachment-0001.htm>

1 similar comment
@mlbridge
Copy link

mlbridge bot commented May 21, 2021

Mailing list message from Maxim Kartashev on awt-dev:

On Fri, May 21, 2021 at 12:33 AM Sergey Bylokhov <serb at openjdk.java.net>
wrote:

On Wed, 19 May 2021 10:23:01 GMT, Maxim Kartashev <github.com+
28651297+mkartashev at openjdk.org> wrote:

This commit introduces a new client property xawt.mwm_decor_title
implementing JDK-8267307. The property can be set prior to showing a window
or after the window has been displayed, in which case the window will have
to be hidden/shown (re-mapped) for the property to take effect.

The general idea is to provide control over the "decorations" part of
the X11 window property called _MOTIF_WM_HINTS. Those "decoration" bits are
set to 1 (XWindowAttributesData.AWT_DECOR_ALL) to show all the decorations
or 0 (XWindowAttributesData.AWT_DECOR_NONE) to ask the window manager (WM)
not to decorate with anything, even borders or resize handles. With
xawt.mwm_decor_title property set to "true", this commit adds the ability
to set the bits to 2 (XWindowAttributesData.AWT_DECOR_BORDER), which some
WMs take as "decorate with only a border", thus effectively removing the
window's title bar, but still leaving the resize capability.

This feature was tested and works correctly on "vanilla" Ubuntu 20.04
with the "GNOME Shell" window manager. It was also tested with Xfwm4 and
KDE, where it did not have any effect; these two WMs have limited respected
for the "decorations" bits of the _MOTIF_WM_HINTS window property.

Hello, thank you for your contribution, One initial question: what the
name "mwm_" of this property actually means?

The name's historical: it's from the _MOTIF_WM_HINTS property of X11 that
has "decorations" bits in it (the 3rd word of the structure). For instance,
this is from a Firefox window in GNOME that does not have a title bar:

$ xprop -id 0x2600003 | grep -i MOTIF_WM_HINTS
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0

Despite the name ("motif"), this property has apparently become a de-facto
standard way to communicate client wishes about its window decoration to
any window manager currently in charge.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210521/f196d645/attachment-0001.htm>

@mlbridge
Copy link

mlbridge bot commented May 31, 2021

Mailing list message from Maxim Kartashev on awt-dev:

Hello All,

I'd appreciate it very much if someone could find time to look at this pull
request.
Thanks a bunch!

On Fri, May 21, 2021 at 11:01 AM Maxim Kartashev <
maxim.kartashev at jetbrains.com> wrote:

On Fri, May 21, 2021 at 12:33 AM Sergey Bylokhov <serb at openjdk.java.net>
wrote:

On Wed, 19 May 2021 10:23:01 GMT, Maxim Kartashev <github.com+
28651297+mkartashev at openjdk.org> wrote:

This commit introduces a new client property xawt.mwm_decor_title
implementing JDK-8267307. The property can be set prior to showing a window
or after the window has been displayed, in which case the window will have
to be hidden/shown (re-mapped) for the property to take effect.

The general idea is to provide control over the "decorations" part of
the X11 window property called _MOTIF_WM_HINTS. Those "decoration" bits are
set to 1 (XWindowAttributesData.AWT_DECOR_ALL) to show all the decorations
or 0 (XWindowAttributesData.AWT_DECOR_NONE) to ask the window manager (WM)
not to decorate with anything, even borders or resize handles. With
xawt.mwm_decor_title property set to "true", this commit adds the ability
to set the bits to 2 (XWindowAttributesData.AWT_DECOR_BORDER), which some
WMs take as "decorate with only a border", thus effectively removing the
window's title bar, but still leaving the resize capability.

This feature was tested and works correctly on "vanilla" Ubuntu 20.04
with the "GNOME Shell" window manager. It was also tested with Xfwm4 and
KDE, where it did not have any effect; these two WMs have limited respected
for the "decorations" bits of the _MOTIF_WM_HINTS window property.

Hello, thank you for your contribution, One initial question: what the
name "mwm_" of this property actually means?

The name's historical: it's from the _MOTIF_WM_HINTS property of X11 that
has "decorations" bits in it (the 3rd word of the structure). For instance,
this is from a Firefox window in GNOME that does not have a title bar:

$ xprop -id 0x2600003 | grep -i MOTIF_WM_HINTS
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0

Despite the name ("motif"), this property has apparently become a
de-facto standard way to communicate client wishes about its window
decoration to any window manager currently in charge.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210531/713e38c0/attachment-0001.htm>

1 similar comment
@mlbridge
Copy link

mlbridge bot commented May 31, 2021

Mailing list message from Maxim Kartashev on awt-dev:

Hello All,

I'd appreciate it very much if someone could find time to look at this pull
request.
Thanks a bunch!

On Fri, May 21, 2021 at 11:01 AM Maxim Kartashev <
maxim.kartashev at jetbrains.com> wrote:

On Fri, May 21, 2021 at 12:33 AM Sergey Bylokhov <serb at openjdk.java.net>
wrote:

On Wed, 19 May 2021 10:23:01 GMT, Maxim Kartashev <github.com+
28651297+mkartashev at openjdk.org> wrote:

This commit introduces a new client property xawt.mwm_decor_title
implementing JDK-8267307. The property can be set prior to showing a window
or after the window has been displayed, in which case the window will have
to be hidden/shown (re-mapped) for the property to take effect.

The general idea is to provide control over the "decorations" part of
the X11 window property called _MOTIF_WM_HINTS. Those "decoration" bits are
set to 1 (XWindowAttributesData.AWT_DECOR_ALL) to show all the decorations
or 0 (XWindowAttributesData.AWT_DECOR_NONE) to ask the window manager (WM)
not to decorate with anything, even borders or resize handles. With
xawt.mwm_decor_title property set to "true", this commit adds the ability
to set the bits to 2 (XWindowAttributesData.AWT_DECOR_BORDER), which some
WMs take as "decorate with only a border", thus effectively removing the
window's title bar, but still leaving the resize capability.

This feature was tested and works correctly on "vanilla" Ubuntu 20.04
with the "GNOME Shell" window manager. It was also tested with Xfwm4 and
KDE, where it did not have any effect; these two WMs have limited respected
for the "decorations" bits of the _MOTIF_WM_HINTS window property.

Hello, thank you for your contribution, One initial question: what the
name "mwm_" of this property actually means?

The name's historical: it's from the _MOTIF_WM_HINTS property of X11 that
has "decorations" bits in it (the 3rd word of the structure). For instance,
this is from a Firefox window in GNOME that does not have a title bar:

$ xprop -id 0x2600003 | grep -i MOTIF_WM_HINTS
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x2, 0x0, 0x0

Despite the name ("motif"), this property has apparently become a
de-facto standard way to communicate client wishes about its window
decoration to any window manager currently in charge.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210531/713e38c0/attachment-0001.htm>


private void captureTitleBarNotVisible() {
runSwing( () -> {
titleBarImageNotVisible = robot.createScreenCapture(titleBarBounds);
Copy link
Member

@azvegint azvegint Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createScreenCapture does not require to be called on EDT.

Copy link
Member Author

@mkartashev mkartashev Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Moved createScreenCapture() out of EDT. Please, have a look at the updated code.

@azvegint
Copy link
Member

azvegint commented Jun 1, 2021

This fix most likely will require a CSR

@mkartashev
Copy link
Member Author

mkartashev commented Jun 1, 2021

This fix most likely will require a CSR

There already is one linked from the enhancement: JDK-8267308

@azvegint
Copy link
Member

azvegint commented Jun 1, 2021

/csr

There already is one linked from the enhancement: JDK-8267308

Sorry, I missed that.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 1, 2021
@openjdk
Copy link

openjdk bot commented Jun 1, 2021

@azvegint this pull request will not be integrated until the CSR request JDK-8267308 for issue JDK-8267307 has been approved.

@mrserb
Copy link
Member

mrserb commented Jun 1, 2021

Please check that the test code added in the JDK-8265005 can be adapted to verify this fix as well.

@mkartashev
Copy link
Member Author

mkartashev commented Jun 2, 2021

Please check that the test code added in the JDK-8265005 can be adapted to verify this fix as well.

@mrserb Please clarify: do you suggest to have one common test code for this feature and JDK-8265005? This is certainly possible, but will contaminate the Mac test with Linux-specific window manager checking stuff, making it harder to debug failures, I think.

@mrserb
Copy link
Member

mrserb commented Jun 2, 2021

You can reuse that test or create the new one, I just pointed out how the "same" feature was tested on mac.

@mlbridge
Copy link

mlbridge bot commented Jun 3, 2021

Mailing list message from Alexey Ushakov on awt-dev:

Could anyone from the dev team review my CSR request for this change: https://bugs.openjdk.java.net/browse/JDK-8267308 <https://bugs.openjdk.java.net/browse/JDK-8267308> ?

Best Regards,
Alexey

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210603/d76006ac/attachment.htm>

1 similar comment
@mlbridge
Copy link

mlbridge bot commented Jun 3, 2021

Mailing list message from Alexey Ushakov on awt-dev:

Could anyone from the dev team review my CSR request for this change: https://bugs.openjdk.java.net/browse/JDK-8267308 <https://bugs.openjdk.java.net/browse/JDK-8267308> ?

Best Regards,
Alexey

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/awt-dev/attachments/20210603/d76006ac/attachment.htm>

}

private void registerWindowDecorationChangeListener() {
if (target instanceof javax.swing.RootPaneContainer) {
Copy link
Member

@mrserb mrserb Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this should be done via runtime check? Overwise the swing classes will be always loaded even if swing is not used. see the usage of SunToolkit.isInstanceOf in java.awt.WIndow.java:3965

Copy link
Member Author

@mkartashev mkartashev Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated the code; please, have a look.

…eContainer in

order to avoid unnecessary class loading if it isn't.

Also updated the test such that robot.createScreenCapture() is not
executed on EDT.
public final Optional<Boolean> getMWMDecorTitleProperty() {
Optional<Boolean> res = Optional.empty();

if (target instanceof javax.swing.RootPaneContainer) {
Copy link
Member

@mrserb mrserb Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this instanceof will load the Swing as well.

Copy link
Member Author

@mkartashev mkartashev Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed that one the first time. Corrected now.

…tPaneContainer in

order to avoid unnecessary class loading if it isn't.
@mrserb
Copy link
Member

mrserb commented Jun 8, 2021

Looks fine, I'll run the tests.

mrserb
mrserb approved these changes Jun 9, 2021
@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jun 30, 2021
@openjdk
Copy link

openjdk bot commented Jun 30, 2021

@mkartashev This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8267307: Introduce new client property for XAWT: xawt.mwm_decor_title

Reviewed-by: azvegint, serb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1079 new commits pushed to the master branch:

  • 54a9c3e: 8133873: Simplify {Register,Unregister}NMethodOopClosure
  • 06d2620: 8268298: jdk/jfr/api/consumer/log/TestVerbosity.java fails: unexpected log message
  • d89e630: 8266746: C1: Replace UnsafeGetRaw with UnsafeGet when setting up OSR entry block
  • 4660f72: 8268870: Remove dead code in metaspaceShared
  • 9def3b0: Merge
  • 9ac63a6: 8262841: Clarify the behavior of PhantomReference::refersTo
  • aba6c55: 8269703: ProblemList vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java on Windows-X64 with -Xcomp
  • 3e02224: 8269513: Clarify the spec wrt useOldISOCodes system property
  • 0dc65d3: 8268897: [TESTBUG] compiler/compilercontrol/mixed/RandomCommandsTest.java must not fail on Command.quiet
  • 3826012: 8268557: Module page uses unstyled table class
  • ... and 1069 more: https://git.openjdk.java.net/jdk/compare/9499175064a8073f37a63a2696fb47f26ae89865...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@azvegint, @mrserb) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 30, 2021
@mkartashev
Copy link
Member Author

mkartashev commented Jul 1, 2021

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 1, 2021
@openjdk
Copy link

openjdk bot commented Jul 1, 2021

@mkartashev
Your change (at version c83c721) is now ready to be sponsored by a Committer.

@avu
Copy link
Contributor

avu commented Jul 1, 2021

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 1, 2021

Going to push as commit 18f356a.
Since your change was applied there have been 1079 commits pushed to the master branch:

  • 54a9c3e: 8133873: Simplify {Register,Unregister}NMethodOopClosure
  • 06d2620: 8268298: jdk/jfr/api/consumer/log/TestVerbosity.java fails: unexpected log message
  • d89e630: 8266746: C1: Replace UnsafeGetRaw with UnsafeGet when setting up OSR entry block
  • 4660f72: 8268870: Remove dead code in metaspaceShared
  • 9def3b0: Merge
  • 9ac63a6: 8262841: Clarify the behavior of PhantomReference::refersTo
  • aba6c55: 8269703: ProblemList vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java on Windows-X64 with -Xcomp
  • 3e02224: 8269513: Clarify the spec wrt useOldISOCodes system property
  • 0dc65d3: 8268897: [TESTBUG] compiler/compilercontrol/mixed/RandomCommandsTest.java must not fail on Command.quiet
  • 3826012: 8268557: Module page uses unstyled table class
  • ... and 1069 more: https://git.openjdk.java.net/jdk/compare/9499175064a8073f37a63a2696fb47f26ae89865...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 1, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jul 1, 2021
@openjdk
Copy link

openjdk bot commented Jul 1, 2021

@avu @mkartashev Pushed as commit 18f356a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awt client-libs-dev@openjdk.org integrated Pull request has been integrated
4 participants