apply vertile layout patch

This commit is contained in:
korei999 2023-11-29 21:59:00 +02:00
parent 1d60a3aece
commit bd0503927b
5 changed files with 593 additions and 5 deletions

View file

@ -58,19 +58,19 @@ static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile },
{ "[M]", monocle },
// { "[v]", vertile },
{ "[v]", vertile },
{ "><>", NULL } /* no layout function means floating behavior */
};
/* monitors */
/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */
static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect x y resx resy rate adaptive custom*/
/* example of a HiDPI laptop monitor at 120Hz:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000, 1, 0 },
/* name mfact nmaster scale layout rotate/reflect x y */
/* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
*/
/* defaults */
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000999, 0, 0 },
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
};

37
dwl.c
View file

@ -334,6 +334,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void vertile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@ -2698,6 +2699,42 @@ tile(Monitor *m)
}
}
void
vertile(Monitor *m)
{
unsigned int i, n = 0, h, mh, my, ty, draw_borders = 1;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
if (n == smartborders)
draw_borders = 0;
if (n > m->nmaster)
ty = mh = m->nmaster ? m->w.height * m->mfact : 0;
else
ty = mh = m->w.height;
i = my = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (i < m->nmaster) {
h = ( mh - my ) / (MIN(n, m->nmaster) - i);
resize(c, (struct wlr_box) { .x = m->w.x, .y = m->w.y + my, .width = m->w.width, .height = h }, 0);
my += c->geom.height;
} else {
h = ( m->w.height - ty ) / (n - i);
resize(c, (struct wlr_box) { .x = m->w.x, .y = m->w.y + ty, .width = m->w.width, .height = h }, 0);
ty += c->geom.height;
}
i++;
}
}
void
togglebar(const Arg *arg) {
DwlIpcOutput *ipc_output;

242
keys.h Normal file
View file

@ -0,0 +1,242 @@
/* You can use the macros within this file
* instead of search the keycodes yourself
* with wev or something like that
* Also probably you search this:
* Key_XF86AudioMute
* Key_XF86AudioLowerVolume
* Key_XF86AudioRaiseVolume
* Key_XF86MonBrightnessDown
* Key_XF86MonBrightnessUp
*/
#define Key_Escape 9
#define Key_1 10
#define Key_2 11
#define Key_3 12
#define Key_4 13
#define Key_5 14
#define Key_6 15
#define Key_7 16
#define Key_8 17
#define Key_9 18
#define Key_0 19
#define Key_minus 20
#define Key_equal 21
#define Key_BackSpace 22
#define Key_Tab 23
#define Key_q 24
#define Key_w 25
#define Key_e 26
#define Key_r 27
#define Key_t 28
#define Key_y 29
#define Key_u 30
#define Key_i 31
#define Key_o 32
#define Key_p 33
#define Key_bracketleft 34
#define Key_bracketright 35
#define Key_Return 36
#define Key_Control_L 37
#define Key_a 38
#define Key_s 39
#define Key_d 40
#define Key_f 41
#define Key_g 42
#define Key_h 43
#define Key_j 44
#define Key_k 45
#define Key_l 46
#define Key_semicolon 47
#define Key_apostrophe 48
#define Key_grave 49
#define Key_Shift_L 50
#define Key_backslash 51
#define Key_z 52
#define Key_x 53
#define Key_c 54
#define Key_v 55
#define Key_b 56
#define Key_n 57
#define Key_m 58
#define Key_comma 59
#define Key_period 60
#define Key_slash 61
#define Key_Shift_R 62
#define Key_KP_Multiply 63
#define Key_Alt_L 64
#define Key_space 65
#define Key_Caps_Lock 66
#define Key_F1 67
#define Key_F2 68
#define Key_F3 69
#define Key_F4 70
#define Key_F5 71
#define Key_F6 72
#define Key_F7 73
#define Key_F8 74
#define Key_F9 75
#define Key_F10 76
#define Key_Num_Lock 77
#define Key_Scroll_Lock 78
#define Key_KP_Home 79
#define Key_KP_7 Key_KP_Home
#define Key_KP_Up 80
#define Key_KP_8 Key_KP_Up
#define Key_KP_Prior 81
#define Key_KP_9 Key_KP_Prior
#define Key_KP_Subtract 82
#define Key_KP_Left 83
#define Key_KP_4 Key_KP_Left
#define Key_KP_Begin 84
#define Key_KP_5 Key_KP_Begin
#define Key_KP_Right 85
#define Key_KP_6 Key_KP_Right
#define Key_KP_Add 86
#define Key_KP_End 87
#define Key_KP_1 Key_KP_End
#define Key_KP_Down 88
#define Key_KP_2 Key_KP_Down
#define Key_KP_Next 89
#define Key_KP_3 Key_KP_Next
#define Key_KP_Insert 90
#define Key_KP_0 Key_KP_Insert
#define Key_KP_Delete 91
#define Key_KP_Period Key_KP_Insert
#define Key_ISO_Level3_Shift 92
#define Key_less 94
#define Key_F11 95
#define Key_F12 96
#define Key_Katakana 98
#define Key_Hiragana 99
#define Key_Henkan_Mode 100
#define Key_Hiragana_Katakana 101
#define Key_Muhenkan 102
#define Key_KP_Enter 104
#define Key_Control_R 105
#define Key_KP_Divide 106
#define Key_Print 107
#define Key_Alt_R 108
#define Key_Linefeed 109
#define Key_Home 110
#define Key_Up 111
#define Key_Prior 112
#define Key_Left 113
#define Key_Right 114
#define Key_End 115
#define Key_Down 116
#define Key_Next 117
#define Key_Insert 118
#define Key_Delete 119
#define Key_XF86AudioMute 121
#define Key_XF86AudioLowerVolume 122
#define Key_XF86AudioRaiseVolume 123
#define Key_XF86PowerOff 124
#define Key_KP_Equal 125
#define Key_plusminus 126
#define Key_Pause 127
#define Key_XF86LaunchA 128
#define Key_KP_Decimal 129
#define Key_Hangul 130
#define Key_Hangul_Hanja 131
#define Key_Super_L 133
#define Key_Super_R 134
#define Key_Menu 135
#define Key_Cancel 136
#define Key_Redo 137
#define Key_SunProps 138
#define Key_Undo 139
#define Key_SunFront 140
#define Key_XF86Copy 141
#define Key_XF86Open 142
#define Key_XF86Paste 143
#define Key_Find 144
#define Key_XF86Cut 145
#define Key_Help 146
#define Key_XF86MenuKB 147
#define Key_XF86Calculator 148
#define Key_XF86Sleep 150
#define Key_XF86WakeUp 151
#define Key_XF86Explorer 152
#define Key_XF86Send 153
#define Key_XF86Xfer 155
#define Key_XF86Launch1 156
#define Key_XF86Launch2 157
#define Key_XF86WWW 158
#define Key_XF86DOS 159
#define Key_XF86ScreenSaver 160
#define Key_XF86RotateWindows 161
#define Key_XF86TaskPane 162
#define Key_XF86Mail 163
#define Key_XF86Favorites 164
#define Key_XF86MyComputer 165
#define Key_XF86Back 166
#define Key_XF86Forward 167
#define Key_XF86Eject1 169
#define Key_XF86Eject2 170
#define Key_XF86AudioNext 171
#define Key_XF86AudioPlay 172
#define Key_XF86AudioPrev 173
#define Key_XF86AudioStop 174
#define Key_XF86AudioRecord 175
#define Key_XF86AudioRewind 176
#define Key_XF86Phone 177
#define Key_XF86Tools 179
#define Key_XF86HomePage 180
#define Key_XF86Reload 181
#define Key_XF86Close 182
#define Key_XF86ScrollUp 185
#define Key_XF86ScrollDown 186
#define Key_parenleft 187
#define Key_parenright 188
#define Key_XF86New 189
#define Key_Redo2 190
#define Key_XF86Tools2 191
#define Key_XF86Launch5 192
#define Key_XF86Launch6 193
#define Key_XF86Launch7 194
#define Key_XF86Launch8 195
#define Key_XF86Launch9 196
#define Key_XF86AudioMicMute 198
#define Key_XF86TouchpadToggle 199
#define Key_XF86TouchpadOn 200
#define Key_XF86TouchpadOff 201
#define Key_Mode_switch 203
#define Key_XF86AudioPlay2 208
#define Key_XF86AudioPause 209
#define Key_XF86Launch3 210
#define Key_XF86Launch4 211
#define Key_XF86LaunchB 212
#define Key_XF86Suspend 213
#define Key_XF86Close2 214
#define Key_XF86AudioPlay3 215
#define Key_XF86AudioForward 216
#define Key_Print2 218
#define Key_XF86WebCam 220
#define Key_XF86AudioPreset 221
#define Key_XF86Mail2 223
#define Key_XF86Messenger 224
#define Key_XF86Search 225
#define Key_XF86Go 226
#define Key_XF86Finance 227
#define Key_XF86Game 228
#define Key_XF86Shop 229
#define Key_Cancel2 231
#define Key_XF86MonBrightnessDown 232
#define Key_XF86MonBrightnessUp 233
#define Key_XF86AudioMedia 234
#define Key_XF86Display 235
#define Key_XF86KbdLightOnOff 236
#define Key_XF86KbdBrightnessDown 237
#define Key_XF86KbdBrightnessUp 238
#define Key_XF86Send2 239
#define Key_XF86Reply 240
#define Key_XF86MailForward 241
#define Key_XF86Save 242
#define Key_XF86Documents 243
#define Key_XF86Battery 244
#define Key_XF86Bluetooth 245
#define Key_XF86WLAN 246
#define Key_XF86MonBrightnessCycle 251
#define Key_XF86WWAN 254
#define Key_XF86RFKill 255

View file

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This is largely ripped from somebar's ipc patchset; just with some personal modifications.
I would probably just submit raphi's patchset but I don't think that would be polite.
-->
<protocol name="dwl_ipc_unstable_v2">
<description summary="inter-proccess-communication about dwl's state">
This protocol allows clients to update and get updates from dwl.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible
changes may be added together with the corresponding interface
version bump.
Backward incompatible changes are done by bumping the version
number in the protocol and interface names and resetting the
interface version. Once the protocol is to be declared stable,
the 'z' prefix and the version number in the protocol and
interface names are removed and the interface version number is
reset.
</description>
<interface name="zdwl_ipc_manager_v2" version="2">
<description summary="manage dwl state">
This interface is exposed as a global in wl_registry.
Clients can use this interface to get a dwl_ipc_output.
After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client.
</description>
<request name="release" type="destructor">
<description summary="release dwl_ipc_manager">
Indicates that the client will not the dwl_ipc_manager object anymore.
Objects created through this instance are not affected.
</description>
</request>
<request name="get_output">
<description summary="get a dwl_ipc_outout for a wl_output">
Get a dwl_ipc_outout for the specified wl_output.
</description>
<arg name="id" type="new_id" interface="zdwl_ipc_output_v2"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<event name="tags">
<description summary="Announces tag amount">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all tags.
</description>
<arg name="amount" type="uint"/>
</event>
<event name="layout">
<description summary="Announces a layout">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all layouts.
</description>
<arg name="name" type="string"/>
</event>
</interface>
<interface name="zdwl_ipc_output_v2" version="2">
<description summary="control dwl output">
Observe and control a dwl output.
Events are double-buffered:
Clients should cache events and redraw when a dwl_ipc_output.frame event is sent.
Request are not double-buffered:
The compositor will update immediately upon request.
</description>
<enum name="tag_state">
<entry name="none" value="0" summary="no state"/>
<entry name="active" value="1" summary="tag is active"/>
<entry name="urgent" value="2" summary="tag has at least one urgent client"/>
</enum>
<request name="release" type="destructor">
<description summary="release dwl_ipc_outout">
Indicates to that the client no longer needs this dwl_ipc_output.
</description>
</request>
<event name="toggle_visibility">
<description summary="Toggle client visibilty">
Indicates the client should hide or show themselves.
If the client is visible then hide, if hidden then show.
</description>
</event>
<event name="active">
<description summary="Update the selected output.">
Indicates if the output is active. Zero is invalid, nonzero is valid.
</description>
<arg name="active" type="uint"/>
</event>
<event name="tag">
<description summary="Update the state of a tag.">
Indicates that a tag has been updated.
</description>
<arg name="tag" type="uint" summary="Index of the tag"/>
<arg name="state" type="uint" enum="tag_state" summary="The state of the tag."/>
<arg name="clients" type="uint" summary="The number of clients in the tag."/>
<arg name="focused" type="uint" summary="If there is a focused client. Nonzero being valid, zero being invalid."/>
</event>
<event name="layout">
<description summary="Update the layout.">
Indicates a new layout is selected.
</description>
<arg name="layout" type="uint" summary="Index of the layout."/>
</event>
<event name="title">
<description summary="Update the title.">
Indicates the title has changed.
</description>
<arg name="title" type="string" summary="The new title name."/>
</event>
<event name="appid" since="1">
<description summary="Update the appid.">
Indicates the appid has changed.
</description>
<arg name="appid" type="string" summary="The new appid."/>
</event>
<event name="layout_symbol" since="1">
<description summary="Update the current layout symbol">
Indicates the layout has changed. Since layout symbols are dynamic.
As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying.
You can ignore the zdwl_ipc_output.layout event.
</description>
<arg name="layout" type="string" summary="The new layout"/>
</event>
<event name="frame">
<description summary="The update sequence is done.">
Indicates that a sequence of status updates have finished and the client should redraw.
</description>
</event>
<request name="set_tags">
<description summary="Set the active tags of this output"/>
<arg name="tagmask" type="uint" summary="bitmask of the tags that should be set."/>
<arg name="toggle_tagset" type="uint" summary="toggle the selected tagset, zero for invalid, nonzero for valid."/>
</request>
<request name="set_client_tags">
<description summary="Set the tags of the focused client.">
The tags are updated as follows:
new_tags = (current_tags AND and_tags) XOR xor_tags
</description>
<arg name="and_tags" type="uint"/>
<arg name="xor_tags" type="uint"/>
</request>
<request name="set_layout">
<description summary="Set the layout of this output"/>
<arg name="index" type="uint" summary="index of a layout recieved by dwl_ipc_manager.layout"/>
</request>
<!-- Version 2 -->
<event name="fullscreen" since="2">
<description summary="Update fullscreen status">
Indicates if the selected client on this output is fullscreen.
</description>
<arg name="is_fullscreen" type="uint" summary="If the selected client is fullscreen. Nonzero is valid, zero invalid"/>
</event>
<event name="floating" since="2">
<description summary="Update the floating status">
Indicates if the selected client on this output is floating.
</description>
<arg name="is_floating" type="uint" summary="If the selected client is floating. Nonzero is valid, zero invalid"/>
</event>
</interface>
</protocol>

View file

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_output_power_management_unstable_v1">
<copyright>
Copyright © 2019 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="Control power management modes of outputs">
This protocol allows clients to control power management modes
of outputs that are currently part of the compositor space. The
intent is to allow special clients like desktop shells to power
down outputs when the system is idle.
To modify outputs not currently part of the compositor space see
wlr-output-management.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<interface name="zwlr_output_power_manager_v1" version="1">
<description summary="manager to create per-output power management">
This interface is a manager that allows creating per-output power
management mode controls.
</description>
<request name="get_output_power">
<description summary="get a power management for an output">
Create a output power management mode control that can be used to
adjust the power management mode for a given output.
</description>
<arg name="id" type="new_id" interface="zwlr_output_power_v1"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
All objects created by the manager will still remain valid, until their
appropriate destroy request has been called.
</description>
</request>
</interface>
<interface name="zwlr_output_power_v1" version="1">
<description summary="adjust power management mode for an output">
This object offers requests to set the power management mode of
an output.
</description>
<enum name="mode">
<entry name="off" value="0"
summary="Output is turned off."/>
<entry name="on" value="1"
summary="Output is turned on, no power saving"/>
</enum>
<enum name="error">
<entry name="invalid_mode" value="1" summary="inexistent power save mode"/>
</enum>
<request name="set_mode">
<description summary="Set an outputs power save mode">
Set an output's power save mode to the given mode. The mode change
is effective immediately. If the output does not support the given
mode a failed event is sent.
</description>
<arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/>
</request>
<event name="mode">
<description summary="Report a power management mode change">
Report the power management mode change of an output.
The mode event is sent after an output changed its power
management mode. The reason can be a client using set_mode or the
compositor deciding to change an output's mode.
This event is also sent immediately when the object is created
so the client is informed about the current power management mode.
</description>
<arg name="mode" type="uint" enum="mode"
summary="the output's new power management mode"/>
</event>
<event name="failed">
<description summary="object no longer valid">
This event indicates that the output power management mode control
is no longer valid. This can happen for a number of reasons,
including:
- The output doesn't support power management
- Another client already has exclusive power management mode control
for this output
- The output disappeared
Upon receiving this event, the client should destroy this object.
</description>
</event>
<request name="destroy" type="destructor">
<description summary="destroy this power management">
Destroys the output power management mode control object.
</description>
</request>
</interface>
</protocol>