Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions metadata/dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@
<default>true</default>
</option>
<option name="autohide_duration" type="int">
<_short>Autohide duration</_short>
<_short>Autohide animation duration</_short>
<_long>Time (in milliseconds) the dock takes to show and hide</_long>
<default>300</default>
</option>
<option name="autohide_show_delay" type="int">
<_short>Autohide show delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be in the zone before showing.</_long>
<default>300</default>
</option>
<option name="autohide_hide_delay" type="int">
<_short>Autohide hide delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be out of the zone before hiding.</_long>
<default>500</default>
</option>
<option name="position" type="string">
<_short>Position</_short>
<default>bottom</default>
Expand All @@ -26,23 +37,50 @@
<value>bottom</value>
<_name>Bottom</_name>
</desc>
<desc>
<value>left</value>
<_name>Left</_name>
</desc>
<desc>
<value>right</value>
<_name>Right</_name>
</desc>
</option>
<option name="max_per_line" type="int">
<_short>Max icons per line</_short>
<_long>If greater than 0, the dock will have a maximum number of entries per line, after which a new line is created.</_long>
<default>0</default>
</option>
<option name="dock_height" type="int">
<_short>Dock height</_short>
<option name="full_span" type="bool">
<_short>Anchor to edges</_short>
<_long>Wether the dock should extend all the way to the left and right; or top and bottom depending on orientation.</_long>
<default>false</default>
</option>
<option name="minimal_height" type="int">
<_short>Minimal height</_short>
<default>100</default>
</option>
<option name="minimal_width" type="int">
<_short>Minimal width</_short>
<default>100</default>
</option>
<option name="icon_height" type="int">
<_short>Dock icons height</_short>
<default>72</default>
</option>
<option name="edge_offset" type="int">
<_short>Edge offset</_short>
<_long>The distance from the cursor to the edge of screen to show the panel when it's hidden.</_long>
<option name="edge_margin" type="int">
<_short>Edge margin</_short>
<_long>Space between the dock the edge</_long>
<default>0</default>
</option>
<option name="edge_hotspot_size" type="int">
<_short>Edge hotspot size</_short>
<_long>The distance to the edge of screen to place the cursor in to show the dock when it's hidden.</_long>
<default>20</default>
</option>
<option name="adjacent_edge_hotspot_size" type="int">
<_short>Ajacent edge hotspot size</_short>
<_long>The distance to the edge of adjacent screens to place the cursor in to show the dock when it's hidden.</_long>
<default>20</default>
</option>
<option name="show_close" type="bool">
Expand Down
61 changes: 54 additions & 7 deletions metadata/panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,47 @@
<_short>Widgets Right</_short>
<default>volume network battery clock</default>
</option>
<option name="full_span" type="bool">
<_short>Anchor to edges</_short>
<_long>Wether the pannel should extend all the way to the left and right; or top and bottom depending on orientation.</_long>
<default>true</default>
</option>
<option name="center" type="bool">
<_short>Center panel contents</_short>
<_long>Ensure the panel’s contents are centered. Effectively:
If full_span is on, it will put the left and right widgets next to the center ones.
If full_span is off, both sides of the panel will take the same amount of space, so that the center widgets are at the middle of the screen. This will lead to unused space on the side that has the least space taken up by the widgets.</_long>
<default>false</default>
</option>
<option name="minimal_height" type="int">
<_short>Minimal Height</_short>
<_short>Minimal height</_short>
<_long>Minimum height the panel takes.</_long>
<default>32</default>
</option>
<option name="minimal_width" type="int">
<_short>Minimal width</_short>
<_long>Minimum width the panel takes.</_long>
<default>32</default>
</option>
<option name="autohide" type="bool">
<_short>Autohide</_short>
<default>false</default>
</option>
<option name="autohide_duration" type="int">
<_short>Autohide Duration</_short>
<_short>Autohide animation duration</_short>
<_long>Time (in milliseconds) the panel takes to expand and retract</_long>
<default>300</default>
</option>
<option name="autohide_show_delay" type="int">
<_short>Autohide show delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be in the zone before showing.</_long>
<default>300</default>
</option>
<option name="autohide_hide_delay" type="int">
<_short>Autohide hide delay</_short>
<_long>Amount of time (in milliseconds) the cursor needs to be out of the zone before hiding.</_long>
<default>500</default>
</option>
<option name="outputs" type="string">
<_short>Outputs on which to show a panel instance</_short>
<_long>A comma separated list of output names on which to show panel instances. Set to * wildcard for all outputs.</_long>
Expand All @@ -49,10 +78,28 @@
<value>bottom</value>
<_name>Bottom</_name>
</desc>
<desc>
<value>left</value>
<_name>Left</_name>
</desc>
<desc>
<value>right</value>
<_name>Right</_name>
</desc>
</option>
<option name="edge_margin" type="int">
<_short>Edge margin</_short>
<_long>Space between the panel the edge</_long>
<default>0</default>
</option>
<option name="edge_hotspot_size" type="int">
<_short>Edge hotspot size</_short>
<_long>The distance to the edge of screen to place the cursor in to show the panel when it's hidden.</_long>
<default>20</default>
</option>
<option name="edge_offset" type="int">
<_short>Edge offset</_short>
<_long>The distance from the cursor to the edge of screen to show the panel when it's hidden.</_long>
<option name="adjacent_edge_hotspot_size" type="int">
<_short>Ajacent edge hotspot size</_short>
<_long>The distance to the edge of adjacent screens to place the cursor in to show the panel when it's hidden.</_long>
<default>20</default>
</option>
<option name="layer" type="string">
Expand Down Expand Up @@ -527,8 +574,8 @@ Set to -1 to only run it by clicking the button.
</desc>
<default>row</default>
</option>
<option name="workspace_switcher_target_height" type="double">
<_short>Target height for workspace switcher widget in pixels</_short>
<option name="workspace_switcher_target_size" type="double">
<_short>Target size for workspace switcher widget in pixels</_short>
<default>0</default>
</option>
<option name="workspace_switcher_render_views" type="bool">
Expand Down
33 changes: 31 additions & 2 deletions src/dock/dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class WfDock::impl
Gtk::FlowBox box;

WfOption<std::string> css_path{"dock/css_path"};
WfOption<int> dock_height{"dock/dock_height"};
WfOption<int> entries_per_line{"dock/max_per_line"};
WfOption<std::string> position{"dock/position"};

// needed as a workaround to shrink down when removing items
WfOption<int> height{"dock/minimal_height"};
WfOption<int> width{"dock/minimal_width"};

public:
impl(WayfireOutput *output)
Expand Down Expand Up @@ -72,6 +76,31 @@ class WfDock::impl
};
entries_per_line.set_callback(update_entries_per_line);
update_entries_per_line();

auto update_position = [=] ()
{
if (position.value() == "bottom")
{
// this is not great, but we lack better options without doing a
// layout with boxes in boxes (ugly) or some sort of custom layout manager
box.set_orientation(Gtk::Orientation::HORIZONTAL);
box.set_direction(Gtk::TextDirection::LTR);
} else if (position.value() == "left")
{
box.set_orientation(Gtk::Orientation::VERTICAL);
box.set_direction(Gtk::TextDirection::LTR);
} else if (position.value() == "right")
{
box.set_orientation(Gtk::Orientation::VERTICAL);
box.set_direction(Gtk::TextDirection::RTL);
} else // top
{
box.set_orientation(Gtk::Orientation::HORIZONTAL);
box.set_direction(Gtk::TextDirection::LTR);
}
};
position.set_callback(update_position);
update_position();
}

void add_child(Gtk::Widget& widget)
Expand All @@ -82,7 +111,7 @@ class WfDock::impl
void rem_child(Gtk::Widget& widget)
{
box.remove(widget);
window->set_default_size(-1, dock_height);
window->set_default_size(width, height);
}

wl_surface *get_wl_surface()
Expand Down
81 changes: 72 additions & 9 deletions src/panel/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class WayfirePanel::impl

WayfireOutput *output;

WfOption<std::string> panel_position{"panel/position"};
WfOption<bool> center{"panel/center"};
WfOption<std::string> panel_layer{"panel/layer"};
std::function<void()> set_panel_layer = [=] ()
{
Expand All @@ -76,23 +78,83 @@ class WayfirePanel::impl
}
};

WfOption<int> minimal_panel_height{"panel/minimal_height"};
void set_boxes_orientation(Gtk::Orientation orientation)
{
content_box.set_orientation(orientation);
left_box.set_orientation(orientation);
center_box.set_orientation(orientation);
right_box.set_orientation(orientation);
}

void update_orientation()
{
bool is_horizontal = !(panel_position.value() == "left" or panel_position.value() ==
"right"); // checking like this also works with the fallback being the top

auto orientation = is_horizontal ? Gtk::Orientation::HORIZONTAL : Gtk::Orientation::VERTICAL;
set_boxes_orientation(orientation);

if (center)
{
left_box.set_expand(true);
right_box.set_expand(true);

int lmin, lnat, lminb, lnatb, rmin, rnat, rminb, rnatb, mmin, mnat, mminb, mnatb;
left_box.measure(orientation, -1, lmin, lnat, lminb, lnatb);
right_box.measure(orientation, -1, rmin, rnat, rminb, rnatb);
center_box.measure(orientation, -1, mmin, mnat, mminb, mnatb);

if (is_horizontal)
{
content_box.set_size_request((std::max(lnat, rnat) * 2) + mnat, -1);

left_box.set_halign(Gtk::Align::END);
right_box.set_halign(Gtk::Align::START);
left_box.set_valign(Gtk::Align::CENTER);
right_box.set_valign(Gtk::Align::CENTER);
} else
{
content_box.set_size_request(-1, (std::max(lnat, rnat) * 2) + mnat);

left_box.set_halign(Gtk::Align::CENTER);
right_box.set_halign(Gtk::Align::CENTER);
left_box.set_valign(Gtk::Align::END);
right_box.set_valign(Gtk::Align::START);
}
} else
{
left_box.set_expand(false);
right_box.set_expand(false);

content_box.set_size_request(-1, -1);

if (is_horizontal)
{
left_box.set_halign(Gtk::Align::START);
right_box.set_halign(Gtk::Align::END);
left_box.set_valign(Gtk::Align::CENTER);
right_box.set_valign(Gtk::Align::CENTER);
} else
{
left_box.set_valign(Gtk::Align::START);
right_box.set_valign(Gtk::Align::END);
left_box.set_halign(Gtk::Align::CENTER);
right_box.set_halign(Gtk::Align::CENTER);
}
}
}

void create_window()
{
window = std::make_unique<WayfireAutohidingWindow>(output, "panel");

window->set_default_size(0, minimal_panel_height);
window->add_css_class("wf-panel");
panel_layer.set_callback(set_panel_layer);
set_panel_layer(); // initial setting
gtk_layer_set_anchor(window->gobj(), GTK_LAYER_SHELL_EDGE_LEFT, true);
gtk_layer_set_anchor(window->gobj(), GTK_LAYER_SHELL_EDGE_RIGHT, true);
gtk_layer_set_margin(window->gobj(), GTK_LAYER_SHELL_EDGE_LEFT, 0);
gtk_layer_set_margin(window->gobj(), GTK_LAYER_SHELL_EDGE_RIGHT, 0);

window->present();
init_layout();
update_orientation();
}

void init_layout()
Expand All @@ -109,10 +171,9 @@ class WayfirePanel::impl
content_box.set_end_widget(right_box);

content_box.set_hexpand(true);

left_box.set_halign(Gtk::Align::START);
content_box.set_vexpand(true);
center_box.set_halign(Gtk::Align::CENTER);
right_box.set_halign(Gtk::Align::END);
center_box.set_valign(Gtk::Align::CENTER);

window->set_child(content_box);
}
Expand Down Expand Up @@ -324,6 +385,8 @@ class WayfirePanel::impl

void handle_config_reload()
{
update_orientation();

for (auto& w : left_widgets)
{
w->handle_config_reload();
Expand Down
4 changes: 3 additions & 1 deletion src/panel/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#define DEFAULT_PANEL_HEIGHT "48"
#define DEFAULT_ICON_SIZE 32

#define PANEL_POSITION_BOTTOM "bottom"
#define PANEL_POSITION_TOP "top"
#define PANEL_POSITION_BOTTOM "bottom"
#define PANEL_POSITION_LEFT "left"
#define PANEL_POSITION_RIGHT "right"

class wayfire_config;
class WayfireWidget
Expand Down
20 changes: 20 additions & 0 deletions src/panel/widgets/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ bool WayfireBatteryInfo::setup_dbus()
return false;
}

void WayfireBatteryInfo::update_layout()
{
WfOption<std::string> panel_position{"panel/position"};

if (panel_position.value() == PANEL_POSITION_LEFT or panel_position.value() == PANEL_POSITION_RIGHT)
{
button_box.set_orientation(Gtk::Orientation::VERTICAL);
} else
{
button_box.set_orientation(Gtk::Orientation::HORIZONTAL);
}
}

void WayfireBatteryInfo::handle_config_reload()
{
update_layout();
}

// TODO: simplify config loading

void WayfireBatteryInfo::init(Gtk::Box *container)
Expand All @@ -251,6 +269,8 @@ void WayfireBatteryInfo::init(Gtk::Box *container)
button.set_child(button_box);
button.property_scale_factor().signal_changed()
.connect(sigc::mem_fun(*this, &WayfireBatteryInfo::update_icon));

update_layout();
}

WayfireBatteryInfo::~WayfireBatteryInfo()
Expand Down
Loading
Loading