fix class name from changing on resize

This commit is contained in:
Sam 2024-10-14 15:40:35 +01:00
parent 31e0ba8cb2
commit cf67a6fd4e
2 changed files with 38 additions and 28 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ st
*.o
*.orig
*.rej
.ccls-cache

65
x.c
View File

@ -886,37 +886,46 @@ xclear(int x1, int y1, int x2, int y2)
void
xhints(void)
{
XClassHint class = {opt_name ? opt_name : "st",
opt_class ? opt_class : "St"};
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints *sizeh;
XClassHint class = {opt_name ? opt_name : "st",
opt_class ? opt_class : "St-class"};
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints *sizeh;
XClassHint current_class;
Status status;
sizeh = XAllocSizeHints();
status = XGetClassHint(xw.dpy, xw.win, &current_class);
if (status == True) {
if (strcmp(current_class.res_class, class.res_class) != 0) {
class.res_class = current_class.res_class; /* current_class.res_class; */
}
}
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
sizeh->height = win.h;
sizeh->width = win.w;
sizeh->height_inc = win.ch;
sizeh->width_inc = win.cw;
sizeh->base_height = 2 * borderpx;
sizeh->base_width = 2 * borderpx;
sizeh->min_height = win.ch + 2 * borderpx;
sizeh->min_width = win.cw + 2 * borderpx;
if (xw.isfixed) {
sizeh->flags |= PMaxSize;
sizeh->min_width = sizeh->max_width = win.w;
sizeh->min_height = sizeh->max_height = win.h;
}
if (xw.gm & (XValue|YValue)) {
sizeh->flags |= USPosition | PWinGravity;
sizeh->x = xw.l;
sizeh->y = xw.t;
sizeh->win_gravity = xgeommasktogravity(xw.gm);
}
sizeh = XAllocSizeHints();
XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
&class);
XFree(sizeh);
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
sizeh->height = win.h;
sizeh->width = win.w;
sizeh->height_inc = win.ch;
sizeh->width_inc = win.cw;
sizeh->base_height = 2 * borderpx;
sizeh->base_width = 2 * borderpx;
sizeh->min_height = win.ch + 2 * borderpx;
sizeh->min_width = win.cw + 2 * borderpx;
if (xw.isfixed) {
sizeh->flags |= PMaxSize;
sizeh->min_width = sizeh->max_width = win.w;
sizeh->min_height = sizeh->max_height = win.h;
}
if (xw.gm & (XValue|YValue)) {
sizeh->flags |= USPosition | PWinGravity;
sizeh->x = xw.l;
sizeh->y = xw.t;
sizeh->win_gravity = xgeommasktogravity(xw.gm);
}
XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
&class);
XFree(sizeh);
}
int