Use bool type

This commit is contained in:
Alex Kotov 2021-11-21 01:01:49 +05:00
parent 5615fc7e1e
commit 6311f52cbb
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 15 additions and 13 deletions

View File

@ -180,7 +180,7 @@ static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static bool setup(); static bool setup();
static void seturgent(Client *c, int urg); static void seturgent(Client *c, bool is_urgent);
static void showhide(Client *c); static void showhide(Client *c);
static void sigchld(int unused); static void sigchld(int unused);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
@ -624,7 +624,7 @@ void focus(Client *c)
if (c->mon != selmon) if (c->mon != selmon)
selmon = c->mon; selmon = c->mon;
if (c->state.is_urgent) if (c->state.is_urgent)
seturgent(c, 0); seturgent(c, false);
detachstack(c); detachstack(c);
attachstack(c); attachstack(c);
grabbuttons(c, 1); grabbuttons(c, 1);
@ -865,7 +865,7 @@ void manage(Window w, XWindowAttributes *wa)
c->state.geometry.basic.y = wa->y; c->state.geometry.basic.y = wa->y;
c->state.geometry.basic.w = wa->width; c->state.geometry.basic.w = wa->width;
c->state.geometry.basic.h = wa->height; c->state.geometry.basic.h = wa->height;
c->state.is_floating = 0; c->state.is_floating = false;
updatetitle(c); updatetitle(c);
@ -1523,13 +1523,13 @@ void setfullscreen(Client *c, int fullscreen)
if (fullscreen && !c->state.is_fullscreen) { if (fullscreen && !c->state.is_fullscreen) {
XChangeProperty(dpy, c->win, atoms->netatom[NetWMState], XA_ATOM, 32, XChangeProperty(dpy, c->win, atoms->netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&atoms->netatom[NetWMFullscreen], 1); PropModeReplace, (unsigned char*)&atoms->netatom[NetWMFullscreen], 1);
c->state.is_fullscreen = 1; c->state.is_fullscreen = true;
// We have to rearrange because borders and gaps may have changed. // We have to rearrange because borders and gaps may have changed.
arrange(c->mon); arrange(c->mon);
} else if (!fullscreen && c->state.is_fullscreen){ } else if (!fullscreen && c->state.is_fullscreen){
XChangeProperty(dpy, c->win, atoms->netatom[NetWMState], XA_ATOM, 32, XChangeProperty(dpy, c->win, atoms->netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0); PropModeReplace, (unsigned char*)0, 0);
c->state.is_fullscreen = 0; c->state.is_fullscreen = false;
// We have to rearrange because borders and gaps may have changed. // We have to rearrange because borders and gaps may have changed.
arrange(c->mon); arrange(c->mon);
} }
@ -1657,14 +1657,15 @@ bool setup()
return true; return true;
} }
void seturgent(Client *c, int urg) void seturgent(Client *c, bool is_urgent)
{ {
XWMHints *wmh; XWMHints *wmh;
c->state.is_urgent = urg; c->state.is_urgent = is_urgent;
if (!(wmh = XGetWMHints(dpy, c->win))) if (!(wmh = XGetWMHints(dpy, c->win)))
return; return;
wmh->flags = urg ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint); wmh->flags =
is_urgent ? (wmh->flags | XUrgencyHint) : (wmh->flags & ~XUrgencyHint);
XSetWMHints(dpy, c->win, wmh); XSetWMHints(dpy, c->win, wmh);
XFree(wmh); XFree(wmh);
} }
@ -1955,7 +1956,7 @@ void updatewindowtype(Client *c)
if (state == atoms->netatom[NetWMFullscreen]) if (state == atoms->netatom[NetWMFullscreen])
setfullscreen(c, 1); setfullscreen(c, 1);
if (wtype == atoms->netatom[NetWMWindowTypeDialog]) if (wtype == atoms->netatom[NetWMWindowTypeDialog])
c->state.is_floating = 1; c->state.is_floating = true;
} }
void updatewmhints(Client *c) void updatewmhints(Client *c)
@ -1967,13 +1968,13 @@ void updatewmhints(Client *c)
wmh->flags &= ~XUrgencyHint; wmh->flags &= ~XUrgencyHint;
XSetWMHints(dpy, c->win, wmh); XSetWMHints(dpy, c->win, wmh);
} else { } else {
c->state.is_urgent = (wmh->flags & XUrgencyHint) ? 1 : 0; c->state.is_urgent = (wmh->flags & XUrgencyHint) ? true : false;
} }
if (wmh->flags & InputHint) { if (wmh->flags & InputHint) {
c->state.never_focus = !wmh->input; c->state.never_focus = !wmh->input;
} else { } else {
c->state.never_focus = 0; c->state.never_focus = false;
} }
XFree(wmh); XFree(wmh);

View File

@ -59,7 +59,7 @@ void on_client_message(XEvent *e)
} }
} else if (cme->message_type == atoms->netatom[NetActiveWindow]) { } else if (cme->message_type == atoms->netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->state.is_urgent) { if (c != selmon->sel && !c->state.is_urgent) {
seturgent(c, 1); seturgent(c, true);
} }
} }
} }

View File

@ -1,6 +1,7 @@
#ifndef _STATE_H #ifndef _STATE_H
#define _STATE_H #define _STATE_H
#include <stdbool.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
struct BasicGeometry { struct BasicGeometry {
@ -20,7 +21,7 @@ typedef struct ClientSizeHints {
struct ClientState { struct ClientState {
char name[256]; char name[256];
struct ClientGeometry geometry; struct ClientGeometry geometry;
int is_fixed, is_floating, is_urgent, never_focus, is_fullscreen; bool is_fixed, is_floating, is_urgent, never_focus, is_fullscreen;
}; };
void client_size_hints_update( void client_size_hints_update(