Skip to content

Commit

Permalink
panel: move p_a_show_timeout field to new config
Browse files Browse the repository at this point in the history
Related issues:
  - #27
  • Loading branch information
jmc-88 committed Oct 1, 2017
1 parent f856a50 commit a9a16c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ bool Reader::AddEntry_Autohide(std::string const& key,
if (!ParseNumber(value, &timeout)) {
return true;
}
panel_autohide_show_timeout = 1000 * timeout;
new_panel_config.autohide_show_timeout = 1000 * timeout;
return true;
}
if (key == "autohide_hide_timeout") {
Expand Down
16 changes: 6 additions & 10 deletions src/panel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ PanelVerticalPosition panel_vertical_position;
bool panel_refresh;
bool task_dragged;

int panel_autohide_show_timeout;
int panel_autohide_hide_timeout;
int panel_autohide_height;
PanelStrutPolicy panel_strut_policy;
Expand Down Expand Up @@ -108,6 +107,8 @@ PanelConfig PanelConfig::Default() {
cfg.percent_y = false;

cfg.autohide = false;
cfg.autohide_show_timeout = 0;

cfg.dock = false;
cfg.horizontal = true;
cfg.wm_menu = false;
Expand All @@ -122,7 +123,6 @@ void DefaultPanel() {
panel_vertical_position = PanelVerticalPosition::kBottom;
panel_horizontal_position = PanelHorizontalPosition::kCenter;
panel_items_order.clear();
panel_autohide_show_timeout = 0;
panel_autohide_hide_timeout = 0;
panel_autohide_height = 5; // for vertical panels this is of course the width
panel_strut_policy = PanelStrutPolicy::kFollowSize;
Expand Down Expand Up @@ -904,14 +904,10 @@ bool Panel::AutohideHide() {
return false;
}

void AutohideTriggerShow(Panel* p, Timer& timer) {
if (!p) {
return;
}

p->autohide_timeout_ =
timer.SetTimeout(std::chrono::milliseconds(panel_autohide_show_timeout),
[p]() -> bool { return p->AutohideShow(); });
void Panel::AutohideTriggerShow(Timer& timer) {
autohide_timeout_ =
timer.SetTimeout(std::chrono::milliseconds(config_.autohide_show_timeout),
[this]() -> bool { return AutohideShow(); });
}

void AutohideTriggerHide(Panel* p, Timer& timer) {
Expand Down
7 changes: 4 additions & 3 deletions src/panel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extern bool panel_refresh;
extern bool task_dragged;

// panel autohide
extern int panel_autohide_show_timeout;
extern int panel_autohide_hide_timeout;
extern int
panel_autohide_height; // for vertical panels this is of course the width
Expand Down Expand Up @@ -103,6 +102,8 @@ class PanelConfig {
bool percent_y;

bool autohide;
int autohide_show_timeout;

bool dock;
bool horizontal;
bool wm_menu;
Expand Down Expand Up @@ -166,13 +167,14 @@ class Panel : public Area {
void UpdateTaskbarVisibility();

bool hidden() const;
bool autohide() const;
bool AutohideShow();
void AutohideTriggerShow(Timer& timer);
bool AutohideHide();

PanelLayer layer() const;
TaskbarMode taskbar_mode() const;
Monitor const& monitor() const;
bool autohide() const;
bool horizontal() const;
bool window_manager_menu() const;
void UseConfig(PanelConfig const& cfg, unsigned int num_desktop);
Expand Down Expand Up @@ -211,7 +213,6 @@ void InitPanel(Timer& timer);
// detect wich panel
Panel* GetPanel(Window win);

void AutohideTriggerShow(Panel* p, Timer& timer);
void AutohideTriggerHide(Panel* p, Timer& timer);

#endif // TINT3_PANEL_HH
2 changes: 1 addition & 1 deletion src/util/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool EventLoop::RunLoop() {

if (panel != nullptr && panel->autohide()) {
if (e.type == EnterNotify) {
AutohideTriggerShow(panel, timer_);
panel->AutohideTriggerShow(timer_);
} else if (e.type == LeaveNotify) {
AutohideTriggerHide(panel, timer_);
}
Expand Down

0 comments on commit a9a16c2

Please sign in to comment.