rofi
1.5.1
|
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <locale.h>
#include <xkbcommon/xkbcommon-x11.h>
#include <xcb/xkb.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
#include <cairo.h>
#include <cairo-xcb.h>
#include <libsn/sn.h>
#include "rofi.h"
#include "timings.h"
#include "settings.h"
#include "mode.h"
#include "display.h"
#include "xcb-internal.h"
#include "helper.h"
#include "helper-theme.h"
#include "xrmoptions.h"
#include "dialogs/dialogs.h"
#include "view.h"
#include "view-internal.h"
#include "theme.h"
#include "xcb.h"
Go to the source code of this file.
Data Structures | |
struct | _thread_state |
Macros | |
#define | G_LOG_DOMAIN "View" |
#define | SN_API_NOT_YET_FROZEN |
Typedefs | |
typedef struct _thread_state | thread_state |
Variables | |
GThreadPool * | tpool = NULL |
RofiViewState * | current_active_menu = NULL |
struct { | |
xcb_window_t main_window | |
cairo_surface_t * fake_bg | |
xcb_gcontext_t gc | |
xcb_pixmap_t edit_pixmap | |
cairo_surface_t * edit_surf | |
cairo_t * edit_draw | |
int fake_bgrel | |
MenuFlags flags | |
GQueue views | |
workarea mon | |
guint idle_timeout | |
unsigned long long count | |
guint repaint_source | |
gboolean fullscreen | |
} | CacheState |
static const int | loc_transtable [9] |
typedef struct _thread_state thread_state |
Structure with data to process by each worker thread.
|
static |
Create a new, 0 initialized RofiViewState structure.
Definition at line 550 of file view.c.
Referenced by rofi_view_create(), and rofi_view_error_dialog().
|
static |
Definition at line 998 of file view.c.
References RofiViewState::distance, RofiViewState::line_map, RofiViewState::list_view, listview_set_max_lines(), mode_get_num_entries(), RofiViewState::num_lines, rofi_view_reload_message_bar(), _thread_state::state, and RofiViewState::sw.
Referenced by rofi_view_refilter().
|
static |
Definition at line 587 of file view.c.
References config, _thread_state::count, RofiViewState::distance, levenshtein(), Settings::levenshtein_sort, RofiViewState::line_map, Settings::matching_method, MM_FUZZY, mode_get_completion(), mode_token_match(), _thread_state::pattern, _thread_state::plen, rofi_scorer_fuzzy_evaluate(), Settings::sort, _thread_state::start, _thread_state::state, _thread_state::stop, RofiViewState::sw, and RofiViewState::tokens.
Referenced by rofi_view_refilter().
|
static |
Definition at line 143 of file view.c.
References Settings::case_sensitive, config, and Settings::sort.
Referenced by rofi_view_add_widget(), and rofi_view_trigger_global_action().
|
static |
Levenshtein Sorting.
Definition at line 164 of file view.c.
Referenced by rofi_view_refilter().
void process_result | ( | RofiViewState * | state | ) |
state | The Menu Handle |
Check if a finalize function is set, and if sets executes it.
Load in the new mode.
Definition at line 193 of file rofi.c.
References curr_switcher, MODE_EXIT, mode_result(), modi, NEXT_DIALOG, num_modi, PREVIOUS_DIALOG, RELOAD_DIALOG, RESET_DIALOG, rofi_view_clear_input(), rofi_view_free(), rofi_view_get_return_value(), rofi_view_get_selected_line(), rofi_view_get_user_input(), rofi_view_set_active(), rofi_view_switch_mode(), and RofiViewState::sw.
Referenced by rofi_view_error_dialog(), and run_switcher().
void rofi_capture_screenshot | ( | void | ) |
Stores a screenshot of Rofi at that point in time.
Definition at line 176 of file view.c.
References CacheState, color_green, and color_reset.
Referenced by record(), and rofi_view_trigger_global_action().
|
static |
MAINBOX
INPUTBAR
PROMPT
CASE INDICATOR
ENTRY BOX
MESSAGE
LISTVIEW
SIDEBAR
Definition at line 1519 of file view.c.
References box_add(), box_create(), RofiViewState::case_indicator, config, container_add(), container_create(), Settings::element_height, get_matching_state(), HIGHLIGHT, RofiViewState::list_view, listview_create(), listview_set_max_lines(), listview_set_mouse_activated_cb(), listview_set_multi_select(), listview_set_num_lines(), listview_set_scroll_type(), RofiViewState::menu_flags, MENU_INDICATOR, Settings::menu_lines, MENU_PASSWORD, RofiViewState::mesg_box, RofiViewState::mesg_tb, mode_get_display_name(), RofiViewState::modi, NORMAL, RofiViewState::num_lines, RofiViewState::num_modi, RofiViewState::prompt, rofi_get_mode(), rofi_get_num_enabled_modi(), ROFI_ORIENTATION_HORIZONTAL, ROFI_ORIENTATION_VERTICAL, rofi_theme_get_integer(), rofi_theme_get_list(), rofi_view_listview_mouse_activated_cb(), rofi_view_reload_message_bar(), rofi_view_update_prompt(), Settings::scroll_method, RofiViewState::sidebar_bar, Settings::sidebar_mode, _thread_state::state, RofiViewState::sw, TB_AUTOHEIGHT, TB_AUTOWIDTH, TB_EDITABLE, TB_MARKUP, TB_PASSWORD, TB_WRAP, RofiViewState::text, textbox_create(), textbox_sidebar_modi_trigger_action(), textbox_text(), update_callback(), WIDGET, widget_set_trigger_action_handler(), WIDGET_TYPE_EDITBOX, WIDGET_TYPE_SIDEBAR_MODI, and WIDGET_TYPE_TEXTBOX_TEXT.
Referenced by rofi_view_create().
|
static |
Definition at line 1460 of file view.c.
References CacheState, distance_get_pixel(), RofiViewState::main_window, main_window, ROFI_ORIENTATION_VERTICAL, rofi_theme_get_distance(), _thread_state::state, WIDGET, and widget_get_desired_height().
Referenced by rofi_view_create(), and rofi_view_refilter().
|
static |
Definition at line 274 of file view.c.
References CacheState, config, distance_get_pixel(), RofiViewState::height, RofiViewState::list_view, listview_get_fixed_num_lines(), loc_transtable, Settings::location, RofiViewState::main_window, ROFI_ORIENTATION_HORIZONTAL, ROFI_ORIENTATION_VERTICAL, rofi_theme_get_distance(), rofi_theme_get_position(), WIDGET, RofiViewState::width, WL_CENTER, WL_EAST, WL_NORTH, WL_NORTH_EAST, WL_NORTH_WEST, WL_SOUTH, WL_SOUTH_EAST, WL_SOUTH_WEST, WL_WEST, RofiViewState::x, Settings::x_offset, RofiViewState::y, and Settings::y_offset.
Referenced by rofi_view_create(), rofi_view_error_dialog(), and rofi_view_refilter().
|
static |
state | Internal state of the menu. |
Calculate the width of the window and the width of an element.
Definition at line 816 of file view.c.
References CacheState, config, distance_get_pixel(), RofiViewState::main_window, Settings::menu_width, ROFI_ORIENTATION_HORIZONTAL, rofi_theme_get_distance(), _thread_state::state, textbox_get_estimated_char_width(), WIDGET, widget_padding_get_padding_width(), and RofiViewState::width.
Referenced by rofi_view_create(), and rofi_view_error_dialog().
|
static |
data | A thread_state object. |
user_data | User data to pass to thread_state callback |
Small wrapper function that is internally used to pass a job to a worker.
Definition at line 577 of file view.c.
References _thread_state::acount, _thread_state::callback, _thread_state::cond, and _thread_state::mutex.
Referenced by rofi_view_refilter(), and rofi_view_workers_initialize().
void rofi_view_get_current_monitor | ( | int * | width, |
int * | height | ||
) |
Return the current monitor workarea.
Definition at line 134 of file view.c.
References CacheState.
Referenced by distance_get_pixel().
|
static |
Definition at line 1506 of file view.c.
References RofiViewState::line_map, listview_get_selected(), MENU_CUSTOM_ACTION, MENU_OK, RofiViewState::quit, RofiViewState::retv, RofiViewState::selected_line, RofiViewState::skip_absorb, and _thread_state::state.
Referenced by rofi_view_add_widget().
|
inlinestatic |
state | The current RofiViewState |
Move the selection to first row.
Definition at line 891 of file view.c.
References RofiViewState::list_view, listview_set_selected(), and _thread_state::state.
Referenced by rofi_view_trigger_global_action().
|
inlinestatic |
state | The current RofiViewState |
Move the selection to last row.
Definition at line 902 of file view.c.
References RofiViewState::filtered_lines, RofiViewState::list_view, listview_set_selected(), and _thread_state::state.
Referenced by rofi_view_trigger_global_action().
|
inlinestatic |
state | The current RofiViewState |
complete current row.
Definition at line 870 of file view.c.
References RofiViewState::line_map, RofiViewState::list_view, listview_get_selected(), mode_get_completion(), MOVE_END, RofiViewState::refilter, _thread_state::state, RofiViewState::sw, RofiViewState::text, textbox_keybinding(), and textbox_text().
Referenced by rofi_view_trigger_global_action().
|
static |
Nav helper functions, to avoid duplicate code.
state | The current RofiViewState |
Tab handling.
Definition at line 845 of file view.c.
References RofiViewState::filtered_lines, RofiViewState::line_map, RofiViewState::list_view, listview_get_selected(), listview_nav_down(), MENU_NEXT, MENU_OK, RofiViewState::prev_action, RofiViewState::quit, RofiViewState::retv, ROW_TAB, RofiViewState::selected_line, and _thread_state::state.
Referenced by rofi_view_trigger_global_action().
|
static |
On long lists it can be beneficial to parallelize. If number of threads is 1, no thread is spawn. If number of threads > 1 and there are enough (> 1000) items, spawn jobs for the thread pool. For large lists with 8 threads I see a factor three speedup of the whole function.
Definition at line 1009 of file view.c.
References _rofi_view_reload_row(), _thread_state::acount, Settings::auto_select, _thread_state::callback, Settings::case_sensitive, _thread_state::cond, config, count, _thread_state::count, RofiViewState::distance, filter_elements(), RofiViewState::filtered_lines, RofiViewState::height, helper_tokenize(), helper_tokenize_free(), lev_sort(), RofiViewState::line_map, RofiViewState::list_view, listview_get_selected(), listview_set_num_elements(), MENU_OK, mode_preprocess_input(), _thread_state::mutex, RofiViewState::num_lines, _thread_state::pattern, _thread_state::plen, RofiViewState::quit, RofiViewState::refilter, RofiViewState::reload, RofiViewState::retv, rofi_view_calculate_height(), rofi_view_calculate_window_position(), rofi_view_call_thread(), rofi_view_window_update_size(), RofiViewState::selected_line, Settings::sort, _thread_state::start, _thread_state::state, _thread_state::stop, RofiViewState::sw, textbox::text, RofiViewState::text, TICK_N, RofiViewState::tokens, and tpool.
Referenced by rofi_view_create(), rofi_view_maybe_update(), and rofi_view_switch_mode().
|
static |
Definition at line 413 of file view.c.
References CacheState, current_active_menu, RofiViewState::refilter, RofiViewState::reload, and rofi_view_queue_redraw().
Referenced by rofi_view_reload().
|
static |
Definition at line 397 of file view.c.
References RofiViewState::mesg_box, RofiViewState::mesg_tb, mode_get_message(), RofiViewState::sw, textbox_text(), WIDGET, widget_disable(), and widget_enable().
Referenced by _rofi_view_reload_row(), and rofi_view_add_widget().
|
static |
Definition at line 225 of file view.c.
References CacheState, _xcb_stuff::connection, current_active_menu, RofiViewState::height, rofi_view_update(), TICK_N, RofiViewState::width, and xcb.
Referenced by rofi_view_frame_callback(), and rofi_view_queue_redraw().
|
static |
Select Background to use for fake transparency. Current options: 'real', 'screenshot','background'
Definition at line 610 of file view.c.
References CacheState, rofi_expand_path(), TICK_N, x11_helper_get_bg_surface(), and x11_helper_get_screenshot_surface().
Referenced by __create_window().
|
static |
Definition at line 1117 of file view.c.
References ACCEPT_ALT, ACCEPT_CUSTOM, ACCEPT_ENTRY, CacheState, CANCEL, RofiViewState::case_indicator, Settings::case_sensitive, CLEAR_LINE, config, _xcb_stuff::connection, CUSTOM_1, CUSTOM_10, CUSTOM_11, CUSTOM_12, CUSTOM_13, CUSTOM_14, CUSTOM_15, CUSTOM_16, CUSTOM_17, CUSTOM_18, CUSTOM_19, CUSTOM_2, CUSTOM_3, CUSTOM_4, CUSTOM_5, CUSTOM_6, CUSTOM_7, CUSTOM_8, CUSTOM_9, DELETE_ENTRY, _xcb_stuff::ewmh, get_matching_state(), RofiViewState::line_map, RofiViewState::list_view, listview_get_selected(), listview_nav_down(), listview_nav_left(), listview_nav_page_next(), listview_nav_page_prev(), listview_nav_right(), listview_nav_up(), MENU_CANCEL, MENU_CUSTOM_ACTION, MENU_CUSTOM_INPUT, MENU_ENTRY_DELETE, MENU_LOWER_MASK, MENU_NEXT, MENU_OK, MENU_PREVIOUS, MENU_QUICK_SWITCH, MODE_NEXT, MODE_PREVIOUS, MOVE_CHAR_BACK, MOVE_CHAR_FORWARD, MOVE_END, MOVE_FRONT, MOVE_WORD_BACK, MOVE_WORD_FORWARD, netatoms, PAGE_NEXT, PAGE_PREV, PASTE_PRIMARY, PASTE_SECONDARY, RofiViewState::quit, RofiViewState::refilter, REMOVE_CHAR_BACK, REMOVE_CHAR_FORWARD, REMOVE_TO_EOL, REMOVE_TO_SOL, REMOVE_WORD_BACK, REMOVE_WORD_FORWARD, RofiViewState::retv, rofi_capture_screenshot(), rofi_view_get_active(), rofi_view_nav_first(), rofi_view_nav_last(), rofi_view_nav_row_select(), rofi_view_nav_row_tab(), ROW_DOWN, ROW_FIRST, ROW_LAST, ROW_LEFT, ROW_RIGHT, ROW_SELECT, ROW_TAB, ROW_UP, SCREENSHOT, SELECT_ELEMENT_1, SELECT_ELEMENT_10, SELECT_ELEMENT_2, SELECT_ELEMENT_3, SELECT_ELEMENT_4, SELECT_ELEMENT_5, SELECT_ELEMENT_6, SELECT_ELEMENT_7, SELECT_ELEMENT_8, SELECT_ELEMENT_9, RofiViewState::selected_line, Settings::sort, _thread_state::state, RofiViewState::text, textbox_keybinding(), textbox_text(), TOGGLE_CASE_SENSITIVITY, TOGGLE_SORT, and xcb.
Referenced by rofi_view_trigger_action().
void rofi_view_update | ( | RofiViewState * | state, |
gboolean | qr | ||
) |
state | The handle to the view |
qr | Indicate if queue_redraw should be called on changes. |
Update the state of the view. This involves filter state.
Definition at line 956 of file view.c.
References CacheState, RofiViewState::main_window, RofiViewState::overlay, rofi_view_queue_redraw(), _thread_state::state, TICK, TICK_N, WIDGET, widget_draw(), widget_need_redraw(), RofiViewState::x, and RofiViewState::y.
Referenced by rofi_view_create(), rofi_view_maybe_update(), rofi_view_repaint(), and rofi_view_switch_mode().
|
static |
Definition at line 243 of file view.c.
References mode_get_display_name(), RofiViewState::prompt, RofiViewState::sw, and textbox_text().
Referenced by rofi_view_add_widget(), and rofi_view_switch_mode().
|
static |
Definition at line 374 of file view.c.
References CacheState, _xcb_stuff::connection, depth, RofiViewState::height, RofiViewState::main_window, visual, WIDGET, widget_resize(), RofiViewState::width, RofiViewState::x, xcb, and RofiViewState::y.
Referenced by rofi_view_create(), rofi_view_error_dialog(), rofi_view_refilter(), and rofi_view_set_active().
void rofi_view_workers_finalize | ( | void | ) |
void rofi_view_workers_initialize | ( | void | ) |
Initialize the threadpool
Definition at line 1815 of file view.c.
References config, rofi_view_call_thread(), Settings::threads, TICK_N, and tpool.
Referenced by main().
|
static |
Definition at line 1477 of file view.c.
References MENU_LOWER_MASK, MENU_QUICK_SWITCH, RofiViewState::modi, MOUSE_CLICK_DOWN, MOUSE_CLICK_UP, MOUSE_DCLICK_DOWN, MOUSE_DCLICK_UP, RofiViewState::num_modi, RofiViewState::quit, RofiViewState::retv, RofiViewState::skip_absorb, _thread_state::state, WIDGET, WIDGET_TRIGGER_ACTION_RESULT_HANDLED, and WIDGET_TRIGGER_ACTION_RESULT_IGNORED.
Referenced by rofi_view_add_widget().
|
static |
Definition at line 912 of file view.c.
References config, helper_token_match_get_pango_attr(), RofiViewState::line_map, mode_get_display_value(), mode_get_icon(), ROFI_HL_BOLD, ROFI_HL_UNDERLINE, rofi_theme_get_highlight(), Settings::show_match, _thread_state::state, RofiViewState::sw, textbox_font(), textbox_get_font_height(), textbox_get_pango_attributes(), textbox_get_visible_text(), textbox_icon(), textbox_set_pango_attributes(), textbox_text(), RofiViewState::tokens, and WIDGET.
Referenced by rofi_view_add_widget().
struct { ... } CacheState |
Structure holding cached state.
Referenced by __create_window(), rofi_capture_screenshot(), rofi_view_calculate_height(), rofi_view_calculate_window_position(), rofi_view_calculate_window_width(), rofi_view_cleanup(), rofi_view_create(), rofi_view_error_dialog(), rofi_view_frame_callback(), rofi_view_get_current_monitor(), rofi_view_get_window(), rofi_view_hide(), rofi_view_queue_redraw(), rofi_view_reload(), rofi_view_reload_idle(), rofi_view_repaint(), rofi_view_set_active(), rofi_view_set_selected_line(), rofi_view_setup_fake_transparency(), rofi_view_temp_click_to_exit(), rofi_view_temp_configure_notify(), rofi_view_trigger_global_action(), rofi_view_update(), and rofi_view_window_update_size().
unsigned long long count |
debug counter for redraws
Definition at line 115 of file view.c.
Referenced by helper_token_match_get_pango_attr(), rofi_view_refilter(), and window_set_atom_prop().
RofiViewState* current_active_menu = NULL |
Global pointer to the currently active RofiViewState
Definition at line 85 of file view.c.
Referenced by rofi_view_get_active(), rofi_view_queue_redraw(), rofi_view_reload_idle(), rofi_view_repaint(), and rofi_view_set_active().
cairo_surface_t* fake_bg |
int fake_bgrel |
MenuFlags flags |
Main flags
Definition at line 107 of file view.c.
Referenced by create_pid_file(), listview_recompute_elements(), textbox_create(), and x11_disable_decoration().
|
static |
Calculates the window position Convert the old location to the new location type. 123 804 765
nw n ne w c e sw s se
Definition at line 263 of file view.c.
Referenced by rofi_view_calculate_window_position().
xcb_window_t main_window |
workarea mon |
Current work area
Definition at line 111 of file view.c.
Referenced by config_sanity_check(), monitor_active(), monitor_active_from_id(), monitor_active_from_id_focused(), monitor_active_from_winid(), monitor_dimensions(), and monitor_get_dimension().
GThreadPool* tpool = NULL |
Thread pool used for filtering
Definition at line 82 of file view.c.
Referenced by rofi_view_refilter(), rofi_view_workers_finalize(), and rofi_view_workers_initialize().