Emoji picker (Super+.): search, tabs, skin tones, recents, text-input-v3 insertion
CI / test (push) Canceled after 0s
CI / test (push) Canceled after 0s
Compositor-drawn Win+. style picker. The focused app keeps keyboard focus so
its text-input-v3 field stays enabled; the emoji goes in with commit_string,
or onto the clipboard with a visible notice when the app has no text field.
Shortcut lives in the shortcut table (rebindable in Settings > Shortcuts).
- compositor/wayland/text_input.mbt: zwp_text_input_manager_v3 (global 12)
- compositor/emoji: Emoji 18.0 + CLDR 49 data (Unicode License), search,
picker model, CBDT/CBLC + GSUB reader for Noto Color Emoji
- Chandra's own pinned bitmap Noto Color Emoji (scripts/fetch-emoji-font.sh,
just emoji-font); Fedora's COLRv1 copy can't be drawn. Missing font shows
an error panel.
- raster WIT: emoji-font, emoji-has, emoji-image; served by wasmhost
- state.edn :emoji {:recent [...] :skin-tone n}
- tests incl. a fake text-input client; docs/emoji-picker.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkABDGJixotaqFv2X2
This commit is contained in:
39 files changed
+4942
-41
No files matched your search
@@ -242,6 +242,13 @@ pub(all) struct ChandraCompositor {
|
||||
/// and where pictures go ("" for ~/Pictures/Screenshots).
|
||||
mut shot : ShotOverlay?
|
||||
mut shot_toast : ShotToast?
|
||||
/// The emoji picker while it is up (emoji_picker.mbt), keys whose release it swallows, and
|
||||
/// which emoji the font can draw (asked once).
|
||||
mut emoji_ui : EmojiUi?
|
||||
emoji_swallow : Array[UInt]
|
||||
mut emoji_cover : Array[Bool]?
|
||||
/// Recent emoji (newest first) and skin tone, read from state.edn at the first Super+.
|
||||
mut emoji_saved : (Array[String], Int)?
|
||||
mut shot_request : (ShotMode, Int)?
|
||||
mut rec_request : (ShotMode, Int)?
|
||||
mut frames_built : Int
|
||||
@@ -412,6 +419,10 @@ pub fn ChandraCompositor::new(
|
||||
session_check_at: 0UL,
|
||||
shot: None,
|
||||
shot_toast: None,
|
||||
emoji_ui: None,
|
||||
emoji_swallow: [],
|
||||
emoji_cover: None,
|
||||
emoji_saved: None,
|
||||
shot_request: None,
|
||||
rec_request: None,
|
||||
frames_built: 0,
|
||||
@@ -1162,6 +1173,7 @@ fn ChandraCompositor::build_scene(
|
||||
panel_ops.append(self.switcher_ops())
|
||||
}
|
||||
panel_ops.append(self.screenshot_ops())
|
||||
panel_ops.append(self.emoji_ops())
|
||||
panel_ops.append(self.face_window_ops())
|
||||
panel_ops.append(self.auth_ops())
|
||||
panel_ops.append(self.auth_notice_ops())
|
||||
@@ -1944,6 +1956,9 @@ pub fn ChandraCompositor::handle_input(
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
if self.emoji_input(ev, time_ms) {
|
||||
return
|
||||
}
|
||||
if self.screenshot_input(ev, time_ms) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,629 @@
|
||||
///| The emoji picker, like Windows' Win+.: Super+. (the "emoji-picker" shortcut) opens a panel
|
||||
/// with a search field, category tabs, a grid of emoji and a skin tone choice. The chosen emoji
|
||||
/// goes where the user was typing.
|
||||
///
|
||||
/// Drawn by the compositor, like the screenshot editor: it needs the keyboard while it is up,
|
||||
/// colour emoji pictures (read from Noto Color Emoji on the host, @raster.emoji_image) and the
|
||||
/// text-input protocol to type into the app, none of which a panel module has.
|
||||
///
|
||||
/// Keyboard: while the picker is up every key is its own (type to search, arrows move, Enter
|
||||
/// inserts, Shift+Enter inserts and stays open, Tab / Shift+Tab change tabs, Ctrl+Left/Right the
|
||||
/// skin tone, Esc closes); only modifier keys still reach the app, so its modifier state stays
|
||||
/// right. Unlike the editor, the app keeps its keyboard focus (no wl_keyboard.leave), the way an
|
||||
/// input method's popup works, so its text field stays active to receive the emoji.
|
||||
///
|
||||
/// Inserting: when the focused window has an enabled text input (zwp_text_input_v3), the emoji is
|
||||
/// typed in with commit_string. Otherwise it is put on the clipboard and a notification says so
|
||||
/// and why ("paste it with Ctrl+V"); Chandra doesn't press Ctrl+V for the app, which would do
|
||||
/// something else in a terminal.
|
||||
///
|
||||
/// Recent emoji and the skin tone are kept in state.edn (`:emoji`).
|
||||
|
||||
///| Sizes: a grid cell, the emoji in it, the padding, the search field and tab row heights.
|
||||
let ep_cell : Int = 40
|
||||
|
||||
///|
|
||||
let ep_emoji : Int = 28
|
||||
|
||||
///|
|
||||
let ep_pad : Int = 12
|
||||
|
||||
///|
|
||||
let ep_bar : Int = 34
|
||||
|
||||
///|
|
||||
let ep_cols : Int = 9
|
||||
|
||||
///|
|
||||
let ep_rows : Int = 6
|
||||
|
||||
///| What a click on the picker hits.
|
||||
priv enum EmojiHit {
|
||||
Cell(Int)
|
||||
Tab(Int)
|
||||
Tone(Int)
|
||||
Panel
|
||||
} derive(Eq)
|
||||
|
||||
///| The picker while it is up.
|
||||
pub(all) struct EmojiUi {
|
||||
/// None when there is no colour emoji font: `error` says why.
|
||||
picker : @emoji.Picker?
|
||||
error : String
|
||||
/// The panel on screen.
|
||||
mut rect : @scene.Rect
|
||||
/// The cell under the pointer.
|
||||
mut hover : Int?
|
||||
}
|
||||
|
||||
///| Whether the picker is up.
|
||||
pub fn ChandraCompositor::emoji_picker_open(self : ChandraCompositor) -> Bool {
|
||||
self.emoji_ui is Some(_)
|
||||
}
|
||||
|
||||
///| The picker's state (tests).
|
||||
pub fn ChandraCompositor::emoji_picker(self : ChandraCompositor) -> @emoji.Picker? {
|
||||
match self.emoji_ui {
|
||||
Some(ui) => ui.picker
|
||||
None => None
|
||||
}
|
||||
}
|
||||
|
||||
///| The message the picker shows instead of emoji ("" when it has emoji).
|
||||
pub fn ChandraCompositor::emoji_picker_error(self : ChandraCompositor) -> String {
|
||||
match self.emoji_ui {
|
||||
Some(ui) => ui.error
|
||||
None => ""
|
||||
}
|
||||
}
|
||||
|
||||
///| Which emoji the font can draw, asked once per session.
|
||||
fn ChandraCompositor::emoji_coverage(self : ChandraCompositor) -> Array[Bool] {
|
||||
match self.emoji_cover {
|
||||
Some(c) => c
|
||||
None => {
|
||||
let c = @raster.emoji_has(@emoji.all().map(e => e.text))
|
||||
let missing = c.filter(b => !b).length()
|
||||
if missing > 0 {
|
||||
@sys.log("emoji: the font has no picture for " + missing.to_string() + " of " + c.length().to_string() + " emoji (newer than the font); they are not listed")
|
||||
}
|
||||
self.emoji_cover = Some(c)
|
||||
c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| Super+.: open the picker, or close it.
|
||||
pub fn ChandraCompositor::toggle_emoji_picker(self : ChandraCompositor) -> Unit {
|
||||
if self.emoji_ui is Some(_) {
|
||||
self.close_emoji_picker()
|
||||
return
|
||||
}
|
||||
if self.shell.inspecting() || self.auth is Some(_) || self.shot is Some(_) || self.shot_edit is Some(_) {
|
||||
return
|
||||
}
|
||||
// The launcher's search has the keyboard otherwise; the emoji are for the app.
|
||||
if self.shell.launcher_open() {
|
||||
self.shell.toggle_launcher()
|
||||
self.overview_sync()
|
||||
}
|
||||
let ui : EmojiUi = match @raster.emoji_font() {
|
||||
Err(why) => { picker: None, error: why, rect: @scene.Rect::new(0, 0, 0, 0), hover: None }
|
||||
Ok(_) => {
|
||||
let cover = self.emoji_coverage()
|
||||
let (recent, tone) = match self.emoji_saved {
|
||||
Some(st) => st
|
||||
None => {
|
||||
let st = self.shell.load_emoji()
|
||||
self.emoji_saved = Some(st)
|
||||
st
|
||||
}
|
||||
}
|
||||
let p = @emoji.Picker::new(recent, tone, has=i => cover[i], cols=ep_cols, rows=ep_rows)
|
||||
{ picker: Some(p), error: "", rect: @scene.Rect::new(0, 0, 0, 0), hover: None }
|
||||
}
|
||||
}
|
||||
self.emoji_ui = Some(ui)
|
||||
self.emoji_place(ui)
|
||||
self.damage.mark_full()
|
||||
}
|
||||
|
||||
///| Keep the picker's recents and skin tone for the next time, and in state.edn when they changed.
|
||||
fn ChandraCompositor::emoji_remember(self : ChandraCompositor, p : @emoji.Picker) -> Unit {
|
||||
let now = (p.recents.copy(), p.tone)
|
||||
match self.emoji_saved {
|
||||
Some((r, t)) if r == now.0 && t == now.1 => ()
|
||||
_ => {
|
||||
self.emoji_saved = Some(now)
|
||||
self.shell.save_emoji(now.0, now.1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| Take the picker down (keeping its recents and skin tone).
|
||||
pub fn ChandraCompositor::close_emoji_picker(self : ChandraCompositor) -> Unit {
|
||||
match self.emoji_ui {
|
||||
Some(ui) => {
|
||||
match ui.picker {
|
||||
Some(p) => self.emoji_remember(p)
|
||||
None => ()
|
||||
}
|
||||
self.emoji_ui = None
|
||||
self.damage.mark_full()
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
||||
///| The panel's size.
|
||||
fn ChandraCompositor::emoji_size(self : ChandraCompositor, ui : EmojiUi) -> (Int, Int) {
|
||||
let w = ep_pad * 2 + ep_cols * ep_cell
|
||||
match ui.picker {
|
||||
Some(_) => (w, ep_pad + ep_bar + 8 + ep_bar + 8 + ep_rows * ep_cell + 8 + 32 + ep_pad)
|
||||
None => (w, 150 + self.theme.font_size * 3)
|
||||
}
|
||||
}
|
||||
|
||||
///| Put the panel under the caret of the focused text field when the app says where it is,
|
||||
/// else in the middle of the focused window, else of the screen; always on screen.
|
||||
fn ChandraCompositor::emoji_place(self : ChandraCompositor, ui : EmojiUi) -> Unit {
|
||||
let (w, h) = self.emoji_size(ui)
|
||||
let sw = self.output_w
|
||||
let sh = self.output_h
|
||||
let mut x = (sw - w) / 2
|
||||
let mut y = (sh - h) / 2
|
||||
match self.kbd_win {
|
||||
Some(wid) =>
|
||||
match self.windows.get(wid) {
|
||||
Some(win) =>
|
||||
match self.server.text_input_cursor(wid) {
|
||||
Some((cx, cy, _, ch)) => {
|
||||
let (ox, oy) = win.surface_origin()
|
||||
x = ox + cx
|
||||
y = oy + cy + ch + 6
|
||||
if y + h > sh - self.theme.panel_height {
|
||||
y = oy + cy - h - 6 // no room under the caret: above it
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let r = win.client_rect()
|
||||
x = r.x + (r.w - w) / 2
|
||||
y = r.y + (r.h - h) / 2
|
||||
}
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
x = x.min(sw - w - 8).max(8)
|
||||
y = y.min(sh - h - 8).max(8)
|
||||
ui.rect = @scene.Rect::new(x, y, w, h)
|
||||
}
|
||||
|
||||
///| The search field, the tabs, the grid and the skin tones, on screen.
|
||||
fn emoji_search_rect(r : @scene.Rect) -> @scene.Rect {
|
||||
@scene.Rect::new(r.x + ep_pad, r.y + ep_pad, r.w - ep_pad * 2, ep_bar)
|
||||
}
|
||||
|
||||
///|
|
||||
fn emoji_tab_rect(r : @scene.Rect, t : Int) -> @scene.Rect {
|
||||
let tw = (r.w - ep_pad * 2) / 10
|
||||
@scene.Rect::new(r.x + ep_pad + t * tw, r.y + ep_pad + ep_bar + 8, tw, ep_bar)
|
||||
}
|
||||
|
||||
///|
|
||||
fn emoji_grid_rect(r : @scene.Rect) -> @scene.Rect {
|
||||
@scene.Rect::new(r.x + ep_pad, r.y + ep_pad + ep_bar * 2 + 16, ep_cols * ep_cell, ep_rows * ep_cell)
|
||||
}
|
||||
|
||||
///|
|
||||
fn emoji_tone_rect(r : @scene.Rect, t : Int) -> @scene.Rect {
|
||||
let g = emoji_grid_rect(r)
|
||||
let s = 28
|
||||
@scene.Rect::new(r.x + r.w - ep_pad - (6 - t) * (s + 2), g.y + g.h + 10, s, s)
|
||||
}
|
||||
|
||||
///| What is at (x, y).
|
||||
fn ChandraCompositor::emoji_hit(self : ChandraCompositor, ui : EmojiUi, x : Int, y : Int) -> EmojiHit? {
|
||||
let r = ui.rect
|
||||
if !r.contains(x, y) {
|
||||
return None
|
||||
}
|
||||
match ui.picker {
|
||||
None => Some(Panel)
|
||||
Some(p) => {
|
||||
let g = emoji_grid_rect(r)
|
||||
if g.contains(x, y) {
|
||||
let i = (p.scroll + (y - g.y) / ep_cell) * ep_cols + (x - g.x) / ep_cell
|
||||
return if i < p.items().length() { Some(Cell(i)) } else { Some(Panel) }
|
||||
}
|
||||
for t = 0; t < 10; t = t + 1 {
|
||||
if emoji_tab_rect(r, t).contains(x, y) {
|
||||
return Some(Tab(t))
|
||||
}
|
||||
}
|
||||
for t = 0; t < 6; t = t + 1 {
|
||||
if emoji_tone_rect(r, t).contains(x, y) {
|
||||
return Some(Tone(t))
|
||||
}
|
||||
}
|
||||
Some(Panel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| evdev codes the picker reads (Enter and the arrows are in screenshot.mbt / switcher.mbt).
|
||||
|
||||
///|
|
||||
let key_tab : UInt = 15
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///|
|
||||
let key_pgup : UInt = 104
|
||||
|
||||
///|
|
||||
let key_pgdn : UInt = 109
|
||||
|
||||
///|
|
||||
let key_home : UInt = 102
|
||||
|
||||
///|
|
||||
let key_end : UInt = 107
|
||||
|
||||
///| Input while the picker is up. True when it was the picker's.
|
||||
fn ChandraCompositor::emoji_input(self : ChandraCompositor, ev : @nested.InputEvent, time_ms : UInt) -> Bool {
|
||||
match ev {
|
||||
Key(code, false) =>
|
||||
// Releases of keys the picker took (also after it closed).
|
||||
if self.emoji_swallow.contains(code) {
|
||||
self.emoji_swallow.retain(c => c != code)
|
||||
return true
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
let ui = match self.emoji_ui {
|
||||
Some(ui) => ui
|
||||
None => return false
|
||||
}
|
||||
match ev {
|
||||
// Other releases (the '.' of Super+., a key held since before) take the usual path.
|
||||
Key(_, false) => false
|
||||
Key(code, true) => {
|
||||
if code == key_lsuper || code == key_rsuper {
|
||||
// Super never reaches clients anyway; a Super tap doesn't open the launcher over the picker.
|
||||
self.super_solo = false
|
||||
return true
|
||||
}
|
||||
if @shell.is_modifier_key(code) {
|
||||
return false // the app keeps its modifier state right
|
||||
}
|
||||
self.emoji_swallow.push(code)
|
||||
if self.shell.shortcuts.lookup({ mods: self.held_mods(), key: code }) == Some(EmojiPicker) {
|
||||
self.close_emoji_picker() // Super+. again
|
||||
} else {
|
||||
self.emoji_key(ui, code)
|
||||
}
|
||||
true
|
||||
}
|
||||
Modifiers(_, _, _, _) => false
|
||||
PointerMove(x, y) => {
|
||||
let hit = self.emoji_hit(ui, x.to_int(), y.to_int())
|
||||
let hover = match hit {
|
||||
Some(Cell(i)) => Some(i)
|
||||
_ => None
|
||||
}
|
||||
if hover != ui.hover {
|
||||
ui.hover = hover
|
||||
self.damage.mark_full()
|
||||
}
|
||||
if hit is Some(_) {
|
||||
self.ptr_x = x
|
||||
self.ptr_y = y
|
||||
self.leave_pointer()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
PointerButton(button, pressed) => {
|
||||
let hit = self.emoji_hit(ui, self.ptr_x.to_int(), self.ptr_y.to_int())
|
||||
match hit {
|
||||
None => {
|
||||
// A click elsewhere closes the picker and goes on as usual.
|
||||
if pressed {
|
||||
self.close_emoji_picker()
|
||||
}
|
||||
false
|
||||
}
|
||||
Some(h) => {
|
||||
if pressed && button == 272U {
|
||||
self.emoji_click(ui, h, (self.mods & mod_shift) != 0U, time_ms)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
Scroll(axis, v, discrete) =>
|
||||
match self.emoji_hit(ui, self.ptr_x.to_int(), self.ptr_y.to_int()) {
|
||||
None => false
|
||||
Some(_) => {
|
||||
match ui.picker {
|
||||
Some(p) if axis == 0U => {
|
||||
let rows = if discrete != 0 { discrete } else if v > 0.0 { 1 } else if v < 0.0 { -1 } else { 0 }
|
||||
p.scroll_by(rows)
|
||||
self.damage.mark_full()
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| A key press on the picker.
|
||||
fn ChandraCompositor::emoji_key(self : ChandraCompositor, ui : EmojiUi, code : UInt) -> Unit {
|
||||
self.damage.mark_full()
|
||||
if code == key_esc {
|
||||
self.close_emoji_picker()
|
||||
return
|
||||
}
|
||||
let p = match ui.picker {
|
||||
Some(p) => p
|
||||
None => return // only Esc (or a click) does anything on the error panel
|
||||
}
|
||||
let shift = (self.mods & mod_shift) != 0U
|
||||
let ctrl = (self.mods & mod_ctrl) != 0U
|
||||
let key : @emoji.Key? = if code == key_enter || code == key_kp_enter {
|
||||
Some(Choose)
|
||||
} else if code == key_backspace {
|
||||
Some(Backspace)
|
||||
} else if code == key_tab {
|
||||
Some(if shift { PrevTab } else { NextTab })
|
||||
} else if code == key_left {
|
||||
Some(if ctrl { PrevTone } else { Left })
|
||||
} else if code == key_right {
|
||||
Some(if ctrl { NextTone } else { Right })
|
||||
} else if code == key_up {
|
||||
Some(Up)
|
||||
} else if code == key_down {
|
||||
Some(Down)
|
||||
} else if code == key_pgup {
|
||||
Some(PageUp)
|
||||
} else if code == key_pgdn {
|
||||
Some(PageDown)
|
||||
} else if code == key_home {
|
||||
Some(Home)
|
||||
} else if code == key_end {
|
||||
Some(End)
|
||||
} else if ctrl || (self.held_mods() & @shell.mod_alt) != 0U {
|
||||
None
|
||||
} else {
|
||||
let mods = self.mods | self.mods_latched | self.mods_locked
|
||||
match self.auth_keymap().char_for(code, mods, self.mods_group) {
|
||||
Some(c) if c.to_int() >= 32 => Some(Type(c))
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
match key {
|
||||
Some(k) =>
|
||||
match p.key(k) {
|
||||
Some(text) => ignore(self.emoji_insert(text, shift))
|
||||
None => ()
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
|
||||
///| A click on the picker.
|
||||
fn ChandraCompositor::emoji_click(self : ChandraCompositor, ui : EmojiUi, h : EmojiHit, keep_open : Bool, _time_ms : UInt) -> Unit {
|
||||
self.damage.mark_full()
|
||||
match ui.picker {
|
||||
None => ()
|
||||
Some(p) =>
|
||||
match h {
|
||||
Cell(i) => {
|
||||
p.select(i)
|
||||
match p.key(Choose) {
|
||||
Some(text) => ignore(self.emoji_insert(text, keep_open))
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
Tab(t) => p.set_tab(t)
|
||||
Tone(t) => p.set_tone(t)
|
||||
Panel => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///| Mime types the emoji is offered as on the clipboard.
|
||||
let text_mimes : Array[String] = ["text/plain;charset=utf-8", "text/plain", "UTF8_STRING", "TEXT", "STRING"]
|
||||
|
||||
///| How an emoji reached the app, for tests and the log.
|
||||
pub(all) enum EmojiDelivery {
|
||||
/// Typed into the focused text field (text-input-v3).
|
||||
Typed
|
||||
/// Put on the clipboard: (why it couldn't be typed).
|
||||
Copied(String)
|
||||
} derive(Eq, Show, Debug)
|
||||
|
||||
///| Put `text` where the user was typing: into the focused window's text field when it has
|
||||
/// one active, else on the clipboard with a notification saying so. Closes the picker unless
|
||||
/// `keep_open`. Saves the recents.
|
||||
pub fn ChandraCompositor::emoji_insert(self : ChandraCompositor, text : String, keep_open : Bool) -> EmojiDelivery {
|
||||
let target = self.kbd_win
|
||||
let delivery = match target {
|
||||
Some(w) if self.server.text_input_commit(w, text) => Typed
|
||||
Some(w) => {
|
||||
let app = match self.windows.get(w) {
|
||||
Some(win) if win.title.length() > 0 => win.title
|
||||
_ => "The focused window"
|
||||
}
|
||||
Copied(app + " has no text field taking typed text (text-input-v3)")
|
||||
}
|
||||
None => Copied("No window has the keyboard")
|
||||
}
|
||||
match delivery {
|
||||
Typed => ()
|
||||
Copied(why) => {
|
||||
self.server.set_own_selection(text_mimes, @utf8.encode(text))
|
||||
@sys.log("emoji: copied to the clipboard: " + why)
|
||||
let img = @raster.emoji_image(text, 48)
|
||||
self.shot_toast = Some({
|
||||
title: "Emoji copied: paste it with Ctrl+V",
|
||||
detail: why,
|
||||
until: @sys.monotonic_ms() + 6000UL,
|
||||
thumb: if img != 0U { [@scene.DrawOp::Image(@scene.Rect::new(0, 0, 48, 48), img)] } else { [] },
|
||||
tw: 48,
|
||||
th: 48,
|
||||
})
|
||||
}
|
||||
}
|
||||
match self.emoji_ui {
|
||||
Some(ui) =>
|
||||
match ui.picker {
|
||||
Some(p) => {
|
||||
p.used(text) // (already done when it came from the picker's keys or a click)
|
||||
self.emoji_remember(p)
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
if !keep_open || delivery != Typed {
|
||||
self.close_emoji_picker()
|
||||
}
|
||||
self.damage.mark_full()
|
||||
delivery
|
||||
}
|
||||
|
||||
///| An emoji picture at `r` (centred, `px` square), or a box with "?" when the font has none.
|
||||
fn ChandraCompositor::emoji_pic(self : ChandraCompositor, text : String, r : @scene.Rect, px : Int, ops : Array[@scene.DrawOp]) -> Unit {
|
||||
let x = r.x + (r.w - px) / 2
|
||||
let y = r.y + (r.h - px) / 2
|
||||
let h = @raster.emoji_image(text, px)
|
||||
if h != 0U {
|
||||
ops.push(@scene.DrawOp::Image(@scene.Rect::new(x, y, px, px), h))
|
||||
} else {
|
||||
let p = self.theme.palette
|
||||
ops.push(@scene.DrawOp::StrokeRect(@scene.Rect::new(x + 2, y + 2, px - 4, px - 4), p.foreground_muted, 1, 3))
|
||||
ops.push(@scene.DrawOp::Text(x + px / 2, y + px / 2, "?", self.theme.font_size, p.foreground_muted, @scene.TextAlign::Center, false))
|
||||
}
|
||||
}
|
||||
|
||||
///| The picker's draw ops.
|
||||
fn ChandraCompositor::emoji_ops(self : ChandraCompositor) -> Array[@scene.DrawOp] {
|
||||
let ops : Array[@scene.DrawOp] = []
|
||||
let ui = match self.emoji_ui {
|
||||
Some(ui) => ui
|
||||
None => return ops
|
||||
}
|
||||
let (w, h) = self.emoji_size(ui)
|
||||
if ui.rect.w != w || ui.rect.h != h || ui.rect.x + w > self.output_w || ui.rect.y + h > self.output_h {
|
||||
self.emoji_place(ui)
|
||||
}
|
||||
let r = ui.rect
|
||||
let pal = self.theme.palette
|
||||
let fs = self.theme.font_size
|
||||
let rad = self.theme.radius + 4
|
||||
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(r.x + 2, r.y + 4, r.w, r.h), @scene.Rgba::new(0, 0, 0, 70), rad))
|
||||
// Opaque: whatever is behind would show through the grid.
|
||||
let bg = pal.surface_popup
|
||||
ops.push(@scene.DrawOp::FillRect(r, { r: bg.r, g: bg.g, b: bg.b, a: b'\xff' }, rad))
|
||||
ops.push(@scene.DrawOp::StrokeRect(r, pal.border, 1, rad))
|
||||
let p = match ui.picker {
|
||||
Some(p) => p
|
||||
None => {
|
||||
// No colour emoji font: say so, and what to install.
|
||||
ops.push(@scene.DrawOp::Text(r.x + ep_pad, r.y + ep_pad + fs, "Emoji need a colour emoji font", fs + 1, @scene.Rgba::from_hex("#f87171"), @scene.TextAlign::Left, true))
|
||||
let mut y = r.y + ep_pad + fs * 3
|
||||
for line in wrap_text(ui.error, fs - 1, false, false, r.w - ep_pad * 2) {
|
||||
ops.push(@scene.DrawOp::Text(r.x + ep_pad, y, line, fs - 1, pal.foreground, @scene.TextAlign::Left, false))
|
||||
y = y + fs + 5
|
||||
}
|
||||
ops.push(@scene.DrawOp::Text(r.x + r.w - ep_pad, r.y + r.h - ep_pad - fs / 2, "Esc: close", fs - 2, pal.foreground_muted, @scene.TextAlign::Right, false))
|
||||
return ops
|
||||
}
|
||||
}
|
||||
// The search field.
|
||||
let s = emoji_search_rect(r)
|
||||
ops.push(@scene.DrawOp::FillRect(s, pal.surface, self.theme.radius))
|
||||
ops.push(@scene.DrawOp::StrokeRect(s, pal.accent, 1, self.theme.radius))
|
||||
let tx = s.x + 10
|
||||
if p.query.length() == 0 {
|
||||
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(tx, s.y + 8, 1, s.h - 16), pal.foreground, 0))
|
||||
ops.push(@scene.DrawOp::Text(tx + 4, s.y + s.h / 2, "Type to search emoji", fs, pal.foreground_muted, @scene.TextAlign::Left, false))
|
||||
} else {
|
||||
ops.push(@scene.DrawOp::Text(tx, s.y + s.h / 2, p.query, fs, pal.foreground, @scene.TextAlign::Left, false))
|
||||
let cw = @renderer.text_width(p.query, fs, false, false)
|
||||
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(tx + cw + 1, s.y + 8, 1, s.h - 16), pal.foreground, 0))
|
||||
}
|
||||
// The tabs (dimmed while searching: results come from every tab).
|
||||
for t = 0; t < 10; t = t + 1 {
|
||||
let tr = emoji_tab_rect(r, t)
|
||||
let on = t == p.tab && p.query.length() == 0
|
||||
if on {
|
||||
ops.push(@scene.DrawOp::FillRect(tr, pal.surface_hover, self.theme.radius))
|
||||
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(tr.x + 8, tr.y + tr.h - 3, tr.w - 16, 3), pal.accent, 1))
|
||||
} else if tr.contains(self.ptr_x.to_int(), self.ptr_y.to_int()) {
|
||||
ops.push(@scene.DrawOp::FillRect(tr, pal.surface_hover, self.theme.radius))
|
||||
}
|
||||
self.emoji_pic(@emoji.tab_icons[t], tr, 20, ops)
|
||||
}
|
||||
// The grid.
|
||||
let g = emoji_grid_rect(r)
|
||||
let items = p.items()
|
||||
if items.length() == 0 {
|
||||
let msg = if p.query.length() > 0 {
|
||||
"No emoji match “" + p.query + "”"
|
||||
} else if p.tab == 0 {
|
||||
"Emoji you use show up here"
|
||||
} else {
|
||||
"The emoji font has none of these"
|
||||
}
|
||||
ops.push(@scene.DrawOp::Text(g.x + g.w / 2, g.y + g.h / 2, msg, fs, pal.foreground_muted, @scene.TextAlign::Center, false))
|
||||
}
|
||||
ops.push(@scene.DrawOp::PushClip(g))
|
||||
let first = p.scroll * ep_cols
|
||||
let last = (first + ep_cols * ep_rows).min(items.length())
|
||||
for i = first; i < last; i = i + 1 {
|
||||
let k = i - first
|
||||
let cell = @scene.Rect::new(g.x + k % ep_cols * ep_cell, g.y + k / ep_cols * ep_cell, ep_cell, ep_cell)
|
||||
if i == p.sel {
|
||||
ops.push(@scene.DrawOp::FillRect(cell, pal.accent, self.theme.radius))
|
||||
} else if ui.hover == Some(i) {
|
||||
ops.push(@scene.DrawOp::FillRect(cell, pal.surface_hover, self.theme.radius))
|
||||
}
|
||||
self.emoji_pic(items[i].text, cell, ep_emoji, ops)
|
||||
}
|
||||
ops.push(@scene.DrawOp::PopClip)
|
||||
// A scroll bar when there is more than one screenful.
|
||||
let total_rows = (items.length() + ep_cols - 1) / ep_cols
|
||||
if total_rows > ep_rows {
|
||||
let bar_h = (g.h * ep_rows / total_rows).max(16)
|
||||
let bar_y = g.y + (g.h - bar_h) * p.scroll / (total_rows - ep_rows)
|
||||
ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(r.x + r.w - 7, bar_y, 3, bar_h), pal.foreground_muted, 1))
|
||||
}
|
||||
// The selected emoji's name, and the skin tones.
|
||||
// (The skin tone shows on the swatches beside it.)
|
||||
let name = match p.selected() {
|
||||
Some(it) => @emoji.all()[it.index].name
|
||||
None => ""
|
||||
}
|
||||
let ty = g.y + g.h + 24
|
||||
let tone0 = emoji_tone_rect(r, 0)
|
||||
ops.push(@scene.DrawOp::PushClip(@scene.Rect::new(r.x + ep_pad, ty - fs, tone0.x - r.x - ep_pad - 6, fs * 2)))
|
||||
ops.push(@scene.DrawOp::Text(r.x + ep_pad, ty, name, fs, pal.foreground, @scene.TextAlign::Left, false))
|
||||
ops.push(@scene.DrawOp::PopClip)
|
||||
for t = 0; t < 6; t = t + 1 {
|
||||
let tr = emoji_tone_rect(r, t)
|
||||
if t == p.tone {
|
||||
ops.push(@scene.DrawOp::StrokeRect(tr, pal.accent, 2, self.theme.radius))
|
||||
}
|
||||
self.emoji_pic(@emoji.tone_swatches[t], tr, 20, ops)
|
||||
}
|
||||
ops
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
///| The emoji picker (Super+.): opening, searching, keys, insertion through text-input-v3 into a
|
||||
/// fake client, the clipboard when the app has no text field, and recents in state.edn.
|
||||
|
||||
///| evdev codes typed in these tests (US layout: tests have no keymap).
|
||||
fn type_keys(comp : @host.ChandraCompositor, codes : Array[UInt], t : UInt) -> Unit {
|
||||
for i, k in codes {
|
||||
comp.handle_input(@nested.InputEvent::Key(k, true), t + i.reinterpret_as_uint() * 2U)
|
||||
comp.handle_input(@nested.InputEvent::Key(k, false), t + i.reinterpret_as_uint() * 2U + 1U)
|
||||
}
|
||||
}
|
||||
|
||||
///| p i z z a
|
||||
let pizza_keys : Array[UInt] = [25U, 23U, 44U, 44U, 30U]
|
||||
|
||||
///| Press Super+. the way a keyboard does it.
|
||||
fn press_super_period(comp : @host.ChandraCompositor, t : UInt) -> Unit {
|
||||
comp.handle_input(@nested.InputEvent::Key(125U, true), t)
|
||||
comp.handle_input(@nested.InputEvent::Key(52U, true), t + 1U)
|
||||
comp.handle_input(@nested.InputEvent::Key(52U, false), t + 2U)
|
||||
comp.handle_input(@nested.InputEvent::Key(125U, false), t + 3U)
|
||||
ignore(comp.compose_frame())
|
||||
}
|
||||
|
||||
///| The string argument of a message's words (length word, then the bytes).
|
||||
fn words_string(args : Array[UInt]) -> String {
|
||||
let n = args[0].reinterpret_as_int() - 1
|
||||
let b : Array[Byte] = []
|
||||
for i = 0; i < n; i = i + 1 {
|
||||
let w = args[1 + i / 4]
|
||||
b.push(((w >> ((i % 4) * 8)) & 0xFFU).to_byte())
|
||||
}
|
||||
@utf8.decode_lossy(Bytes::from_array(b))
|
||||
}
|
||||
|
||||
///| A client with a zwp_text_input_v3 on its seat: (text input id, keyboard id).
|
||||
fn text_input_for(comp : @host.ChandraCompositor, c : TestWaylandClient) -> (UInt, UInt) {
|
||||
let seat = bind_global(c, 2U, "wl_seat", 7U)
|
||||
let kbd = c.alloc_id()
|
||||
let wk = @wayland.WireWriter::new()
|
||||
wk.u32(kbd)
|
||||
c.send(wk.finish_msg(seat, 1U)) // get_keyboard
|
||||
let mgr = bind_global(c, 2U, "zwp_text_input_manager_v3", 1U)
|
||||
let ti = c.alloc_id()
|
||||
let w = @wayland.WireWriter::new()
|
||||
w.u32(ti)
|
||||
w.u32(seat)
|
||||
c.send(w.finish_msg(mgr, 1U))
|
||||
for _i = 0; _i < 5; _i = _i + 1 {
|
||||
comp.step()
|
||||
@sys.sleep_ms(2)
|
||||
}
|
||||
(ti, kbd)
|
||||
}
|
||||
|
||||
///| enable (or disable) the text input with the caret at (x, y, 2, h), then commit.
|
||||
fn text_input_state(comp : @host.ChandraCompositor, c : TestWaylandClient, ti : UInt, on : Bool, x : Int, y : Int, h : Int) -> Unit {
|
||||
c.send(@wayland.WireWriter::new().finish_msg(ti, if on { 1U } else { 2U }))
|
||||
if on {
|
||||
let r = @wayland.WireWriter::new()
|
||||
r.i32(x)
|
||||
r.i32(y)
|
||||
r.i32(2)
|
||||
r.i32(h)
|
||||
c.send(r.finish_msg(ti, 6U))
|
||||
}
|
||||
c.send(@wayland.WireWriter::new().finish_msg(ti, 7U))
|
||||
for _i = 0; _i < 5; _i = _i + 1 {
|
||||
comp.step()
|
||||
@sys.sleep_ms(2)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "Super+. opens the picker; typing searches, Enter types the emoji into the app's text field" {
|
||||
let socket_path = "/tmp/wayland-moon-emoji-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Editor", "editor")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
assert_eq(comp.kbd_win, Some(1UL))
|
||||
let (ti, kbd) = text_input_for(comp, a)
|
||||
// Created while its window has the keyboard: told so at once (enter with the surface).
|
||||
let first = drain_args(a)
|
||||
let enter = first.iter().find_first(m => m.0 == ti && m.1 == 0U).unwrap()
|
||||
assert_eq(enter.2[0], surf_a)
|
||||
// The app enables it with the caret at (100, 50) in its surface.
|
||||
text_input_state(comp, a, ti, true, 100, 50, 18)
|
||||
assert_true(comp.server.text_input_active(1UL))
|
||||
press_super_period(comp, 10U)
|
||||
assert_true(comp.emoji_picker_open())
|
||||
assert_eq(comp.emoji_picker_error(), "")
|
||||
// The panel sits under the caret.
|
||||
let (ox, oy) = comp.windows.get(1UL).unwrap().surface_origin()
|
||||
let r = comp.emoji_ui.unwrap().rect
|
||||
assert_eq((r.x, r.y), (ox + 100, oy + 50 + 18 + 6))
|
||||
type_keys(comp, pizza_keys, 20U)
|
||||
let p = comp.emoji_picker().unwrap()
|
||||
assert_eq(p.query, "pizza")
|
||||
assert_eq(p.selected().unwrap().text, "🍕")
|
||||
ignore(drain_args(a))
|
||||
type_keys(comp, [28U], 40U) // Enter
|
||||
assert_false(comp.emoji_picker_open())
|
||||
let msgs = drain_args(a)
|
||||
// commit_string("🍕") then done(serial 1: one commit so far), and no key reached the app.
|
||||
let commit = msgs.iter().find_first(m => m.0 == ti && m.1 == 3U).unwrap()
|
||||
assert_eq(words_string(commit.2), "🍕")
|
||||
let done = msgs.iter().find_first(m => m.0 == ti && m.1 == 5U).unwrap()
|
||||
assert_eq(done.2[0], 1U)
|
||||
assert_eq(count_msgs(msgs, kbd, 3U), 0) // wl_keyboard.key
|
||||
assert_eq(count_msgs(msgs, kbd, 2U), 0) // the app never lost the keyboard
|
||||
assert_false(comp.screenshot_toast_shown())
|
||||
// Keys reach the app again.
|
||||
type_keys(comp, [30U], 50U)
|
||||
assert_eq(count_msgs(drain_args(a), kbd, 3U), 2)
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "without an active text field the emoji goes to the clipboard, and a notice says so" {
|
||||
let socket_path = "/tmp/wayland-moon-emoji2-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Terminal", "term")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
let (ti, _) = text_input_for(comp, a)
|
||||
text_input_state(comp, a, ti, true, 10, 10, 16)
|
||||
text_input_state(comp, a, ti, false, 0, 0, 0) // the app turned it off again
|
||||
assert_false(comp.server.text_input_active(1UL))
|
||||
press_super_period(comp, 10U)
|
||||
ignore(drain_args(a))
|
||||
match comp.emoji_picker().unwrap().selected() {
|
||||
Some(it) => assert_eq(comp.emoji_insert(it.text, false), Copied("Terminal has no text field taking typed text (text-input-v3)"))
|
||||
None => fail("nothing selected")
|
||||
}
|
||||
assert_false(comp.emoji_picker_open())
|
||||
assert_true(comp.server.owns_selection())
|
||||
assert_true(comp.screenshot_toast_shown())
|
||||
// Nothing was typed into the app.
|
||||
assert_eq(count_msgs(drain_args(a), ti, 3U), 0)
|
||||
comp.close()
|
||||
}
|
||||
|
||||
///|
|
||||
test "picker keys: arrows, tabs, skin tone, Esc; clicks outside close it" {
|
||||
let comp = new_comp("emoji-keys")
|
||||
press_super_period(comp, 10U)
|
||||
let p = comp.emoji_picker().unwrap()
|
||||
assert_eq(p.tab, 1) // no recents yet: Smileys
|
||||
type_keys(comp, [106U, 108U], 20U) // Right, Down
|
||||
assert_eq(p.sel, 1 + 9)
|
||||
type_keys(comp, [15U], 30U) // Tab: People
|
||||
assert_eq((p.tab, p.sel), (2, 0))
|
||||
// Ctrl+Right twice: medium-light skin tone, applied to the waving hand.
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(4U, 0U, 0U, 0U), 40U)
|
||||
type_keys(comp, [106U, 106U], 41U)
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 45U)
|
||||
assert_eq(p.tone, 2)
|
||||
assert_eq(p.selected().unwrap().text, "👋🏼")
|
||||
// Backspace with nothing typed does nothing; Esc closes.
|
||||
type_keys(comp, [14U], 50U)
|
||||
assert_true(comp.emoji_picker_open())
|
||||
type_keys(comp, [1U], 60U)
|
||||
assert_false(comp.emoji_picker_open())
|
||||
// Super+. again opens it; a click outside closes it.
|
||||
press_super_period(comp, 70U)
|
||||
assert_true(comp.emoji_picker_open())
|
||||
click_at(comp, 5, 300, 80U)
|
||||
assert_false(comp.emoji_picker_open())
|
||||
// Super+. twice: open, then closed.
|
||||
press_super_period(comp, 90U)
|
||||
press_super_period(comp, 100U)
|
||||
assert_false(comp.emoji_picker_open())
|
||||
}
|
||||
|
||||
///|
|
||||
test "clicking an emoji in the grid picks it; Shift keeps the picker open" {
|
||||
let comp = new_comp("emoji-click")
|
||||
press_super_period(comp, 10U)
|
||||
let r = comp.emoji_ui.unwrap().rect
|
||||
// The grid starts under the search field and the tabs: its third cell.
|
||||
let gx = r.x + 12 + 2 * 40 + 20
|
||||
let gy = r.y + 12 + 34 * 2 + 16 + 20
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(1U, 0U, 0U, 0U), 20U)
|
||||
click_at(comp, gx, gy, 21U)
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 25U)
|
||||
// No window: copied, and the picker closes (there is nothing to keep typing into).
|
||||
assert_false(comp.emoji_picker_open())
|
||||
assert_true(comp.server.owns_selection())
|
||||
press_super_period(comp, 30U)
|
||||
let p = comp.emoji_picker().unwrap()
|
||||
assert_eq(p.tab, 0) // the recent emoji
|
||||
assert_eq(p.items().map(i => i.text), [@emoji.all()[2].text])
|
||||
}
|
||||
|
||||
///|
|
||||
test "recent emoji and the skin tone are kept in state.edn" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\"}\n")
|
||||
let a = new_comp("emoji-save-a")
|
||||
a.shell.persist = true
|
||||
press_super_period(a, 10U)
|
||||
let p = a.emoji_picker().unwrap()
|
||||
p.set_tone(3)
|
||||
ignore(a.emoji_insert("👍🏽", false))
|
||||
press_super_period(a, 20U)
|
||||
ignore(a.emoji_insert("🍕", false))
|
||||
// read_state_edn reads the file as ASCII; the emoji are UTF-8.
|
||||
let dir = @sys.getenv("XDG_CONFIG_HOME")
|
||||
let text = @utf8.decode_lossy(@sys.read_file_bytes(dir + "/chandra/state.edn"))
|
||||
assert_true(text.contains(":emoji"))
|
||||
assert_true(text.contains("\"🍕\" \"👍🏽\""))
|
||||
assert_true(text.contains(":skin-tone 3"))
|
||||
assert_true(text.contains(":note \"keep\""))
|
||||
let b = new_comp("emoji-save-b")
|
||||
b.shell.persist = true
|
||||
press_super_period(b, 10U)
|
||||
let q = b.emoji_picker().unwrap()
|
||||
assert_eq(q.tab, 0)
|
||||
assert_eq(q.tone, 3)
|
||||
assert_eq(q.items().map(i => i.text), ["🍕", "👍🏽"])
|
||||
}
|
||||
}
|
||||
|
||||
///| CHANDRA_EMOJI_SHOTS=<dir>: pictures of the picker over a window (docs, the thread).
|
||||
test "screenshots of the picker" {
|
||||
let dir = @sys.getenv("CHANDRA_EMOJI_SHOTS")
|
||||
if dir.length() > 0 {
|
||||
ignore(@sys.mkdir_p(dir))
|
||||
let socket_path = "/tmp/wayland-moon-emojishots-" + @sys.getpid().to_string() + ".sock"
|
||||
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
||||
let (a, shm_a, surf_a, xdg_a, _, _) = open_and_configure_client(comp, socket_path, "Notes", "notes")
|
||||
commit_shm_frame(comp, a, shm_a, surf_a, xdg_a, 1UL)
|
||||
let (ti, _) = text_input_for(comp, a)
|
||||
text_input_state(comp, a, ti, true, 120, 90, 18)
|
||||
let shot = fn(name : String) raise {
|
||||
let frame = comp.compose_frame()
|
||||
assert_eq(@sys.write_file_bytes(dir + "/" + name, @renderer.encode_png_compressed(frame)), 0)
|
||||
}
|
||||
press_super_period(comp, 10U)
|
||||
shot("picker-smileys.png")
|
||||
type_keys(comp, [35U, 18U, 30U, 19U, 20U], 20U) // h e a r t
|
||||
shot("picker-search.png")
|
||||
type_keys(comp, [14U, 14U, 14U, 14U, 14U, 15U], 40U) // clear, then Tab: People
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(4U, 0U, 0U, 0U), 60U)
|
||||
type_keys(comp, [106U, 106U, 106U], 61U) // Ctrl+Right x3: medium skin tone
|
||||
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 70U)
|
||||
type_keys(comp, [106U, 108U], 71U)
|
||||
shot("picker-people-tone.png")
|
||||
// The clipboard notice: the app turns its text field off, then an emoji is chosen.
|
||||
text_input_state(comp, a, ti, false, 0, 0, 0)
|
||||
type_keys(comp, [28U], 80U)
|
||||
shot("picker-copied-notice.png")
|
||||
comp.close()
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
"chandra/desktop/compositor/network" @network,
|
||||
"chandra/desktop/compositor/portal" @portal,
|
||||
"chandra/desktop/compositor/polkit" @polkit,
|
||||
"chandra/desktop/compositor/emoji" @emoji,
|
||||
}
|
||||
|
||||
supported_targets = "+native+wasm"
|
||||
|
||||
@@ -579,6 +579,8 @@ fn thumbnail_ops(p : @renderer.Pixmap, max_w : Int, max_h : Int) -> (Array[@scen
|
||||
fn offset_ops(ops : Array[@scene.DrawOp], dx : Int, dy : Int) -> Array[@scene.DrawOp] {
|
||||
ops.map(op => match op {
|
||||
FillRect(r, c, rad) => @scene.DrawOp::FillRect(@scene.Rect::new(r.x + dx, r.y + dy, r.w, r.h), c, rad)
|
||||
// The emoji picker's notification shows the emoji as its thumbnail.
|
||||
Image(r, h) => @scene.DrawOp::Image(@scene.Rect::new(r.x + dx, r.y + dy, r.w, r.h), h)
|
||||
other => other
|
||||
})
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ pub fn ChandraCompositor::run_shortcut(self : ChandraCompositor, action : @shell
|
||||
RecordScreen => self.toggle_recording(ShotMode::FullScreen)
|
||||
RecordWindow => self.toggle_recording(ShotMode::WindowUnderCursor)
|
||||
DockApps => ignore(self.open_dock_app(1))
|
||||
EmojiPicker => self.toggle_emoji_picker()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ test "the default shortcuts are the compositor's long-standing combos" {
|
||||
("record-window", "Super+Ctrl+R"),
|
||||
("dock-apps", "Super+1"),
|
||||
("overview", "Super+W"),
|
||||
("emoji-picker", "Super+Period"),
|
||||
]
|
||||
let sc = @shell.Shortcuts::defaults()
|
||||
assert_eq(@shell.shortcut_table.length(), want.length())
|
||||
|
||||
Reference in new issue
Block a user