mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-10 15:44:41 -05:00
Indent the code.
This commit is contained in:
parent
4631ac711f
commit
859a9c79d6
21 changed files with 420 additions and 432 deletions
|
@ -23,7 +23,6 @@ void rofi_icon_fetcher_init ( void );
|
||||||
*/
|
*/
|
||||||
void rofi_icon_fetcher_destroy ( void );
|
void rofi_icon_fetcher_destroy ( void );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name The name of the icon to fetch.
|
* @param name The name of the icon to fetch.
|
||||||
* @param size The size 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 );
|
uint32_t rofi_icon_fetcher_query ( const char *name, const int size );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uid The unique id representing the matching request.
|
* @param uid The unique id representing the matching request.
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
|
|
||||||
char *DRUN_GROUP_NAME = "Desktop Entry";
|
char *DRUN_GROUP_NAME = "Desktop Entry";
|
||||||
|
|
||||||
|
|
||||||
typedef struct _DRunModePrivateData DRunModePrivateData;
|
typedef struct _DRunModePrivateData DRunModePrivateData;
|
||||||
/**
|
/**
|
||||||
* Store extra information about the entry.
|
* Store extra information about the entry.
|
||||||
|
@ -420,10 +419,10 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
|
||||||
pd->entry_list[pd->cmd_list_length].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) );
|
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 );
|
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 *na = g_key_file_get_locale_string ( kf, action, "Name", NULL, NULL );
|
||||||
gchar *l = g_strdup_printf("%s - %s", n, na);
|
gchar *l = g_strdup_printf ( "%s - %s", n, na );
|
||||||
g_free(n);
|
g_free ( n );
|
||||||
n = l;
|
n = l;
|
||||||
}
|
}
|
||||||
pd->entry_list[pd->cmd_list_length].name = n;
|
pd->entry_list[pd->cmd_list_length].name = n;
|
||||||
|
@ -463,13 +462,13 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
|
||||||
if ( !parse_action ) {
|
if ( !parse_action ) {
|
||||||
gsize actions_length = 0;
|
gsize actions_length = 0;
|
||||||
char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL );
|
char **actions = g_key_file_get_string_list ( kf, DRUN_GROUP_NAME, "Actions", &actions_length, NULL );
|
||||||
for ( gsize iter = 0; iter < actions_length; iter++ ){
|
for ( gsize iter = 0; iter < actions_length; iter++ ) {
|
||||||
char *new_action = g_strdup_printf("Desktop Action %s", actions[iter]);
|
char *new_action = g_strdup_printf ( "Desktop Action %s", actions[iter] );
|
||||||
if (! read_desktop_file ( pd, root, path, basename, new_action ) ){
|
if ( !read_desktop_file ( pd, root, path, basename, new_action ) ) {
|
||||||
g_free ( new_action );
|
g_free ( new_action );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_strfreev(actions);
|
g_strfreev ( actions );
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +617,6 @@ static void get_apps ( DRunModePrivateData *pd )
|
||||||
TICK_N ( "Sorting done." );
|
TICK_N ( "Sorting done." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void drun_mode_parse_entry_fields ()
|
static void drun_mode_parse_entry_fields ()
|
||||||
{
|
{
|
||||||
char *savept = NULL;
|
char *savept = NULL;
|
||||||
|
@ -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 );
|
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
||||||
g_return_val_if_fail ( pd->entry_list != NULL, NULL );
|
g_return_val_if_fail ( pd->entry_list != NULL, NULL );
|
||||||
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
|
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
|
||||||
if ( dr->icon_name == NULL ) return NULL;
|
if ( dr->icon_name == NULL ) {
|
||||||
if ( dr->icon_fetch_uid >0){
|
return NULL;
|
||||||
|
}
|
||||||
|
if ( dr->icon_fetch_uid > 0 ) {
|
||||||
return rofi_icon_fetcher_get ( dr->icon_fetch_uid );
|
return rofi_icon_fetcher_get ( dr->icon_fetch_uid );
|
||||||
}
|
}
|
||||||
dr->icon_fetch_uid = rofi_icon_fetcher_query ( dr->icon_name, height );
|
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;
|
char *value = line + length_key + 1;
|
||||||
if ( strcasecmp ( line, "message" ) == 0 ) {
|
if ( strcasecmp ( line, "message" ) == 0 ) {
|
||||||
g_free ( pd->message );
|
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 ) {
|
else if ( strcasecmp ( line, "prompt" ) == 0 ) {
|
||||||
g_free ( pd->prompt );
|
g_free ( pd->prompt );
|
||||||
|
@ -198,7 +198,6 @@ static void script_mode_reset_highlight ( Mode *sw )
|
||||||
rmpd->num_active_list = 0;
|
rmpd->num_active_list = 0;
|
||||||
g_free ( rmpd->active_list );
|
g_free ( rmpd->active_list );
|
||||||
rmpd->active_list = NULL;
|
rmpd->active_list = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
|
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;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sw Object handle to the SSH Mode object
|
* @param sw Object handle to the SSH Mode object
|
||||||
* @param selected_line The line to view
|
* @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 = get_net_wm_icon ( rmpd->ids->array[selected_line], size );
|
||||||
c->icon_checked = TRUE;
|
c->icon_checked = TRUE;
|
||||||
}
|
}
|
||||||
if ( c->icon == NULL && c->class ){
|
if ( c->icon == NULL && c->class ) {
|
||||||
if ( c->icon_fetch_uid > 0){
|
if ( c->icon_fetch_uid > 0 ) {
|
||||||
return rofi_icon_fetcher_get ( c->icon_fetch_uid );
|
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;
|
return c->icon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -587,7 +587,8 @@ int config_sanity_check ( void )
|
||||||
}
|
}
|
||||||
else if ( g_strcmp0 ( config.sorting_method, "fzf" ) == 0 ) {
|
else if ( g_strcmp0 ( config.sorting_method, "fzf" ) == 0 ) {
|
||||||
config.sorting_method_enum = SORT_FZF;
|
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",
|
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 );
|
config.sorting_method );
|
||||||
found_error = 1;
|
found_error = 1;
|
||||||
|
|
|
@ -113,7 +113,7 @@ static char ** __history_get_element_list_fields ( FILE *fd, unsigned int *lengt
|
||||||
|
|
||||||
( *length )++;
|
( *length )++;
|
||||||
}
|
}
|
||||||
if ( buffer_length > 0 ){
|
if ( buffer_length > 0 ) {
|
||||||
g_free ( buffer );
|
g_free ( buffer );
|
||||||
}
|
}
|
||||||
return retv;
|
return retv;
|
||||||
|
|
|
@ -119,7 +119,7 @@ ActionBindingEntry rofi_bindings[] =
|
||||||
|
|
||||||
{ .id = SELECT_HOVERED_ENTRY, .scope = SCOPE_MOUSE_LISTVIEW_ELEMENT, .name = "me-select-entry", .binding = "MousePrimary", .comment = "Select hovered row" },
|
{ .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_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 = 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. */
|
/** Default binding of mouse button to action. */
|
||||||
|
|
|
@ -39,7 +39,8 @@
|
||||||
|
|
||||||
#include "nkutils-xdg-theme.h"
|
#include "nkutils-xdg-theme.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
// Context for icon-themes.
|
// Context for icon-themes.
|
||||||
NkXdgThemeContext *xdg_context;
|
NkXdgThemeContext *xdg_context;
|
||||||
|
|
||||||
|
@ -49,17 +50,16 @@ typedef struct {
|
||||||
GHashTable *icon_cache_uid;
|
GHashTable *icon_cache_uid;
|
||||||
|
|
||||||
uint32_t last_uid;
|
uint32_t last_uid;
|
||||||
|
|
||||||
|
|
||||||
} IconFetcher;
|
} IconFetcher;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
typedef struct {
|
{
|
||||||
char *name;
|
char *name;
|
||||||
GList *sizes;
|
GList *sizes;
|
||||||
} IconFetcherNameEntry;
|
} IconFetcherNameEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
thread_state state;
|
thread_state state;
|
||||||
|
|
||||||
GCond *cond;
|
GCond *cond;
|
||||||
|
@ -78,17 +78,15 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
IconFetcher *rofi_icon_fetcher_data = NULL;
|
IconFetcher *rofi_icon_fetcher_data = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void rofi_icon_fetch_entry_free ( gpointer data )
|
static void rofi_icon_fetch_entry_free ( gpointer data )
|
||||||
{
|
{
|
||||||
IconFetcherNameEntry *entry = (IconFetcherNameEntry*) data;
|
IconFetcherNameEntry *entry = (IconFetcherNameEntry *) data;
|
||||||
|
|
||||||
// Free name/key.
|
// Free name/key.
|
||||||
g_free ( entry->name );
|
g_free ( entry->name );
|
||||||
|
|
||||||
|
|
||||||
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 ) ) {
|
||||||
IconFetcherEntry *sentry = (IconFetcherEntry *)(iter->data);
|
IconFetcherEntry *sentry = (IconFetcherEntry *) ( iter->data );
|
||||||
|
|
||||||
cairo_surface_destroy ( sentry->surface );
|
cairo_surface_destroy ( sentry->surface );
|
||||||
g_free ( sentry );
|
g_free ( sentry );
|
||||||
|
@ -98,7 +96,6 @@ static void rofi_icon_fetch_entry_free ( gpointer data )
|
||||||
g_free ( entry );
|
g_free ( entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rofi_icon_fetcher_init ( void )
|
void rofi_icon_fetcher_init ( void )
|
||||||
{
|
{
|
||||||
g_assert ( rofi_icon_fetcher_data == NULL );
|
g_assert ( rofi_icon_fetcher_data == NULL );
|
||||||
|
@ -108,26 +105,25 @@ void rofi_icon_fetcher_init ( void )
|
||||||
"gnome",
|
"gnome",
|
||||||
NULL
|
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 );
|
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 );
|
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_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 );
|
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 )
|
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 );
|
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_uid );
|
||||||
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache );
|
g_hash_table_unref ( rofi_icon_fetcher_data->icon_cache );
|
||||||
|
|
||||||
|
@ -138,7 +134,7 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
||||||
g_debug ( "starting up icon fetching thread." );
|
g_debug ( "starting up icon fetching thread." );
|
||||||
// as long as dr->icon is updated atomicly.. (is a pointer write atomic?)
|
// as long as dr->icon is updated atomicly.. (is a pointer write atomic?)
|
||||||
// this should be fine running in another thread.
|
// this should be fine running in another thread.
|
||||||
IconFetcherEntry *sentry = (IconFetcherEntry*) sdata;
|
IconFetcherEntry *sentry = (IconFetcherEntry *) sdata;
|
||||||
const gchar *themes[] = {
|
const gchar *themes[] = {
|
||||||
config.icon_theme,
|
config.icon_theme,
|
||||||
NULL
|
NULL
|
||||||
|
@ -153,7 +149,7 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
||||||
else {
|
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 );
|
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 ) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -177,51 +173,49 @@ static void rofi_icon_fetcher_worker ( thread_state *sdata, G_GNUC_UNUSED gpoint
|
||||||
cairo_surface_destroy ( icon_surf );
|
cairo_surface_destroy ( icon_surf );
|
||||||
icon_surf = NULL;
|
icon_surf = NULL;
|
||||||
}
|
}
|
||||||
sentry->surface= icon_surf;
|
sentry->surface = icon_surf;
|
||||||
}
|
}
|
||||||
g_free ( icon_path_ );
|
g_free ( icon_path_ );
|
||||||
rofi_view_reload ();
|
rofi_view_reload ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t rofi_icon_fetcher_query ( const char *name, const int size )
|
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 );
|
IconFetcherNameEntry *entry = g_hash_table_lookup ( rofi_icon_fetcher_data->icon_cache, name );
|
||||||
if ( entry == NULL ) {
|
if ( entry == NULL ) {
|
||||||
entry = g_new0(IconFetcherNameEntry,1);
|
entry = g_new0 ( IconFetcherNameEntry, 1 );
|
||||||
entry->name = g_strdup(name);
|
entry->name = g_strdup ( name );
|
||||||
g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache, entry->name, entry );
|
g_hash_table_insert ( rofi_icon_fetcher_data->icon_cache, entry->name, entry );
|
||||||
}
|
}
|
||||||
IconFetcherEntry *sentry;
|
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;
|
sentry = iter->data;
|
||||||
if ( sentry->size == size ){
|
if ( sentry->size == size ) {
|
||||||
return sentry->uid;
|
return sentry->uid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not found.
|
// Not found.
|
||||||
sentry = g_new0(IconFetcherEntry, 1);
|
sentry = g_new0 ( IconFetcherEntry, 1 );
|
||||||
sentry->uid = ++(rofi_icon_fetcher_data->last_uid);
|
sentry->uid = ++( rofi_icon_fetcher_data->last_uid );
|
||||||
sentry->size = size;
|
sentry->size = size;
|
||||||
sentry->entry = entry;
|
sentry->entry = entry;
|
||||||
sentry->surface = NULL;
|
sentry->surface = NULL;
|
||||||
|
|
||||||
entry->sizes = g_list_prepend ( entry->sizes, sentry );
|
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.
|
// Push into fetching queue.
|
||||||
sentry->state.callback = rofi_icon_fetcher_worker;
|
sentry->state.callback = rofi_icon_fetcher_worker;
|
||||||
g_thread_pool_push ( tpool, sentry, NULL);
|
g_thread_pool_push ( tpool, sentry, NULL );
|
||||||
|
|
||||||
return sentry->uid;
|
return sentry->uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cairo_surface_t * rofi_icon_fetcher_get ( const uint32_t 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 ) {
|
if ( sentry ) {
|
||||||
return sentry->surface;
|
return sentry->surface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -858,7 +858,8 @@ int main ( int argc, char *argv[] )
|
||||||
rofi_theme_free ( rofi_theme );
|
rofi_theme_free ( rofi_theme );
|
||||||
rofi_theme = NULL;
|
rofi_theme = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
g_free ( config_path_new );
|
g_free ( config_path_new );
|
||||||
config_path_new = NULL;
|
config_path_new = NULL;
|
||||||
config_parse_xresource_options_file ( config_path );
|
config_parse_xresource_options_file ( config_path );
|
||||||
|
|
|
@ -640,7 +640,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl
|
||||||
}
|
}
|
||||||
return def;
|
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 );
|
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -581,7 +581,6 @@ typedef struct _thread_state_view
|
||||||
const char *pattern;
|
const char *pattern;
|
||||||
/** Length of pattern. */
|
/** Length of pattern. */
|
||||||
glong plen;
|
glong plen;
|
||||||
|
|
||||||
} thread_state_view;
|
} thread_state_view;
|
||||||
/**
|
/**
|
||||||
* @param data A thread_state object.
|
* @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 )
|
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++ ) {
|
for ( unsigned int i = t->start; i < t->stop; i++ ) {
|
||||||
int match = mode_token_match ( t->state->sw, t->state->tokens, i );
|
int match = mode_token_match ( t->state->sw, t->state->tokens, i );
|
||||||
// If each token was matched, add it to list.
|
// If each token was matched, add it to list.
|
||||||
|
@ -804,7 +803,8 @@ void __create_window ( MenuFlags menu_flags )
|
||||||
const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL );
|
const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL );
|
||||||
if ( transparency ) {
|
if ( transparency ) {
|
||||||
rofi_view_setup_fake_transparency ( 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 );
|
rofi_view_setup_fake_transparency ( config.fake_background );
|
||||||
}
|
}
|
||||||
if ( xcb->sncontext != NULL ) {
|
if ( xcb->sncontext != NULL ) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ static int box_get_desired_width ( widget *wid )
|
||||||
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 );
|
width = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
|
||||||
if ( width > 0 ) {
|
if ( width > 0 ) {
|
||||||
return width ;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
|
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
|
||||||
|
|
|
@ -50,7 +50,6 @@ struct _icon
|
||||||
cairo_surface_t *icon;
|
cairo_surface_t *icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int icon_get_desired_height ( widget *widget )
|
static int icon_get_desired_height ( widget *widget )
|
||||||
{
|
{
|
||||||
icon *b = (icon *) widget;
|
icon *b = (icon *) widget;
|
||||||
|
@ -71,7 +70,6 @@ static void icon_draw ( widget *wid, cairo_t *draw )
|
||||||
icon *b = (icon *) wid;
|
icon *b = (icon *) wid;
|
||||||
// If no icon is loaded. quit.
|
// If no icon is loaded. quit.
|
||||||
if ( b->icon == NULL && b->icon_fetch_id > 0 ) {
|
if ( b->icon == NULL && b->icon_fetch_id > 0 ) {
|
||||||
|
|
||||||
b->icon = rofi_icon_fetcher_get ( b->icon_fetch_id );
|
b->icon = rofi_icon_fetcher_get ( b->icon_fetch_id );
|
||||||
if ( b->icon ) {
|
if ( b->icon ) {
|
||||||
cairo_surface_reference ( 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 iconh = cairo_image_surface_get_height ( b->icon );
|
||||||
int iconw = cairo_image_surface_get_width ( b->icon );
|
int iconw = cairo_image_surface_get_width ( b->icon );
|
||||||
int icons = MAX ( iconh, iconw );
|
int icons = MAX ( iconh, iconw );
|
||||||
double scale = (double) b->size/ icons;
|
double scale = (double) b->size / icons;
|
||||||
|
|
||||||
cairo_save ( draw );
|
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_set_source_surface ( draw, b->icon, 0, 0 );
|
||||||
cairo_paint ( draw );
|
cairo_paint ( draw );
|
||||||
cairo_restore ( draw );
|
cairo_restore ( draw );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void icon_free ( widget *wid )
|
static void icon_free ( widget *wid )
|
||||||
|
@ -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_height = icon_get_desired_height;
|
||||||
b->widget.get_desired_width = icon_get_desired_width;
|
b->widget.get_desired_width = icon_get_desired_width;
|
||||||
|
|
||||||
|
|
||||||
b->size = rofi_theme_get_integer ( WIDGET ( b ), "size", b->size );
|
b->size = rofi_theme_get_integer ( WIDGET ( b ), "size", b->size );
|
||||||
|
|
||||||
const char * filename = rofi_theme_get_string ( WIDGET ( b ), "filename", NULL );
|
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 );
|
b->icon_fetch_id = rofi_icon_fetcher_query ( filename, b->size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,9 @@ void widget_init ( widget *wid, widget *parent, WidgetType type, const char *nam
|
||||||
wid->type = type;
|
wid->type = type;
|
||||||
wid->parent = parent;
|
wid->parent = parent;
|
||||||
wid->name = g_strdup ( name );
|
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_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 = (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_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 } };
|
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 } };
|
||||||
|
@ -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
|
// 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_ltl = ( radius_inner_tl > 0 ) ? ( left ) + radius_inner_tl : left;
|
||||||
double offset_rtr = ( radius_inner_tr > 0 ) ? ( right ) +radius_inner_tr : right;
|
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_lbl = ( radius_inner_bl > 0 ) ? ( left ) + radius_inner_bl : left;
|
||||||
double offset_rbr = ( radius_inner_br > 0 ) ? ( right ) +radius_inner_br : right;
|
double offset_rbr = ( radius_inner_br > 0 ) ? ( right ) + radius_inner_br : right;
|
||||||
// The top and bottom part (#) go into the corner when no radius
|
// 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_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_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_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_bbr = ( radius_inner_br > 0 ) ? ( bottom ) + radius_inner_br : ( radius_br > 0 ) ? bottom : 0;
|
||||||
|
|
||||||
if ( left > 0 ) {
|
if ( left > 0 ) {
|
||||||
cairo_set_line_width ( d, left );
|
cairo_set_line_width ( d, left );
|
||||||
distance_get_linestyle ( widget->border.left, d );
|
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_line_to ( d, margin_left + left / 2.0, widget->h - margin_bottom - offset_bbl );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
|
@ -282,7 +284,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
if ( bottom > 0 ) {
|
if ( bottom > 0 ) {
|
||||||
cairo_set_line_width ( d, bottom );
|
cairo_set_line_width ( d, bottom );
|
||||||
distance_get_linestyle ( widget->border.bottom, d );
|
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_line_to ( d, widget->w - margin_right - offset_rbr, widget->h - bottom / 2.0 - margin_bottom );
|
||||||
cairo_stroke ( d );
|
cairo_stroke ( d );
|
||||||
}
|
}
|
||||||
|
@ -309,8 +311,8 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
cairo_set_line_width ( d, 0 );
|
cairo_set_line_width ( d, 0 );
|
||||||
double radius_outer = radius_tr + minof_tr;
|
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_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, 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 - right, margin_top + offset_ttr );
|
||||||
if ( radius_inner_tr > 0 ) {
|
if ( radius_inner_tr > 0 ) {
|
||||||
cairo_arc_negative ( d, widget->w - margin_right - right - radius_inner_tr,
|
cairo_arc_negative ( d, widget->w - margin_right - right - radius_inner_tr,
|
||||||
margin_top + top + radius_inner_tr,
|
margin_top + top + radius_inner_tr,
|
||||||
|
@ -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_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 );
|
||||||
cairo_line_to ( d, widget->w - margin_right - offset_rbr, widget->h - margin_bottom - 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,
|
cairo_arc_negative ( d, widget->w - margin_right - right - radius_inner_br,
|
||||||
widget->h - margin_bottom - bottom - radius_inner_br,
|
widget->h - margin_bottom - bottom - radius_inner_br,
|
||||||
radius_inner_br, G_PI_2, 0.0 );
|
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 - 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_close_path ( d );
|
||||||
cairo_fill ( d );
|
cairo_fill ( d );
|
||||||
}
|
}
|
||||||
|
@ -343,7 +345,7 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
cairo_set_line_width ( d, 1.0 );
|
cairo_set_line_width ( d, 1.0 );
|
||||||
double radius_outer = radius_bl + minof_bl;
|
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_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 );
|
cairo_line_to ( d, margin_left + left, widget->h - margin_bottom - offset_bbl );
|
||||||
if ( radius_inner_bl > 0 ) {
|
if ( radius_inner_bl > 0 ) {
|
||||||
cairo_arc_negative ( d, margin_left + left + radius_inner_bl,
|
cairo_arc_negative ( d, margin_left + left + radius_inner_bl,
|
||||||
|
@ -353,14 +355,13 @@ void widget_draw ( widget *widget, cairo_t *d )
|
||||||
}
|
}
|
||||||
cairo_line_to ( d, margin_left + offset_lbl, widget->h - margin_bottom );
|
cairo_line_to ( d, margin_left + offset_lbl, widget->h - margin_bottom );
|
||||||
cairo_close_path ( d );
|
cairo_close_path ( d );
|
||||||
cairo_fill( d );
|
cairo_fill ( d );
|
||||||
}
|
}
|
||||||
cairo_restore ( d );
|
cairo_restore ( d );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void widget_free ( widget *wid )
|
void widget_free ( widget *wid )
|
||||||
{
|
{
|
||||||
if ( wid ) {
|
if ( wid ) {
|
||||||
|
|
42
source/xcb.c
42
source/xcb.c
|
@ -241,7 +241,7 @@ static workarea * x11_get_monitor_from_output ( xcb_randr_output_t out )
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( ( (XCB_RANDR_MAJOR_VERSION >= RANDR_PREF_MAJOR_VERSION ) && (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_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_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||||
/**
|
/**
|
||||||
* @param mon The randr monitor to parse.
|
* @param mon The randr monitor to parse.
|
||||||
|
@ -254,11 +254,11 @@ static workarea *x11_get_monitor_from_randr_monitor ( xcb_randr_monitor_info_t *
|
||||||
{
|
{
|
||||||
// Query to the name of the monitor.
|
// Query to the name of the monitor.
|
||||||
xcb_generic_error_t *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_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);
|
xcb_get_atom_name_reply_t *atom_reply = xcb_get_atom_name_reply ( xcb->connection, anc, &err );
|
||||||
if (err != NULL) {
|
if ( err != NULL ) {
|
||||||
g_warning ("Could not get RandR monitor name: X11 error code %d\n", err->error_code);
|
g_warning ( "Could not get RandR monitor name: X11 error code %d\n", err->error_code );
|
||||||
free(err);
|
free ( err );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
workarea *retv = g_malloc0 ( sizeof ( workarea ) );
|
workarea *retv = g_malloc0 ( sizeof ( workarea ) );
|
||||||
|
@ -277,7 +277,7 @@ static workarea *x11_get_monitor_from_randr_monitor ( xcb_randr_monitor_info_t *
|
||||||
retv->mh = mon->height_in_millimeters;
|
retv->mh = mon->height_in_millimeters;
|
||||||
|
|
||||||
// Name
|
// 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 name atom.
|
||||||
free ( atom_reply );
|
free ( atom_reply );
|
||||||
|
@ -354,19 +354,19 @@ static void x11_build_monitor_layout ()
|
||||||
g_debug ( "Query RANDR for 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 );
|
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 ) ) \
|
#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_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION )
|
||||||
xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version(xcb->connection,
|
xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version ( xcb->connection,
|
||||||
RANDR_PREF_MAJOR_VERSION, RANDR_PREF_MINOR_VERSION);
|
RANDR_PREF_MAJOR_VERSION, RANDR_PREF_MINOR_VERSION );
|
||||||
xcb_randr_query_version_reply_t *rversion = xcb_randr_query_version_reply( xcb->connection, cversion, NULL );
|
xcb_randr_query_version_reply_t *rversion = xcb_randr_query_version_reply ( xcb->connection, cversion, NULL );
|
||||||
if ( rversion ) {
|
if ( rversion ) {
|
||||||
g_debug ( "Found randr version: %d.%d", rversion->major_version, rversion->minor_version );
|
g_debug ( "Found randr version: %d.%d", rversion->major_version, rversion->minor_version );
|
||||||
// Check if we are 1.5 and up.
|
// Check if we are 1.5 and up.
|
||||||
if ( ( ( rversion->major_version == XCB_RANDR_MAJOR_VERSION ) && (rversion->minor_version >= XCB_RANDR_MINOR_VERSION ) ) ||
|
if ( ( ( rversion->major_version == XCB_RANDR_MAJOR_VERSION ) && ( rversion->minor_version >= XCB_RANDR_MINOR_VERSION ) ) ||
|
||||||
( rversion->major_version > XCB_RANDR_MAJOR_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_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 );
|
xcb_randr_get_monitors_reply_t *mreply = xcb_randr_get_monitors_reply ( xcb->connection, t, NULL );
|
||||||
if( mreply ) {
|
if ( mreply ) {
|
||||||
xcb_randr_monitor_info_iterator_t iter = xcb_randr_get_monitors_monitors_iterator ( mreply );
|
xcb_randr_monitor_info_iterator_t iter = xcb_randr_get_monitors_monitors_iterator ( mreply );
|
||||||
while ( iter.rem > 0 ) {
|
while ( iter.rem > 0 ) {
|
||||||
workarea *w = x11_get_monitor_from_randr_monitor ( iter.data );
|
workarea *w = x11_get_monitor_from_randr_monitor ( iter.data );
|
||||||
|
@ -374,7 +374,7 @@ static void x11_build_monitor_layout ()
|
||||||
w->next = xcb->monitors;
|
w->next = xcb->monitors;
|
||||||
xcb->monitors = w;
|
xcb->monitors = w;
|
||||||
}
|
}
|
||||||
xcb_randr_monitor_info_next (&iter);
|
xcb_randr_monitor_info_next ( &iter );
|
||||||
}
|
}
|
||||||
free ( mreply );
|
free ( mreply );
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,6 @@ static void x11_build_monitor_layout ()
|
||||||
free ( pc_rep );
|
free ( pc_rep );
|
||||||
}
|
}
|
||||||
free ( res_reply );
|
free ( res_reply );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number monitor
|
// Number monitor
|
||||||
|
@ -850,10 +849,12 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
|
||||||
|
|
||||||
xcb->last_timestamp = bpe->time;
|
xcb->last_timestamp = bpe->time;
|
||||||
rofi_view_handle_mouse_motion ( state, bpe->event_x, bpe->event_y );
|
rofi_view_handle_mouse_motion ( state, bpe->event_x, bpe->event_y );
|
||||||
if ( x11_button_to_nk_bindings_button ( bpe->detail, &button ) )
|
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 );
|
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) )
|
}
|
||||||
|
else if ( x11_button_to_nk_bindings_scroll ( bpe->detail, &axis, &steps ) ) {
|
||||||
nk_bindings_seat_handle_scroll ( xcb->bindings_seat, NULL, axis, steps );
|
nk_bindings_seat_handle_scroll ( xcb->bindings_seat, NULL, axis, steps );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XCB_BUTTON_RELEASE:
|
case XCB_BUTTON_RELEASE:
|
||||||
|
@ -862,8 +863,9 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
|
||||||
NkBindingsMouseButton button;
|
NkBindingsMouseButton button;
|
||||||
|
|
||||||
xcb->last_timestamp = bre->time;
|
xcb->last_timestamp = bre->time;
|
||||||
if ( x11_button_to_nk_bindings_button ( bre->detail, &button ) )
|
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 );
|
nk_bindings_seat_handle_button ( xcb->bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||||
|
}
|
||||||
if ( config.click_to_exit == TRUE ) {
|
if ( config.click_to_exit == TRUE ) {
|
||||||
if ( !xcb->mouse_seen ) {
|
if ( !xcb->mouse_seen ) {
|
||||||
rofi_view_temp_click_to_exit ( state, bre->event );
|
rofi_view_temp_click_to_exit ( state, bre->event );
|
||||||
|
|
Loading…
Add table
Reference in a new issue