mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Run indenter.
This commit is contained in:
parent
684211aba4
commit
9a62bfd172
23 changed files with 263 additions and 262 deletions
|
@ -40,24 +40,24 @@
|
|||
*
|
||||
* @returns Whether the setup succeeded or not
|
||||
*/
|
||||
gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings);
|
||||
gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings );
|
||||
|
||||
/**
|
||||
* Do some late setup of the display backend
|
||||
*
|
||||
* @returns Whether the setup succeeded or not
|
||||
*/
|
||||
gboolean display_late_setup(void);
|
||||
gboolean display_late_setup ( void );
|
||||
|
||||
/**
|
||||
* Do some early cleanup, like unmapping the surface
|
||||
*/
|
||||
void display_early_cleanup(void);
|
||||
void display_early_cleanup ( void );
|
||||
|
||||
/**
|
||||
* Cleanup any remaining display related stuff
|
||||
*/
|
||||
void display_cleanup(void);
|
||||
void display_cleanup ( void );
|
||||
|
||||
/**
|
||||
* Dumps the display layout for -help output
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* Type of a mode.
|
||||
* Access should be done via mode_* functions.
|
||||
*/
|
||||
typedef struct rofi_mode Mode;
|
||||
typedef struct rofi_mode Mode;
|
||||
|
||||
/**
|
||||
* Enum used to sum the possible states of ROFI.
|
||||
|
|
|
@ -80,11 +80,11 @@ typedef enum
|
|||
typedef struct
|
||||
{
|
||||
/** Distance */
|
||||
double distance;
|
||||
double distance;
|
||||
/** Unit type of the distance */
|
||||
RofiPixelUnit type;
|
||||
RofiPixelUnit type;
|
||||
/** Style of the line (optional)*/
|
||||
RofiLineStyle style;
|
||||
RofiLineStyle style;
|
||||
} RofiDistance;
|
||||
|
||||
/**
|
||||
|
@ -158,22 +158,23 @@ typedef struct
|
|||
/** style to display */
|
||||
RofiHighlightStyle style;
|
||||
/** Color */
|
||||
ThemeColor color;
|
||||
ThemeColor color;
|
||||
} RofiHighlightColorStyle;
|
||||
|
||||
typedef union {
|
||||
typedef union
|
||||
{
|
||||
/** integer */
|
||||
int i;
|
||||
int i;
|
||||
/** Double */
|
||||
double f;
|
||||
double f;
|
||||
/** String */
|
||||
char *s;
|
||||
char *s;
|
||||
/** boolean */
|
||||
gboolean b;
|
||||
gboolean b;
|
||||
/** Color */
|
||||
ThemeColor color;
|
||||
ThemeColor color;
|
||||
/** RofiPadding */
|
||||
RofiPadding padding;
|
||||
RofiPadding padding;
|
||||
/** Reference */
|
||||
struct
|
||||
{
|
||||
|
@ -181,11 +182,11 @@ typedef union {
|
|||
char *name;
|
||||
/** Cached looked up ref */
|
||||
struct Property *ref;
|
||||
} link;
|
||||
} link;
|
||||
/** Highlight Style */
|
||||
RofiHighlightColorStyle highlight;
|
||||
/** List */
|
||||
GList *list;
|
||||
GList *list;
|
||||
} PropertyValue;
|
||||
|
||||
/**
|
||||
|
@ -194,9 +195,9 @@ typedef union {
|
|||
typedef struct Property
|
||||
{
|
||||
/** Name of property */
|
||||
char *name;
|
||||
char *name;
|
||||
/** Type of property. */
|
||||
PropertyType type;
|
||||
PropertyType type;
|
||||
/** Value */
|
||||
PropertyValue value;
|
||||
} Property;
|
||||
|
@ -463,7 +464,7 @@ ThemeWidget *rofi_theme_find_widget ( const char *name, const char *state, gbool
|
|||
*/
|
||||
Property *rofi_theme_find_property ( ThemeWidget *widget, PropertyType type, const char *property, gboolean exact );
|
||||
|
||||
GList *rofi_theme_get_list ( const widget *widget, const char * property, const char *defaults);
|
||||
GList *rofi_theme_get_list ( const widget *widget, const char * property, const char *defaults );
|
||||
/**
|
||||
* Checks if a theme is set, or is empty.
|
||||
* @returns TRUE when empty.
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* @{
|
||||
*/
|
||||
typedef struct RofiViewState RofiViewState;
|
||||
typedef struct RofiViewState RofiViewState;
|
||||
typedef enum
|
||||
{
|
||||
/** Create a menu for entering text */
|
||||
|
@ -105,7 +105,7 @@ void rofi_view_handle_text ( RofiViewState *state, char *text );
|
|||
*
|
||||
* Update the state if needed.
|
||||
*/
|
||||
void rofi_view_handle_mouse_motion( RofiViewState *state, gint x, gint y );
|
||||
void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y );
|
||||
/**
|
||||
* @param state the Menu handle
|
||||
*
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
/**
|
||||
* Abstract handle to the box widget internal state.
|
||||
*/
|
||||
typedef struct _box box;
|
||||
typedef struct _box box;
|
||||
|
||||
/**
|
||||
* @param name The name of the widget.
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
/**
|
||||
* Abstract handle to the container widget internal state.
|
||||
*/
|
||||
typedef struct _window container;
|
||||
typedef struct _window container;
|
||||
|
||||
/**
|
||||
* @param name The name of the widget.
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* Handle to the listview.
|
||||
* No internal fields should be accessed directly.
|
||||
*/
|
||||
typedef struct _listview listview;
|
||||
typedef struct _listview listview;
|
||||
|
||||
/**
|
||||
* The scrolling type used in the list view
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef struct _scrollbar
|
|||
unsigned int length;
|
||||
unsigned int pos;
|
||||
unsigned int pos_length;
|
||||
RofiDistance width;
|
||||
RofiDistance width;
|
||||
} scrollbar;
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef struct
|
|||
int blink;
|
||||
guint blink_timeout;
|
||||
|
||||
double yalign ;
|
||||
double yalign;
|
||||
|
||||
PangoFontMetrics *metrics;
|
||||
int left_offset;
|
||||
|
|
|
@ -45,14 +45,14 @@ struct _widget
|
|||
/** Height of the widget */
|
||||
short h;
|
||||
/** RofiPadding */
|
||||
RofiPadding def_margin;
|
||||
RofiPadding def_padding;
|
||||
RofiPadding def_border;
|
||||
RofiPadding def_border_radius;
|
||||
RofiPadding margin;
|
||||
RofiPadding padding;
|
||||
RofiPadding border;
|
||||
RofiPadding border_radius;
|
||||
RofiPadding def_margin;
|
||||
RofiPadding def_padding;
|
||||
RofiPadding def_border;
|
||||
RofiPadding def_border_radius;
|
||||
RofiPadding margin;
|
||||
RofiPadding padding;
|
||||
RofiPadding border;
|
||||
RofiPadding border_radius;
|
||||
|
||||
/** enabled or not */
|
||||
gboolean enabled;
|
||||
|
@ -78,8 +78,8 @@ struct _widget
|
|||
/** Handle mouse motion, used for dragging */
|
||||
gboolean ( *motion_notify )( struct _widget *, gint x, gint y );
|
||||
|
||||
int ( *get_desired_height )( struct _widget * );
|
||||
int ( *get_desired_width )( struct _widget * );
|
||||
int ( *get_desired_height )( struct _widget * );
|
||||
int ( *get_desired_width )( struct _widget * );
|
||||
|
||||
/** widget find_mouse_target callback */
|
||||
widget_find_mouse_target_cb find_mouse_target;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
* Abstract structure holding internal state of a widget.
|
||||
* Structure is elaborated in widget-internal.h
|
||||
*/
|
||||
typedef struct _widget widget;
|
||||
typedef struct _widget widget;
|
||||
|
||||
/**
|
||||
* Type of the widget. It is used to bubble events to the relevant widget.
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/**
|
||||
* xcb data structure type declaration.
|
||||
*/
|
||||
typedef struct _xcb_stuff xcb_stuff;
|
||||
typedef struct _xcb_stuff xcb_stuff;
|
||||
|
||||
/**
|
||||
* Global pointer to xcb_stuff instance.
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
|
||||
#define DRUN_CACHE_FILE "rofi2.druncache"
|
||||
|
||||
|
||||
/**
|
||||
* Store extra information about the entry.
|
||||
* Currently the executable and if it should run in terminal.
|
||||
|
@ -62,13 +61,13 @@
|
|||
typedef struct
|
||||
{
|
||||
/* Root */
|
||||
char *root;
|
||||
char *root;
|
||||
/* Path to desktop file */
|
||||
char *path;
|
||||
char *path;
|
||||
/* Application id (.desktop filename) */
|
||||
char *app_id;
|
||||
char *app_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 )
|
||||
*/
|
||||
|
@ -97,12 +96,12 @@ typedef struct
|
|||
GHashTable *disabled_entries;
|
||||
unsigned int disabled_entries_length;
|
||||
GThread *thread;
|
||||
GAsyncQueue *icon_fetch_queue;
|
||||
GAsyncQueue *icon_fetch_queue;
|
||||
|
||||
unsigned int expected_line_height;
|
||||
DRunModeEntry quit_entry;
|
||||
DRunModeEntry quit_entry;
|
||||
// Theme
|
||||
const gchar *icon_theme;
|
||||
const gchar *icon_theme;
|
||||
} DRunModePrivateData;
|
||||
|
||||
struct RegexEvalArg
|
||||
|
@ -194,12 +193,12 @@ static void exec_cmd_entry ( DRunModeEntry *e )
|
|||
}
|
||||
|
||||
RofiHelperExecuteContext context = {
|
||||
.name = e->name,
|
||||
.icon = e->icon_name,
|
||||
.name = e->name,
|
||||
.icon = e->icon_name,
|
||||
.app_id = e->app_id,
|
||||
};
|
||||
gboolean sn = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "StartupNotify", NULL );
|
||||
gchar *wmclass = NULL;
|
||||
gboolean sn = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "StartupNotify", NULL );
|
||||
gchar *wmclass = NULL;
|
||||
if ( sn && g_key_file_has_key ( e->key_file, "Desktop Entry", "StartupWMClass", NULL ) ) {
|
||||
context.wmclass = wmclass = g_key_file_get_string ( e->key_file, "Desktop Entry", "StartupWMClass", NULL );
|
||||
}
|
||||
|
@ -298,15 +297,15 @@ static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, c
|
|||
pd->entry_list = g_realloc ( pd->entry_list, pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) );
|
||||
}
|
||||
pd->entry_list[pd->cmd_list_length].icon_size = 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].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].app_id = g_strndup ( basename, strlen ( basename ) - strlen ( ".desktop" ) );
|
||||
gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].name = n;
|
||||
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].generic_name = gn;
|
||||
pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL );
|
||||
pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL );
|
||||
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL );
|
||||
|
||||
if ( config.show_icons ) {
|
||||
pd->entry_list[pd->cmd_list_length].icon_name = g_key_file_get_locale_string ( kf, "Desktop Entry", "Icon", NULL, NULL );
|
||||
|
@ -435,16 +434,16 @@ static void get_apps ( DRunModePrivateData *pd )
|
|||
TICK_N ( "Get Desktop apps (user dir)" );
|
||||
// Then read thee system data dirs.
|
||||
const gchar * const * sys = g_get_system_data_dirs ();
|
||||
for (const gchar * const *iter = sys ; *iter != NULL; ++iter ) {
|
||||
for ( const gchar * const *iter = sys; *iter != NULL; ++iter ) {
|
||||
gboolean unique = TRUE;
|
||||
// Stupid duplicate detection, better then walking dir.
|
||||
for ( const gchar *const *iterd = sys ; iterd != iter; ++iterd ){
|
||||
for ( const gchar *const *iterd = sys; iterd != iter; ++iterd ) {
|
||||
if ( g_strcmp0 ( *iter, *iterd ) == 0 ) {
|
||||
unique = FALSE;
|
||||
}
|
||||
}
|
||||
// Check, we seem to be getting empty string...
|
||||
if ( unique && (**iter) != '\0') {
|
||||
if ( unique && ( **iter ) != '\0' ) {
|
||||
dir = g_build_filename ( *iter, "applications", NULL );
|
||||
walk_dir ( pd, dir, dir );
|
||||
g_free ( dir );
|
||||
|
@ -459,9 +458,8 @@ static gpointer drun_icon_fetch ( gpointer data )
|
|||
// as long as dr->icon is updated atomicly.. (is a pointer write atomic?)
|
||||
// this should be fine running in another thread.
|
||||
DRunModePrivateData *pd = (DRunModePrivateData *) data;
|
||||
DRunModeEntry *dr;
|
||||
while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue )) != &(pd->quit_entry) )
|
||||
{
|
||||
DRunModeEntry *dr;
|
||||
while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue ) ) != &( pd->quit_entry ) ) {
|
||||
if ( dr->icon_name == NULL ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -478,7 +476,7 @@ static gpointer drun_icon_fetch ( gpointer data )
|
|||
icon_surf = cairo_image_surface_create_from_png ( icon_path );
|
||||
}
|
||||
else if ( g_str_has_suffix ( icon_path, ".svg" ) ) {
|
||||
icon_surf = cairo_image_surface_create_from_svg ( icon_path, dr->icon_size);
|
||||
icon_surf = cairo_image_surface_create_from_svg ( icon_path, dr->icon_size );
|
||||
}
|
||||
else {
|
||||
g_debug ( "Icon type not yet supported: %s", icon_path );
|
||||
|
@ -488,7 +486,7 @@ static gpointer drun_icon_fetch ( gpointer data )
|
|||
if ( cairo_surface_status ( icon_surf ) != CAIRO_STATUS_SUCCESS ) {
|
||||
g_debug ( "Icon failed to open: %s(%d): %s", dr->icon_name, dr->icon_size, icon_path );
|
||||
cairo_surface_destroy ( icon_surf );
|
||||
icon_surf = NULL;
|
||||
icon_surf = NULL;
|
||||
}
|
||||
dr->icon = icon_surf;
|
||||
}
|
||||
|
@ -556,7 +554,7 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
|
|||
if ( rmpd->thread ) {
|
||||
g_async_queue_lock ( rmpd->icon_fetch_queue );
|
||||
DRunModeEntry *dr;
|
||||
while ( (dr = g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue )) != NULL ){
|
||||
while ( ( dr = g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) ) != NULL ) {
|
||||
// Reset for possible re-fetch.
|
||||
dr->icon_size = 0;
|
||||
}
|
||||
|
@ -578,9 +576,11 @@ static void drun_mode_destroy ( Mode *sw )
|
|||
if ( rmpd != NULL ) {
|
||||
if ( rmpd->thread ) {
|
||||
g_async_queue_lock ( rmpd->icon_fetch_queue );
|
||||
while ( g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) );
|
||||
while ( g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) ) {
|
||||
;
|
||||
}
|
||||
// Make the thread quit.
|
||||
g_async_queue_push_unlocked ( rmpd->icon_fetch_queue, (gpointer) &(rmpd->quit_entry));
|
||||
g_async_queue_push_unlocked ( rmpd->icon_fetch_queue, ( gpointer ) & ( rmpd->quit_entry ) );
|
||||
g_async_queue_unlock ( rmpd->icon_fetch_queue );
|
||||
g_thread_join ( rmpd->thread );
|
||||
rmpd->thread = NULL;
|
||||
|
|
|
@ -91,7 +91,7 @@ static void exec_cmd ( const char *cmd, int run_in_term )
|
|||
return;
|
||||
}
|
||||
|
||||
char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL );
|
||||
char *path = g_build_filename ( cache_dir, RUN_CACHE_FILE, NULL );
|
||||
RofiHelperExecuteContext context = { .name = NULL };
|
||||
// FIXME: assume startup notification support for terminals
|
||||
if ( helper_execute_command ( NULL, lf_cmd, run_in_term, run_in_term ? &context : NULL ) ) {
|
||||
|
|
|
@ -201,7 +201,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
|
|||
// Reading one line per time.
|
||||
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
|
||||
// Evaluate one line.
|
||||
unsigned int index = 0, ti = 0;
|
||||
unsigned int index = 0, ti = 0;
|
||||
char *token = buffer;
|
||||
|
||||
// Tokenize it.
|
||||
|
|
|
@ -257,7 +257,7 @@ GRegex **tokenize ( const char *input, int case_sensitive )
|
|||
}
|
||||
|
||||
char *saveptr = NULL, *token;
|
||||
GRegex **retv = NULL;
|
||||
GRegex **retv = NULL;
|
||||
if ( !config.tokenize ) {
|
||||
retv = g_malloc0 ( sizeof ( GRegex* ) * 2 );
|
||||
retv[0] = (GRegex *) create_regex ( input, case_sensitive );
|
||||
|
@ -896,8 +896,8 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st
|
|||
// uleft: value of the upper left cell; ulefts: maximum value of uleft and cells on the left. The arbitrary initial
|
||||
// values suppress warnings.
|
||||
int uleft = 0, ulefts = 0, left, lefts;
|
||||
const gchar *pit = pattern, *sit;
|
||||
enum CharClass prev = NON_WORD;
|
||||
const gchar *pit = pattern, *sit;
|
||||
enum CharClass prev = NON_WORD;
|
||||
for ( si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char ( sit ) ) {
|
||||
enum CharClass cur = rofi_scorer_get_character_class ( g_utf8_get_char ( sit ) );
|
||||
score[si] = rofi_scorer_get_score_for ( prev, cur );
|
||||
|
|
|
@ -95,10 +95,10 @@ unsigned int num_modi = 0;
|
|||
/** Current selected mode */
|
||||
unsigned int curr_switcher = 0;
|
||||
|
||||
NkBindings *bindings = NULL;
|
||||
NkBindings *bindings = NULL;
|
||||
|
||||
/** Glib main loop. */
|
||||
GMainLoop *main_loop = NULL;
|
||||
GMainLoop *main_loop = NULL;
|
||||
|
||||
/** Flag indicating we are in dmenu mode. */
|
||||
static int dmenu_mode = FALSE;
|
||||
|
|
|
@ -386,7 +386,8 @@ static ThemeWidget *rofi_theme_find ( ThemeWidget *widget, const char *name, con
|
|||
if ( f != widget ) {
|
||||
widget = f;
|
||||
found = TRUE;
|
||||
} else if ( exact ) {
|
||||
}
|
||||
else if ( exact ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -505,7 +506,7 @@ int rofi_theme_get_integer_exact ( const widget *widget, const char *property, i
|
|||
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||
return def;
|
||||
}
|
||||
static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char *property, int def , gboolean exact)
|
||||
static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char *property, int def, gboolean exact )
|
||||
{
|
||||
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, exact );
|
||||
Property *p = rofi_theme_find_property ( wid, P_PADDING, property, exact );
|
||||
|
@ -521,14 +522,13 @@ static RofiDistance _rofi_theme_get_distance ( const widget *widget, const char
|
|||
return (RofiDistance){ def, ROFI_PU_PX, ROFI_HL_SOLID };
|
||||
}
|
||||
|
||||
|
||||
RofiDistance rofi_theme_get_distance_exact ( const widget *widget, const char *property, int def )
|
||||
{
|
||||
return _rofi_theme_get_distance ( widget, property, def , TRUE );
|
||||
return _rofi_theme_get_distance ( widget, property, def, TRUE );
|
||||
}
|
||||
RofiDistance rofi_theme_get_distance ( const widget *widget, const char *property, int def )
|
||||
{
|
||||
return _rofi_theme_get_distance ( widget, property, def , FALSE);
|
||||
return _rofi_theme_get_distance ( widget, property, def, FALSE );
|
||||
}
|
||||
|
||||
int rofi_theme_get_boolean ( const widget *widget, const char *property, int def )
|
||||
|
@ -608,19 +608,19 @@ RofiPadding rofi_theme_get_padding ( const widget *widget, const char *property,
|
|||
GList *rofi_theme_get_list ( const widget *widget, const char * property, const char *defaults )
|
||||
{
|
||||
ThemeWidget *wid2 = rofi_theme_find_widget ( widget->name, widget->state, TRUE );
|
||||
Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE);
|
||||
Property *p = rofi_theme_find_property ( wid2, P_LIST, property, TRUE );
|
||||
if ( p ) {
|
||||
if ( p->type == P_LIST ){
|
||||
if ( p->type == P_LIST ) {
|
||||
return g_list_copy_deep ( p->value.list, g_strdup, NULL );
|
||||
}
|
||||
}
|
||||
char **r = defaults?g_strsplit (defaults, ",",0):NULL;
|
||||
if ( r ){
|
||||
char **r = defaults ? g_strsplit ( defaults, ",", 0 ) : NULL;
|
||||
if ( r ) {
|
||||
GList *l = NULL;
|
||||
for ( int i =0; r[i] != NULL; i++){
|
||||
l = g_list_append(l, r[i]);
|
||||
for ( int i = 0; r[i] != NULL; i++ ) {
|
||||
l = g_list_append ( l, r[i] );
|
||||
}
|
||||
g_free(r);
|
||||
g_free ( r );
|
||||
return l;
|
||||
}
|
||||
return NULL;
|
||||
|
|
109
source/view.c
109
source/view.c
|
@ -652,9 +652,9 @@ void __create_window ( MenuFlags menu_flags )
|
|||
};
|
||||
|
||||
xcb_window_t box_window = xcb_generate_id ( xcb->connection );
|
||||
xcb_void_cookie_t cc = xcb_create_window_checked ( xcb->connection, depth->depth, box_window, xcb_stuff_get_root_window ( ),
|
||||
0, 0, 200, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
visual->visual_id, selmask, selval );
|
||||
xcb_void_cookie_t cc = xcb_create_window_checked ( xcb->connection, depth->depth, box_window, xcb_stuff_get_root_window ( ),
|
||||
0, 0, 200, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
visual->visual_id, selmask, selval );
|
||||
xcb_generic_error_t *error;
|
||||
error = xcb_request_check ( xcb->connection, cc );
|
||||
if ( error ) {
|
||||
|
@ -709,7 +709,7 @@ void __create_window ( MenuFlags menu_flags )
|
|||
}
|
||||
// Setup font.
|
||||
// Dummy widget.
|
||||
box *win = box_create ( "window.box_window", ROFI_ORIENTATION_HORIZONTAL);
|
||||
box *win = box_create ( "window.box_window", ROFI_ORIENTATION_HORIZONTAL );
|
||||
const char *font = rofi_theme_get_string ( WIDGET ( win ), "font", config.menu_font );
|
||||
if ( font ) {
|
||||
PangoFontDescription *pfd = pango_font_description_from_string ( font );
|
||||
|
@ -1325,7 +1325,7 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, BindingsScope scope, g
|
|||
case SCOPE_MOUSE_SCROLLBAR:
|
||||
case SCOPE_MOUSE_SIDEBAR_MODI:
|
||||
{
|
||||
gint x = state->mouse.x, y = state->mouse.y;
|
||||
gint x = state->mouse.x, y = state->mouse.y;
|
||||
widget *target = widget_find_mouse_target ( WIDGET ( state->main_window ), scope, x, y );
|
||||
if ( target == NULL ) {
|
||||
return FALSE;
|
||||
|
@ -1355,7 +1355,7 @@ void rofi_view_handle_text ( RofiViewState *state, char *text )
|
|||
}
|
||||
}
|
||||
|
||||
void rofi_view_handle_mouse_motion( RofiViewState *state, gint x, gint y )
|
||||
void rofi_view_handle_mouse_motion ( RofiViewState *state, gint x, gint y )
|
||||
{
|
||||
state->mouse.x = x;
|
||||
state->mouse.y = y;
|
||||
|
@ -1372,7 +1372,7 @@ void rofi_view_maybe_update ( RofiViewState *state )
|
|||
rofi_view_finalize ( state );
|
||||
// cleanup
|
||||
if ( rofi_view_get_active () == NULL ) {
|
||||
rofi_quit_main_loop();
|
||||
rofi_quit_main_loop ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1484,78 +1484,77 @@ static void rofi_view_listview_mouse_activated_cb ( listview *lv, gboolean custo
|
|||
state->skip_absorb = TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, const char *parent, const char *name )
|
||||
{
|
||||
char *defaults = NULL;
|
||||
widget *wid = NULL;
|
||||
char *str= g_strjoin ( "." , parent, name, NULL );
|
||||
char *strbox= g_strjoin ( "." , str, "box",NULL );
|
||||
char *defaults = NULL;
|
||||
widget *wid = NULL;
|
||||
char *str = g_strjoin ( ".", parent, name, NULL );
|
||||
char *strbox = g_strjoin ( ".", str, "box", NULL );
|
||||
|
||||
/**
|
||||
* MAINBOX
|
||||
*/
|
||||
if ( strcmp ( name, "mainbox") == 0 ){
|
||||
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
|
||||
box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE );
|
||||
if ( strcmp ( name, "mainbox" ) == 0 ) {
|
||||
wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
|
||||
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
||||
defaults = "inputbar,message,listview,sidebar";
|
||||
}
|
||||
/**
|
||||
* INPUTBAR
|
||||
*/
|
||||
else if ( strcmp ( name, "inputbar" ) == 0 ){
|
||||
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
|
||||
else if ( strcmp ( name, "inputbar" ) == 0 ) {
|
||||
wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
|
||||
defaults = "prompt,entry,case-indicator";
|
||||
|
||||
box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE );
|
||||
box_add ( (box *) parent_widget, WIDGET ( wid ), FALSE );
|
||||
}
|
||||
/**
|
||||
* PROMPT
|
||||
*/
|
||||
else if ( strcmp ( name, "prompt" ) == 0 ){
|
||||
else if ( strcmp ( name, "prompt" ) == 0 ) {
|
||||
// Prompt box.
|
||||
state->prompt = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "" );
|
||||
rofi_view_update_prompt ( state );
|
||||
box_add ( (box *)parent_widget, WIDGET ( state->prompt ), FALSE );
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->prompt ), FALSE );
|
||||
defaults = NULL;
|
||||
}
|
||||
/**
|
||||
* CASE INDICATOR
|
||||
*/
|
||||
else if ( strcmp ( name, "case-indicator") == 0 ){
|
||||
else if ( strcmp ( name, "case-indicator" ) == 0 ) {
|
||||
state->case_indicator = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_AUTOWIDTH | TB_AUTOHEIGHT, NORMAL, "*" );
|
||||
// Add small separator between case indicator and text box.
|
||||
box_add ( (box *)parent_widget, WIDGET ( state->case_indicator ), FALSE );
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->case_indicator ), FALSE );
|
||||
textbox_text ( state->case_indicator, get_matching_state () );
|
||||
}
|
||||
/**
|
||||
* ENTRY BOX
|
||||
*/
|
||||
else if ( strcmp ( name, "entry" ) == 0 ){
|
||||
else if ( strcmp ( name, "entry" ) == 0 ) {
|
||||
// Entry box
|
||||
TextboxFlags tfl = TB_EDITABLE;
|
||||
tfl |= ( ( state->menu_flags & MENU_PASSWORD ) == MENU_PASSWORD ) ? TB_PASSWORD : 0;
|
||||
state->text = textbox_create ( WIDGET_TYPE_EDITBOX, str, tfl | TB_AUTOHEIGHT, NORMAL, NULL);
|
||||
box_add ( (box*)parent_widget, WIDGET ( state->text ), TRUE );
|
||||
state->text = textbox_create ( WIDGET_TYPE_EDITBOX, str, tfl | TB_AUTOHEIGHT, NORMAL, NULL );
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->text ), TRUE );
|
||||
}
|
||||
/**
|
||||
* MESSAGE
|
||||
*/
|
||||
else if ( strcmp ( name, "message") == 0 ){
|
||||
char *strmsg= g_strjoin ( "." , str, "textbox",NULL );
|
||||
else if ( strcmp ( name, "message" ) == 0 ) {
|
||||
char *strmsg = g_strjoin ( ".", str, "textbox", NULL );
|
||||
state->mesg_box = container_create ( strbox );
|
||||
state->mesg_tb = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, strmsg, TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, NORMAL, NULL );
|
||||
container_add ( state->mesg_box, WIDGET ( state->mesg_tb ) );
|
||||
rofi_view_reload_message_bar ( state );
|
||||
box_add ( (box*)parent_widget, WIDGET ( state->mesg_box ), FALSE );
|
||||
g_free(strmsg);
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->mesg_box ), FALSE );
|
||||
g_free ( strmsg );
|
||||
}
|
||||
/**
|
||||
* LISTVIEW
|
||||
*/
|
||||
else if ( strcmp ( name, "listview" ) == 0 ) {
|
||||
state->list_view = listview_create ( str, update_callback, state, config.element_height, 0);
|
||||
box_add ( (box*)parent_widget, WIDGET ( state->list_view ), TRUE );
|
||||
state->list_view = listview_create ( str, update_callback, state, config.element_height, 0 );
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->list_view ), TRUE );
|
||||
// Set configuration
|
||||
listview_set_multi_select ( state->list_view, ( state->menu_flags & MENU_INDICATOR ) == MENU_INDICATOR );
|
||||
listview_set_scroll_type ( state->list_view, config.scroll_method );
|
||||
|
@ -1568,39 +1567,41 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
|
|||
/**
|
||||
* SIDEBAR
|
||||
*/
|
||||
else if ( strcmp( name, "sidebar" ) == 0 ) {
|
||||
if ( config.sidebar_mode ){
|
||||
else if ( strcmp ( name, "sidebar" ) == 0 ) {
|
||||
if ( config.sidebar_mode ) {
|
||||
state->sidebar_bar = box_create ( strbox, ROFI_ORIENTATION_HORIZONTAL );
|
||||
box_add ( (box*)parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
|
||||
box_add ( (box *) parent_widget, WIDGET ( state->sidebar_bar ), FALSE );
|
||||
state->num_modi = rofi_get_num_enabled_modi ();
|
||||
state->modi = g_malloc0 ( state->num_modi * sizeof ( textbox * ) );
|
||||
char *strbutton= g_strjoin ( "." , str, "button",NULL );
|
||||
char *strbutton = g_strjoin ( ".", str, "button", NULL );
|
||||
for ( unsigned int j = 0; j < state->num_modi; j++ ) {
|
||||
const Mode * mode = rofi_get_mode ( j );
|
||||
state->modi[j] = textbox_create ( WIDGET_TYPE_SIDEBAR_MODI, strbutton, TB_CENTER | TB_AUTOHEIGHT, ( mode == state->sw ) ? HIGHLIGHT : NORMAL,
|
||||
mode_get_display_name ( mode ) );
|
||||
mode_get_display_name ( mode ) );
|
||||
box_add ( state->sidebar_bar, WIDGET ( state->modi[j] ), TRUE );
|
||||
widget_set_trigger_action_handler ( WIDGET ( state->modi[j] ), textbox_sidebar_modi_trigger_action, state );
|
||||
}
|
||||
g_free(strbutton);
|
||||
g_free ( strbutton );
|
||||
}
|
||||
} else if ( g_ascii_strncasecmp ( name, "textbox", 7) == 0 ){
|
||||
textbox *t = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_WRAP, NORMAL, "");
|
||||
box_add ( (box *)parent_widget, WIDGET(t), TRUE);
|
||||
} else {
|
||||
wid = (widget *)box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
|
||||
box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE );
|
||||
}
|
||||
else if ( g_ascii_strncasecmp ( name, "textbox", 7 ) == 0 ) {
|
||||
textbox *t = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, str, TB_WRAP, NORMAL, "" );
|
||||
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
|
||||
}
|
||||
else {
|
||||
wid = (widget *) box_create ( strbox, ROFI_ORIENTATION_VERTICAL );
|
||||
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );
|
||||
//g_error("The widget %s does not exists. Invalid layout.", name);
|
||||
}
|
||||
if ( wid ) {
|
||||
GList *list = rofi_theme_get_list ( wid, "children",defaults);
|
||||
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter )){
|
||||
rofi_view_add_widget ( state, wid, str, (const char *)iter->data );
|
||||
GList *list = rofi_theme_get_list ( wid, "children", defaults );
|
||||
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
rofi_view_add_widget ( state, wid, str, (const char *) iter->data );
|
||||
}
|
||||
g_list_free_full ( list, g_free );
|
||||
}
|
||||
g_free(strbox);
|
||||
g_free(str);
|
||||
g_free ( strbox );
|
||||
g_free ( str );
|
||||
}
|
||||
|
||||
RofiViewState *rofi_view_create ( Mode *sw,
|
||||
|
@ -1630,16 +1631,15 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
|||
// Get active monitor size.
|
||||
TICK_N ( "Get active monitor" );
|
||||
|
||||
|
||||
state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL );
|
||||
// Get children.
|
||||
GList *list = rofi_theme_get_list ( WIDGET(state->main_window), "children", "mainbox");
|
||||
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter )){
|
||||
rofi_view_add_widget ( state, WIDGET(state->main_window), "window", (const char *)iter->data );
|
||||
GList *list = rofi_theme_get_list ( WIDGET ( state->main_window ), "children", "mainbox" );
|
||||
for ( const GList *iter = list; iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
rofi_view_add_widget ( state, WIDGET ( state->main_window ), "window", (const char *) iter->data );
|
||||
}
|
||||
g_list_free_full ( list, g_free );
|
||||
|
||||
if ( state->text && input) {
|
||||
if ( state->text && input ) {
|
||||
textbox_text ( state->text, input );
|
||||
}
|
||||
|
||||
|
@ -1647,7 +1647,6 @@ RofiViewState *rofi_view_create ( Mode *sw,
|
|||
state->overlay->widget.parent = WIDGET ( state->main_window );
|
||||
widget_disable ( WIDGET ( state->overlay ) );
|
||||
|
||||
|
||||
// filtered list
|
||||
state->line_map = g_malloc0_n ( state->num_lines, sizeof ( unsigned int ) );
|
||||
state->distance = (int *) g_malloc0_n ( state->num_lines, sizeof ( int ) );
|
||||
|
@ -1683,7 +1682,7 @@ int rofi_view_error_dialog ( const char *msg, int markup )
|
|||
state->finalize = process_result;
|
||||
|
||||
state->main_window = box_create ( "window.box", ROFI_ORIENTATION_VERTICAL );
|
||||
box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL );
|
||||
box *box = box_create ( "window.mainbox.message.box", ROFI_ORIENTATION_VERTICAL );
|
||||
box_add ( state->main_window, WIDGET ( box ), TRUE );
|
||||
state->text = textbox_create ( WIDGET_TYPE_TEXTBOX_TEXT, "window.mainbox.message.textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||
NORMAL, ( msg != NULL ) ? msg : "" );
|
||||
|
|
|
@ -39,23 +39,22 @@
|
|||
|
||||
struct _box
|
||||
{
|
||||
widget widget;
|
||||
widget widget;
|
||||
RofiOrientation type;
|
||||
int max_size;
|
||||
int max_size;
|
||||
// RofiPadding between elements
|
||||
RofiDistance spacing;
|
||||
RofiDistance spacing;
|
||||
|
||||
GList *children;
|
||||
GList *children;
|
||||
};
|
||||
|
||||
static void box_update ( widget *wid );
|
||||
|
||||
|
||||
static int box_get_desired_width ( widget *wid )
|
||||
{
|
||||
box *b = (box *) wid;
|
||||
int spacing = distance_get_pixel ( b->spacing, b->type );
|
||||
int width = 0;
|
||||
int width = 0;
|
||||
if ( b->type == ROFI_ORIENTATION_HORIZONTAL ) {
|
||||
int active_widgets = 0;
|
||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
|
@ -91,7 +90,7 @@ static int box_get_desired_height ( widget *wid )
|
|||
box *b = (box *) wid;
|
||||
int spacing = distance_get_pixel ( b->spacing, b->type );
|
||||
int height = 0;
|
||||
if ( b->type == ROFI_ORIENTATION_VERTICAL) {
|
||||
if ( b->type == ROFI_ORIENTATION_VERTICAL ) {
|
||||
int active_widgets = 0;
|
||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
widget * child = (widget *) iter->data;
|
||||
|
@ -197,8 +196,8 @@ static void hori_calculate_size ( box *b )
|
|||
widget * child = (widget *) iter->data;
|
||||
if ( child->enabled && child->expand == FALSE ) {
|
||||
widget_resize ( child,
|
||||
widget_get_desired_width ( child ), //child->w,
|
||||
rem_height );
|
||||
widget_get_desired_width ( child ), //child->w,
|
||||
rem_height );
|
||||
}
|
||||
}
|
||||
b->max_size = 0;
|
||||
|
@ -340,7 +339,7 @@ box * box_create ( const char *name, RofiOrientation type )
|
|||
b->widget.get_desired_width = box_get_desired_width;
|
||||
b->widget.enabled = rofi_theme_get_boolean ( WIDGET ( b ), "enabled", TRUE );
|
||||
|
||||
b->type = rofi_theme_get_orientation ( WIDGET (b), "orientation",b->type );
|
||||
b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type );
|
||||
|
||||
b->spacing = rofi_theme_get_distance ( WIDGET ( b ), "spacing", DEFAULT_SPACING );
|
||||
return b;
|
||||
|
|
|
@ -37,21 +37,23 @@
|
|||
|
||||
#define DEFAULT_SPACING 2
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
LISTVIEW = 0,
|
||||
BARVIEW = 1,
|
||||
} ViewType;
|
||||
|
||||
typedef enum {
|
||||
LEFT_TO_RIGHT = 0,
|
||||
RIGHT_TO_LEFT = 1
|
||||
typedef enum
|
||||
{
|
||||
LEFT_TO_RIGHT = 0,
|
||||
RIGHT_TO_LEFT = 1
|
||||
} MoveDirection;
|
||||
|
||||
struct _listview
|
||||
{
|
||||
widget widget;
|
||||
widget widget;
|
||||
|
||||
ViewType type;
|
||||
ViewType type;
|
||||
|
||||
// RChanged
|
||||
// Text needs to be repainted.
|
||||
|
@ -100,9 +102,10 @@ struct _listview
|
|||
char *listview_name;
|
||||
|
||||
/** Barview */
|
||||
struct {
|
||||
MoveDirection direction;
|
||||
unsigned int cur_visible;
|
||||
struct
|
||||
{
|
||||
MoveDirection direction;
|
||||
unsigned int cur_visible;
|
||||
} barview;
|
||||
};
|
||||
|
||||
|
@ -127,14 +130,14 @@ static unsigned int scroll_per_page_barview ( listview *lv )
|
|||
// selected row is always visible.
|
||||
// If selected is visible do not scroll.
|
||||
if ( lv->selected < lv->last_offset ) {
|
||||
offset = lv->selected;
|
||||
offset = lv->selected;
|
||||
lv->rchanged = TRUE;
|
||||
} else if ( lv->selected >= (lv->last_offset + lv->barview.cur_visible ) ) {
|
||||
offset = lv->selected;
|
||||
}
|
||||
else if ( lv->selected >= ( lv->last_offset + lv->barview.cur_visible ) ) {
|
||||
offset = lv->selected;
|
||||
lv->rchanged = TRUE;
|
||||
}
|
||||
return offset;
|
||||
|
||||
}
|
||||
static unsigned int scroll_per_page ( listview * lv )
|
||||
{
|
||||
|
@ -194,14 +197,14 @@ static void update_element ( listview *lv, unsigned int tb, unsigned int index,
|
|||
static void barview_draw ( widget *wid, cairo_t *draw )
|
||||
{
|
||||
unsigned int offset = 0;
|
||||
listview *lv = (listview *) wid;
|
||||
offset = scroll_per_page_barview ( lv );
|
||||
listview *lv = (listview *) wid;
|
||||
offset = scroll_per_page_barview ( lv );
|
||||
lv->last_offset = offset;
|
||||
int spacing_hori = distance_get_pixel ( lv->spacing, ROFI_ORIENTATION_HORIZONTAL );
|
||||
|
||||
int left_offset = widget_padding_get_left ( wid );
|
||||
int right_offset = lv->widget.w - widget_padding_get_right( wid );
|
||||
int top_offset = widget_padding_get_top ( wid );
|
||||
int left_offset = widget_padding_get_left ( wid );
|
||||
int right_offset = lv->widget.w - widget_padding_get_right ( wid );
|
||||
int top_offset = widget_padding_get_top ( wid );
|
||||
if ( lv->cur_elements > 0 ) {
|
||||
// Set new x/y possition.
|
||||
unsigned int max = MIN ( lv->cur_elements, lv->req_elements - offset );
|
||||
|
@ -209,13 +212,13 @@ static void barview_draw ( widget *wid, cairo_t *draw )
|
|||
int first = TRUE;
|
||||
int width = lv->widget.w;
|
||||
lv->barview.cur_visible = 0;
|
||||
width -= widget_padding_get_padding_width ( wid );
|
||||
width -= widget_padding_get_padding_width ( wid );
|
||||
if ( lv->barview.direction == LEFT_TO_RIGHT ) {
|
||||
for ( unsigned int i = 0; i < max&& width > 0; i++ ) {
|
||||
for ( unsigned int i = 0; i < max && width > 0; i++ ) {
|
||||
update_element ( lv, i, i + offset, TRUE );
|
||||
int twidth = textbox_get_desired_width ( WIDGET(lv->boxes[i]));
|
||||
int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] ) );
|
||||
if ( twidth >= width ) {
|
||||
if ( ! first ) {
|
||||
if ( !first ) {
|
||||
break;
|
||||
}
|
||||
twidth = width;
|
||||
|
@ -223,17 +226,18 @@ static void barview_draw ( widget *wid, cairo_t *draw )
|
|||
textbox_moveresize ( lv->boxes[i], left_offset, top_offset, twidth, lv->element_height );
|
||||
|
||||
widget_draw ( WIDGET ( lv->boxes[i] ), draw );
|
||||
width -= twidth + spacing_hori;
|
||||
width -= twidth + spacing_hori;
|
||||
left_offset += twidth + spacing_hori;
|
||||
first = FALSE;
|
||||
lv->barview.cur_visible++ ;
|
||||
first = FALSE;
|
||||
lv->barview.cur_visible++;
|
||||
}
|
||||
} else {
|
||||
for ( unsigned int i = 0; i < lv->cur_elements && width > 0 && i <= offset; i++ ) {
|
||||
update_element ( lv, i, offset-i, TRUE );
|
||||
int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] ));
|
||||
}
|
||||
else {
|
||||
for ( unsigned int i = 0; i < lv->cur_elements && width > 0 && i <= offset; i++ ) {
|
||||
update_element ( lv, i, offset - i, TRUE );
|
||||
int twidth = textbox_get_desired_width ( WIDGET ( lv->boxes[i] ) );
|
||||
if ( twidth >= width ) {
|
||||
if ( ! first ) {
|
||||
if ( !first ) {
|
||||
break;
|
||||
}
|
||||
twidth = width;
|
||||
|
@ -242,21 +246,19 @@ static void barview_draw ( widget *wid, cairo_t *draw )
|
|||
textbox_moveresize ( lv->boxes[i], right_offset, top_offset, twidth, lv->element_height );
|
||||
|
||||
widget_draw ( WIDGET ( lv->boxes[i] ), draw );
|
||||
width -= twidth + spacing_hori;
|
||||
width -= twidth + spacing_hori;
|
||||
right_offset -= spacing_hori;
|
||||
first = FALSE;
|
||||
lv->barview.cur_visible++ ;
|
||||
first = FALSE;
|
||||
lv->barview.cur_visible++;
|
||||
}
|
||||
offset -= lv->barview.cur_visible-1;
|
||||
offset -= lv->barview.cur_visible - 1;
|
||||
lv->last_offset = offset;
|
||||
for ( unsigned int i = 0; i < (lv->barview.cur_visible/2); i++)
|
||||
{
|
||||
for ( unsigned int i = 0; i < ( lv->barview.cur_visible / 2 ); i++ ) {
|
||||
void * temp = lv->boxes[i];
|
||||
int sw = lv->barview.cur_visible-i-1;
|
||||
lv->boxes[i] = lv->boxes[sw];
|
||||
int sw = lv->barview.cur_visible - i - 1;
|
||||
lv->boxes[i] = lv->boxes[sw];
|
||||
lv->boxes[sw] = temp;
|
||||
}
|
||||
|
||||
}
|
||||
lv->rchanged = FALSE;
|
||||
}
|
||||
|
@ -295,10 +297,10 @@ static void listview_draw ( widget *wid, cairo_t *draw )
|
|||
int left_offset = widget_padding_get_left ( wid );
|
||||
int top_offset = widget_padding_get_top ( wid );
|
||||
/*
|
||||
if ( lv->scrollbar->widget.index == 0 ) {
|
||||
if ( lv->scrollbar->widget.index == 0 ) {
|
||||
left_offset += spacing_hori + lv->scrollbar->widget.w;
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
if ( lv->cur_elements > 0 && lv->max_rows > 0 ) {
|
||||
// Set new x/y possition.
|
||||
unsigned int max = MIN ( lv->cur_elements, lv->req_elements - offset );
|
||||
|
@ -339,11 +341,11 @@ static WidgetTriggerActionResult listview_element_trigger_action ( widget *wid,
|
|||
|
||||
static void _listview_draw ( widget *wid, cairo_t *draw )
|
||||
{
|
||||
listview *lv = (listview *)wid;
|
||||
if ( lv->type == LISTVIEW )
|
||||
{
|
||||
listview *lv = (listview *) wid;
|
||||
if ( lv->type == LISTVIEW ) {
|
||||
listview_draw ( wid, draw );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
barview_draw ( wid, draw );
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +403,7 @@ unsigned int listview_get_selected ( listview *lv )
|
|||
void listview_set_selected ( listview *lv, unsigned int selected )
|
||||
{
|
||||
if ( lv && lv->req_elements > 0 ) {
|
||||
lv->selected = MIN ( selected, lv->req_elements - 1 );
|
||||
lv->selected = MIN ( selected, lv->req_elements - 1 );
|
||||
lv->barview.direction = LEFT_TO_RIGHT;
|
||||
widget_queue_redraw ( WIDGET ( lv ) );
|
||||
}
|
||||
|
@ -429,7 +431,7 @@ static void listview_resize ( widget *wid, short w, short h )
|
|||
}
|
||||
widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), height );
|
||||
|
||||
if ( lv->type == BARVIEW ) {
|
||||
if ( lv->type == BARVIEW ) {
|
||||
lv->max_elements = lv->menu_lines;
|
||||
}
|
||||
|
||||
|
@ -547,12 +549,13 @@ listview *listview_create ( const char *name, listview_update_callback cb, void
|
|||
lv->fixed_num_lines = rofi_theme_get_boolean ( WIDGET ( lv ), "fixed-height", config.fixed_num_lines );
|
||||
lv->dynamic = rofi_theme_get_boolean ( WIDGET ( lv ), "dynamic", TRUE );
|
||||
lv->reverse = rofi_theme_get_boolean ( WIDGET ( lv ), "reverse", reverse );
|
||||
lv->cycle = rofi_theme_get_boolean ( WIDGET ( lv ), "cycle", config.cycle );
|
||||
lv->cycle = rofi_theme_get_boolean ( WIDGET ( lv ), "cycle", config.cycle );
|
||||
|
||||
lv->type = rofi_theme_get_boolean ( WIDGET (lv) , "barview", FALSE );
|
||||
lv->type = rofi_theme_get_boolean ( WIDGET ( lv ), "barview", FALSE );
|
||||
if ( lv->type == LISTVIEW ) {
|
||||
listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( WIDGET ( lv ), "scrollbar", FALSE ) );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
listview_set_show_scrollbar ( lv, FALSE );
|
||||
}
|
||||
return lv;
|
||||
|
@ -585,7 +588,7 @@ static void listview_nav_down_int ( listview *lv )
|
|||
if ( lv->req_elements == 0 || ( lv->selected == ( lv->req_elements - 1 ) && !lv->cycle ) ) {
|
||||
return;
|
||||
}
|
||||
lv->selected = lv->selected < lv->req_elements - 1 ? MIN ( lv->req_elements - 1, lv->selected + 1 ) : 0;
|
||||
lv->selected = lv->selected < lv->req_elements - 1 ? MIN ( lv->req_elements - 1, lv->selected + 1 ) : 0;
|
||||
lv->barview.direction = LEFT_TO_RIGHT;
|
||||
widget_queue_redraw ( WIDGET ( lv ) );
|
||||
}
|
||||
|
@ -620,8 +623,8 @@ void listview_nav_left ( listview *lv )
|
|||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->type == BARVIEW ){
|
||||
listview_nav_up_int(lv);
|
||||
if ( lv->type == BARVIEW ) {
|
||||
listview_nav_up_int ( lv );
|
||||
return;
|
||||
}
|
||||
if ( lv->selected >= lv->max_rows ) {
|
||||
|
@ -634,8 +637,8 @@ void listview_nav_right ( listview *lv )
|
|||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->type == BARVIEW ){
|
||||
listview_nav_down_int(lv);
|
||||
if ( lv->type == BARVIEW ) {
|
||||
listview_nav_down_int ( lv );
|
||||
return;
|
||||
}
|
||||
if ( ( lv->selected + lv->max_rows ) < lv->req_elements ) {
|
||||
|
@ -662,12 +665,12 @@ static void listview_nav_page_prev_int ( listview *lv )
|
|||
if ( lv == NULL ) {
|
||||
return;
|
||||
}
|
||||
if ( lv->type == BARVIEW ){
|
||||
|
||||
if ( lv->last_offset == 0 ){
|
||||
if ( lv->type == BARVIEW ) {
|
||||
if ( lv->last_offset == 0 ) {
|
||||
lv->selected = 0;
|
||||
} else {
|
||||
lv->selected = lv->last_offset-1;
|
||||
}
|
||||
else {
|
||||
lv->selected = lv->last_offset - 1;
|
||||
}
|
||||
lv->barview.direction = RIGHT_TO_LEFT;
|
||||
widget_queue_redraw ( WIDGET ( lv ) );
|
||||
|
@ -691,8 +694,8 @@ static void listview_nav_page_next_int ( listview *lv )
|
|||
return;
|
||||
}
|
||||
if ( lv->type == BARVIEW ) {
|
||||
unsigned int new = lv->last_offset+lv->barview.cur_visible;
|
||||
lv->selected = MIN ( new, lv->req_elements-1);
|
||||
unsigned int new = lv->last_offset + lv->barview.cur_visible;
|
||||
lv->selected = MIN ( new, lv->req_elements - 1 );
|
||||
lv->barview.direction = LEFT_TO_RIGHT;
|
||||
|
||||
widget_queue_redraw ( WIDGET ( lv ) );
|
||||
|
@ -746,7 +749,7 @@ static int listview_get_desired_height ( widget *wid )
|
|||
h = MIN ( lv->menu_lines, lv->max_displayed_lines );
|
||||
}
|
||||
}
|
||||
if ( lv->type == BARVIEW ){
|
||||
if ( lv->type == BARVIEW ) {
|
||||
h = MIN ( h, 1 );
|
||||
}
|
||||
if ( h == 0 ) {
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef struct TBFontConfig
|
|||
/** Font metrics */
|
||||
PangoFontMetrics *metrics;
|
||||
/** height */
|
||||
double height;
|
||||
double height;
|
||||
}TBFontConfig;
|
||||
|
||||
/** HashMap of previously parsed font descriptions. */
|
||||
|
@ -119,9 +119,10 @@ static WidgetTriggerActionResult textbox_editable_trigger_action ( widget *wid,
|
|||
x -= widget_padding_get_left ( wid );
|
||||
gint max = textbox_get_font_width ( tb );
|
||||
// Right of text, move to end.
|
||||
if ( x >= max ){
|
||||
if ( x >= max ) {
|
||||
textbox_cursor_end ( tb );
|
||||
} else if ( x > 0 ) {
|
||||
}
|
||||
else if ( x > 0 ) {
|
||||
// If in range, get index.
|
||||
pango_layout_xy_to_index ( tb->layout, x * PANGO_SCALE, y * PANGO_SCALE, &i, NULL );
|
||||
textbox_cursor ( tb, i );
|
||||
|
@ -148,7 +149,7 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
tb->widget.get_width = textbox_get_width;
|
||||
tb->widget.get_height = _textbox_get_height;
|
||||
tb->widget.get_desired_height = textbox_get_desired_height;
|
||||
tb->widget.get_desired_width = textbox_get_desired_width;
|
||||
tb->widget.get_desired_width = textbox_get_desired_width;
|
||||
tb->flags = flags;
|
||||
|
||||
tb->changed = FALSE;
|
||||
|
@ -158,7 +159,7 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
|
||||
tb->metrics = p_metrics;
|
||||
const char * font = rofi_theme_get_string ( WIDGET ( tb ), "font", NULL );
|
||||
tb->left_offset = textbox_get_estimated_char_height();
|
||||
tb->left_offset = textbox_get_estimated_char_height ();
|
||||
|
||||
if ( font ) {
|
||||
TBFontConfig *tbfc = g_hash_table_lookup ( tbfc_cache, font );
|
||||
|
@ -167,7 +168,7 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
tbfc->pfd = pango_font_description_from_string ( font );
|
||||
if ( helper_validate_font ( tbfc->pfd, font ) ) {
|
||||
tbfc->metrics = pango_context_get_metrics ( p_context, tbfc->pfd, NULL );
|
||||
tbfc->height = pango_font_metrics_get_ascent ( tbfc->metrics ) + pango_font_metrics_get_descent ( tbfc->metrics );
|
||||
tbfc->height = pango_font_metrics_get_ascent ( tbfc->metrics ) + pango_font_metrics_get_descent ( tbfc->metrics );
|
||||
|
||||
// Cast away consts. (*yuck*) because table_insert does not know it is const.
|
||||
g_hash_table_insert ( tbfc_cache, (char *) font, tbfc );
|
||||
|
@ -181,8 +182,8 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
if ( tbfc ) {
|
||||
// Update for used font.
|
||||
pango_layout_set_font_description ( tb->layout, tbfc->pfd );
|
||||
tb->metrics = tbfc->metrics;
|
||||
tb->left_offset = (tbfc->height)/(double)PANGO_SCALE;
|
||||
tb->metrics = tbfc->metrics;
|
||||
tb->left_offset = ( tbfc->height ) / (double) PANGO_SCALE;
|
||||
}
|
||||
}
|
||||
if ( ( tb->flags & TB_ICON ) != TB_ICON ) {
|
||||
|
@ -193,8 +194,8 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR );
|
||||
}
|
||||
|
||||
const char *txt = rofi_theme_get_string ( WIDGET ( tb ), "str", text);
|
||||
textbox_text ( tb, txt? txt: "" );
|
||||
const char *txt = rofi_theme_get_string ( WIDGET ( tb ), "str", text );
|
||||
textbox_text ( tb, txt ? txt : "" );
|
||||
textbox_cursor_end ( tb );
|
||||
|
||||
// auto height/width modes get handled here
|
||||
|
@ -207,8 +208,8 @@ textbox* textbox_create ( WidgetType type, const char *name, TextboxFlags flags,
|
|||
tb->widget.trigger_action = textbox_editable_trigger_action;
|
||||
}
|
||||
|
||||
tb->yalign = rofi_theme_get_double ( WIDGET ( tb ), "vertical-align" , 0.0);
|
||||
tb->yalign = MAX ( 0, MIN ( 1.0, tb->yalign));
|
||||
tb->yalign = rofi_theme_get_double ( WIDGET ( tb ), "vertical-align", 0.0 );
|
||||
tb->yalign = MAX ( 0, MIN ( 1.0, tb->yalign ) );
|
||||
// Enabled by default
|
||||
tb->widget.enabled = rofi_theme_get_boolean ( WIDGET ( tb ), "enabled", TRUE );
|
||||
|
||||
|
@ -280,21 +281,21 @@ static void __textbox_update_pango_text ( textbox *tb )
|
|||
}
|
||||
const char *textbox_get_visible_text ( const textbox *tb )
|
||||
{
|
||||
if ( tb == NULL ){
|
||||
if ( tb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
return pango_layout_get_text ( tb->layout );
|
||||
}
|
||||
PangoAttrList *textbox_get_pango_attributes ( textbox *tb )
|
||||
{
|
||||
if ( tb == NULL ){
|
||||
if ( tb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
return pango_layout_get_attributes ( tb->layout );
|
||||
}
|
||||
void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list )
|
||||
{
|
||||
if ( tb == NULL ){
|
||||
if ( tb == NULL ) {
|
||||
return;
|
||||
}
|
||||
pango_layout_set_attributes ( tb->layout, list );
|
||||
|
@ -303,7 +304,7 @@ void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list )
|
|||
// set the default text to display
|
||||
void textbox_text ( textbox *tb, const char *text )
|
||||
{
|
||||
if ( tb == NULL ){
|
||||
if ( tb == NULL ) {
|
||||
return;
|
||||
}
|
||||
g_free ( tb->text );
|
||||
|
@ -343,7 +344,7 @@ void textbox_icon ( textbox *tb, cairo_surface_t *icon )
|
|||
// within the parent handled auto width/height modes
|
||||
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
|
||||
{
|
||||
unsigned int offset = tb->left_offset*1.2 + (( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0);
|
||||
unsigned int offset = tb->left_offset * 1.2 + ( ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0 );
|
||||
if ( tb->flags & TB_AUTOWIDTH ) {
|
||||
pango_layout_set_width ( tb->layout, -1 );
|
||||
w = textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( WIDGET ( tb ) ) + offset;
|
||||
|
@ -404,7 +405,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
return;
|
||||
}
|
||||
textbox *tb = (textbox *) wid;
|
||||
unsigned int offset = tb->left_offset*1.2 + (( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0);
|
||||
unsigned int offset = tb->left_offset * 1.2 + ( ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0 );
|
||||
|
||||
if ( tb->changed ) {
|
||||
__textbox_update_pango_text ( tb );
|
||||
|
@ -416,21 +417,21 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
int y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE;
|
||||
|
||||
// draw Icon
|
||||
if ( (tb->flags&TB_ICON) == TB_ICON && tb->icon != NULL ) {
|
||||
if ( ( tb->flags & TB_ICON ) == TB_ICON && tb->icon != NULL ) {
|
||||
int iconheight = tb->left_offset;
|
||||
cairo_save(draw);
|
||||
cairo_save ( draw );
|
||||
|
||||
/*int iconw = cairo_image_surface_get_width (tb->icon);*/
|
||||
int iconh = cairo_image_surface_get_height (tb->icon);
|
||||
double scale = (double)iconheight / iconh;
|
||||
int iconh = cairo_image_surface_get_height ( tb->icon );
|
||||
double scale = (double) iconheight / iconh;
|
||||
|
||||
cairo_translate(draw, x, y);
|
||||
cairo_scale(draw, scale, scale);
|
||||
cairo_set_source_surface(draw, tb->icon, 0,0);
|
||||
cairo_paint(draw);
|
||||
cairo_restore(draw);
|
||||
cairo_translate ( draw, x, y );
|
||||
cairo_scale ( draw, scale, scale );
|
||||
cairo_set_source_surface ( draw, tb->icon, 0, 0 );
|
||||
cairo_paint ( draw );
|
||||
cairo_restore ( draw );
|
||||
}
|
||||
x+=offset;
|
||||
x += offset;
|
||||
|
||||
if ( tb->flags & TB_RIGHT ) {
|
||||
int line_width = 0;
|
||||
|
@ -444,9 +445,9 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
}
|
||||
|
||||
if ( tb->yalign > 0.001 ) {
|
||||
int height = (pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics ))/PANGO_SCALE;
|
||||
int height = ( pango_font_metrics_get_ascent ( tb->metrics ) + pango_font_metrics_get_descent ( tb->metrics ) ) / PANGO_SCALE;
|
||||
int bottom = widget_padding_get_bottom ( WIDGET ( tb ) );
|
||||
top = (tb->widget.h - bottom - height -top)*tb->yalign+top;
|
||||
top = ( tb->widget.h - bottom - height - top ) * tb->yalign + top;
|
||||
}
|
||||
|
||||
rofi_theme_get_color ( WIDGET ( tb ), "foreground", draw );
|
||||
|
@ -470,7 +471,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
cairo_fill ( draw );
|
||||
}
|
||||
|
||||
|
||||
// Set ARGB
|
||||
// We need to set over, otherwise subpixel hinting wont work.
|
||||
cairo_set_operator ( draw, CAIRO_OPERATOR_OVER );
|
||||
|
@ -478,7 +478,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
pango_cairo_show_layout ( draw, tb->layout );
|
||||
|
||||
if ( ( tb->flags & TB_INDICATOR ) == TB_INDICATOR && ( tb->tbft & ( SELECTED ) ) ) {
|
||||
cairo_arc ( draw, tb->left_offset*1.2 + DOT_OFFSET / 2.0, tb->widget.h / 2.0, 2.0, 0, 2.0 * M_PI );
|
||||
cairo_arc ( draw, tb->left_offset * 1.2 + DOT_OFFSET / 2.0, tb->widget.h / 2.0, 2.0, 0, 2.0 * M_PI );
|
||||
cairo_fill ( draw );
|
||||
}
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ static void textbox_cursor_del_sol ( textbox *tb )
|
|||
}
|
||||
static void textbox_cursor_del_word ( textbox *tb )
|
||||
{
|
||||
if ( tb && tb->cursor >= 0 ) {
|
||||
if ( tb && tb->cursor >= 0 ) {
|
||||
int cursor = tb->cursor;
|
||||
textbox_cursor_inc_word ( tb );
|
||||
if ( cursor < tb->cursor ) {
|
||||
|
@ -799,9 +799,9 @@ gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len )
|
|||
|
||||
// Filter When alt/ctrl is pressed do not accept the character.
|
||||
|
||||
gboolean used_something = FALSE;
|
||||
gboolean used_something = FALSE;
|
||||
const gchar *w, *n, *e;
|
||||
for ( w = pad, n = g_utf8_next_char(w), e = w + pad_len ; w < e ; w = n, n = g_utf8_next_char(n) ) {
|
||||
for ( w = pad, n = g_utf8_next_char ( w ), e = w + pad_len; w < e; w = n, n = g_utf8_next_char ( n ) ) {
|
||||
if ( g_unichar_iscntrl ( g_utf8_get_char ( w ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ int textbox_get_font_width ( const textbox *tb )
|
|||
{
|
||||
PangoRectangle rect;
|
||||
pango_layout_get_pixel_extents ( tb->layout, NULL, &rect );
|
||||
return rect.width+rect.x;
|
||||
return rect.width + rect.x;
|
||||
}
|
||||
|
||||
/** Caching for the expected character height. */
|
||||
|
@ -913,14 +913,13 @@ int textbox_get_estimated_height ( const textbox *tb, int eh )
|
|||
int textbox_get_desired_width ( widget *wid )
|
||||
{
|
||||
textbox *tb = (textbox *) wid;
|
||||
unsigned int offset = tb->left_offset*1.2 + (( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0);
|
||||
unsigned int offset = tb->left_offset * 1.2 + ( ( tb->flags & TB_INDICATOR ) ? DOT_OFFSET : 0 );
|
||||
if ( wid->expand && tb->flags & TB_AUTOWIDTH ) {
|
||||
return textbox_get_font_width ( tb ) + widget_padding_get_padding_width ( wid ) + offset;
|
||||
}
|
||||
RofiDistance w = rofi_theme_get_distance ( WIDGET ( tb ), "width", 0 );
|
||||
int wi = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
|
||||
if ( wi > 0 )
|
||||
{
|
||||
RofiDistance w = rofi_theme_get_distance ( WIDGET ( tb ), "width", 0 );
|
||||
int wi = distance_get_pixel ( w, ROFI_ORIENTATION_HORIZONTAL );
|
||||
if ( wi > 0 ) {
|
||||
return wi;
|
||||
}
|
||||
int padding = widget_padding_get_left ( WIDGET ( tb ) );
|
||||
|
|
10
source/xcb.c
10
source/xcb.c
|
@ -651,7 +651,7 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
|
|||
xcb->last_timestamp = bre->time;
|
||||
nk_bindings_seat_handle_button ( xcb->bindings_seat, bre->detail, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
|
||||
if ( config.click_to_exit == TRUE ) {
|
||||
if ( ! xcb->mouse_seen ) {
|
||||
if ( !xcb->mouse_seen ) {
|
||||
rofi_view_temp_click_to_exit ( state, bre->event );
|
||||
}
|
||||
xcb->mouse_seen = FALSE;
|
||||
|
@ -881,7 +881,7 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings )
|
|||
find_arg_str ( "-display", &display_str );
|
||||
|
||||
xcb->main_loop = main_loop;
|
||||
xcb->source = g_water_xcb_source_new ( g_main_loop_get_context ( xcb->main_loop ), display_str, &xcb->screen_nbr, main_loop_x11_event_handler, NULL, NULL );
|
||||
xcb->source = g_water_xcb_source_new ( g_main_loop_get_context ( xcb->main_loop ), display_str, &xcb->screen_nbr, main_loop_x11_event_handler, NULL, NULL );
|
||||
if ( xcb->source == NULL ) {
|
||||
g_warning ( "Failed to open display: %s", display_str );
|
||||
return FALSE;
|
||||
|
@ -967,8 +967,8 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings )
|
|||
}
|
||||
|
||||
nk_bindings_seat_update_keymap ( xcb->bindings_seat, keymap, state );
|
||||
xkb_state_unref(state);
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_state_unref ( state );
|
||||
xkb_keymap_unref ( keymap );
|
||||
|
||||
// determine numlock mask so we can bind on keys with and without it
|
||||
x11_create_frequently_used_atoms ( );
|
||||
|
@ -1135,7 +1135,7 @@ void display_cleanup ( void )
|
|||
xcb_flush ( xcb->connection );
|
||||
xcb_aux_sync ( xcb->connection );
|
||||
g_water_xcb_source_free ( xcb->source );
|
||||
xcb->source = NULL;
|
||||
xcb->source = NULL;
|
||||
xcb->connection = NULL;
|
||||
xcb->screen = NULL;
|
||||
xcb->screen_nbr = 0;
|
||||
|
|
Loading…
Reference in a new issue