Skip to content

Commit ebcef09

Browse files
committed
snapshot: Serialize all client's bool member variables
Previously Client::is_mapped_ and Client::has_unmap_req_from_wm_ were not serialized into snapshot, so if the WM crashes, all windows that are mapped will be considered unmapped. This commit fixes this.
1 parent 3a1e98e commit ebcef09

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/snapshot.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@ void Snapshot::Load() {
5151
for (int i = 0; i < client_count; i++) {
5252
Window window = None;
5353
int workspace_id = 0;
54+
bool is_mapped = false;
5455
bool is_floating = false;
5556
bool is_fullscreen = false;
56-
fin >> window >> workspace_id >> is_floating >> is_fullscreen;
57+
bool has_unmap_req_from_wm = false;
58+
59+
fin >> window >> workspace_id
60+
>> is_mapped >> is_floating >> is_fullscreen
61+
>> has_unmap_req_from_wm;
5762

5863
Client* client = new Client(wm->dpy_, window, wm->workspaces_[workspace_id]);
64+
client->set_mapped(is_mapped);
5965
client->set_floating(is_floating);
6066
client->set_fullscreen(is_fullscreen);
67+
client->set_has_unmap_req_from_wm(has_unmap_req_from_wm);
6168
Client::mapper_[window] = client;
6269
}
6370

@@ -70,8 +77,14 @@ void Snapshot::Load() {
7077
workspace->Deserialize(data);
7178
}
7279

80+
81+
// 4. Current workspace deserialization.
82+
int current_workspace = 0;
83+
fin >> current_workspace;
84+
wm->GotoWorkspace(current_workspace);
85+
7386

74-
// 4. Docks/Notifications deserialization.
87+
// 5. Docks/Notifications deserialization.
7588
string line;
7689

7790
std::getline(fin, line);
@@ -117,8 +130,10 @@ void Snapshot::Save() {
117130

118131
fout << window << Snapshot::kDelimiter_
119132
<< client->workspace()->id() << Snapshot::kDelimiter_
133+
<< client->is_mapped() << Snapshot::kDelimiter_
120134
<< client->is_floating() << Snapshot::kDelimiter_
121-
<< client->is_fullscreen() << endl;
135+
<< client->is_fullscreen() << Snapshot::kDelimiter_
136+
<< client->has_unmap_req_from_wm() << endl;
122137
}
123138

124139

@@ -128,7 +143,11 @@ void Snapshot::Save() {
128143
}
129144

130145

131-
// 4. Docks/notifications serialization.
146+
// 4. Curernt Workspace serialization.
147+
fout << wm->current_ << endl;
148+
149+
150+
// 5. Docks/notifications serialization.
132151
if (wm->docks_.empty()) {
133152
fout << Snapshot::kNone_;
134153
} else {

0 commit comments

Comments
 (0)