rofi 2.0.0
view.c File Reference
#include <config.h>
#include <errno.h>
#include <locale.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xkb.h>
#include <xkbcommon/xkbcommon-x11.h>
#include <cairo-xcb.h>
#include <cairo.h>
#include <gio/gio.h>
#include "rofi.h"
#include <libsn/sn.h>
#include "settings.h"
#include "timings.h"
#include "display.h"
#include "helper-theme.h"
#include "helper.h"
#include "mode.h"
#include "modes/modes.h"
#include "xcb-internal.h"
#include "xrmoptions.h"
#include "view-internal.h"
#include "view.h"
#include "theme.h"
#include "xcb.h"
Include dependency graph for view.c:

Go to the source code of this file.

Macros

#define G_LOG_DOMAIN   "View"
#define SN_API_NOT_YET_FROZEN

Functions

static int xcb_rofi_view_calculate_window_height (RofiViewState *state)
static void xcb_rofi_view_set_window_title (const char *title)
static void xcb_rofi_view_queue_redraw (void)
static void xcb_rofi_view_get_current_monitor (int *width, int *height)
static gboolean bench_update (void)
static gboolean xcb_rofi_view_repaint (G_GNUC_UNUSED void *data)
static void xcb_rofi_view_update (RofiViewState *state, gboolean qr)
static void xcb_rofi_view_calculate_window_position (RofiViewState *state)
static void xcb_rofi_view_window_update_size (RofiViewState *state)
static X11CursorType rofi_cursor_type_to_x11_cursor_type (RofiCursorType type)
static void xcb_rofi_view_set_cursor (RofiCursorType type)
static void xcb_rofi_view_ping_mouse (RofiViewState *state)
static gboolean xcb_rofi_view_reload_idle (G_GNUC_UNUSED gpointer data)
static void xcb_rofi_view_reload (void)
static void xcb_rofi_view_setup_fake_transparency (widget *win, const char *const fake_background)
static void xcb___create_window (MenuFlags menu_flags)
static void xcb_rofi_view_calculate_window_width (RofiViewState *state)
static void xcb_rofi_view_temp_configure_notify (RofiViewState *state, xcb_configure_notify_event_t *xce)
static void xcb_rofi_view_temp_click_to_exit (RofiViewState *state, xcb_window_t target)
static void xcb_rofi_view_frame_callback (void)
static void xcb_rofi_view_hide (void)
static void xcb_rofi_view_cleanup (void)
static xcb_window_t xcb_rofi_view_get_window (void)

Variables

GThreadPool * tpool
struct { 
   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 
   workarea   mon 
   guint   idle_timeout 
   unsigned long long   count 
   guint   repaint_source 
   gboolean   fullscreen 
   X11CursorType   cursor_type 
XcbState
gboolean do_bench = TRUE
struct { 
   GTimer *   time 
   uint64_t   draws 
   double   last_ts 
   double   min 
BenchMark = {.time = NULL, .draws = 0, .last_ts = 0.0, .min = G_MAXDOUBLE}
static const int loc_transtable [9]
static view_proxy view_
const view_proxyxcb_view_proxy = &view_

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "View"

The Rofi View log domain

Definition at line 29 of file view.c.

◆ SN_API_NOT_YET_FROZEN

#define SN_API_NOT_YET_FROZEN

Indicated we understand the startup notification api is not yet stable.

Definition at line 55 of file view.c.

Function Documentation

◆ bench_update()

gboolean bench_update ( void )
static

Definition at line 168 of file view.c.

References BenchMark, and config.

Referenced by xcb_rofi_view_repaint().

Here is the caller graph for this function:

◆ rofi_cursor_type_to_x11_cursor_type()

X11CursorType rofi_cursor_type_to_x11_cursor_type ( RofiCursorType type)
static

Definition at line 396 of file view.c.

References CURSOR_DEFAULT, CURSOR_POINTER, CURSOR_TEXT, ROFI_CURSOR_DEFAULT, ROFI_CURSOR_POINTER, and ROFI_CURSOR_TEXT.

Referenced by xcb_rofi_view_set_cursor().

Here is the caller graph for this function:

◆ xcb___create_window()

◆ xcb_rofi_view_calculate_window_height()

int xcb_rofi_view_calculate_window_height ( RofiViewState * state)
static

◆ xcb_rofi_view_calculate_window_position()

◆ xcb_rofi_view_calculate_window_width()

void xcb_rofi_view_calculate_window_width ( RofiViewState * state)
static
Parameters
stateInternal state of the menu.

Calculate the width of the window and the width of an element.

Definition at line 789 of file view.c.

References DEFAULT_MENU_WIDTH, distance_get_pixel(), RofiViewState::main_window, ROFI_ORIENTATION_HORIZONTAL, rofi_theme_get_distance(), WIDGET, RofiViewState::width, and XcbState.

Here is the call graph for this function:

◆ xcb_rofi_view_cleanup()

void xcb_rofi_view_cleanup ( void )
static

Definition at line 885 of file view.c.

References CacheState, input_history_save(), map, xcb, xcb_stuff_set_clipboard(), XCB_WINDOW_NONE, and XcbState.

Here is the call graph for this function:

◆ xcb_rofi_view_frame_callback()

void xcb_rofi_view_frame_callback ( void )
static

Definition at line 851 of file view.c.

References xcb_rofi_view_repaint(), and XcbState.

Here is the call graph for this function:

◆ xcb_rofi_view_get_current_monitor()

void xcb_rofi_view_get_current_monitor ( int * width,
int * height )
static

Definition at line 139 of file view.c.

References XcbState.

◆ xcb_rofi_view_get_window()

xcb_window_t xcb_rofi_view_get_window ( void )
static

Definition at line 939 of file view.c.

References CacheState.

◆ xcb_rofi_view_hide()

void xcb_rofi_view_hide ( void )
static

Definition at line 877 of file view.c.

References CacheState, display_early_cleanup(), display_revert_input_focus(), xcb, and XCB_WINDOW_NONE.

Here is the call graph for this function:

◆ xcb_rofi_view_ping_mouse()

void xcb_rofi_view_ping_mouse ( RofiViewState * state)
static

Definition at line 423 of file view.c.

References CacheState, config, rofi_view_handle_mouse_motion(), and xcb.

Here is the call graph for this function:

◆ xcb_rofi_view_queue_redraw()

void xcb_rofi_view_queue_redraw ( void )
static

Definition at line 464 of file view.c.

References rofi_view_get_active(), xcb_rofi_view_repaint(), and XcbState.

Referenced by xcb_rofi_view_reload_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xcb_rofi_view_reload()

void xcb_rofi_view_reload ( void )
static

Definition at line 457 of file view.c.

References xcb_rofi_view_reload_idle(), and XcbState.

Here is the call graph for this function:

◆ xcb_rofi_view_reload_idle()

gboolean xcb_rofi_view_reload_idle ( G_GNUC_UNUSED gpointer data)
static

Definition at line 439 of file view.c.

References mode_get_num_entries(), RofiViewState::refilter, RofiViewState::reload, rofi_view_get_active(), RofiViewState::sw, RofiViewState::tb_total_rows, textbox_text(), xcb_rofi_view_queue_redraw(), and XcbState.

Referenced by xcb_rofi_view_reload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xcb_rofi_view_repaint()

gboolean xcb_rofi_view_repaint ( G_GNUC_UNUSED void * data)
static

Definition at line 192 of file view.c.

References bench_update(), CacheState, RofiViewState::height, rofi_view_get_active(), rofi_view_update(), TICK_N, RofiViewState::width, xcb, and XcbState.

Referenced by xcb_rofi_view_frame_callback(), and xcb_rofi_view_queue_redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xcb_rofi_view_set_cursor()

void xcb_rofi_view_set_cursor ( RofiCursorType type)
static

Definition at line 411 of file view.c.

References CacheState, rofi_cursor_type_to_x11_cursor_type(), x11_set_cursor(), and XcbState.

Here is the call graph for this function:

◆ xcb_rofi_view_set_window_title()

void xcb_rofi_view_set_window_title ( const char * title)
static

Definition at line 943 of file view.c.

References CacheState, and xcb.

Referenced by xcb___create_window().

Here is the caller graph for this function:

◆ xcb_rofi_view_setup_fake_transparency()

void xcb_rofi_view_setup_fake_transparency ( widget * win,
const char *const fake_background )
static

Select Background to use for fake transparency. Current options: 'real', 'screenshot','background'

Definition at line 476 of file view.c.

References cairo_image_surface_blur(), rofi_expand_path(), rofi_theme_get_integer(), TICK_N, WIDGET, x11_helper_get_bg_surface(), x11_helper_get_screenshot_surface(), and XcbState.

Referenced by xcb___create_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xcb_rofi_view_temp_click_to_exit()

void xcb_rofi_view_temp_click_to_exit ( RofiViewState * state,
xcb_window_t target )
static

Quit rofi on click (outside of view )

Definition at line 841 of file view.c.

References CacheState, MENU_CANCEL, MENU_NORMAL_WINDOW, RofiViewState::quit, and RofiViewState::retv.

◆ xcb_rofi_view_temp_configure_notify()

void xcb_rofi_view_temp_configure_notify ( RofiViewState * state,
xcb_configure_notify_event_t * xce )
static

Handle window configure event. Handles resizes.

Definition at line 807 of file view.c.

References CacheState, depth, RofiViewState::height, RofiViewState::main_window, visual, WIDGET, widget_queue_redraw(), widget_resize(), RofiViewState::width, RofiViewState::x, xcb, XcbState, and RofiViewState::y.

Here is the call graph for this function:

◆ xcb_rofi_view_update()

void xcb_rofi_view_update ( RofiViewState * state,
gboolean qr )
static
Parameters
stateThe handle to the view
qrIndicate if queue_redraw should be called on changes.

Update the state of the view. This involves filter state.

Definition at line 218 of file view.c.

References config, RofiViewState::main_window, rofi_set_im_window_pos(), rofi_view_queue_redraw(), RofiViewState::text, textbox_get_cursor_x_pos(), TICK, TICK_N, WIDGET, textbox::widget, widget_draw(), widget_get_height(), widget_get_x_pos(), widget_get_y_pos(), widget_need_redraw(), RofiViewState::x, XcbState, and RofiViewState::y.

Here is the call graph for this function:

◆ xcb_rofi_view_window_update_size()

void xcb_rofi_view_window_update_size ( RofiViewState * state)
static

Definition at line 367 of file view.c.

References CacheState, depth, RofiViewState::height, RofiViewState::main_window, visual, WIDGET, widget_resize(), RofiViewState::width, RofiViewState::x, xcb, XcbState, and RofiViewState::y.

Here is the call graph for this function:

Variable Documentation

◆ [struct]

struct { ... } BenchMark

Internal structure that hold benchmarking information.

Referenced by bench_update().

◆ count

unsigned long long count

debug counter for redraws

Definition at line 121 of file view.c.

◆ cursor_type

X11CursorType cursor_type

Cursor type

Definition at line 127 of file view.c.

Referenced by rofi_view_handle_mouse_motion().

◆ do_bench

gboolean do_bench = TRUE

Code used for benchmarking drawing the gui, this will keep updating the UI as fast as possible.

Definition at line 152 of file view.c.

◆ draws

uint64_t draws

number of draws done.

Definition at line 161 of file view.c.

◆ edit_draw

cairo_t* edit_draw

Drawable context for edit_surf

Definition at line 113 of file view.c.

◆ edit_pixmap

xcb_pixmap_t edit_pixmap

Main X11 side pixmap to draw on.

Definition at line 109 of file view.c.

◆ edit_surf

cairo_surface_t* edit_surf

Cairo Surface for edit_pixmap

Definition at line 111 of file view.c.

◆ fake_bg

cairo_surface_t* fake_bg

surface containing the fake background.

Definition at line 105 of file view.c.

◆ fake_bgrel

int fake_bgrel

Indicate that fake background should be drawn relative to the window

Definition at line 115 of file view.c.

◆ fullscreen

gboolean fullscreen

Window fullscreen

Definition at line 125 of file view.c.

◆ gc

xcb_gcontext_t gc

Draw context for main window

Definition at line 107 of file view.c.

◆ idle_timeout

guint idle_timeout

timeout for reloading

Definition at line 119 of file view.c.

◆ last_ts

double last_ts

previous timestamp

Definition at line 163 of file view.c.

◆ loc_transtable

const int loc_transtable[9]
static
Initial value:

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 276 of file view.c.

◆ min

double min

minimum draw time.

Definition at line 165 of file view.c.

◆ mon

◆ repaint_source

guint repaint_source

redraw idle time.

Definition at line 123 of file view.c.

◆ time

◆ tpool

GThreadPool* tpool
extern

Thread pool used for filtering

Definition at line 70 of file view.c.

◆ view_

view_proxy view_
static
Initial value:
= {
.temp_configure_notify = xcb_rofi_view_temp_configure_notify,
.temp_click_to_exit = xcb_rofi_view_temp_click_to_exit,
.frame_callback = xcb_rofi_view_frame_callback,
.queue_redraw = xcb_rofi_view_queue_redraw,
.set_window_title = xcb_rofi_view_set_window_title,
.calculate_window_position = xcb_rofi_view_calculate_window_position,
.calculate_window_width = xcb_rofi_view_calculate_window_width,
.calculate_window_height = xcb_rofi_view_calculate_window_height,
.window_update_size = xcb_rofi_view_window_update_size,
.set_cursor = xcb_rofi_view_set_cursor,
.ping_mouse = xcb_rofi_view_ping_mouse,
.__create_window = xcb___create_window,
.get_window = xcb_rofi_view_get_window,
.get_current_monitor = xcb_rofi_view_get_current_monitor,
.set_size = NULL,
.get_size = NULL,
}
static void xcb_rofi_view_get_current_monitor(int *width, int *height)
Definition view.c:139
static void xcb_rofi_view_temp_configure_notify(RofiViewState *state, xcb_configure_notify_event_t *xce)
Definition view.c:807
static void xcb_rofi_view_calculate_window_width(RofiViewState *state)
Definition view.c:789
static void xcb___create_window(MenuFlags menu_flags)
Definition view.c:608
static void xcb_rofi_view_window_update_size(RofiViewState *state)
Definition view.c:367
static void xcb_rofi_view_set_window_title(const char *title)
Definition view.c:943
static void xcb_rofi_view_update(RofiViewState *state, gboolean qr)
Definition view.c:218
static void xcb_rofi_view_cleanup(void)
Definition view.c:885
static void xcb_rofi_view_set_cursor(RofiCursorType type)
Definition view.c:411
static void xcb_rofi_view_calculate_window_position(RofiViewState *state)
Definition view.c:280
static int xcb_rofi_view_calculate_window_height(RofiViewState *state)
Definition view.c:860
static void xcb_rofi_view_reload(void)
Definition view.c:457
static void xcb_rofi_view_frame_callback(void)
Definition view.c:851
static xcb_window_t xcb_rofi_view_get_window(void)
Definition view.c:939
static void xcb_rofi_view_temp_click_to_exit(RofiViewState *state, xcb_window_t target)
Definition view.c:841
static void xcb_rofi_view_ping_mouse(RofiViewState *state)
Definition view.c:423
static void xcb_rofi_view_queue_redraw(void)
Definition view.c:464
static void xcb_rofi_view_hide(void)
Definition view.c:877

Definition at line 953 of file view.c.

◆ [struct]