mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Indent the code.
This commit is contained in:
parent
4631ac711f
commit
859a9c79d6
21 changed files with 420 additions and 432 deletions
|
@ -41,13 +41,13 @@ Settings config = {
|
|||
.modi = "run,ssh",
|
||||
#endif
|
||||
/** Border width around the window. */
|
||||
.menu_bw = 1,
|
||||
.menu_bw = 1,
|
||||
/** The width of the switcher. (0100 in % > 100 in pixels) */
|
||||
.menu_width = 50,
|
||||
.menu_width = 50,
|
||||
/** Maximum number of options to show. */
|
||||
.menu_lines = 15,
|
||||
.menu_lines = 15,
|
||||
/** Number of columns */
|
||||
.menu_columns = 1,
|
||||
.menu_columns = 1,
|
||||
/** Font */
|
||||
.menu_font = "mono 12",
|
||||
|
||||
|
@ -68,7 +68,7 @@ Settings config = {
|
|||
/** Command executed on accep-entry-custom for window modus */
|
||||
.window_command = "xkill -id {window}",
|
||||
/** No default icon theme, we search Adwaita and gnome as fallback */
|
||||
.icon_theme = NULL,
|
||||
.icon_theme = NULL,
|
||||
/**
|
||||
* Location of the window.
|
||||
* Enumeration indicating location or gravity of window.
|
||||
|
@ -82,11 +82,11 @@ Settings config = {
|
|||
*/
|
||||
.location = WL_CENTER,
|
||||
/** Padding between elements */
|
||||
.padding = 5,
|
||||
.padding = 5,
|
||||
/** Y offset */
|
||||
.y_offset = 0,
|
||||
.y_offset = 0,
|
||||
/** X offset */
|
||||
.x_offset = 0,
|
||||
.x_offset = 0,
|
||||
/** Always show config.menu_lines lines, even if less lines are available */
|
||||
.fixed_num_lines = TRUE,
|
||||
/** Do not use history */
|
||||
|
@ -100,7 +100,7 @@ Settings config = {
|
|||
/** Cycle through in the element list */
|
||||
.cycle = TRUE,
|
||||
/** Height of an element in #chars */
|
||||
.element_height = 1,
|
||||
.element_height = 1,
|
||||
/** Sidebar mode, show the modi */
|
||||
.sidebar_mode = FALSE,
|
||||
/** auto select */
|
||||
|
@ -124,8 +124,8 @@ Settings config = {
|
|||
/** Monitor */
|
||||
.monitor = "-5",
|
||||
/** set line margin */
|
||||
.line_margin = 2,
|
||||
.line_padding = 1,
|
||||
.line_margin = 2,
|
||||
.line_padding = 1,
|
||||
/** Set filter */
|
||||
.filter = NULL,
|
||||
/** Separator style: dash/solid */
|
||||
|
@ -134,10 +134,10 @@ Settings config = {
|
|||
.hide_scrollbar = FALSE,
|
||||
.fullscreen = FALSE,
|
||||
.fake_transparency = FALSE,
|
||||
.dpi = -1,
|
||||
.threads = 0,
|
||||
.scroll_method = 0,
|
||||
.scrollbar_width = 8,
|
||||
.dpi = -1,
|
||||
.threads = 0,
|
||||
.scroll_method = 0,
|
||||
.scrollbar_width = 8,
|
||||
.fake_background = "screenshot",
|
||||
.window_format = "{w} {i}{c} {t}",
|
||||
.click_to_exit = TRUE,
|
||||
|
@ -148,6 +148,6 @@ Settings config = {
|
|||
.color_urgent = NULL,
|
||||
.color_window = NULL,
|
||||
.plugin_path = PLUGIN_PATH,
|
||||
.max_history_size = 25,
|
||||
.max_history_size = 25,
|
||||
.combi_hide_mode_prefix = FALSE,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ typedef struct CSSColor
|
|||
/**
|
||||
* Array with all the named colors. Of type #CSSColor, there are #num_CSSColors items in this array.
|
||||
*/
|
||||
extern const CSSColor CSSColors[];
|
||||
extern const CSSColor CSSColors[];
|
||||
/**
|
||||
* Number of named colors.
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,6 @@ void rofi_icon_fetcher_init ( void );
|
|||
*/
|
||||
void rofi_icon_fetcher_destroy ( void );
|
||||
|
||||
|
||||
/**
|
||||
* @param name The name of the icon to fetch.
|
||||
* @param size The size of the icon to fetch.
|
||||
|
@ -37,7 +36,6 @@ void rofi_icon_fetcher_destroy ( void );
|
|||
*/
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size );
|
||||
|
||||
|
||||
/**
|
||||
* @param uid The unique id representing the matching request.
|
||||
*
|
||||
|
|
|
@ -45,8 +45,8 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SORT_NORMAL = 0,
|
||||
SORT_FZF = 1
|
||||
SORT_NORMAL = 0,
|
||||
SORT_FZF = 1
|
||||
} SortingMethod;
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,14 +78,14 @@ typedef struct
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_ICON = 1 << 24,
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
TB_AUTOWIDTH = 1 << 1,
|
||||
TB_EDITABLE = 1 << 19,
|
||||
TB_MARKUP = 1 << 20,
|
||||
TB_WRAP = 1 << 21,
|
||||
TB_PASSWORD = 1 << 22,
|
||||
TB_INDICATOR = 1 << 23,
|
||||
TB_ICON = 1 << 24,
|
||||
} TextboxFlags;
|
||||
/**
|
||||
* Flags indicating current state of the textbox.
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
|
||||
char *DRUN_GROUP_NAME = "Desktop Entry";
|
||||
|
||||
|
||||
typedef struct _DRunModePrivateData DRunModePrivateData;
|
||||
/**
|
||||
* Store extra information about the entry.
|
||||
|
@ -67,20 +66,20 @@ typedef struct _DRunModePrivateData DRunModePrivateData;
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
thread_state st;
|
||||
thread_state st;
|
||||
DRunModePrivateData *pd;
|
||||
/* category */
|
||||
char *action;
|
||||
char *action;
|
||||
/* Root */
|
||||
char *root;
|
||||
char *root;
|
||||
/* Path to desktop file */
|
||||
char *path;
|
||||
char *path;
|
||||
/* Application id (.desktop filename) */
|
||||
char *app_id;
|
||||
char *app_id;
|
||||
/* Desktop id */
|
||||
char *desktop_id;
|
||||
char *desktop_id;
|
||||
/* Icon stuff */
|
||||
char *icon_name;
|
||||
char *icon_name;
|
||||
/* Icon size is used to indicate what size is requested by the gui.
|
||||
* secondary it indicates if the request for a lookup has been issued (0 not issued )
|
||||
*/
|
||||
|
@ -131,18 +130,18 @@ static DRunEntryField matching_entry_fields[DRUN_MATCH_NUM_FIELDS] = {
|
|||
|
||||
struct _DRunModePrivateData
|
||||
{
|
||||
DRunModeEntry *entry_list;
|
||||
unsigned int cmd_list_length;
|
||||
unsigned int cmd_list_length_actual;
|
||||
DRunModeEntry *entry_list;
|
||||
unsigned int cmd_list_length;
|
||||
unsigned int cmd_list_length_actual;
|
||||
// List of disabled entries.
|
||||
GHashTable *disabled_entries;
|
||||
unsigned int disabled_entries_length;
|
||||
unsigned int expected_line_height;
|
||||
GHashTable *disabled_entries;
|
||||
unsigned int disabled_entries_length;
|
||||
unsigned int expected_line_height;
|
||||
|
||||
// Theme
|
||||
const gchar *icon_theme;
|
||||
const gchar *icon_theme;
|
||||
// DE
|
||||
gchar **current_desktop_list;
|
||||
gchar **current_desktop_list;
|
||||
};
|
||||
|
||||
struct RegexEvalArg
|
||||
|
@ -412,21 +411,21 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
|
|||
else {
|
||||
pd->entry_list[pd->cmd_list_length].sort_index = -pd->cmd_list_length;
|
||||
}
|
||||
pd->entry_list[pd->cmd_list_length].icon_size = 0;
|
||||
pd->entry_list[pd->cmd_list_length].icon_size = 0;
|
||||
pd->entry_list[pd->cmd_list_length].icon_fetch_uid = 0;
|
||||
pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
|
||||
pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
|
||||
pd->entry_list[pd->cmd_list_length].desktop_id = g_strdup ( id );
|
||||
pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) );
|
||||
pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
|
||||
pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
|
||||
pd->entry_list[pd->cmd_list_length].desktop_id = g_strdup ( id );
|
||||
pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) );
|
||||
gchar *n = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "Name", NULL, NULL );
|
||||
|
||||
if ( action != DRUN_GROUP_NAME ){
|
||||
if ( action != DRUN_GROUP_NAME ) {
|
||||
gchar *na = g_key_file_get_locale_string ( kf, action, "Name", NULL, NULL );
|
||||
gchar *l = g_strdup_printf("%s - %s", n, na);
|
||||
g_free(n);
|
||||
gchar *l = g_strdup_printf ( "%s - %s", n, na );
|
||||
g_free ( n );
|
||||
n = l;
|
||||
}
|
||||
pd->entry_list[pd->cmd_list_length].name = n;
|
||||
pd->entry_list[pd->cmd_list_length].name = n;
|
||||
pd->entry_list[pd->cmd_list_length].action = DRUN_GROUP_NAME;
|
||||
gchar *gn = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "GenericName", NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].generic_name = gn;
|
||||
|
@ -462,14 +461,14 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
|
|||
|
||||
if ( !parse_action ) {
|
||||
gsize actions_length = 0;
|
||||
char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL );
|
||||
for ( gsize iter = 0; iter < actions_length; iter++ ){
|
||||
char *new_action = g_strdup_printf("Desktop Action %s", actions[iter]);
|
||||
if (! read_desktop_file ( pd, root, path, basename, new_action ) ){
|
||||
char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL );
|
||||
for ( gsize iter = 0; iter < actions_length; iter++ ) {
|
||||
char *new_action = g_strdup_printf ( "Desktop Action %s", actions[iter] );
|
||||
if ( !read_desktop_file ( pd, root, path, basename, new_action ) ) {
|
||||
g_free ( new_action );
|
||||
}
|
||||
}
|
||||
g_strfreev(actions);
|
||||
g_strfreev ( actions );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -618,7 +617,6 @@ static void get_apps ( DRunModePrivateData *pd )
|
|||
TICK_N ( "Sorting done." );
|
||||
}
|
||||
|
||||
|
||||
static void drun_mode_parse_entry_fields ()
|
||||
{
|
||||
char *savept = NULL;
|
||||
|
@ -660,7 +658,7 @@ static int drun_mode_init ( Mode *sw )
|
|||
if ( mode_get_private_data ( sw ) != NULL ) {
|
||||
return TRUE;
|
||||
}
|
||||
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
||||
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
||||
pd->disabled_entries = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL );
|
||||
mode_set_private_data ( sw, (void *) pd );
|
||||
// current destkop
|
||||
|
@ -772,8 +770,10 @@ static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line,
|
|||
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
||||
g_return_val_if_fail ( pd->entry_list != NULL, NULL );
|
||||
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
|
||||
if ( dr->icon_name == NULL ) return NULL;
|
||||
if ( dr->icon_fetch_uid >0){
|
||||
if ( dr->icon_name == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
if ( dr->icon_fetch_uid > 0 ) {
|
||||
return rofi_icon_fetcher_get ( dr->icon_fetch_uid );
|
||||
}
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->icon_name, height );
|
||||
|
|
|
@ -79,7 +79,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
|
|||
char *value = line + length_key + 1;
|
||||
if ( strcasecmp ( line, "message" ) == 0 ) {
|
||||
g_free ( pd->message );
|
||||
pd->message = strlen(value)? g_strdup ( value ):NULL;
|
||||
pd->message = strlen ( value ) ? g_strdup ( value ) : NULL;
|
||||
}
|
||||
else if ( strcasecmp ( line, "prompt" ) == 0 ) {
|
||||
g_free ( pd->prompt );
|
||||
|
@ -100,11 +100,11 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
|
|||
|
||||
static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length )
|
||||
{
|
||||
int fd = -1;
|
||||
GError *error = NULL;
|
||||
char **retv = NULL;
|
||||
char **argv = NULL;
|
||||
int argc = 0;
|
||||
int fd = -1;
|
||||
GError *error = NULL;
|
||||
char **retv = NULL;
|
||||
char **argv = NULL;
|
||||
int argc = 0;
|
||||
*length = 0;
|
||||
if ( g_shell_parse_argv ( command, &argc, &argv, &error ) ) {
|
||||
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
|
||||
|
@ -126,7 +126,7 @@ static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned i
|
|||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
ssize_t read_length = 0;
|
||||
size_t actual_size = 0;
|
||||
size_t actual_size = 0;
|
||||
while ( ( read_length = getline ( &buffer, &buffer_length, inp ) ) > 0 ) {
|
||||
// Filter out line-end.
|
||||
if ( buffer[read_length - 1] == '\n' ) {
|
||||
|
@ -190,15 +190,14 @@ static unsigned int script_mode_get_num_entries ( const Mode *sw )
|
|||
|
||||
static void script_mode_reset_highlight ( Mode *sw )
|
||||
{
|
||||
ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data;
|
||||
ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data;
|
||||
|
||||
rmpd->num_urgent_list = 0;
|
||||
g_free ( rmpd->urgent_list );
|
||||
rmpd->urgent_list = NULL;
|
||||
rmpd->urgent_list = NULL;
|
||||
rmpd->num_active_list = 0;
|
||||
g_free ( rmpd->active_list );
|
||||
rmpd->active_list = NULL;
|
||||
|
||||
}
|
||||
|
||||
static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
|
||||
|
|
|
@ -487,7 +487,6 @@ static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned in
|
|||
return retv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param sw Object handle to the SSH Mode object
|
||||
* @param selected_line The line to view
|
||||
|
|
|
@ -914,12 +914,11 @@ static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line,
|
|||
c->icon = get_net_wm_icon ( rmpd->ids->array[selected_line], size );
|
||||
c->icon_checked = TRUE;
|
||||
}
|
||||
if ( c->icon == NULL && c->class ){
|
||||
if ( c->icon_fetch_uid > 0){
|
||||
if ( c->icon == NULL && c->class ) {
|
||||
if ( c->icon_fetch_uid > 0 ) {
|
||||
return rofi_icon_fetcher_get ( c->icon_fetch_uid );
|
||||
}
|
||||
c->icon_fetch_uid = rofi_icon_fetcher_query ( c->class, size);
|
||||
|
||||
c->icon_fetch_uid = rofi_icon_fetcher_query ( c->class, size );
|
||||
}
|
||||
return c->icon;
|
||||
}
|
||||
|
|
|
@ -587,7 +587,8 @@ int config_sanity_check ( void )
|
|||
}
|
||||
else if ( g_strcmp0 ( config.sorting_method, "fzf" ) == 0 ) {
|
||||
config.sorting_method_enum = SORT_FZF;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
g_string_append_printf ( msg, "\t<b>config.sorting_method</b>=%s is not a valid sorting strategy.\nValid options are: normal or fzf.\n",
|
||||
config.sorting_method );
|
||||
found_error = 1;
|
||||
|
|
|
@ -113,7 +113,7 @@ static char ** __history_get_element_list_fields ( FILE *fd, unsigned int *lengt
|
|||
|
||||
( *length )++;
|
||||
}
|
||||
if ( buffer_length > 0 ){
|
||||
if ( buffer_length > 0 ) {
|
||||
g_free ( buffer );
|
||||
}
|
||||
return retv;
|
||||
|
|
|
@ -112,14 +112,14 @@ ActionBindingEntry rofi_bindings[] =
|
|||
|
||||
/* Mouse-aware bindings */
|
||||
|
||||
{ .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" },
|
||||
{ .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" },
|
||||
{ .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" },
|
||||
{ .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" },
|
||||
{ .id = SCROLL_LEFT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-left", .binding = "ScrollLeft", .comment = "Go to the previous column" },
|
||||
{ .id = SCROLL_RIGHT, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-right", .binding = "ScrollRight", .comment = "Go to the next column" },
|
||||
{ .id = SCROLL_UP, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-up", .binding = "ScrollUp", .comment = "Select previous entry" },
|
||||
{ .id = SCROLL_DOWN, .scope = SCOPE_MOUSE_LISTVIEW, .name = "ml-row-down", .binding = "ScrollDown", .comment = "Select next entry" },
|
||||
|
||||
{ .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action" },
|
||||
{ .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-entry", .binding = "MouseDPrimary", .comment = "Accept hovered row" },
|
||||
{ .id = ACCEPT_HOVERED_CUSTOM, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-accept-custom", .binding = "Control+MouseDPrimary", .comment = "Accept hovered row with custom action"},
|
||||
};
|
||||
|
||||
/** Default binding of mouse button to action. */
|
||||
|
|
|
@ -39,36 +39,36 @@
|
|||
|
||||
#include "nkutils-xdg-theme.h"
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
// Context for icon-themes.
|
||||
NkXdgThemeContext *xdg_context;
|
||||
|
||||
// On name.
|
||||
GHashTable *icon_cache;
|
||||
GHashTable *icon_cache;
|
||||
// On uid.
|
||||
GHashTable *icon_cache_uid;
|
||||
|
||||
uint32_t last_uid;
|
||||
|
||||
GHashTable *icon_cache_uid;
|
||||
|
||||
uint32_t last_uid;
|
||||
} IconFetcher;
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
GList *sizes;
|
||||
} IconFetcherNameEntry;
|
||||
|
||||
typedef struct {
|
||||
thread_state state;
|
||||
typedef struct
|
||||
{
|
||||
thread_state state;
|
||||
|
||||
GCond *cond;
|
||||
GMutex *mutex;
|
||||
unsigned int *acount;
|
||||
GCond *cond;
|
||||
GMutex *mutex;
|
||||
unsigned int *acount;
|
||||
|
||||
uint32_t uid;
|
||||
int size;
|
||||
cairo_surface_t *surface;
|
||||
uint32_t uid;
|
||||
int size;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
IconFetcherNameEntry *entry;
|
||||
} IconFetcherEntry;
|
||||
|
@ -78,17 +78,15 @@ typedef struct {
|
|||
*/
|
||||
IconFetcher *rofi_icon_fetcher_data = NULL;
|
||||
|
||||
|
||||
static void rofi_icon_fetch_entry_free ( gpointer data )
|
||||
{
|
||||
IconFetcherNameEntry *entry = (IconFetcherNameEntry*) data;
|
||||
IconFetcherNameEntry *entry = (IconFetcherNameEntry *) data;
|
||||
|
||||
// Free name/key.
|
||||
g_free ( entry->name );
|
||||
|
||||
|
||||
for ( GList *iter = g_list_first ( entry->sizes ); iter; iter = g_list_next ( iter ) ) {
|
||||
IconFetcherEntry *sentry = (IconFetcherEntry *)(iter->data);
|
||||
IconFetcherEntry *sentry = (IconFetcherEntry *) ( iter->data );
|
||||
|
||||
cairo_surface_destroy ( sentry->surface );
|
||||
g_free ( sentry );
|
||||
|
@ -98,7 +96,6 @@ static void rofi_icon_fetch_entry_free ( gpointer data )
|
|||
g_free ( entry );
|
||||
}
|
||||
|
||||
|
||||
void rofi_icon_fetcher_init ( void )
|
||||
{
|
||||
g_assert ( rofi_icon_fetcher_data == NULL );
|
||||
|
@ -108,26 +105,25 @@ void rofi_icon_fetcher_init ( void )
|
|||
"gnome",
|
||||
NULL
|
||||
};
|
||||
const char *themes[2] = { config.icon_theme, NULL};
|
||||
const char *themes[2] = { config.icon_theme, NULL };
|
||||
|
||||
rofi_icon_fetcher_data = g_malloc0(sizeof(IconFetcher));
|
||||
rofi_icon_fetcher_data = g_malloc0 ( sizeof ( IconFetcher ) );
|
||||
|
||||
rofi_icon_fetcher_data->xdg_context = nk_xdg_theme_context_new ( icon_fallback_themes, NULL );
|
||||
nk_xdg_theme_preload_themes_icon ( rofi_icon_fetcher_data->xdg_context, themes );
|
||||
|
||||
|
||||
rofi_icon_fetcher_data->icon_cache_uid = g_hash_table_new ( g_direct_hash, g_direct_equal );
|
||||
rofi_icon_fetcher_data->icon_cache = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, rofi_icon_fetch_entry_free );
|
||||
}
|
||||
|
||||
|
||||
void rofi_icon_fetcher_destroy ( void )
|
||||
{
|
||||
if ( rofi_icon_fetcher_data == NULL ) return;
|
||||
if ( rofi_icon_fetcher_data == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
nk_xdg_theme_context_free ( rofi_icon_fetcher_data->xdg_context );
|
||||
|
||||
|
||||
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache_uid );
|
||||
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache );
|
||||
|
||||
|
@ -138,14 +134,14 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
|||
g_debug ( "starting up icon fetching thread." );
|
||||
// as long as dr->icon is updated atomicly.. (is a pointer write atomic?)
|
||||
// this should be fine running in another thread.
|
||||
IconFetcherEntry *sentry = (IconFetcherEntry*) sdata;
|
||||
const gchar *themes[] = {
|
||||
IconFetcherEntry *sentry = (IconFetcherEntry *) sdata;
|
||||
const gchar *themes[] = {
|
||||
config.icon_theme,
|
||||
NULL
|
||||
};
|
||||
|
||||
const gchar *icon_path;
|
||||
gchar *icon_path_ = NULL;
|
||||
const gchar *icon_path;
|
||||
gchar *icon_path_ = NULL;
|
||||
|
||||
if ( g_path_is_absolute ( sentry->entry->name ) ) {
|
||||
icon_path = sentry->entry->name;
|
||||
|
@ -153,7 +149,7 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
|||
else {
|
||||
icon_path = icon_path_ = nk_xdg_theme_get_icon ( rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name, sentry->size, 1, TRUE );
|
||||
if ( icon_path_ == NULL ) {
|
||||
g_debug ( "failed to get icon %s(%d): n/a",sentry->entry->name, sentry->size );
|
||||
g_debug ( "failed to get icon %s(%d): n/a", sentry->entry->name, sentry->size );
|
||||
return;
|
||||
}
|
||||
else{
|
||||
|
@ -177,51 +173,49 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
|||
cairo_surface_destroy ( icon_surf );
|
||||
icon_surf = NULL;
|
||||
}
|
||||
sentry->surface= icon_surf;
|
||||
sentry->surface = icon_surf;
|
||||
}
|
||||
g_free ( icon_path_ );
|
||||
rofi_view_reload ();
|
||||
}
|
||||
|
||||
|
||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
||||
{
|
||||
g_debug ("Query: %s(%d)", name, size);
|
||||
g_debug ( "Query: %s(%d)", name, size );
|
||||
IconFetcherNameEntry *entry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache, name );
|
||||
if ( entry == NULL ) {
|
||||
entry = g_new0(IconFetcherNameEntry,1);
|
||||
entry->name = g_strdup(name);
|
||||
entry = g_new0 ( IconFetcherNameEntry, 1 );
|
||||
entry->name = g_strdup ( name );
|
||||
g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache, entry->name, entry );
|
||||
}
|
||||
IconFetcherEntry *sentry;
|
||||
for ( GList *iter = g_list_first(entry->sizes); iter; iter = g_list_next ( iter ) ) {
|
||||
for ( GList *iter = g_list_first ( entry->sizes ); iter; iter = g_list_next ( iter ) ) {
|
||||
sentry = iter->data;
|
||||
if ( sentry->size == size ){
|
||||
if ( sentry->size == size ) {
|
||||
return sentry->uid;
|
||||
}
|
||||
}
|
||||
|
||||
// Not found.
|
||||
sentry = g_new0(IconFetcherEntry, 1);
|
||||
sentry->uid = ++(rofi_icon_fetcher_data->last_uid);
|
||||
sentry->size = size;
|
||||
sentry->entry = entry;
|
||||
sentry = g_new0 ( IconFetcherEntry, 1 );
|
||||
sentry->uid = ++( rofi_icon_fetcher_data->last_uid );
|
||||
sentry->size = size;
|
||||
sentry->entry = entry;
|
||||
sentry->surface = NULL;
|
||||
|
||||
entry->sizes = g_list_prepend ( entry->sizes, sentry );
|
||||
g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER(sentry->uid), sentry );
|
||||
g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER ( sentry->uid ), sentry );
|
||||
|
||||
// Push into fetching queue.
|
||||
sentry->state.callback = rofi_icon_fetcher_worker;
|
||||
g_thread_pool_push ( tpool, sentry, NULL);
|
||||
g_thread_pool_push ( tpool, sentry, NULL );
|
||||
|
||||
return sentry->uid;
|
||||
}
|
||||
|
||||
|
||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t uid )
|
||||
{
|
||||
IconFetcherEntry *sentry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER(uid) );
|
||||
IconFetcherEntry *sentry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache_uid, GINT_TO_POINTER ( uid ) );
|
||||
if ( sentry ) {
|
||||
return sentry->surface;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
#include "mode-private.h"
|
||||
|
||||
/** Location of pidfile for this instance. */
|
||||
char *pidfile = NULL;
|
||||
char *pidfile = NULL;
|
||||
/** Location of Cache directory. */
|
||||
const char *cache_dir = NULL;
|
||||
|
||||
|
@ -92,7 +92,7 @@ void rofi_add_error_message ( GString *str )
|
|||
}
|
||||
|
||||
/** Path to the configuration file */
|
||||
G_MODULE_EXPORT char *config_path = NULL;
|
||||
G_MODULE_EXPORT char *config_path = NULL;
|
||||
/** Path to the configuration file in the new format */
|
||||
G_MODULE_EXPORT char *config_path_new = NULL;
|
||||
/** Array holding all activated modi. */
|
||||
|
@ -108,7 +108,7 @@ unsigned int num_modi = 0;
|
|||
unsigned int curr_switcher = 0;
|
||||
|
||||
/** Handle to NkBindings object for input devices. */
|
||||
NkBindings *bindings = NULL;
|
||||
NkBindings *bindings = NULL;
|
||||
|
||||
/** Glib main loop. */
|
||||
GMainLoop *main_loop = NULL;
|
||||
|
@ -858,7 +858,8 @@ int main ( int argc, char *argv[] )
|
|||
rofi_theme_free ( rofi_theme );
|
||||
rofi_theme = NULL;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
g_free ( config_path_new );
|
||||
config_path_new = NULL;
|
||||
config_parse_xresource_options_file ( config_path );
|
||||
|
|
|
@ -632,7 +632,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl
|
|||
return p->value.f;
|
||||
}
|
||||
// Fallback to integer if double is not found.
|
||||
p = rofi_theme_find_property ( wid, P_INTEGER, property, FALSE );
|
||||
p = rofi_theme_find_property ( wid, P_INTEGER, property, FALSE );
|
||||
if ( p ) {
|
||||
if ( p->type == P_INHERIT ) {
|
||||
if ( widget->parent ) {
|
||||
|
@ -640,7 +640,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl
|
|||
}
|
||||
return def;
|
||||
}
|
||||
return (double)p->value.i;
|
||||
return (double) p->value.i;
|
||||
}
|
||||
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||
return def;
|
||||
|
|
|
@ -126,9 +126,9 @@ struct
|
|||
.fake_bgrel = FALSE,
|
||||
.flags = MENU_NORMAL,
|
||||
.views = G_QUEUE_INIT,
|
||||
.idle_timeout = 0,
|
||||
.count = 0L,
|
||||
.repaint_source = 0,
|
||||
.idle_timeout = 0,
|
||||
.count = 0L,
|
||||
.repaint_source = 0,
|
||||
.fullscreen = FALSE,
|
||||
};
|
||||
|
||||
|
@ -559,14 +559,14 @@ static RofiViewState * __rofi_view_state_create ( void )
|
|||
typedef struct _thread_state_view
|
||||
{
|
||||
/** Generic thread state. */
|
||||
thread_state st;
|
||||
thread_state st;
|
||||
|
||||
/** Condition. */
|
||||
GCond *cond;
|
||||
GCond *cond;
|
||||
/** Lock for condition. */
|
||||
GMutex *mutex;
|
||||
GMutex *mutex;
|
||||
/** Count that is protected by lock. */
|
||||
unsigned int *acount;
|
||||
unsigned int *acount;
|
||||
|
||||
/** Current state. */
|
||||
RofiViewState *state;
|
||||
|
@ -581,7 +581,6 @@ typedef struct _thread_state_view
|
|||
const char *pattern;
|
||||
/** Length of pattern. */
|
||||
glong plen;
|
||||
|
||||
} thread_state_view;
|
||||
/**
|
||||
* @param data A thread_state object.
|
||||
|
@ -597,7 +596,7 @@ static void rofi_view_call_thread ( gpointer data, gpointer user_data )
|
|||
|
||||
static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data )
|
||||
{
|
||||
thread_state_view *t = (thread_state_view *)ts;
|
||||
thread_state_view *t = (thread_state_view *) ts;
|
||||
for ( unsigned int i = t->start; i < t->stop; i++ ) {
|
||||
int match = mode_token_match ( t->state->sw, t->state->tokens, i );
|
||||
// If each token was matched, add it to list.
|
||||
|
@ -609,13 +608,13 @@ static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data
|
|||
glong slen = g_utf8_strlen ( str, -1 );
|
||||
switch ( config.sorting_method_enum )
|
||||
{
|
||||
case SORT_FZF:
|
||||
t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( t->pattern, t->plen, str, slen );
|
||||
break;
|
||||
case SORT_NORMAL:
|
||||
default:
|
||||
t->state->distance[i] = levenshtein ( t->pattern, t->plen, str, slen );
|
||||
break;
|
||||
case SORT_FZF:
|
||||
t->state->distance[i] = rofi_scorer_fuzzy_evaluate ( t->pattern, t->plen, str, slen );
|
||||
break;
|
||||
case SORT_NORMAL:
|
||||
default:
|
||||
t->state->distance[i] = levenshtein ( t->pattern, t->plen, str, slen );
|
||||
break;
|
||||
}
|
||||
g_free ( str );
|
||||
}
|
||||
|
@ -804,7 +803,8 @@ void __create_window ( MenuFlags menu_flags )
|
|||
const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL );
|
||||
if ( transparency ) {
|
||||
rofi_view_setup_fake_transparency ( transparency );
|
||||
} else if ( config.fake_transparency && config.fake_background ) {
|
||||
}
|
||||
else if ( config.fake_transparency && config.fake_background ) {
|
||||
rofi_view_setup_fake_transparency ( config.fake_background );
|
||||
}
|
||||
if ( xcb->sncontext != NULL ) {
|
||||
|
@ -1051,24 +1051,24 @@ static void rofi_view_refilter ( RofiViewState *state )
|
|||
* 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.
|
||||
*/
|
||||
unsigned int nt = MAX ( 1, state->num_lines / 500 );
|
||||
unsigned int nt = MAX ( 1, state->num_lines / 500 );
|
||||
thread_state_view states[nt];
|
||||
GCond cond;
|
||||
GMutex mutex;
|
||||
GCond cond;
|
||||
GMutex mutex;
|
||||
g_mutex_init ( &mutex );
|
||||
g_cond_init ( &cond );
|
||||
unsigned int count = nt;
|
||||
unsigned int steps = ( state->num_lines + nt ) / nt;
|
||||
for ( unsigned int i = 0; i < nt; i++ ) {
|
||||
states[i].state = state;
|
||||
states[i].start = i * steps;
|
||||
states[i].stop = MIN ( state->num_lines, ( i + 1 ) * steps );
|
||||
states[i].count = 0;
|
||||
states[i].cond = &cond;
|
||||
states[i].mutex = &mutex;
|
||||
states[i].acount = &count;
|
||||
states[i].plen = plen;
|
||||
states[i].pattern = pattern;
|
||||
states[i].state = state;
|
||||
states[i].start = i * steps;
|
||||
states[i].stop = MIN ( state->num_lines, ( i + 1 ) * steps );
|
||||
states[i].count = 0;
|
||||
states[i].cond = &cond;
|
||||
states[i].mutex = &mutex;
|
||||
states[i].acount = &count;
|
||||
states[i].plen = plen;
|
||||
states[i].pattern = pattern;
|
||||
states[i].st.callback = filter_elements;
|
||||
if ( i > 0 ) {
|
||||
g_thread_pool_push ( tpool, &states[i], NULL );
|
||||
|
@ -1668,7 +1668,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
|||
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
|
||||
}
|
||||
else if ( g_ascii_strncasecmp ( name, "icon", 4 ) == 0 ) {
|
||||
icon *t = icon_create ( parent_widget, name );
|
||||
icon *t = icon_create ( parent_widget, name );
|
||||
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -58,10 +58,10 @@ static int box_get_desired_width ( widget *wid )
|
|||
int width = 0;
|
||||
|
||||
// Allow user to override.
|
||||
RofiDistance w = rofi_theme_get_distance ( wid, "width", 0 );
|
||||
RofiDistance w = rofi_theme_get_distance ( wid, "width", 0 );
|
||||
width = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
|
||||
if ( width > 0 ) {
|
||||
return width ;
|
||||
return width;
|
||||
}
|
||||
|
||||
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
|
||||
|
|
|
@ -39,29 +39,28 @@
|
|||
|
||||
struct _icon
|
||||
{
|
||||
widget widget;
|
||||
widget widget;
|
||||
|
||||
// Size of the icon.
|
||||
int size;
|
||||
int size;
|
||||
|
||||
uint32_t icon_fetch_id;
|
||||
uint32_t icon_fetch_id;
|
||||
|
||||
// Source surface.
|
||||
cairo_surface_t *icon;
|
||||
cairo_surface_t *icon;
|
||||
};
|
||||
|
||||
|
||||
static int icon_get_desired_height ( widget *widget )
|
||||
{
|
||||
icon *b = (icon *) widget;
|
||||
int height = b->size;
|
||||
int height = b->size;
|
||||
height += widget_padding_get_padding_height ( widget );
|
||||
return height;
|
||||
}
|
||||
static int icon_get_desired_width ( widget *widget )
|
||||
{
|
||||
icon *b = (icon *) widget;
|
||||
int width = b->size;
|
||||
icon *b = (icon *) widget;
|
||||
int width = b->size;
|
||||
width += widget_padding_get_padding_width ( widget );
|
||||
return width;
|
||||
}
|
||||
|
@ -71,7 +70,6 @@ static void icon_draw ( widget *wid, cairo_t *draw )
|
|||
icon *b = (icon *) wid;
|
||||
// If no icon is loaded. quit.
|
||||
if ( b->icon == NULL && b->icon_fetch_id > 0 ) {
|
||||
|
||||
b->icon = rofi_icon_fetcher_get ( b->icon_fetch_id );
|
||||
if ( b->icon ) {
|
||||
cairo_surface_reference ( b->icon );
|
||||
|
@ -83,7 +81,7 @@ static void icon_draw ( widget *wid, cairo_t *draw )
|
|||
int iconh = cairo_image_surface_get_height ( b->icon );
|
||||
int iconw = cairo_image_surface_get_width ( b->icon );
|
||||
int icons = MAX ( iconh, iconw );
|
||||
double scale = (double) b->size/ icons;
|
||||
double scale = (double) b->size / icons;
|
||||
|
||||
cairo_save ( draw );
|
||||
|
||||
|
@ -92,7 +90,6 @@ static void icon_draw ( widget *wid, cairo_t *draw )
|
|||
cairo_set_source_surface ( draw, b->icon, 0, 0 );
|
||||
cairo_paint ( draw );
|
||||
cairo_restore ( draw );
|
||||
|
||||
}
|
||||
|
||||
static void icon_free ( widget *wid )
|
||||
|
@ -134,7 +131,7 @@ icon * icon_create ( widget *parent, const char *name )
|
|||
{
|
||||
icon *b = g_malloc0 ( sizeof ( icon ) );
|
||||
|
||||
b->size = 16;
|
||||
b->size = 16;
|
||||
// Initialize widget.
|
||||
widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
|
||||
b->widget.draw = icon_draw;
|
||||
|
@ -143,7 +140,6 @@ icon * icon_create ( widget *parent, const char *name )
|
|||
b->widget.get_desired_height = icon_get_desired_height;
|
||||
b->widget.get_desired_width = icon_get_desired_width;
|
||||
|
||||
|
||||
b->size = rofi_theme_get_integer ( WIDGET ( b ), "size", b->size );
|
||||
|
||||
const char * filename = rofi_theme_get_string ( WIDGET ( b ), "filename", NULL );
|
||||
|
@ -151,7 +147,5 @@ icon * icon_create ( widget *parent, const char *name )
|
|||
b->icon_fetch_id = rofi_icon_fetcher_query ( filename, b->size );
|
||||
}
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,10 +36,12 @@
|
|||
|
||||
void widget_init ( widget *wid, widget *parent, WidgetType type, const char *name )
|
||||
{
|
||||
wid->type = type;
|
||||
wid->parent = parent;
|
||||
wid->name = g_strdup ( name );
|
||||
wid->def_padding = (RofiPadding){ { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||
wid->type = type;
|
||||
wid->parent = parent;
|
||||
wid->name = g_strdup ( name );
|
||||
wid->def_padding =
|
||||
(RofiPadding){ { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID },
|
||||
{ WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||
wid->def_border = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||
wid->def_border_radius = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||
wid->def_margin = (RofiPadding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
|
||||
|
@ -164,22 +166,22 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
double vspace = widget->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0;
|
||||
double hspace = widget->w - margin_left - margin_right - left / 2.0 - right / 2.0;
|
||||
if ( ( radius_bl + radius_tl ) > ( vspace ) ) {
|
||||
int j = ( ( vspace ) / 2.0 );
|
||||
int j = ( ( vspace ) / 2.0 );
|
||||
radius_bl = MIN ( radius_bl, j );
|
||||
radius_tl = MIN ( radius_tl, j );
|
||||
}
|
||||
if ( ( radius_br + radius_tr ) > ( vspace ) ) {
|
||||
int j = ( ( vspace ) / 2.0 );
|
||||
int j = ( ( vspace ) / 2.0 );
|
||||
radius_br = MIN ( radius_br, j );
|
||||
radius_tr = MIN ( radius_tr, j );
|
||||
}
|
||||
if ( ( radius_tl + radius_tr ) > ( hspace ) ) {
|
||||
int j = ( ( hspace ) / 2.0 );
|
||||
int j = ( ( hspace ) / 2.0 );
|
||||
radius_tr = MIN ( radius_tr, j );
|
||||
radius_tl = MIN ( radius_tl, j );
|
||||
}
|
||||
if ( ( radius_bl + radius_br ) > ( hspace ) ) {
|
||||
int j = ( ( hspace ) / 2.0 );
|
||||
int j = ( ( hspace ) / 2.0 );
|
||||
radius_br = MIN ( radius_br, j );
|
||||
radius_bl = MIN ( radius_bl, j );
|
||||
}
|
||||
|
@ -224,10 +226,10 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
cairo_new_path ( d );
|
||||
rofi_theme_get_color ( widget, "border-color", d );
|
||||
// Calculate the different offsets for the corners.
|
||||
double minof_tr = MIN ( right / 2.0, top / 2.0 );
|
||||
double minof_tl = MIN ( left / 2.0, top / 2.0 );
|
||||
double minof_br = MIN ( right / 2.0, bottom / 2.0 );
|
||||
double minof_bl = MIN ( left / 2.0, bottom / 2.0 );
|
||||
double minof_tr = MIN ( right / 2.0, top / 2.0 );
|
||||
double minof_tl = MIN ( left / 2.0, top / 2.0 );
|
||||
double minof_br = MIN ( right / 2.0, bottom / 2.0 );
|
||||
double minof_bl = MIN ( left / 2.0, bottom / 2.0 );
|
||||
// Inner radius
|
||||
double radius_inner_tl = radius_tl - minof_tl;
|
||||
double radius_inner_tr = radius_tr - minof_tr;
|
||||
|
@ -248,20 +250,20 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
// | |
|
||||
//
|
||||
// The left and right part ($) start at thinkness top bottom when no radius
|
||||
double offset_ltl = ( radius_inner_tl > 0 ) ? ( left ) +radius_inner_tl : left;
|
||||
double offset_rtr = ( radius_inner_tr > 0 ) ? ( right ) +radius_inner_tr : right;
|
||||
double offset_lbl = ( radius_inner_bl > 0 ) ? ( left ) +radius_inner_bl : left;
|
||||
double offset_rbr = ( radius_inner_br > 0 ) ? ( right ) +radius_inner_br : right;
|
||||
double offset_ltl = ( radius_inner_tl > 0 ) ? ( left ) + radius_inner_tl : left;
|
||||
double offset_rtr = ( radius_inner_tr > 0 ) ? ( right ) + radius_inner_tr : right;
|
||||
double offset_lbl = ( radius_inner_bl > 0 ) ? ( left ) + radius_inner_bl : left;
|
||||
double offset_rbr = ( radius_inner_br > 0 ) ? ( right ) + radius_inner_br : right;
|
||||
// The top and bottom part (#) go into the corner when no radius
|
||||
double offset_ttl = ( radius_inner_tl > 0 ) ? ( top ) +radius_inner_tl : (radius_tl>0)?top:0;
|
||||
double offset_ttr = ( radius_inner_tr > 0 ) ? ( top ) +radius_inner_tr : (radius_tr>0)?top:0;
|
||||
double offset_bbl = ( radius_inner_bl > 0 ) ? ( bottom ) +radius_inner_bl : (radius_bl>0)?bottom:0;
|
||||
double offset_bbr = ( radius_inner_br > 0 ) ? ( bottom ) +radius_inner_br : (radius_br>0)?bottom:0;
|
||||
double offset_ttl = ( radius_inner_tl > 0 ) ? ( top ) + radius_inner_tl : ( radius_tl > 0 ) ? top : 0;
|
||||
double offset_ttr = ( radius_inner_tr > 0 ) ? ( top ) + radius_inner_tr : ( radius_tr > 0 ) ? top : 0;
|
||||
double offset_bbl = ( radius_inner_bl > 0 ) ? ( bottom ) + radius_inner_bl : ( radius_bl > 0 ) ? bottom : 0;
|
||||
double offset_bbr = ( radius_inner_br > 0 ) ? ( bottom ) + radius_inner_br : ( radius_br > 0 ) ? bottom : 0;
|
||||
|
||||
if ( left > 0 ) {
|
||||
cairo_set_line_width ( d, left );
|
||||
distance_get_linestyle ( widget->border.left, d );
|
||||
cairo_move_to ( d, margin_left + (left / 2.0), margin_top + offset_ttl );
|
||||
cairo_move_to ( d, margin_left + ( left / 2.0 ), margin_top + offset_ttl );
|
||||
cairo_line_to ( d, margin_left + left / 2.0, widget->h - margin_bottom - offset_bbl );
|
||||
cairo_stroke ( d );
|
||||
}
|
||||
|
@ -282,7 +284,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
if ( bottom > 0 ) {
|
||||
cairo_set_line_width ( d, bottom );
|
||||
distance_get_linestyle ( widget->border.bottom, d );
|
||||
cairo_move_to ( d, margin_left + offset_lbl, widget->h - (bottom / 2.0) - margin_bottom );
|
||||
cairo_move_to ( d, margin_left + offset_lbl, widget->h - ( bottom / 2.0 ) - margin_bottom );
|
||||
cairo_line_to ( d, widget->w - margin_right - offset_rbr, widget->h - bottom / 2.0 - margin_bottom );
|
||||
cairo_stroke ( d );
|
||||
}
|
||||
|
@ -295,9 +297,9 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
cairo_line_to ( d, margin_left + offset_ltl, margin_top + top );
|
||||
if ( radius_inner_tl > 0 ) {
|
||||
cairo_arc_negative ( d,
|
||||
margin_left + left + radius_inner_tl,
|
||||
margin_top + top + radius_inner_tl,
|
||||
radius_inner_tl, -G_PI_2, G_PI );
|
||||
margin_left + left + radius_inner_tl,
|
||||
margin_top + top + radius_inner_tl,
|
||||
radius_inner_tl, -G_PI_2, G_PI );
|
||||
cairo_line_to ( d, margin_left + left, margin_top + offset_ttl );
|
||||
}
|
||||
cairo_line_to ( d, margin_left, margin_top + offset_ttl );
|
||||
|
@ -309,12 +311,12 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
cairo_set_line_width ( d, 0 );
|
||||
double radius_outer = radius_tr + minof_tr;
|
||||
cairo_arc ( d, widget->w - margin_right - radius_outer, margin_top + radius_outer, radius_outer, -G_PI_2, 0 );
|
||||
cairo_line_to ( d, widget->w - margin_right, margin_top + offset_ttr);
|
||||
cairo_line_to ( d, widget->w - margin_right - right, margin_top + offset_ttr);
|
||||
cairo_line_to ( d, widget->w - margin_right, margin_top + offset_ttr );
|
||||
cairo_line_to ( d, widget->w - margin_right - right, margin_top + offset_ttr );
|
||||
if ( radius_inner_tr > 0 ) {
|
||||
cairo_arc_negative ( d, widget->w - margin_right - right - radius_inner_tr,
|
||||
margin_top + top + radius_inner_tr,
|
||||
radius_inner_tr, 0, -G_PI_2 );
|
||||
margin_top + top + radius_inner_tr,
|
||||
radius_inner_tr, 0, -G_PI_2 );
|
||||
cairo_line_to ( d, widget->w - margin_right - offset_rtr, margin_top + top );
|
||||
}
|
||||
cairo_line_to ( d, widget->w - margin_right - offset_rtr, margin_top );
|
||||
|
@ -328,13 +330,13 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
cairo_arc ( d, widget->w - margin_right - radius_outer, widget->h - margin_bottom - radius_outer, radius_outer, 0.0, G_PI_2 );
|
||||
cairo_line_to ( d, widget->w - margin_right - offset_rbr, widget->h - margin_bottom );
|
||||
cairo_line_to ( d, widget->w - margin_right - offset_rbr, widget->h - margin_bottom - bottom );
|
||||
if ( radius_inner_br > 0 ){
|
||||
if ( radius_inner_br > 0 ) {
|
||||
cairo_arc_negative ( d, widget->w - margin_right - right - radius_inner_br,
|
||||
widget->h - margin_bottom - bottom - radius_inner_br,
|
||||
radius_inner_br, G_PI_2, 0.0 );
|
||||
cairo_line_to ( d, widget->w - margin_right -right, widget->h - margin_bottom - offset_bbr );
|
||||
widget->h - margin_bottom - bottom - radius_inner_br,
|
||||
radius_inner_br, G_PI_2, 0.0 );
|
||||
cairo_line_to ( d, widget->w - margin_right - right, widget->h - margin_bottom - offset_bbr );
|
||||
}
|
||||
cairo_line_to ( d, widget->w - margin_right, widget->h - margin_bottom - offset_bbr);
|
||||
cairo_line_to ( d, widget->w - margin_right, widget->h - margin_bottom - offset_bbr );
|
||||
cairo_close_path ( d );
|
||||
cairo_fill ( d );
|
||||
}
|
||||
|
@ -343,24 +345,23 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
cairo_set_line_width ( d, 1.0 );
|
||||
double radius_outer = radius_bl + minof_bl;
|
||||
cairo_arc ( d, margin_left + radius_outer, widget->h - margin_bottom - radius_outer, radius_outer, G_PI_2, G_PI );
|
||||
cairo_line_to ( d, margin_left , widget->h - margin_bottom - offset_bbl );
|
||||
cairo_line_to ( d, margin_left, widget->h - margin_bottom - offset_bbl );
|
||||
cairo_line_to ( d, margin_left + left, widget->h - margin_bottom - offset_bbl );
|
||||
if ( radius_inner_bl > 0 ) {
|
||||
cairo_arc_negative ( d, margin_left + left + radius_inner_bl,
|
||||
widget->h - margin_bottom - bottom - radius_inner_bl,
|
||||
radius_inner_bl, G_PI, G_PI_2 );
|
||||
widget->h - margin_bottom - bottom - radius_inner_bl,
|
||||
radius_inner_bl, G_PI, G_PI_2 );
|
||||
cairo_line_to ( d, margin_left + offset_lbl, widget->h - margin_bottom - bottom );
|
||||
}
|
||||
cairo_line_to ( d, margin_left + offset_lbl, widget->h - margin_bottom );
|
||||
cairo_close_path ( d );
|
||||
cairo_fill( d );
|
||||
cairo_fill ( d );
|
||||
}
|
||||
cairo_restore ( d );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void widget_free ( widget *wid )
|
||||
{
|
||||
if ( wid ) {
|
||||
|
|
410
source/xcb.c
410
source/xcb.c
|
@ -65,9 +65,9 @@
|
|||
#include <rofi.h>
|
||||
|
||||
/** Minimal randr prefered for running rofi (1.5) (Major version number) */
|
||||
#define RANDR_PREF_MAJOR_VERSION 1
|
||||
#define RANDR_PREF_MAJOR_VERSION 1
|
||||
/** Minimal randr prefered for running rofi (1.5) (Minor version number) */
|
||||
#define RANDR_PREF_MINOR_VERSION 5
|
||||
#define RANDR_PREF_MINOR_VERSION 5
|
||||
|
||||
/** Checks if the if x and y is inside rectangle. */
|
||||
#define INTERSECT( x, y, x1, y1, w1, h1 ) ( ( ( ( x ) >= ( x1 ) ) && ( ( x ) < ( x1 + w1 ) ) ) && ( ( ( y ) >= ( y1 ) ) && ( ( y ) < ( y1 + h1 ) ) ) )
|
||||
|
@ -79,7 +79,7 @@ WindowManagerQuirk current_window_manager = WM_EWHM;
|
|||
struct _xcb_stuff xcb_int = {
|
||||
.connection = NULL,
|
||||
.screen = NULL,
|
||||
.screen_nbr = -1,
|
||||
.screen_nbr = -1,
|
||||
.sndisplay = NULL,
|
||||
.sncontext = NULL,
|
||||
.monitors = NULL
|
||||
|
@ -106,25 +106,25 @@ const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) };
|
|||
cairo_surface_t *x11_helper_get_screenshot_surface ( void )
|
||||
{
|
||||
return cairo_xcb_surface_create ( xcb->connection,
|
||||
xcb_stuff_get_root_window (), root_visual,
|
||||
xcb->screen->width_in_pixels, xcb->screen->height_in_pixels );
|
||||
xcb_stuff_get_root_window (), root_visual,
|
||||
xcb->screen->width_in_pixels, xcb->screen->height_in_pixels );
|
||||
}
|
||||
|
||||
static xcb_pixmap_t get_root_pixmap ( xcb_connection_t *c,
|
||||
xcb_screen_t *screen,
|
||||
xcb_atom_t atom )
|
||||
xcb_screen_t *screen,
|
||||
xcb_atom_t atom )
|
||||
{
|
||||
xcb_get_property_cookie_t cookie;
|
||||
xcb_get_property_reply_t *reply;
|
||||
xcb_pixmap_t rootpixmap = XCB_NONE;
|
||||
|
||||
cookie = xcb_get_property ( c,
|
||||
0,
|
||||
screen->root,
|
||||
atom,
|
||||
XCB_ATOM_PIXMAP,
|
||||
0,
|
||||
1 );
|
||||
0,
|
||||
screen->root,
|
||||
atom,
|
||||
XCB_ATOM_PIXMAP,
|
||||
0,
|
||||
1 );
|
||||
|
||||
reply = xcb_get_property_reply ( c, cookie, NULL );
|
||||
|
||||
|
@ -145,7 +145,7 @@ cairo_surface_t * x11_helper_get_bg_surface ( void )
|
|||
return NULL;
|
||||
}
|
||||
return cairo_xcb_surface_create ( xcb->connection, pm, root_visual,
|
||||
xcb->screen->width_in_pixels, xcb->screen->height_in_pixels );
|
||||
xcb->screen->width_in_pixels, xcb->screen->height_in_pixels );
|
||||
}
|
||||
|
||||
// retrieve a text property from a window
|
||||
|
@ -241,8 +241,8 @@ static workarea * x11_get_monitor_from_output ( xcb_randr_output_t out )
|
|||
return retv;
|
||||
}
|
||||
|
||||
#if ( ( (XCB_RANDR_MAJOR_VERSION >= RANDR_PREF_MAJOR_VERSION ) && (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \
|
||||
|| XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||
#if ( ( ( XCB_RANDR_MAJOR_VERSION >= RANDR_PREF_MAJOR_VERSION ) && ( XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \
|
||||
|| XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||
/**
|
||||
* @param mon The randr monitor to parse.
|
||||
*
|
||||
|
@ -253,12 +253,12 @@ static workarea * x11_get_monitor_from_output ( xcb_randr_output_t out )
|
|||
static workarea *x11_get_monitor_from_randr_monitor ( xcb_randr_monitor_info_t *mon )
|
||||
{
|
||||
// Query to the name of the monitor.
|
||||
xcb_generic_error_t *err;
|
||||
xcb_get_atom_name_cookie_t anc = xcb_get_atom_name(xcb->connection, mon->name);
|
||||
xcb_get_atom_name_reply_t *atom_reply = xcb_get_atom_name_reply( xcb->connection, anc, &err);
|
||||
if (err != NULL) {
|
||||
g_warning ("Could not get RandR monitor name: X11 error code %d\n", err->error_code);
|
||||
free(err);
|
||||
xcb_generic_error_t *err;
|
||||
xcb_get_atom_name_cookie_t anc = xcb_get_atom_name ( xcb->connection, mon->name );
|
||||
xcb_get_atom_name_reply_t *atom_reply = xcb_get_atom_name_reply ( xcb->connection, anc, &err );
|
||||
if ( err != NULL ) {
|
||||
g_warning ( "Could not get RandR monitor name: X11 error code %d\n", err->error_code );
|
||||
free ( err );
|
||||
return NULL;
|
||||
}
|
||||
workarea *retv = g_malloc0 ( sizeof ( workarea ) );
|
||||
|
@ -267,17 +267,17 @@ static workarea *x11_get_monitor_from_randr_monitor ( xcb_randr_monitor_info_t *
|
|||
retv->primary = mon->primary;
|
||||
|
||||
// Position and size.
|
||||
retv->x = mon->x;
|
||||
retv->y = mon->y;
|
||||
retv->w = mon->width;
|
||||
retv->h = mon->height;
|
||||
retv->x = mon->x;
|
||||
retv->y = mon->y;
|
||||
retv->w = mon->width;
|
||||
retv->h = mon->height;
|
||||
|
||||
// Physical
|
||||
retv->mw = mon->width_in_millimeters;
|
||||
retv->mh = mon->height_in_millimeters;
|
||||
|
||||
// Name
|
||||
retv->name = g_strdup_printf("%.*s", xcb_get_atom_name_name_length(atom_reply), xcb_get_atom_name_name(atom_reply));
|
||||
retv->name = g_strdup_printf ( "%.*s", xcb_get_atom_name_name_length ( atom_reply ), xcb_get_atom_name_name ( atom_reply ) );
|
||||
|
||||
// Free name atom.
|
||||
free ( atom_reply );
|
||||
|
@ -302,18 +302,18 @@ static int x11_is_extension_present ( const char *extension )
|
|||
static void x11_build_monitor_layout_xinerama ()
|
||||
{
|
||||
xcb_xinerama_query_screens_cookie_t screens_cookie = xcb_xinerama_query_screens_unchecked (
|
||||
xcb->connection
|
||||
);
|
||||
xcb->connection
|
||||
);
|
||||
|
||||
xcb_xinerama_query_screens_reply_t *screens_reply = xcb_xinerama_query_screens_reply (
|
||||
xcb->connection,
|
||||
screens_cookie,
|
||||
NULL
|
||||
);
|
||||
xcb->connection,
|
||||
screens_cookie,
|
||||
NULL
|
||||
);
|
||||
|
||||
xcb_xinerama_screen_info_iterator_t screens_iterator = xcb_xinerama_query_screens_screen_info_iterator (
|
||||
screens_reply
|
||||
);
|
||||
screens_reply
|
||||
);
|
||||
|
||||
for (; screens_iterator.rem > 0; xcb_xinerama_screen_info_next ( &screens_iterator ) ) {
|
||||
workarea *w = g_malloc0 ( sizeof ( workarea ) );
|
||||
|
@ -354,19 +354,19 @@ static void x11_build_monitor_layout ()
|
|||
g_debug ( "Query RANDR for monitor layout." );
|
||||
|
||||
g_debug ( "Randr XCB api version: %d.%d.", XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION );
|
||||
#if ( ( ( XCB_RANDR_MAJOR_VERSION == RANDR_PREF_MAJOR_VERSION ) && (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \
|
||||
|| XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||
xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version(xcb->connection,
|
||||
RANDR_PREF_MAJOR_VERSION, RANDR_PREF_MINOR_VERSION);
|
||||
xcb_randr_query_version_reply_t *rversion = xcb_randr_query_version_reply( xcb->connection, cversion, NULL );
|
||||
#if ( ( ( XCB_RANDR_MAJOR_VERSION == RANDR_PREF_MAJOR_VERSION ) && ( XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \
|
||||
|| XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||
xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version ( xcb->connection,
|
||||
RANDR_PREF_MAJOR_VERSION, RANDR_PREF_MINOR_VERSION );
|
||||
xcb_randr_query_version_reply_t *rversion = xcb_randr_query_version_reply ( xcb->connection, cversion, NULL );
|
||||
if ( rversion ) {
|
||||
g_debug ( "Found randr version: %d.%d", rversion->major_version, rversion->minor_version );
|
||||
// Check if we are 1.5 and up.
|
||||
if ( ( ( rversion->major_version == XCB_RANDR_MAJOR_VERSION ) && (rversion->minor_version >= XCB_RANDR_MINOR_VERSION ) ) ||
|
||||
( rversion->major_version > XCB_RANDR_MAJOR_VERSION ) ){
|
||||
xcb_randr_get_monitors_cookie_t t = xcb_randr_get_monitors( xcb->connection, xcb->screen->root, 1 );
|
||||
xcb_randr_get_monitors_reply_t *mreply = xcb_randr_get_monitors_reply ( xcb->connection, t, NULL );
|
||||
if( mreply ) {
|
||||
if ( ( ( rversion->major_version == XCB_RANDR_MAJOR_VERSION ) && ( rversion->minor_version >= XCB_RANDR_MINOR_VERSION ) ) ||
|
||||
( rversion->major_version > XCB_RANDR_MAJOR_VERSION ) ) {
|
||||
xcb_randr_get_monitors_cookie_t t = xcb_randr_get_monitors ( xcb->connection, xcb->screen->root, 1 );
|
||||
xcb_randr_get_monitors_reply_t *mreply = xcb_randr_get_monitors_reply ( xcb->connection, t, NULL );
|
||||
if ( mreply ) {
|
||||
xcb_randr_monitor_info_iterator_t iter = xcb_randr_get_monitors_monitors_iterator ( mreply );
|
||||
while ( iter.rem > 0 ) {
|
||||
workarea *w = x11_get_monitor_from_randr_monitor ( iter.data );
|
||||
|
@ -374,7 +374,7 @@ static void x11_build_monitor_layout ()
|
|||
w->next = xcb->monitors;
|
||||
xcb->monitors = w;
|
||||
}
|
||||
xcb_randr_monitor_info_next (&iter);
|
||||
xcb_randr_monitor_info_next ( &iter );
|
||||
}
|
||||
free ( mreply );
|
||||
}
|
||||
|
@ -414,7 +414,6 @@ static void x11_build_monitor_layout ()
|
|||
free ( pc_rep );
|
||||
}
|
||||
free ( res_reply );
|
||||
|
||||
}
|
||||
|
||||
// Number monitor
|
||||
|
@ -439,13 +438,13 @@ void display_dump_monitor_layout ( void )
|
|||
printf ( "%s size%s: %d,%d\n", ( is_term ) ? color_bold : "", is_term ? color_reset : "", iter->w, iter->h );
|
||||
if ( iter->mw > 0 && iter->mh > 0 ) {
|
||||
printf ( "%s size%s: %dmm,%dmm dpi: %.0f,%.0f\n",
|
||||
( is_term ) ? color_bold : "",
|
||||
is_term ? color_reset : "",
|
||||
iter->mw,
|
||||
iter->mh,
|
||||
iter->w * 25.4 / (double) iter->mw,
|
||||
iter->h * 25.4 / (double) iter->mh
|
||||
);
|
||||
( is_term ) ? color_bold : "",
|
||||
is_term ? color_reset : "",
|
||||
iter->mw,
|
||||
iter->mh,
|
||||
iter->w * 25.4 / (double) iter->mw,
|
||||
iter->h * 25.4 / (double) iter->mh
|
||||
);
|
||||
}
|
||||
printf ( "\n" );
|
||||
}
|
||||
|
@ -643,7 +642,7 @@ static int monitor_active_from_id ( int mon_id, workarea *mon )
|
|||
if ( xcb_ewmh_get_desktop_viewport_reply ( &xcb->ewmh, c, &vp, NULL ) ) {
|
||||
if ( current_desktop < vp.desktop_viewport_len ) {
|
||||
monitor_dimensions ( vp.desktop_viewport[current_desktop].x,
|
||||
vp.desktop_viewport[current_desktop].y, mon );
|
||||
vp.desktop_viewport[current_desktop].y, mon );
|
||||
xcb_ewmh_get_desktop_viewport_reply_wipe ( &vp );
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -762,28 +761,28 @@ static gboolean x11_button_to_nk_bindings_button ( guint32 x11_button, NkBinding
|
|||
{
|
||||
switch ( x11_button )
|
||||
{
|
||||
case 1:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_PRIMARY;
|
||||
break;
|
||||
case 3:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_SECONDARY;
|
||||
break;
|
||||
case 2:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
case 8:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_BACK;
|
||||
break;
|
||||
case 9:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_FORWARD;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return FALSE;
|
||||
default:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_EXTRA + x11_button;
|
||||
case 1:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_PRIMARY;
|
||||
break;
|
||||
case 3:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_SECONDARY;
|
||||
break;
|
||||
case 2:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_MIDDLE;
|
||||
break;
|
||||
case 8:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_BACK;
|
||||
break;
|
||||
case 9:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_FORWARD;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return FALSE;
|
||||
default:
|
||||
*button = NK_BINDINGS_MOUSE_BUTTON_EXTRA + x11_button;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -793,20 +792,20 @@ static gboolean x11_button_to_nk_bindings_scroll ( guint32 x11_button, NkBinding
|
|||
*steps = 1;
|
||||
switch ( x11_button )
|
||||
{
|
||||
case 4:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 5:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
|
||||
break;
|
||||
case 6:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 7:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
case 4:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 5:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
|
||||
break;
|
||||
case 6:
|
||||
*steps = -1;
|
||||
/* fallthrough */
|
||||
case 7:
|
||||
*axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -823,93 +822,96 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
|
|||
|
||||
switch ( event->response_type & ~0x80 )
|
||||
{
|
||||
case XCB_EXPOSE:
|
||||
rofi_view_frame_callback ();
|
||||
break;
|
||||
case XCB_CONFIGURE_NOTIFY:
|
||||
{
|
||||
xcb_configure_notify_event_t *xce = (xcb_configure_notify_event_t *) event;
|
||||
rofi_view_temp_configure_notify ( state, xce );
|
||||
break;
|
||||
}
|
||||
case XCB_MOTION_NOTIFY:
|
||||
{
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
xcb->mouse_seen = TRUE;
|
||||
}
|
||||
xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *) event;
|
||||
rofi_view_handle_mouse_motion ( state, xme->event_x, xme->event_y );
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_PRESS:
|
||||
{
|
||||
xcb_button_press_event_t *bpe = (xcb_button_press_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
NkBindingsScrollAxis axis;
|
||||
gint32 steps;
|
||||
case XCB_EXPOSE:
|
||||
rofi_view_frame_callback ();
|
||||
break;
|
||||
case XCB_CONFIGURE_NOTIFY:
|
||||
{
|
||||
xcb_configure_notify_event_t *xce = (xcb_configure_notify_event_t *) event;
|
||||
rofi_view_temp_configure_notify ( state, xce );
|
||||
break;
|
||||
}
|
||||
case XCB_MOTION_NOTIFY:
|
||||
{
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
xcb->mouse_seen = TRUE;
|
||||
}
|
||||
xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *) event;
|
||||
rofi_view_handle_mouse_motion ( state, xme->event_x, xme->event_y );
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_PRESS:
|
||||
{
|
||||
xcb_button_press_event_t *bpe = (xcb_button_press_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
NkBindingsScrollAxis axis;
|
||||
gint32 steps;
|
||||
|
||||
xcb->last_timestamp = bpe->time;
|
||||
rofi_view_handle_mouse_motion ( state, bpe->event_x, bpe->event_y );
|
||||
if ( x11_button_to_nk_bindings_button ( bpe->detail, &button ) )
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time );
|
||||
else if ( x11_button_to_nk_bindings_scroll ( bpe->detail, &axis, &steps) )
|
||||
nk_bindings_seat_handle_scroll ( xcb->bindings_seat, NULL, axis, steps );
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_RELEASE:
|
||||
{
|
||||
xcb_button_release_event_t *bre = (xcb_button_release_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
xcb->last_timestamp = bpe->time;
|
||||
rofi_view_handle_mouse_motion ( state, bpe->event_x, bpe->event_y );
|
||||
if ( x11_button_to_nk_bindings_button ( bpe->detail, &button ) ) {
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time );
|
||||
}
|
||||
else if ( x11_button_to_nk_bindings_scroll ( bpe->detail, &axis, &steps ) ) {
|
||||
nk_bindings_seat_handle_scroll ( xcb->bindings_seat, NULL, axis, steps );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_BUTTON_RELEASE:
|
||||
{
|
||||
xcb_button_release_event_t *bre = (xcb_button_release_event_t *) event;
|
||||
NkBindingsMouseButton button;
|
||||
|
||||
xcb->last_timestamp = bre->time;
|
||||
if ( x11_button_to_nk_bindings_button ( bre->detail, &button ) )
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
if ( !xcb->mouse_seen ) {
|
||||
rofi_view_temp_click_to_exit ( state, bre->event );
|
||||
}
|
||||
xcb->mouse_seen = FALSE;
|
||||
}
|
||||
break;
|
||||
xcb->last_timestamp = bre->time;
|
||||
if ( x11_button_to_nk_bindings_button ( bre->detail, &button ) ) {
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||
}
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
if ( !xcb->mouse_seen ) {
|
||||
rofi_view_temp_click_to_exit ( state, bre->event );
|
||||
}
|
||||
// Paste event.
|
||||
case XCB_SELECTION_NOTIFY:
|
||||
rofi_view_paste ( state, (xcb_selection_notify_event_t *) event );
|
||||
break;
|
||||
case XCB_KEYMAP_NOTIFY:
|
||||
{
|
||||
xcb_keymap_notify_event_t *kne = (xcb_keymap_notify_event_t *) event;
|
||||
for ( gint32 by = 0; by < 31; ++by ) {
|
||||
for ( gint8 bi = 0; bi < 7; ++bi ) {
|
||||
if ( kne->keys[by] & ( 1 << bi ) ) {
|
||||
// X11 keycodes starts at 8
|
||||
nk_bindings_seat_handle_key ( xcb->bindings_seat, NULL, ( 8 * by + bi ) + 8, NK_BINDINGS_KEY_STATE_PRESSED );
|
||||
}
|
||||
}
|
||||
xcb->mouse_seen = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Paste event.
|
||||
case XCB_SELECTION_NOTIFY:
|
||||
rofi_view_paste ( state, (xcb_selection_notify_event_t *) event );
|
||||
break;
|
||||
case XCB_KEYMAP_NOTIFY:
|
||||
{
|
||||
xcb_keymap_notify_event_t *kne = (xcb_keymap_notify_event_t *) event;
|
||||
for ( gint32 by = 0; by < 31; ++by ) {
|
||||
for ( gint8 bi = 0; bi < 7; ++bi ) {
|
||||
if ( kne->keys[by] & ( 1 << bi ) ) {
|
||||
// X11 keycodes starts at 8
|
||||
nk_bindings_seat_handle_key ( xcb->bindings_seat, NULL, ( 8 * by + bi ) + 8, NK_BINDINGS_KEY_STATE_PRESSED );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_KEY_PRESS:
|
||||
{
|
||||
xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *) event;
|
||||
gchar *text;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_KEY_PRESS:
|
||||
{
|
||||
xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *) event;
|
||||
gchar *text;
|
||||
|
||||
xcb->last_timestamp = xkpe->time;
|
||||
text = nk_bindings_seat_handle_key_with_modmask ( xcb->bindings_seat, NULL, xkpe->state, xkpe->detail, NK_BINDINGS_KEY_STATE_PRESS );
|
||||
if ( text != NULL ) {
|
||||
rofi_view_handle_text ( state, text );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_KEY_RELEASE:
|
||||
{
|
||||
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *) event;
|
||||
xcb->last_timestamp = xkre->time;
|
||||
nk_bindings_seat_handle_key ( xcb->bindings_seat, NULL, xkre->detail, NK_BINDINGS_KEY_STATE_RELEASE );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
xcb->last_timestamp = xkpe->time;
|
||||
text = nk_bindings_seat_handle_key_with_modmask ( xcb->bindings_seat, NULL, xkpe->state, xkpe->detail, NK_BINDINGS_KEY_STATE_PRESS );
|
||||
if ( text != NULL ) {
|
||||
rofi_view_handle_text ( state, text );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XCB_KEY_RELEASE:
|
||||
{
|
||||
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *) event;
|
||||
xcb->last_timestamp = xkre->time;
|
||||
nk_bindings_seat_handle_key ( xcb->bindings_seat, NULL, xkre->detail, NK_BINDINGS_KEY_STATE_RELEASE );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rofi_view_maybe_update ( state );
|
||||
}
|
||||
|
@ -932,28 +934,28 @@ static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UN
|
|||
if ( type == xcb->xkb.first_event ) {
|
||||
switch ( ev->pad0 )
|
||||
{
|
||||
case XCB_XKB_MAP_NOTIFY:
|
||||
{
|
||||
struct xkb_keymap *keymap = xkb_x11_keymap_new_from_device ( nk_bindings_seat_get_context ( xcb->bindings_seat ), xcb->connection, xcb->xkb.device_id, 0 );
|
||||
struct xkb_state *state = xkb_x11_state_new_from_device ( keymap, xcb->connection, xcb->xkb.device_id );
|
||||
nk_bindings_seat_update_keymap ( xcb->bindings_seat, keymap, state );
|
||||
xkb_keymap_unref ( keymap );
|
||||
xkb_state_unref ( state );
|
||||
break;
|
||||
}
|
||||
case XCB_XKB_STATE_NOTIFY:
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
nk_bindings_seat_update_mask ( xcb->bindings_seat, NULL,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
rofi_view_maybe_update ( rofi_view_get_active () );
|
||||
break;
|
||||
}
|
||||
case XCB_XKB_MAP_NOTIFY:
|
||||
{
|
||||
struct xkb_keymap *keymap = xkb_x11_keymap_new_from_device ( nk_bindings_seat_get_context ( xcb->bindings_seat ), xcb->connection, xcb->xkb.device_id, 0 );
|
||||
struct xkb_state *state = xkb_x11_state_new_from_device ( keymap, xcb->connection, xcb->xkb.device_id );
|
||||
nk_bindings_seat_update_keymap ( xcb->bindings_seat, keymap, state );
|
||||
xkb_keymap_unref ( keymap );
|
||||
xkb_state_unref ( state );
|
||||
break;
|
||||
}
|
||||
case XCB_XKB_STATE_NOTIFY:
|
||||
{
|
||||
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
|
||||
nk_bindings_seat_update_mask ( xcb->bindings_seat, NULL,
|
||||
ksne->baseMods,
|
||||
ksne->latchedMods,
|
||||
ksne->lockedMods,
|
||||
ksne->baseGroup,
|
||||
ksne->latchedGroup,
|
||||
ksne->lockedGroup );
|
||||
rofi_view_maybe_update ( rofi_view_get_active () );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
@ -973,7 +975,7 @@ static int take_pointer ( xcb_window_t w, int iters )
|
|||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
xcb_grab_pointer_cookie_t cc = xcb_grab_pointer ( xcb->connection, 1, w, XCB_EVENT_MASK_BUTTON_RELEASE,
|
||||
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, w, XCB_NONE, XCB_CURRENT_TIME );
|
||||
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, w, XCB_NONE, XCB_CURRENT_TIME );
|
||||
xcb_grab_pointer_reply_t *r = xcb_grab_pointer_reply ( xcb->connection, cc, NULL );
|
||||
if ( r ) {
|
||||
if ( r->status == XCB_GRAB_STATUS_SUCCESS ) {
|
||||
|
@ -999,8 +1001,8 @@ static int take_keyboard ( xcb_window_t w, int iters )
|
|||
exit ( EXIT_FAILURE );
|
||||
}
|
||||
xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard ( xcb->connection,
|
||||
1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC );
|
||||
1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC );
|
||||
xcb_grab_keyboard_reply_t *r = xcb_grab_keyboard_reply ( xcb->connection, cc, NULL );
|
||||
if ( r ) {
|
||||
if ( r->status == XCB_GRAB_STATUS_SUCCESS ) {
|
||||
|
@ -1064,7 +1066,7 @@ static void x11_helper_discover_window_manager ( void )
|
|||
{
|
||||
xcb_window_t wm_win = 0;
|
||||
xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked ( &xcb->ewmh,
|
||||
xcb_stuff_get_root_window () );
|
||||
xcb_stuff_get_root_window () );
|
||||
|
||||
if ( xcb_ewmh_get_supporting_wm_check_reply ( &xcb->ewmh, cc, &wm_win, NULL ) ) {
|
||||
xcb_ewmh_get_utf8_strings_reply_t wtitle;
|
||||
|
@ -1114,7 +1116,7 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings )
|
|||
TICK_N ( "Setup XCB" );
|
||||
|
||||
if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xcb->xkb.first_event, NULL ) < 0 ) {
|
||||
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &xcb->xkb.first_event, NULL ) < 0 ) {
|
||||
g_warning ( "cannot setup XKB extension!" );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1156,11 +1158,11 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings )
|
|||
.stateDetails = required_state_details,
|
||||
};
|
||||
xcb_xkb_select_events ( xcb->connection, xcb->xkb.device_id, required_events, /* affectWhich */
|
||||
0, /* clear */
|
||||
required_events, /* selectAll */
|
||||
required_map_parts, /* affectMap */
|
||||
required_map_parts, /* map */
|
||||
&details );
|
||||
0, /* clear */
|
||||
required_events, /* selectAll */
|
||||
required_map_parts, /* affectMap */
|
||||
required_map_parts, /* map */
|
||||
&details );
|
||||
|
||||
xcb->bindings_seat = nk_bindings_seat_new ( bindings, XKB_CONTEXT_NO_FLAGS );
|
||||
struct xkb_keymap *keymap = xkb_x11_keymap_new_from_device ( nk_bindings_seat_get_context ( xcb->bindings_seat ), xcb->connection, xcb->xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
|
||||
|
|
|
@ -141,7 +141,7 @@ static XrmOption xrmOptions[] = {
|
|||
"Disable history in run/ssh", CONFIG_DEFAULT },
|
||||
{ xrm_Boolean, "sort", { .num = &config.sort }, NULL,
|
||||
"Use sorting", CONFIG_DEFAULT },
|
||||
{ xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL,
|
||||
{ xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL,
|
||||
"Choose the strategy used for sorting: normal (levenshtein) or fzf.", CONFIG_DEFAULT },
|
||||
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL,
|
||||
"Set case-sensitivity", CONFIG_DEFAULT },
|
||||
|
|
Loading…
Reference in a new issue