Skip to content

Commit be4bb25

Browse files
committed
XSetWMName, and use it it TopLevelWindow instead of XStoreName
1 parent fc99865 commit be4bb25

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/Guitor.winxed

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ extern function getselectionclearview;
4343
extern function getselectionrequestview;
4444
extern function getselectionview;
4545
extern function getclientview;
46+
extern function gettextpropertyview;
47+
extern function textpropertyfromstring;
4648
extern function getxcolorview;
4749
extern function getxftcolorview;
4850
extern function getxftfontview;
@@ -1516,6 +1518,17 @@ class Window : Drawable
15161518
getfun("XStoreName")(self.display.xdisplay, self.xdrawable,
15171519
str_to_cstring(name));
15181520
}
1521+
function SetWMName(string name)
1522+
{
1523+
__DEBUG__ && cry(__FUNCTION__);
1524+
int xdrawable = self.xdrawable;
1525+
if (xdrawable != None) {
1526+
// Not sure if using UTF8_STRING is correct, but works for a now
1527+
var prop = textpropertyfromstring(name,
1528+
self.InternAtom("UTF8_STRING"));
1529+
getfun("XSetWMName")(self.display.xdisplay, self.xdrawable, prop);
1530+
}
1531+
}
15191532
function SetWMProtocols(names)
15201533
{
15211534
self.display.SetWMProtocols(self, names);
@@ -1958,7 +1971,7 @@ class TopLevelWindow : ListenerWindow
19581971
}
19591972
self.xdrawable = display.CreateSimpleWindow(x, y, width, height,
19601973
0, 0, background);
1961-
self.StoreName(title);
1974+
self.SetWMName(title);
19621975
self.ListenerWindow(controller);
19631976
}
19641977
}

src/GuitorNci.winxed

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const string
3333
SELECTIONVIEW = "selectionview",
3434
SELECTIONREQUESTVIEW = "selectionrequestview",
3535
CLIENTVIEW = "clientview",
36+
XTEXTPROPERTY = "xtextproperty",
3637
XAWMHINTSVIEW = "xawmhintsview",
3738
ATOMVIEW = "atomview",
3839
XCOLORVIEW = "xcolorview",
@@ -435,6 +436,33 @@ function getatomview(int n)
435436
return new ["StructView"] (init);
436437
}
437438

439+
function gettextpropertyview()
440+
{
441+
var ns = namespace Xlib__nci;
442+
var st = ns[XTEXTPROPERTY];
443+
if (st == null)
444+
ns[XTEXTPROPERTY] = st = new ["StructView"]( [ DATATYPE_STRUCT, 4,
445+
DATATYPE_PTR, // value
446+
XLIB_Atom, // encoding
447+
DATATYPE_INT, // format
448+
DATATYPE_LONG // nitems
449+
] );
450+
return st;
451+
}
452+
453+
function textpropertyfromstring(string str, int encoding)
454+
{
455+
var view = gettextpropertyview();
456+
var prop = view.alloc();
457+
var pstr = str_to_achar_utf8(str);
458+
int l = elements(pstr);
459+
view[prop, 0] = pstr;
460+
view[prop, 1] = encoding;
461+
view[prop, 2] = 8;
462+
view[prop, 3] = l;
463+
return prop;
464+
}
465+
438466
function getxawmhints()
439467
{
440468
var ns = namespace Xlib__nci;
@@ -656,6 +684,9 @@ function create_function(string funcname)
656684
case "XStoreName":
657685
sig = "ipip";
658686
break;
687+
case "XSetWMName":
688+
sig = "vpip";
689+
break;
659690
case "XDrawPoint":
660691
sig = "ipipii";
661692
break;

0 commit comments

Comments
 (0)