Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dwm-autoconfig
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Kirilin
dwm-autoconfig
Commits
f03decdb
Commit
f03decdb
authored
4 years ago
by
Pavel Kirilin
Browse files
Options
Downloads
Patches
Plain Diff
Patch "centeredmaster-layout" applied.
parent
d4488620
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dwm/config.def.h
+4
-0
4 additions, 0 deletions
dwm/config.def.h
dwm/dwm.c
+105
-0
105 additions, 0 deletions
dwm/dwm.c
with
109 additions
and
0 deletions
dwm/config.def.h
+
4
−
0
View file @
f03decdb
...
...
@@ -42,6 +42,8 @@ static const Layout layouts[] = {
{
"[]="
,
tile
},
/* first entry is default */
{
"><>"
,
NULL
},
/* no layout function means floating behavior */
{
"[M]"
,
monocle
},
{
"|M|"
,
centeredmaster
},
{
">M>"
,
centeredfloatingmaster
},
};
/* key definitions */
...
...
@@ -85,6 +87,8 @@ static Key keys[] = {
{
MODKEY
,
XK_t
,
setlayout
,
{.
v
=
&
layouts
[
0
]}
},
{
MODKEY
,
XK_f
,
setlayout
,
{.
v
=
&
layouts
[
1
]}
},
{
MODKEY
,
XK_m
,
setlayout
,
{.
v
=
&
layouts
[
2
]}
},
{
MODKEY
,
XK_u
,
setlayout
,
{.
v
=
&
layouts
[
3
]}
},
{
MODKEY
,
XK_o
,
setlayout
,
{.
v
=
&
layouts
[
4
]}
},
{
MODKEY
,
XK_space
,
setlayout
,
{
0
}
},
{
MODKEY
|
ShiftMask
,
XK_space
,
togglefloating
,
{
0
}
},
{
MODKEY
,
XK_0
,
view
,
{.
ui
=
~
0
}
},
...
...
This diff is collapsed.
Click to expand it.
dwm/dwm.c
+
105
−
0
View file @
f03decdb
...
...
@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static
int
xerrordummy
(
Display
*
dpy
,
XErrorEvent
*
ee
);
static
int
xerrorstart
(
Display
*
dpy
,
XErrorEvent
*
ee
);
static
void
zoom
(
const
Arg
*
arg
);
static
void
centeredmaster
(
Monitor
*
m
);
static
void
centeredfloatingmaster
(
Monitor
*
m
);
/* variables */
static
const
char
broken
[]
=
"broken"
;
...
...
@@ -2147,3 +2149,106 @@ main(int argc, char *argv[])
XCloseDisplay
(
dpy
);
return
EXIT_SUCCESS
;
}
void
centeredmaster
(
Monitor
*
m
)
{
unsigned
int
i
,
n
,
h
,
mw
,
mx
,
my
,
oty
,
ety
,
tw
;
Client
*
c
;
/* count number of clients in the selected monitor */
for
(
n
=
0
,
c
=
nexttiled
(
m
->
clients
);
c
;
c
=
nexttiled
(
c
->
next
),
n
++
);
if
(
n
==
0
)
return
;
/* initialize areas */
mw
=
m
->
ww
;
mx
=
0
;
my
=
0
;
tw
=
mw
;
if
(
n
>
m
->
nmaster
)
{
/* go mfact box in the center if more than nmaster clients */
mw
=
m
->
nmaster
?
m
->
ww
*
m
->
mfact
:
0
;
tw
=
m
->
ww
-
mw
;
if
(
n
-
m
->
nmaster
>
1
)
{
/* only one client */
mx
=
(
m
->
ww
-
mw
)
/
2
;
tw
=
(
m
->
ww
-
mw
)
/
2
;
}
}
oty
=
0
;
ety
=
0
;
for
(
i
=
0
,
c
=
nexttiled
(
m
->
clients
);
c
;
c
=
nexttiled
(
c
->
next
),
i
++
)
if
(
i
<
m
->
nmaster
)
{
/* nmaster clients are stacked vertically, in the center
* of the screen */
h
=
(
m
->
wh
-
my
)
/
(
MIN
(
n
,
m
->
nmaster
)
-
i
);
resize
(
c
,
m
->
wx
+
mx
,
m
->
wy
+
my
,
mw
-
(
2
*
c
->
bw
),
h
-
(
2
*
c
->
bw
),
0
);
my
+=
HEIGHT
(
c
);
}
else
{
/* stack clients are stacked vertically */
if
((
i
-
m
->
nmaster
)
%
2
)
{
h
=
(
m
->
wh
-
ety
)
/
(
(
1
+
n
-
i
)
/
2
);
resize
(
c
,
m
->
wx
,
m
->
wy
+
ety
,
tw
-
(
2
*
c
->
bw
),
h
-
(
2
*
c
->
bw
),
0
);
ety
+=
HEIGHT
(
c
);
}
else
{
h
=
(
m
->
wh
-
oty
)
/
((
1
+
n
-
i
)
/
2
);
resize
(
c
,
m
->
wx
+
mx
+
mw
,
m
->
wy
+
oty
,
tw
-
(
2
*
c
->
bw
),
h
-
(
2
*
c
->
bw
),
0
);
oty
+=
HEIGHT
(
c
);
}
}
}
void
centeredfloatingmaster
(
Monitor
*
m
)
{
unsigned
int
i
,
n
,
w
,
mh
,
mw
,
mx
,
mxo
,
my
,
myo
,
tx
;
Client
*
c
;
/* count number of clients in the selected monitor */
for
(
n
=
0
,
c
=
nexttiled
(
m
->
clients
);
c
;
c
=
nexttiled
(
c
->
next
),
n
++
);
if
(
n
==
0
)
return
;
/* initialize nmaster area */
if
(
n
>
m
->
nmaster
)
{
/* go mfact box in the center if more than nmaster clients */
if
(
m
->
ww
>
m
->
wh
)
{
mw
=
m
->
nmaster
?
m
->
ww
*
m
->
mfact
:
0
;
mh
=
m
->
nmaster
?
m
->
wh
*
0
.
9
:
0
;
}
else
{
mh
=
m
->
nmaster
?
m
->
wh
*
m
->
mfact
:
0
;
mw
=
m
->
nmaster
?
m
->
ww
*
0
.
9
:
0
;
}
mx
=
mxo
=
(
m
->
ww
-
mw
)
/
2
;
my
=
myo
=
(
m
->
wh
-
mh
)
/
2
;
}
else
{
/* go fullscreen if all clients are in the master area */
mh
=
m
->
wh
;
mw
=
m
->
ww
;
mx
=
mxo
=
0
;
my
=
myo
=
0
;
}
for
(
i
=
tx
=
0
,
c
=
nexttiled
(
m
->
clients
);
c
;
c
=
nexttiled
(
c
->
next
),
i
++
)
if
(
i
<
m
->
nmaster
)
{
/* nmaster clients are stacked horizontally, in the center
* of the screen */
w
=
(
mw
+
mxo
-
mx
)
/
(
MIN
(
n
,
m
->
nmaster
)
-
i
);
resize
(
c
,
m
->
wx
+
mx
,
m
->
wy
+
my
,
w
-
(
2
*
c
->
bw
),
mh
-
(
2
*
c
->
bw
),
0
);
mx
+=
WIDTH
(
c
);
}
else
{
/* stack clients are stacked horizontally */
w
=
(
m
->
ww
-
tx
)
/
(
n
-
i
);
resize
(
c
,
m
->
wx
+
tx
,
m
->
wy
,
w
-
(
2
*
c
->
bw
),
m
->
wh
-
(
2
*
c
->
bw
),
0
);
tx
+=
WIDTH
(
c
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment