Skip to content

Commit 6652635

Browse files
authored
Don't autohide if zwf_shell_manager_v2 is not supported by compositor (#186)
Without wayfire-shell plugin loaded, wf-panel and wf-dock autohide and never show again. If zwf_shell_manager_v2 is not adavertised, don't autohide and throw an error. Fixes #184.
1 parent 0fb7f50 commit 6652635

1 file changed

Lines changed: 37 additions & 31 deletions

File tree

src/util/wf-autohide-window.cpp

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,9 @@ WayfireAutohidingWindow::WayfireAutohidingWindow(WayfireOutput *output,
3030
this->position.set_callback([=] () { this->update_position(); });
3131
this->update_position();
3232

33-
this->edge_offset.set_callback([=] () { this->setup_hotspot(); });
34-
35-
this->autohide_opt.set_callback([=] { update_autohide(); });
36-
set_auto_exclusive_zone(!autohide_opt);
37-
3833
this->signal_draw().connect_notify(
3934
[=] (const Cairo::RefPtr<Cairo::Context>&) { update_margin(); });
4035

41-
this->signal_size_allocate().connect_notify(
42-
[=] (Gtk::Allocation&)
43-
{
44-
this->set_auto_exclusive_zone(this->has_auto_exclusive_zone);
45-
this->setup_hotspot();
46-
});
47-
4836
this->signal_focus_out_event().connect_notify(
4937
[=] (const GdkEventFocus*)
5038
{
@@ -54,20 +42,38 @@ WayfireAutohidingWindow::WayfireAutohidingWindow(WayfireOutput *output,
5442
}
5543
});
5644

57-
if (output->output)
58-
{
59-
static const zwf_output_v2_listener listener = {
60-
.enter_fullscreen = [] (void *data, zwf_output_v2*)
61-
{
62-
((WayfireAutohidingWindow*)data)->increase_autohide();
63-
},
64-
.leave_fullscreen = [] (void *data, zwf_output_v2*)
65-
{
66-
((WayfireAutohidingWindow*)data)->decrease_autohide();
67-
}
68-
};
69-
zwf_output_v2_add_listener(output->output, &listener, this);
45+
set_auto_exclusive_zone(!autohide_opt);
46+
47+
if (!output->output)
48+
{
49+
std::cerr << "WARNING: Compositor does not support zwf_shell_manager_v2 " << \
50+
"disabling hotspot and autohide features " << \
51+
"(is wayfire-shell plugin enabled?)" << std::endl;
52+
return;
7053
}
54+
55+
this->signal_size_allocate().connect_notify(
56+
[=] (Gtk::Allocation&)
57+
{
58+
this->set_auto_exclusive_zone(this->has_auto_exclusive_zone);
59+
this->setup_hotspot();
60+
});
61+
62+
this->edge_offset.set_callback([=] () { this->setup_hotspot(); });
63+
64+
this->autohide_opt.set_callback([=] { update_autohide(); });
65+
66+
static const zwf_output_v2_listener listener = {
67+
.enter_fullscreen = [] (void *data, zwf_output_v2*)
68+
{
69+
((WayfireAutohidingWindow*)data)->increase_autohide();
70+
},
71+
.leave_fullscreen = [] (void *data, zwf_output_v2*)
72+
{
73+
((WayfireAutohidingWindow*)data)->decrease_autohide();
74+
}
75+
};
76+
zwf_output_v2_add_listener(output->output, &listener, this);
7177
}
7278

7379
WayfireAutohidingWindow::~WayfireAutohidingWindow()
@@ -146,10 +152,15 @@ void WayfireAutohidingWindow::update_position()
146152
GtkLayerShellEdge anchor = get_anchor_edge(position);
147153
gtk_layer_set_anchor(this->gobj(), anchor, true);
148154

155+
if (!this->output->output)
156+
{
157+
return;
158+
}
159+
149160
/* When the position changes, show an animation from the new edge. */
150161
y_position.animate(-this->get_allocated_height(), -this->get_allocated_height());
151-
setup_hotspot();
152162
m_show_uncertain();
163+
setup_hotspot();
153164
}
154165

155166
struct WayfireAutohidingWindowHotspotCallbacks
@@ -186,11 +197,6 @@ static zwf_hotspot_v2_listener hotspot_listener = {
186197

187198
void WayfireAutohidingWindow::setup_hotspot()
188199
{
189-
if (!this->output->output)
190-
{
191-
return;
192-
}
193-
194200
/* No need to recreate hotspots if the height didn't change */
195201
if ((this->get_allocated_height() == last_hotspot_height) && (edge_offset == last_edge_offset))
196202
{

0 commit comments

Comments
 (0)