|
@@ -187,6 +187,37 @@ static unsigned int sw_mru_count;
|
|
|
static int sw_last_focus = -1;
|
|
static int sw_last_focus = -1;
|
|
|
static unsigned int sw_chord_seen;
|
|
static unsigned int sw_chord_seen;
|
|
|
static int sw_chord_seen_valid;
|
|
static int sw_chord_seen_valid;
|
|
|
|
|
+/* Win/Super app runner: a centered query field with ranked app suggestions.
|
|
|
|
|
+ * The kernel toggles the keyboard grab; this side mirrors
|
|
|
|
|
+ * wm_status.runner_active, consumes the raw keys from the same chord ring
|
|
|
|
|
+ * (WM_CHORD_KEY | key), and launches the selected app through sm_launch().
|
|
|
|
|
+ * Enter/Esc are also released by the kernel, so a crashed WM cannot leave
|
|
|
|
|
+ * the keyboard grabbed. */
|
|
|
|
|
+#define RUN_QUERY_MAX 48
|
|
|
|
|
+#define RUN_ROWS_MAX 7
|
|
|
|
|
+#define RUN_ROW_H 28
|
|
|
|
|
+#define RUN_FIELD_H 34
|
|
|
|
|
+#define RUN_HINT_H 18
|
|
|
|
|
+#define RUN_PAD 14
|
|
|
|
|
+#define RUN_W 560
|
|
|
|
|
+#define RUN_ICON 20
|
|
|
|
|
+#define RUN_MAX_APPS 32
|
|
|
|
|
+static int run_open;
|
|
|
|
|
+static char run_query[RUN_QUERY_MAX];
|
|
|
|
|
+static unsigned int run_len, run_caret;
|
|
|
|
|
+static int run_sel, run_top;
|
|
|
|
|
+static int run_matches[RUN_MAX_APPS];
|
|
|
|
|
+static int run_scores[RUN_MAX_APPS];
|
|
|
|
|
+static int run_nmatch;
|
|
|
|
|
+static int run_visible;
|
|
|
|
|
+static int run_x, run_y;
|
|
|
|
|
+static unsigned int run_w, run_h;
|
|
|
|
|
+/* The panel height depends on the match count, so a query edit can move and
|
|
|
|
|
+ * resize it. Remember the painted rectangle and damage both the old and new
|
|
|
|
|
+ * one, otherwise the old panel stays on screen. */
|
|
|
|
|
+static int run_prev_x, run_prev_y;
|
|
|
|
|
+static unsigned int run_prev_w, run_prev_h;
|
|
|
|
|
+static int run_prev_valid;
|
|
|
static char bar_msg[24];
|
|
static char bar_msg[24];
|
|
|
static unsigned int bar_msg_until;
|
|
static unsigned int bar_msg_until;
|
|
|
static int bar_msg_dirty;
|
|
static int bar_msg_dirty;
|
|
@@ -298,6 +329,11 @@ static void sw_geom(void);
|
|
|
static void sw_draw(void);
|
|
static void sw_draw(void);
|
|
|
static void sw_add_present(struct wm_present_info *p);
|
|
static void sw_add_present(struct wm_present_info *p);
|
|
|
|
|
|
|
|
|
|
+/* Win/Super app runner overlay (defined with the switcher state). */
|
|
|
|
|
+static void run_geom(void);
|
|
|
|
|
+static void run_draw(void);
|
|
|
|
|
+static void run_add_present(struct wm_present_info *p);
|
|
|
|
|
+
|
|
|
/* Bottom dock (defined with the start-menu/launch helpers further down). */
|
|
/* Bottom dock (defined with the start-menu/launch helpers further down). */
|
|
|
static void dock_update(unsigned int mx, unsigned int my);
|
|
static void dock_update(unsigned int mx, unsigned int my);
|
|
|
static void dock_draw(void);
|
|
static void dock_draw(void);
|
|
@@ -1579,6 +1615,10 @@ static void wm_overlays(struct wm_present_info *p)
|
|
|
sw_draw();
|
|
sw_draw();
|
|
|
sw_add_present(p);
|
|
sw_add_present(p);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (run_open) {
|
|
|
|
|
+ run_draw();
|
|
|
|
|
+ run_add_present(p);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* True when a screen rectangle contains pixels from an overlay rather than
|
|
/* True when a screen rectangle contains pixels from an overlay rather than
|
|
@@ -1601,6 +1641,10 @@ static int shadow_overlay_covers(int x, int y, int w, int h)
|
|
|
x < sw_x + (int)sw_w && x + w > sw_x &&
|
|
x < sw_x + (int)sw_w && x + w > sw_x &&
|
|
|
y < sw_y + (int)sw_h && y + h > sw_y)
|
|
y < sw_y + (int)sw_h && y + h > sw_y)
|
|
|
return 1;
|
|
return 1;
|
|
|
|
|
+ if (run_visible &&
|
|
|
|
|
+ x < run_x + (int)run_w && x + w > run_x &&
|
|
|
|
|
+ y < run_y + (int)run_h && y + h > run_y)
|
|
|
|
|
+ return 1;
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2007,6 +2051,8 @@ static void sw_build(void)
|
|
|
* as entry 0, so the selection moves to the previously used window. */
|
|
* as entry 0, so the selection moves to the previously used window. */
|
|
|
static void sw_step(int dir)
|
|
static void sw_step(int dir)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (run_open)
|
|
|
|
|
+ return;
|
|
|
if (!sw_active) {
|
|
if (!sw_active) {
|
|
|
sw_build();
|
|
sw_build();
|
|
|
if (sw_count < 2)
|
|
if (sw_count < 2)
|
|
@@ -2048,9 +2094,460 @@ static void sw_commit(void)
|
|
|
full_redraw = 1;
|
|
full_redraw = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Consume queued chords and end the session when Alt is released. Returns 1
|
|
|
|
|
- * when an active session needs its panel repainted. */
|
|
|
|
|
-static int sw_process(struct wm_status *st)
|
|
|
|
|
|
|
+/* ---- Win/Super app runner -------------------------------------------- */
|
|
|
|
|
+
|
|
|
|
|
+static char run_lower(char c)
|
|
|
|
|
+{
|
|
|
|
|
+ return c >= 'A' && c <= 'Z' ? (char)(c - 'A' + 'a') : c;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Case-insensitive prefix/substring tests for the app-name and command
|
|
|
|
|
+ * matches. The query length is known, so these avoid needing a lowered
|
|
|
|
|
+ * copy of every string. */
|
|
|
|
|
+static int run_prefix(const char *s, const char *q, unsigned int n)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
|
|
+ if (!s[i] || run_lower(s[i]) != run_lower(q[i]))
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int run_contains(const char *s, const char *q, unsigned int n)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (!n)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ for (; *s; s++) {
|
|
|
|
|
+ for (i = 0; i < n; i++)
|
|
|
|
|
+ if (!s[i] || run_lower(s[i]) != run_lower(q[i]))
|
|
|
|
|
+ break;
|
|
|
|
|
+ if (i == n)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static const char *run_basename(const char *path)
|
|
|
|
|
+{
|
|
|
|
|
+ const char *base = path;
|
|
|
|
|
+
|
|
|
|
|
+ while (*path) {
|
|
|
|
|
+ if (*path == '/')
|
|
|
|
|
+ base = path + 1;
|
|
|
|
|
+ path++;
|
|
|
|
|
+ }
|
|
|
|
|
+ return base;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Lower is a better match: app label, command name, window title, then the
|
|
|
|
|
+ * same three as substrings. */
|
|
|
|
|
+static int run_score(const struct sm_app *a, const char *q, unsigned int n)
|
|
|
|
|
+{
|
|
|
|
|
+ const char *cmd = run_basename(a->path);
|
|
|
|
|
+
|
|
|
|
|
+ if (!n)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ if (run_prefix(a->label, q, n))
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ if (a->path[0] && run_prefix(cmd, q, n))
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ if (a->win_title && run_prefix(a->win_title, q, n))
|
|
|
|
|
+ return 2;
|
|
|
|
|
+ if (run_contains(a->label, q, n))
|
|
|
|
|
+ return 3;
|
|
|
|
|
+ if (a->path[0] && run_contains(cmd, q, n))
|
|
|
|
|
+ return 4;
|
|
|
|
|
+ if (a->win_title && run_contains(a->win_title, q, n))
|
|
|
|
|
+ return 5;
|
|
|
|
|
+ return -1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Rank the apps into run_matches. Insertion sort keeps equal scores in
|
|
|
|
|
+ * start-menu order, and the list is small enough to rebuild per keystroke. */
|
|
|
|
|
+static void run_recompute(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int i, n = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < SM_NAPP && i < RUN_MAX_APPS; i++) {
|
|
|
|
|
+ int score = run_score(&sm_apps[i], run_query, run_len);
|
|
|
|
|
+ int pos;
|
|
|
|
|
+
|
|
|
|
|
+ if (score < 0)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ pos = n;
|
|
|
|
|
+ while (pos > 0 && score < run_scores[pos - 1]) {
|
|
|
|
|
+ run_matches[pos] = run_matches[pos - 1];
|
|
|
|
|
+ run_scores[pos] = run_scores[pos - 1];
|
|
|
|
|
+ pos--;
|
|
|
|
|
+ }
|
|
|
|
|
+ run_matches[pos] = i;
|
|
|
|
|
+ run_scores[pos] = score;
|
|
|
|
|
+ n++;
|
|
|
|
|
+ }
|
|
|
|
|
+ run_nmatch = n;
|
|
|
|
|
+ run_sel = 0;
|
|
|
|
|
+ run_top = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int run_rows_max(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int avail = (int)fbh - WM_BAR_H - 40;
|
|
|
|
|
+ int rows = (avail - 2 * RUN_PAD - RUN_FIELD_H - 8 - RUN_HINT_H) /
|
|
|
|
|
+ RUN_ROW_H;
|
|
|
|
|
+
|
|
|
|
|
+ if (rows > RUN_ROWS_MAX)
|
|
|
|
|
+ rows = RUN_ROWS_MAX;
|
|
|
|
|
+ if (rows < 1)
|
|
|
|
|
+ rows = 1;
|
|
|
|
|
+ return rows;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_geom(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int rows = run_nmatch < run_rows_max() ? run_nmatch : run_rows_max();
|
|
|
|
|
+
|
|
|
|
|
+ if (rows < 1)
|
|
|
|
|
+ rows = 1;
|
|
|
|
|
+ run_w = RUN_W;
|
|
|
|
|
+ if ((int)run_w > (int)fbw - 48)
|
|
|
|
|
+ run_w = fbw - 48;
|
|
|
|
|
+ run_h = 2 * RUN_PAD + RUN_FIELD_H + 8 +
|
|
|
|
|
+ (unsigned int)rows * RUN_ROW_H + RUN_HINT_H;
|
|
|
|
|
+ run_x = ((int)fbw - (int)run_w) / 2;
|
|
|
|
|
+ run_y = WM_BAR_H + ((int)fbh - WM_BAR_H - (int)run_h) / 2;
|
|
|
|
|
+ if (run_x < 8)
|
|
|
|
|
+ run_x = 8;
|
|
|
|
|
+ if (run_x + (int)run_w > (int)fbw - 8)
|
|
|
|
|
+ run_x = (int)fbw - 8 - (int)run_w;
|
|
|
|
|
+ if (run_y < WM_BAR_H + 8)
|
|
|
|
|
+ run_y = WM_BAR_H + 8;
|
|
|
|
|
+ if (run_y + (int)run_h > (int)fbh - 8)
|
|
|
|
|
+ run_y = (int)fbh - 8 - (int)run_h;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_sel_visible(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int rows = run_rows_max();
|
|
|
|
|
+ int max_top = run_nmatch - rows;
|
|
|
|
|
+
|
|
|
|
|
+ if (run_sel < run_top)
|
|
|
|
|
+ run_top = run_sel;
|
|
|
|
|
+ if (run_sel >= run_top + rows)
|
|
|
|
|
+ run_top = run_sel - rows + 1;
|
|
|
|
|
+ if (run_top < 0)
|
|
|
|
|
+ run_top = 0;
|
|
|
|
|
+ if (max_top < 0)
|
|
|
|
|
+ max_top = 0;
|
|
|
|
|
+ if (run_top > max_top)
|
|
|
|
|
+ run_top = max_top;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_move(int delta)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!run_nmatch)
|
|
|
|
|
+ return;
|
|
|
|
|
+ run_sel += delta;
|
|
|
|
|
+ if (run_sel < 0)
|
|
|
|
|
+ run_sel = 0;
|
|
|
|
|
+ if (run_sel >= run_nmatch)
|
|
|
|
|
+ run_sel = run_nmatch - 1;
|
|
|
|
|
+ run_sel_visible();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* The selected label's suffix after the typed prefix, for the inline ghost
|
|
|
|
|
+ * completion. NULL when the query is empty or the match came from another
|
|
|
|
|
+ * field. */
|
|
|
|
|
+static const char *run_completion(void)
|
|
|
|
|
+{
|
|
|
|
|
+ const struct sm_app *a;
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (!run_nmatch || !run_len || run_sel < 0 || run_sel >= run_nmatch)
|
|
|
|
|
+ return (void *)0;
|
|
|
|
|
+ a = &sm_apps[run_matches[run_sel]];
|
|
|
|
|
+ for (i = 0; i < run_len; i++)
|
|
|
|
|
+ if (!a->label[i] ||
|
|
|
|
|
+ run_lower(a->label[i]) != run_lower(run_query[i]))
|
|
|
|
|
+ return (void *)0;
|
|
|
|
|
+ return a->label;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_complete(void)
|
|
|
|
|
+{
|
|
|
|
|
+ const char *completion = run_completion();
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (!completion)
|
|
|
|
|
+ return;
|
|
|
|
|
+ for (i = 0; completion[i] && i + 1 < RUN_QUERY_MAX; i++)
|
|
|
|
|
+ run_query[i] = completion[i];
|
|
|
|
|
+ run_query[i] = '\0';
|
|
|
|
|
+ run_len = run_caret = i;
|
|
|
|
|
+ run_recompute();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_insert(char c)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (run_len + 1 >= RUN_QUERY_MAX)
|
|
|
|
|
+ return;
|
|
|
|
|
+ for (i = run_len; i > run_caret; i--)
|
|
|
|
|
+ run_query[i] = run_query[i - 1];
|
|
|
|
|
+ run_query[run_caret] = c;
|
|
|
|
|
+ run_len++;
|
|
|
|
|
+ run_caret++;
|
|
|
|
|
+ run_query[run_len] = '\0';
|
|
|
|
|
+ run_recompute();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_erase_before(void)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (!run_caret)
|
|
|
|
|
+ return;
|
|
|
|
|
+ for (i = run_caret - 1; i + 1 <= run_len; i++)
|
|
|
|
|
+ run_query[i] = run_query[i + 1];
|
|
|
|
|
+ run_len--;
|
|
|
|
|
+ run_caret--;
|
|
|
|
|
+ run_query[run_len] = '\0';
|
|
|
|
|
+ run_recompute();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_erase_at(void)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i;
|
|
|
|
|
+
|
|
|
|
|
+ if (run_caret >= run_len)
|
|
|
|
|
+ return;
|
|
|
|
|
+ for (i = run_caret; i + 1 <= run_len; i++)
|
|
|
|
|
+ run_query[i] = run_query[i + 1];
|
|
|
|
|
+ run_len--;
|
|
|
|
|
+ run_query[run_len] = '\0';
|
|
|
|
|
+ run_recompute();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_open_ui(void)
|
|
|
|
|
+{
|
|
|
|
|
+ run_open = 1;
|
|
|
|
|
+ run_prev_valid = 0;
|
|
|
|
|
+ run_query[0] = '\0';
|
|
|
|
|
+ run_len = 0;
|
|
|
|
|
+ run_caret = 0;
|
|
|
|
|
+ run_sel = 0;
|
|
|
|
|
+ run_top = 0;
|
|
|
|
|
+ run_recompute();
|
|
|
|
|
+ sw_active = 0;
|
|
|
|
|
+ sw_count = 0;
|
|
|
|
|
+ sm_close();
|
|
|
|
|
+ full_redraw = 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_close_ui(void)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!run_open)
|
|
|
|
|
+ return;
|
|
|
|
|
+ run_open = 0;
|
|
|
|
|
+ run_nmatch = 0;
|
|
|
|
|
+ run_len = 0;
|
|
|
|
|
+ run_caret = 0;
|
|
|
|
|
+ run_query[0] = '\0';
|
|
|
|
|
+ run_prev_valid = 0;
|
|
|
|
|
+ full_redraw = 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_launch(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int idx;
|
|
|
|
|
+
|
|
|
|
|
+ if (run_sel < 0 || run_sel >= run_nmatch) {
|
|
|
|
|
+ run_close_ui();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ idx = run_matches[run_sel];
|
|
|
|
|
+ run_close_ui();
|
|
|
|
|
+ if (idx >= 0 && idx < SM_NAPP)
|
|
|
|
|
+ sm_launch(idx);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_key(unsigned int key)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!run_open)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (key == 0x1B) {
|
|
|
|
|
+ run_close_ui();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == '\n' || key == '\r') {
|
|
|
|
|
+ run_launch();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == '\t') {
|
|
|
|
|
+ run_complete();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_UP) {
|
|
|
|
|
+ run_move(-1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_DOWN) {
|
|
|
|
|
+ run_move(1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_PAGE_UP) {
|
|
|
|
|
+ run_move(-run_rows_max());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_PAGE_DOWN) {
|
|
|
|
|
+ run_move(run_rows_max());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_LEFT) {
|
|
|
|
|
+ if (run_caret)
|
|
|
|
|
+ run_caret--;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_RIGHT) {
|
|
|
|
|
+ if (run_caret < run_len)
|
|
|
|
|
+ run_caret++;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_HOME) {
|
|
|
|
|
+ run_caret = 0;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_END) {
|
|
|
|
|
+ run_caret = run_len;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == 0x08) {
|
|
|
|
|
+ run_erase_before();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key == WM_RUNNER_KEY_DELETE) {
|
|
|
|
|
+ run_erase_at();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (key >= 32 && key < 127) {
|
|
|
|
|
+ run_insert((char)key);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_draw(void)
|
|
|
|
|
+{
|
|
|
|
|
+ const struct sm_app *a;
|
|
|
|
|
+ const char *completion;
|
|
|
|
|
+ char saved;
|
|
|
|
|
+ unsigned int i, qw;
|
|
|
|
|
+ int fx, fy, fw, ry, rows, shown, hint_y;
|
|
|
|
|
+
|
|
|
|
|
+ if (!run_open)
|
|
|
|
|
+ return;
|
|
|
|
|
+ run_geom();
|
|
|
|
|
+ usurf_fill_round_alpha(&screen, run_x, run_y, (int)run_w, (int)run_h,
|
|
|
|
|
+ 10, 0x141824u, 242);
|
|
|
|
|
+
|
|
|
|
|
+ fx = run_x + RUN_PAD;
|
|
|
|
|
+ fy = run_y + RUN_PAD;
|
|
|
|
|
+ fw = (int)run_w - 2 * RUN_PAD;
|
|
|
|
|
+ sm_fill_round(fx, fy, fw, RUN_FIELD_H, 7, 0x0B0D14u);
|
|
|
|
|
+
|
|
|
|
|
+ /* The query text, a dim placeholder, and the caret at the edit point.
|
|
|
|
|
+ * Temporarily terminating at the caret gives the measured prefix. */
|
|
|
|
|
+ if (run_len)
|
|
|
|
|
+ usurf_text(&screen, fx + 10, fy + (RUN_FIELD_H - 16) / 2,
|
|
|
|
|
+ run_query, SM_TEXT, fx, fy, (unsigned int)fw,
|
|
|
|
|
+ RUN_FIELD_H);
|
|
|
|
|
+ else
|
|
|
|
|
+ usurf_text(&screen, fx + 10, fy + (RUN_FIELD_H - 16) / 2,
|
|
|
|
|
+ "Search apps", SM_TEXT_DIM, fx, fy,
|
|
|
|
|
+ (unsigned int)fw, RUN_FIELD_H);
|
|
|
|
|
+ saved = run_query[run_caret];
|
|
|
|
|
+ run_query[run_caret] = '\0';
|
|
|
|
|
+ qw = usurf_text_width(&screen, run_query);
|
|
|
|
|
+ run_query[run_caret] = saved;
|
|
|
|
|
+ usurf_fill(&screen, fx + 10 + (int)qw, fy + 9, 1, 16, 0xE8EAF6u);
|
|
|
|
|
+
|
|
|
|
|
+ completion = run_completion();
|
|
|
|
|
+ if (completion && run_caret == run_len)
|
|
|
|
|
+ usurf_text(&screen, fx + 10 + (int)qw + 1,
|
|
|
|
|
+ fy + (RUN_FIELD_H - 16) / 2,
|
|
|
|
|
+ completion + run_len, SM_TEXT_DIM, fx, fy,
|
|
|
|
|
+ (unsigned int)fw, RUN_FIELD_H);
|
|
|
|
|
+
|
|
|
|
|
+ rows = run_rows_max();
|
|
|
|
|
+ ry = fy + RUN_FIELD_H + 8;
|
|
|
|
|
+ shown = run_nmatch - run_top;
|
|
|
|
|
+ if (shown > rows)
|
|
|
|
|
+ shown = rows;
|
|
|
|
|
+ if (!run_nmatch) {
|
|
|
|
|
+ usurf_text(&screen, fx + 10, ry + 5, "No matching apps",
|
|
|
|
|
+ SM_TEXT_DIM, fx, ry, (unsigned int)fw,
|
|
|
|
|
+ RUN_ROW_H);
|
|
|
|
|
+ shown = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (i = 0; i < (unsigned int)shown; i++) {
|
|
|
|
|
+ int mi = run_top + (int)i;
|
|
|
|
|
+ int row_y = ry + (int)i * RUN_ROW_H;
|
|
|
|
|
+ const char *cmd;
|
|
|
|
|
+ int tx = fx + 34;
|
|
|
|
|
+ int tw;
|
|
|
|
|
+
|
|
|
|
|
+ a = &sm_apps[run_matches[mi]];
|
|
|
|
|
+ if (mi == run_sel)
|
|
|
|
|
+ sm_fill_round(fx, row_y, fw, RUN_ROW_H - 2, 6,
|
|
|
|
|
+ 0x365CA6);
|
|
|
|
|
+ if (!usurf_app_icon(&screen, fx + 6,
|
|
|
|
|
+ row_y + (RUN_ROW_H - RUN_ICON) / 2,
|
|
|
|
|
+ RUN_ICON, (enum app_icon)a->icon))
|
|
|
|
|
+ sm_tile(fx + 6, row_y + (RUN_ROW_H - RUN_ICON) / 2,
|
|
|
|
|
+ RUN_ICON, a->tile, a->letter);
|
|
|
|
|
+ usurf_text(&screen, tx, row_y + (RUN_ROW_H - 16) / 2,
|
|
|
|
|
+ a->label, mi == run_sel ? COL_WHITE : SM_TEXT,
|
|
|
|
|
+ fx, row_y, (unsigned int)fw, RUN_ROW_H);
|
|
|
|
|
+ cmd = run_basename(a->path);
|
|
|
|
|
+ if (a->path[0] && cmd[0]) {
|
|
|
|
|
+ tw = (int)usurf_text_width(&screen, cmd);
|
|
|
|
|
+ if (tx + tw + 10 < fx + fw)
|
|
|
|
|
+ usurf_text(&screen, fx + fw - 10 - tw,
|
|
|
|
|
+ row_y + (RUN_ROW_H - 16) / 2,
|
|
|
|
|
+ cmd, SM_TEXT_DIM, fx, row_y,
|
|
|
|
|
+ (unsigned int)fw, RUN_ROW_H);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ hint_y = run_y + (int)run_h - RUN_PAD - RUN_HINT_H + 2;
|
|
|
|
|
+ usurf_text(&screen, fx + 2, hint_y,
|
|
|
|
|
+ "Tab complete Up/Down select Enter run Esc close",
|
|
|
|
|
+ SM_TEXT_DIM, run_x, run_y, run_w, run_h);
|
|
|
|
|
+
|
|
|
|
|
+ run_prev_x = run_x;
|
|
|
|
|
+ run_prev_y = run_y;
|
|
|
|
|
+ run_prev_w = run_w;
|
|
|
|
|
+ run_prev_h = run_h;
|
|
|
|
|
+ run_prev_valid = 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void run_add_present(struct wm_present_info *p)
|
|
|
|
|
+{
|
|
|
|
|
+ if (!run_open)
|
|
|
|
|
+ return;
|
|
|
|
|
+ run_geom();
|
|
|
|
|
+ add_rect(p, run_x, run_y, run_w, run_h);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Consume the kernel's WM input ring: Alt+Tab chords, runner keys, and the
|
|
|
|
|
+ * runner grab transition. Returns a bitmask of overlays that need a
|
|
|
|
|
+ * repaint (WM_INPUT_SW / WM_INPUT_RUN). */
|
|
|
|
|
+#define WM_INPUT_SW 1
|
|
|
|
|
+#define WM_INPUT_RUN 2
|
|
|
|
|
+static int wm_input_process(struct wm_status *st)
|
|
|
{
|
|
{
|
|
|
int changed = 0;
|
|
int changed = 0;
|
|
|
unsigned int n;
|
|
unsigned int n;
|
|
@@ -2059,48 +2556,64 @@ static int sw_process(struct wm_status *st)
|
|
|
sw_chord_seen = st->chord_head;
|
|
sw_chord_seen = st->chord_head;
|
|
|
sw_chord_seen_valid = 1;
|
|
sw_chord_seen_valid = 1;
|
|
|
}
|
|
}
|
|
|
|
|
+ /* The Win key already toggled the kernel grab, so open the runner
|
|
|
|
|
+ * before applying keys typed in the same interval. */
|
|
|
|
|
+ if (st->runner_active && !run_open) {
|
|
|
|
|
+ run_open_ui();
|
|
|
|
|
+ changed |= WM_INPUT_RUN;
|
|
|
|
|
+ }
|
|
|
while (sw_chord_seen != st->chord_head) {
|
|
while (sw_chord_seen != st->chord_head) {
|
|
|
- unsigned int key =
|
|
|
|
|
|
|
+ unsigned int event =
|
|
|
st->chord_keys[sw_chord_seen % WM_CHORD_QUEUE];
|
|
st->chord_keys[sw_chord_seen % WM_CHORD_QUEUE];
|
|
|
|
|
|
|
|
sw_chord_seen++;
|
|
sw_chord_seen++;
|
|
|
- if (key == WM_CHORD_NEXT)
|
|
|
|
|
|
|
+ if (event & WM_CHORD_KEY) {
|
|
|
|
|
+ if (run_open)
|
|
|
|
|
+ run_key(event & 0xFFFFu);
|
|
|
|
|
+ changed |= WM_INPUT_RUN;
|
|
|
|
|
+ } else if (event == WM_CHORD_NEXT) {
|
|
|
sw_step(1);
|
|
sw_step(1);
|
|
|
- else if (key == WM_CHORD_PREV)
|
|
|
|
|
|
|
+ changed |= WM_INPUT_SW;
|
|
|
|
|
+ } else if (event == WM_CHORD_PREV) {
|
|
|
sw_step(-1);
|
|
sw_step(-1);
|
|
|
- changed = 1;
|
|
|
|
|
|
|
+ changed |= WM_INPUT_SW;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if (!sw_active)
|
|
|
|
|
- return 0;
|
|
|
|
|
- if (!st->alt_down) {
|
|
|
|
|
- sw_commit();
|
|
|
|
|
- return 0;
|
|
|
|
|
|
|
+ /* A runner launch or Esc/Enter already ended the local session; the
|
|
|
|
|
+ * kernel has released the grab for Enter/Esc and for a second Win. */
|
|
|
|
|
+ if (!st->runner_active && run_open) {
|
|
|
|
|
+ run_close_ui();
|
|
|
|
|
+ changed |= WM_INPUT_RUN;
|
|
|
}
|
|
}
|
|
|
- /* A window may have closed while the session is open. */
|
|
|
|
|
- {
|
|
|
|
|
- unsigned int keep = sw_sel < sw_count ? sw_slots[sw_sel] :
|
|
|
|
|
- WM_MAX_WINDOWS;
|
|
|
|
|
- unsigned int i, sel = 0;
|
|
|
|
|
-
|
|
|
|
|
- n = 0;
|
|
|
|
|
- for (i = 0; i < sw_count; i++)
|
|
|
|
|
- if (sw_slot_usable(sw_slots[i])) {
|
|
|
|
|
- if (sw_slots[i] == keep)
|
|
|
|
|
- sel = n;
|
|
|
|
|
- sw_slots[n++] = sw_slots[i];
|
|
|
|
|
|
|
+ if (sw_active) {
|
|
|
|
|
+ if (!st->alt_down) {
|
|
|
|
|
+ sw_commit();
|
|
|
|
|
+ changed |= WM_INPUT_SW;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ /* A window may have closed while the session is open. */
|
|
|
|
|
+ unsigned int keep = sw_sel < sw_count ?
|
|
|
|
|
+ sw_slots[sw_sel] : WM_MAX_WINDOWS;
|
|
|
|
|
+ unsigned int i, sel = 0;
|
|
|
|
|
+
|
|
|
|
|
+ n = 0;
|
|
|
|
|
+ for (i = 0; i < sw_count; i++)
|
|
|
|
|
+ if (sw_slot_usable(sw_slots[i])) {
|
|
|
|
|
+ if (sw_slots[i] == keep)
|
|
|
|
|
+ sel = n;
|
|
|
|
|
+ sw_slots[n++] = sw_slots[i];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (n != sw_count) {
|
|
|
|
|
+ sw_count = n;
|
|
|
|
|
+ sw_sel = sel;
|
|
|
|
|
+ changed |= WM_INPUT_SW;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sw_count < 2) {
|
|
|
|
|
+ sw_active = 0;
|
|
|
|
|
+ sw_count = 0;
|
|
|
|
|
+ full_redraw = 1;
|
|
|
}
|
|
}
|
|
|
- if (n != sw_count) {
|
|
|
|
|
- sw_count = n;
|
|
|
|
|
- sw_sel = sel;
|
|
|
|
|
- changed = 1;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (sw_count < 2) {
|
|
|
|
|
- sw_active = 0;
|
|
|
|
|
- sw_count = 0;
|
|
|
|
|
- full_redraw = 1;
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
return changed;
|
|
return changed;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2414,7 +2927,7 @@ static void do_update(struct wm_status *st)
|
|
|
int osd_hide = 0, osd_repaint = 0;
|
|
int osd_hide = 0, osd_repaint = 0;
|
|
|
int sm_dirty;
|
|
int sm_dirty;
|
|
|
int dock_redraw = 0, dock_overlap = 0;
|
|
int dock_redraw = 0, dock_overlap = 0;
|
|
|
- int sw_repaint = 0;
|
|
|
|
|
|
|
+ int input_repaint = 0;
|
|
|
unsigned int dj;
|
|
unsigned int dj;
|
|
|
|
|
|
|
|
/* The kernel bumps backlight_seq on every brightness key/command.
|
|
/* The kernel bumps backlight_seq on every brightness key/command.
|
|
@@ -2566,7 +3079,7 @@ static void do_update(struct wm_status *st)
|
|
|
/* Alt+Tab runs after the info refresh: focus transitions are visible
|
|
/* Alt+Tab runs after the info refresh: focus transitions are visible
|
|
|
* in wins[] and a window that closed mid-session is filtered out. */
|
|
* in wins[] and a window that closed mid-session is filtered out. */
|
|
|
sw_track_focus();
|
|
sw_track_focus();
|
|
|
- sw_repaint = sw_process(st);
|
|
|
|
|
|
|
+ input_repaint = wm_input_process(st);
|
|
|
/* Close-icon hover: only the topmost window under a free pointer
|
|
/* Close-icon hover: only the topmost window under a free pointer
|
|
|
* reacts; an open menu, the dock and the top bar own the pointer when
|
|
* reacts; an open menu, the dock and the top bar own the pointer when
|
|
|
* they are under it. A change repaints just the two button rects. */
|
|
* they are under it. A change repaints just the two button rects. */
|
|
@@ -2698,6 +3211,8 @@ static void do_update(struct wm_status *st)
|
|
|
sm_draw();
|
|
sm_draw();
|
|
|
sw_draw();
|
|
sw_draw();
|
|
|
sw_visible = sw_active;
|
|
sw_visible = sw_active;
|
|
|
|
|
+ run_draw();
|
|
|
|
|
+ run_visible = run_open;
|
|
|
present.count = 0;
|
|
present.count = 0;
|
|
|
add_rect(&present, 0, 0, fbw, fbh);
|
|
add_rect(&present, 0, 0, fbw, fbh);
|
|
|
present.immediate = 0;
|
|
present.immediate = 0;
|
|
@@ -2726,11 +3241,19 @@ static void do_update(struct wm_status *st)
|
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
|
need = 1;
|
|
need = 1;
|
|
|
}
|
|
}
|
|
|
- if (sw_repaint && sw_active) {
|
|
|
|
|
|
|
+ if ((input_repaint & WM_INPUT_SW) && sw_active) {
|
|
|
sw_geom();
|
|
sw_geom();
|
|
|
add_rect(&present, sw_x, sw_y, sw_w, sw_h);
|
|
add_rect(&present, sw_x, sw_y, sw_w, sw_h);
|
|
|
need = 1;
|
|
need = 1;
|
|
|
}
|
|
}
|
|
|
|
|
+ if ((input_repaint & WM_INPUT_RUN) && run_open) {
|
|
|
|
|
+ run_geom();
|
|
|
|
|
+ if (run_prev_valid)
|
|
|
|
|
+ add_rect(&present, run_prev_x, run_prev_y,
|
|
|
|
|
+ run_prev_w, run_prev_h);
|
|
|
|
|
+ add_rect(&present, run_x, run_y, run_w, run_h);
|
|
|
|
|
+ need = 1;
|
|
|
|
|
+ }
|
|
|
if (osd_show)
|
|
if (osd_show)
|
|
|
need = 1;
|
|
need = 1;
|
|
|
if (bar_dirty) {
|
|
if (bar_dirty) {
|
|
@@ -2774,9 +3297,9 @@ static void do_update(struct wm_status *st)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /* A window damage rectangle under the switcher panel would overwrite
|
|
|
|
|
|
|
+ /* A window damage rectangle under an overlay panel would overwrite
|
|
|
* its pixels; repaint the panel after the window draw. */
|
|
* its pixels; repaint the panel after the window draw. */
|
|
|
- if (sw_active && !sw_repaint) {
|
|
|
|
|
|
|
+ if (sw_active && !(input_repaint & WM_INPUT_SW)) {
|
|
|
sw_geom();
|
|
sw_geom();
|
|
|
for (dj = 0; dj < present.count; dj++) {
|
|
for (dj = 0; dj < present.count; dj++) {
|
|
|
int rx = present.rect[dj].x;
|
|
int rx = present.rect[dj].x;
|
|
@@ -2786,13 +3309,30 @@ static void do_update(struct wm_status *st)
|
|
|
rx + (int)present.rect[dj].w > sw_x &&
|
|
rx + (int)present.rect[dj].w > sw_x &&
|
|
|
ry < sw_y + (int)sw_h &&
|
|
ry < sw_y + (int)sw_h &&
|
|
|
ry + (int)present.rect[dj].h > sw_y) {
|
|
ry + (int)present.rect[dj].h > sw_y) {
|
|
|
- sw_repaint = 1;
|
|
|
|
|
|
|
+ input_repaint |= WM_INPUT_SW;
|
|
|
add_rect(&present, sw_x, sw_y, sw_w, sw_h);
|
|
add_rect(&present, sw_x, sw_y, sw_w, sw_h);
|
|
|
need = 1;
|
|
need = 1;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (run_open && !(input_repaint & WM_INPUT_RUN)) {
|
|
|
|
|
+ run_geom();
|
|
|
|
|
+ for (dj = 0; dj < present.count; dj++) {
|
|
|
|
|
+ int rx = present.rect[dj].x;
|
|
|
|
|
+ int ry = present.rect[dj].y;
|
|
|
|
|
+
|
|
|
|
|
+ if (rx < run_x + (int)run_w &&
|
|
|
|
|
+ rx + (int)present.rect[dj].w > run_x &&
|
|
|
|
|
+ ry < run_y + (int)run_h &&
|
|
|
|
|
+ ry + (int)present.rect[dj].h > run_y) {
|
|
|
|
|
+ input_repaint |= WM_INPUT_RUN;
|
|
|
|
|
+ add_rect(&present, run_x, run_y, run_w, run_h);
|
|
|
|
|
+ need = 1;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (dock_dirty || dock_overlap) {
|
|
if (dock_dirty || dock_overlap) {
|
|
|
dock_damage(&present);
|
|
dock_damage(&present);
|
|
|
dock_redraw = 1;
|
|
dock_redraw = 1;
|
|
@@ -2830,6 +3370,11 @@ static void do_update(struct wm_status *st)
|
|
|
sw_visible = sw_active;
|
|
sw_visible = sw_active;
|
|
|
if (sw_active)
|
|
if (sw_active)
|
|
|
sw_add_present(&present);
|
|
sw_add_present(&present);
|
|
|
|
|
+ if (run_open)
|
|
|
|
|
+ run_draw();
|
|
|
|
|
+ run_visible = run_open;
|
|
|
|
|
+ if (run_open)
|
|
|
|
|
+ run_add_present(&present);
|
|
|
|
|
|
|
|
for (i = 0; i < WM_MAX_WINDOWS; i++) {
|
|
for (i = 0; i < WM_MAX_WINDOWS; i++) {
|
|
|
struct uwin *u = &wins[i];
|
|
struct uwin *u = &wins[i];
|
|
@@ -3603,6 +4148,13 @@ static void handle_mouse(struct wm_status *st)
|
|
|
int down = (buttons & 1) != 0;
|
|
int down = (buttons & 1) != 0;
|
|
|
int was = (prev_buttons & 1) != 0;
|
|
int was = (prev_buttons & 1) != 0;
|
|
|
|
|
|
|
|
|
|
+ /* The app runner is modal: clicks cannot reach the start menu, the
|
|
|
|
|
+ * dock or a window below the overlay. Dismiss it with Win/Esc. */
|
|
|
|
|
+ if (run_open) {
|
|
|
|
|
+ prev_buttons = buttons;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (down && !was) {
|
|
if (down && !was) {
|
|
|
int prev_title_id = last_title_id;
|
|
int prev_title_id = last_title_id;
|
|
|
unsigned int now = u_ticks_ms();
|
|
unsigned int now = u_ticks_ms();
|