Skip to content

Commit c8d516b

Browse files
authored
[win][x11] Fix wsl2 menu display issues (#22458)
* [win][x11] Fix wsl2 menu display issues Fixes #17483 * comment out unused arguments
1 parent 862d26f commit c8d516b

9 files changed

Lines changed: 43 additions & 0 deletions

File tree

core/base/inc/TVirtualX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe
5050
enum EBoxMode { kHollow, kFilled };
5151
enum ETextMode { kClear, kOpaque };
5252
enum ETextSetMode { kCheck, kLoad };
53+
enum EWindowHint { kHintCombo, kHintPopup, kHintTooltip };
5354

5455
protected:
5556
EDrawMode fDrawMode; //Drawing mode
@@ -265,6 +266,7 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe
265266
virtual void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr);
266267
virtual void ChangeProperty(Window_t id, Atom_t property, Atom_t type,
267268
UChar_t *data, Int_t len);
269+
virtual void SetWindowHint(Window_t id, EWindowHint hint);
268270
virtual void DrawLine(Drawable_t id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
269271
virtual void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h);
270272
virtual Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev);

core/base/src/TVirtualX.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,17 @@ void TVirtualX::ChangeProperty(Window_t /*id*/, Atom_t /*property*/,
17861786
{
17871787
}
17881788

1789+
////////////////////////////////////////////////////////////////////////////////
1790+
/// Alters the property for the specified window and causes the X server
1791+
/// to generate a PropertyNotify event on that window.
1792+
///
1793+
/// \param [in] id the window whose property you want to change
1794+
/// \param [in] hint specifies the type to be changed
1795+
1796+
void TVirtualX::SetWindowHint(Window_t /*id*/, EWindowHint /*hint*/)
1797+
{
1798+
}
1799+
17891800
////////////////////////////////////////////////////////////////////////////////
17901801
/// Uses the components of the specified GC to draw a line between the
17911802
/// specified set of points (x1, y1) and (x2, y2).

graf2d/x11/inc/TGX11.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ friend struct XWindow_t;
325325
void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr) override;
326326
void ChangeProperty(Window_t id, Atom_t property, Atom_t type,
327327
UChar_t *data, Int_t len) override;
328+
void SetWindowHint(Window_t id, EWindowHint hint) override;
328329
void DrawLine(Drawable_t id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override;
329330
void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h) override;
330331
Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev) override;

graf2d/x11/src/GX11Gui.cxx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,27 @@ void TGX11::ChangeProperty(Window_t id, Atom_t property, Atom_t type,
17251725
8, PropModeReplace, data, len);
17261726
}
17271727

1728+
////////////////////////////////////////////////////////////////////////////////
1729+
/// This function alters the property for the specified window and
1730+
/// causes the X server to generate a PropertyNotify event on that
1731+
/// window. Specifically for WSL (Windows Subsytem for Linux)
1732+
1733+
void TGX11::SetWindowHint(Window_t id, EWindowHint hint)
1734+
{
1735+
if (!id)
1736+
return;
1737+
static const char *property_names[] = {
1738+
"_NET_WM_WINDOW_TYPE_COMBO",
1739+
"_NET_WM_WINDOW_TYPE_POPUP_MENU",
1740+
"_NET_WM_WINDOW_TYPE_TOOLTIP"
1741+
};
1742+
const char *property_name = property_names[hint];
1743+
Atom_t property_type = gVirtualX->InternAtom("_NET_WM_WINDOW_TYPE", kFALSE);
1744+
Atom_t property_value = gVirtualX->InternAtom(property_name, kFALSE);
1745+
XChangeProperty((Display*)fDisplay, (Window) id, (Atom) property_type,
1746+
(Atom) XA_ATOM, 32, PropModeReplace, (UChar_t*)&property_value, 1);
1747+
}
1748+
17281749
////////////////////////////////////////////////////////////////////////////////
17291750
/// Draw a line.
17301751

gui/ged/src/TGedPatternSelect.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ TGedPopup::TGedPopup(const TGWindow *p, const TGWindow *m, UInt_t w, UInt_t h,
312312
wattr.fOverrideRedirect = kTRUE;
313313
wattr.fSaveUnder = kTRUE;
314314
gVirtualX->ChangeWindowAttributes(fId, &wattr);
315+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
315316

316317
AddInput(kStructureNotifyMask);
317318
}

gui/gui/src/TGColorSelect.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ TGColorPopup::TGColorPopup(const TGWindow *p, const TGWindow *m, Pixel_t color)
227227
wattr.fOverrideRedirect = kTRUE;
228228
//wattr.fSaveUnder = kTRUE;
229229
gVirtualX->ChangeWindowAttributes(fId, &wattr);
230+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
230231

231232
AddInput(kStructureNotifyMask);
232233

gui/gui/src/TGComboBox.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ TGComboBoxPopup::TGComboBoxPopup(const TGWindow *p, UInt_t w, UInt_t h,
7474
wattr.fBorderPixel = fgBlackPixel;
7575
wattr.fBorderWidth = 1;
7676
gVirtualX->ChangeWindowAttributes(fId, &wattr);
77+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintCombo);
7778

7879
AddInput(kStructureNotifyMask);
7980
fEditDisabled = kEditDisable | kEditDisableGrab | kEditDisableBtnEnable;

gui/gui/src/TGMenu.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ TGPopupMenu::TGPopupMenu(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options)
961961
wattr.fSaveUnder = kTRUE;
962962

963963
gVirtualX->ChangeWindowAttributes(fId, &wattr);
964+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintPopup);
964965

965966
AddInput(kPointerMotionMask | kEnterWindowMask | kLeaveWindowMask);
966967
}

gui/gui/src/TGToolTip.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ TGToolTip::TGToolTip(const TGWindow *p, const TGFrame *f, const char *text,
8787
attr.fSaveUnder = kTRUE;
8888

8989
gVirtualX->ChangeWindowAttributes(fId, &attr);
90+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
9091
SetBackgroundColor(fClient->GetResourcePool()->GetTipBgndColor());
9192

9293
fLabel = new TGLabel(this, text);
@@ -122,6 +123,7 @@ TGToolTip::TGToolTip(const TGWindow *p, const TBox *box, const char *text,
122123
attr.fSaveUnder = kTRUE;
123124

124125
gVirtualX->ChangeWindowAttributes(fId, &attr);
126+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
125127
SetBackgroundColor(fClient->GetResourcePool()->GetTipBgndColor());
126128

127129
fLabel = new TGLabel(this, text);
@@ -155,6 +157,7 @@ TGToolTip::TGToolTip(const TBox *box, const char *text,Long_t delayms)
155157
attr.fSaveUnder = kTRUE;
156158

157159
gVirtualX->ChangeWindowAttributes(fId, &attr);
160+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
158161
SetBackgroundColor(fClient->GetResourcePool()->GetTipBgndColor());
159162

160163
fLabel = new TGLabel(this, text);
@@ -186,6 +189,7 @@ TGToolTip::TGToolTip(Int_t x, Int_t y, const char *text, Long_t delayms)
186189
attr.fSaveUnder = kTRUE;
187190

188191
gVirtualX->ChangeWindowAttributes(fId, &attr);
192+
gVirtualX->SetWindowHint(fId, TVirtualX::kHintTooltip);
189193
SetBackgroundColor(fClient->GetResourcePool()->GetTipBgndColor());
190194

191195
fLabel = new TGLabel(this, text);

0 commit comments

Comments
 (0)