Skip to content

Commit

Permalink
Merge pull request #34 from aesophor/staging
Browse files Browse the repository at this point in the history
add windowfocus-follows-mouse feature #33
  • Loading branch information
aesophor authored Feb 27, 2020
2 parents 5356ae8 + 4ded7f4 commit a85c69c
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 130 deletions.
26 changes: 17 additions & 9 deletions example/config
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
; `set <Key> = <Value>` to set a builtin varaible
; `set $<Variable> = <Value>` to define your own variable
; -----------------------------------------------------------------------
set gap_width = 12
set gap_width = 10
set border_width = 3
set min_window_width = 100
set min_window_height = 100
set focused_color = ff4c5d70
set focused_color = ff596e84
set unfocused_color = ff394859
set focus_follows_mouse = true
set $Mod = Mod4


Expand All @@ -31,16 +32,16 @@ set $Mod = Mod4
assign URxvt 1
assign jetbrains-idea 2
assign Google-chrome 3
assign Firefox 3
assign dolphin 4
assign ark 4
assign Et 5
assign Wps 5
assign Wpp 5
assign Spotify 6
assign vlc 6
assign Gimp-2.10 7
assign Popcorn-Time 6
assign krita 7
assign tiled 7
assign Wine,steam.exe 8
assign Steam 8
assign PCSX2 8
assign PPSSPPQt 8
Expand All @@ -53,6 +54,9 @@ assign Transmission 9
; [Floating Rules]
; Applications that should be floating by default
; -----------------------------------------------------------------------
floating plasmashell true
floating krunner true
floating kcalc true
floating systemsettings true
floating SimpleScreenRecorder true
floating Sxiv true
Expand All @@ -63,19 +67,22 @@ floating Gcolor2 true
floating Steam true
floating PCSX2 true
floating Wine true
floating Wine,steam.exe true
floating Wine,tesv.exe true
floating VirtualBox Machine true
floating Vigilante true
floating xfreerdp true
floating steam_app_72850 true
floating steam_app_105600 true
floating com.hacklympics.main.Main true
floating pyRollCall true


; [Fullscreen Rules]
; Applications that should be fullscreen by default
; -----------------------------------------------------------------------
fullscreen Wine,maplelegendswindowed.exe true
fullscreen Wine,tesv.exe true
fullscreen insurgency_linux true
fullscreen steam_app_72850 tesv_original.exe true
fullscreen postal2-bin true


; [Prohibit Rules]
Expand Down Expand Up @@ -137,6 +144,7 @@ bindsym XF86AudioMute exec amixer -q -D pulse set Master toggle
bindsym XF86AudioRaiseVolume exec amixer -q -D pulse set Master 5%+ unmute
bindsym XF86AudioLowerVolume exec amixer -q -D pulse set Master 5%- unmute
bindsym XF86PowerOff exec qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1
bindsym $Mod+Escape exec toggle_screen.sh

bindsym Control+Shift+3 exec scrotutl -f
bindsym Control+Shift+4 exec scrotutl -s
Expand All @@ -150,7 +158,7 @@ bindsym $Mod+Return goto_workspace 1; exec urxvt
; Applications to execute when WM starts up (DON'T append '&' at the end)
; -----------------------------------------------------------------------
exec pulseaudio --start --log-target=syslog
exec ~/.config/mpd/launch.sh
exec_on_reload ~/.config/mpd/launch.sh
exec dunst
exec dispad
exec displayctl
Expand Down
4 changes: 4 additions & 0 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ void Client::SetBorderColor(unsigned long color) const {
XSetWindowBorder(dpy_, window_, color);
}

void Client::SelectInput(long input_mask) const {
XSelectInput(dpy_, window_, input_mask);
}

XWindowAttributes Client::GetXWindowAttributes() const {
return wm_utils::GetXWindowAttributes(window_);
}
Expand Down
1 change: 1 addition & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Client {
void SetInputFocus() const;
void SetBorderWidth(unsigned int width) const;
void SetBorderColor(unsigned long color) const;
void SelectInput(long input_mask) const;
XWindowAttributes GetXWindowAttributes() const;

Window window() const;
Expand Down
7 changes: 7 additions & 0 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ unsigned long Config::unfocused_color() const {
return unfocused_color_;
}

bool Config::focus_follows_mouse() const {
return focus_follows_mouse_;
}

const map<pair<unsigned int, KeyCode>, vector<Action>>& Config::keybind_rules() const {
return keybind_rules_;
}
Expand Down Expand Up @@ -171,6 +175,7 @@ ifstream& operator>>(ifstream& ifs, Config& config) {
config.min_window_height_ = MIN_WINDOW_HEIGHT;
config.focused_color_ = DEFAULT_FOCUSED_COLOR;
config.unfocused_color_ = DEFAULT_UNFOCUSED_COLOR;
config.focus_follows_mouse_ = DEFAULT_FOCUS_FOLLOWS_MOUSE;

config.symtab_.clear();
config.spawn_rules_.clear();
Expand Down Expand Up @@ -224,6 +229,8 @@ ifstream& operator>>(ifstream& ifs, Config& config) {
config.focused_color_ = std::stoul(value, nullptr, 16);
} else if (key == "unfocused_color") {
config.unfocused_color_ = std::stoul(value, nullptr, 16);
} else if (key == "focus_follows_mouse") {
stringstream(tokens.back()) >> std::boolalpha >> config.focus_follows_mouse_;
} else {
WM_LOG(ERROR, "config: unrecognized identifier: " << key);
}
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern "C" {
#define DEFAULT_BORDER_WIDTH 3
#define DEFAULT_FOCUSED_COLOR 0xffffffff
#define DEFAULT_UNFOCUSED_COLOR 0xff41485f
#define DEFAULT_FOCUS_FOLLOWS_MOUSE true

#define VARIABLE_PREFIX "$"
#define DEFAULT_EXIT_KEY "Mod4+Shift+Escape"
Expand All @@ -81,6 +82,7 @@ class Config {
unsigned int min_window_height() const;
unsigned long focused_color() const;
unsigned long unfocused_color() const;
bool focus_follows_mouse() const;
const std::map<std::pair<unsigned int, KeyCode>, std::vector<Action>>& keybind_rules() const;
const std::vector<std::string>& autostart_cmds() const;
const std::vector<std::string>& autostart_cmds_on_reload() const;
Expand Down Expand Up @@ -113,6 +115,7 @@ class Config {
unsigned int min_window_height_;
unsigned long focused_color_;
unsigned long unfocused_color_;
bool focus_follows_mouse_;

// symtab: for storing user-declared identifiers.
// spawn_rules_: spawn certain apps in certain workspaces.
Expand Down
Loading

0 comments on commit a85c69c

Please sign in to comment.