rofi 2.1.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.

Data Structures

struct  [struct].XcbState
struct  [struct].BenchMark

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
static struct  XcbState
gboolean do_bench = TRUE
static struct  BenchMark = {.time = NULL, .draws = 0, .last_ts = 0.0, .min = G_MAXDOUBLE}
static const int loc_transtable [9]
static view_proxy view_
const view_proxy * xcb_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 bench_update(), BenchMark, Settings::benchmark_ui, and config.

Referenced by bench_update(), and xcb_rofi_view_repaint().

Here is the call graph for this function:
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 395 of file view.c.

References CURSOR_DEFAULT, CURSOR_POINTER, CURSOR_TEXT, ROFI_CURSOR_DEFAULT, ROFI_CURSOR_POINTER, ROFI_CURSOR_TEXT, and rofi_cursor_type_to_x11_cursor_type().

Referenced by rofi_cursor_type_to_x11_cursor_type(), and xcb_rofi_view_set_cursor().

Here is the call graph for this function:
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

Definition at line 883 of file view.c.

References distance_get_pixel(), RofiViewState::main_window, ROFI_ORIENTATION_VERTICAL, rofi_theme_get_distance(), WIDGET, widget_get_desired_height(), RofiViewState::width, xcb_rofi_view_calculate_window_height(), and XcbState.

Referenced by xcb_rofi_view_calculate_window_height().

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

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

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

Referenced by xcb_rofi_view_calculate_window_width().

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

◆ xcb_rofi_view_cleanup()

◆ xcb_rofi_view_frame_callback()

void xcb_rofi_view_frame_callback ( void )
static

Definition at line 874 of file view.c.

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

Referenced by xcb_rofi_view_frame_callback().

Here is the call graph for this function:
Here is the caller 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 xcb_rofi_view_get_current_monitor(), and XcbState.

Referenced by xcb_rofi_view_get_current_monitor().

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

◆ xcb_rofi_view_get_window()

xcb_window_t xcb_rofi_view_get_window ( void )
static

Definition at line 962 of file view.c.

References CacheState, _rofi_view_cache_state::main_window, and xcb_rofi_view_get_window().

Referenced by xcb_rofi_view_get_window().

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

◆ xcb_rofi_view_hide()

void xcb_rofi_view_hide ( void )
static

Definition at line 900 of file view.c.

References CacheState, _xcb_stuff::connection, display_early_cleanup(), display_revert_input_focus(), _rofi_view_cache_state::main_window, xcb, xcb_rofi_view_hide(), and XCB_WINDOW_NONE.

Referenced by xcb_rofi_view_hide().

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

◆ xcb_rofi_view_ping_mouse()

void xcb_rofi_view_ping_mouse ( RofiViewState * state)
static

Definition at line 422 of file view.c.

References CacheState, config, _xcb_stuff::connection, Settings::hover_select, _rofi_view_cache_state::main_window, rofi_view_handle_mouse_motion(), xcb, and xcb_rofi_view_ping_mouse().

Referenced by xcb_rofi_view_ping_mouse().

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

◆ xcb_rofi_view_queue_redraw()

void xcb_rofi_view_queue_redraw ( void )
static

Definition at line 466 of file view.c.

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

Referenced by xcb_rofi_view_queue_redraw(), and 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 459 of file view.c.

References xcb_rofi_view_reload(), xcb_rofi_view_reload_idle(), 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_reload_idle()

gboolean xcb_rofi_view_reload_idle ( G_GNUC_UNUSED gpointer data)
static

◆ xcb_rofi_view_repaint()

gboolean xcb_rofi_view_repaint ( G_GNUC_UNUSED void * data)
static

◆ xcb_rofi_view_set_cursor()

void xcb_rofi_view_set_cursor ( RofiCursorType type)
static

Definition at line 410 of file view.c.

References CacheState, _rofi_view_cache_state::main_window, rofi_cursor_type_to_x11_cursor_type(), x11_set_cursor(), xcb_rofi_view_set_cursor(), and XcbState.

Referenced by xcb_rofi_view_set_cursor().

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

◆ xcb_rofi_view_set_window_title()

void xcb_rofi_view_set_window_title ( const char * title)
static

Definition at line 966 of file view.c.

References CacheState, _xcb_stuff::connection, _xcb_stuff::ewmh, _rofi_view_cache_state::main_window, xcb, and xcb_rofi_view_set_window_title().

Referenced by xcb___create_window(), and xcb_rofi_view_set_window_title().

Here is the call graph for this function:
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 478 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(), xcb_rofi_view_setup_fake_transparency(), and XcbState.

Referenced by xcb___create_window(), and xcb_rofi_view_setup_fake_transparency().

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

References CacheState, _rofi_view_cache_state::flags, _rofi_view_cache_state::main_window, MENU_CANCEL, MENU_NORMAL_WINDOW, RofiViewState::quit, RofiViewState::retv, and xcb_rofi_view_temp_click_to_exit().

Referenced by xcb_rofi_view_temp_click_to_exit().

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

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

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

Referenced by xcb_rofi_view_temp_configure_notify().

Here is the call graph for this function:
Here is the caller 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, Settings::enable_imdkit, 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, xcb_rofi_view_update(), XcbState, and RofiViewState::y.

Referenced by xcb_rofi_view_update().

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

◆ xcb_rofi_view_window_update_size()

void xcb_rofi_view_window_update_size ( RofiViewState * state)
static

Variable Documentation

◆ BenchMark

struct [struct].BenchMark BenchMark

Referenced by bench_update().

◆ 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.

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

◆ 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:830
static void xcb_rofi_view_calculate_window_width(RofiViewState *state)
Definition view.c:812
static void xcb___create_window(MenuFlags menu_flags)
Definition view.c:610
static void xcb_rofi_view_window_update_size(RofiViewState *state)
Definition view.c:366
static void xcb_rofi_view_set_window_title(const char *title)
Definition view.c:966
static void xcb_rofi_view_update(RofiViewState *state, gboolean qr)
Definition view.c:218
static void xcb_rofi_view_cleanup(void)
Definition view.c:908
static void xcb_rofi_view_set_cursor(RofiCursorType type)
Definition view.c:410
static void xcb_rofi_view_calculate_window_position(RofiViewState *state)
Definition view.c:279
static int xcb_rofi_view_calculate_window_height(RofiViewState *state)
Definition view.c:883
static void xcb_rofi_view_reload(void)
Definition view.c:459
static void xcb_rofi_view_frame_callback(void)
Definition view.c:874
static xcb_window_t xcb_rofi_view_get_window(void)
Definition view.c:962
static void xcb_rofi_view_temp_click_to_exit(RofiViewState *state, xcb_window_t target)
Definition view.c:864
static void xcb_rofi_view_ping_mouse(RofiViewState *state)
Definition view.c:422
static void xcb_rofi_view_queue_redraw(void)
Definition view.c:466
static void xcb_rofi_view_hide(void)
Definition view.c:900

Definition at line 976 of file view.c.

◆ XcbState