gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

Commit 3856c3b92f7d1a2b08e92eb173fd7ca58757d1f0
Parent: 77f0123d758926d2ff4b122e1901f2f4009ae62c
Author: mcol <mcol@posteo.net>
Date: 2021-02-06 23:59:44 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-02-06 23:59:44 +0000

Add auto_focus config option

Closes #23

wimp.conf Modified

@@ -42,6 +42,8 @@
 # natural or reverse scrolling
 #scroll_direction natural
 
+# Focus when moving the pointer over a window
+#auto_focus on
 
 ## Key bindings
 

src/types.h Modified

@@ -106,6 +106,7 @@
     uint32_t resize_edges;
     double zoom_min, zoom_max;
     bool vt_switching;
+    bool auto_focus;
 
     struct wl_list scratchpads;
     pid_t scratchpad_waiting;

src/main.c Modified

@@ -38,6 +38,7 @@
     .mark_indicator.box.x = 0,
     .mark_indicator.box.y = 0,
     .scratchpad_waiting = false,
+    .auto_focus = false,
 };
 
 

src/cursor.c Modified

@@ -148,11 +148,13 @@
 		wlr_xcursor_manager_set_cursor_image(wimp.cursor_manager, "left_ptr", wimp.cursor);
 	    }
 	    if (surface) {
-		bool focus_changed = seat->pointer_state.focused_surface != surface;
 		wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
-		if (!focus_changed) {
+		if (seat->pointer_state.focused_surface == surface) {
 		    wlr_seat_pointer_notify_motion(seat, time, sx, sy);
 		}
+		if (wimp.auto_focus && seat->keyboard_state.focused_surface != surface) {
+		    focus_view(view, surface);
+		}
 	    } else {
 		wlr_seat_pointer_clear_focus(seat);
 	    }

src/config.c Modified

@@ -35,6 +35,7 @@
 vt_switching on\n\
 scroll_direction natural\n\
 set_modifier Logo\n\
+auto_focus on\n\
 bind Ctrl Escape shutdown\n\
 ";
 
@@ -649,6 +650,16 @@
 	    wimp.auto_start = strdup(strtok(NULL, " \t\n\r"));
 	}
 
+	// auto_focus [on|off]
+	else if (!strcasecmp(s, "auto_focus")) {
+	    s = strtok(NULL, " \t\n\r");
+	    if (!strcasecmp(s, "off")) {
+		wimp.auto_focus = false;
+	    } else if (!strcasecmp(s, "on")) {
+		wimp.auto_focus = true;
+	    }
+	}
+
 	// other non-empty, non-commented lines
 	else {
 	    wlr_log(WLR_ERROR, "Config line %i: unknown option '%s'.", line, s);