mirror of
https://github.com/lbonn/rofi
synced 2024-11-22 03:43:09 +00:00
Adjust new editor width
This commit is contained in:
parent
442e235c24
commit
b18d68eff2
24 changed files with 258 additions and 504 deletions
|
@ -1,7 +1,9 @@
|
|||
#
|
||||
# My favorite format
|
||||
#
|
||||
code_width = 100
|
||||
code_width = 140
|
||||
nl_max = 2
|
||||
ls_func_split_full = True
|
||||
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
|
||||
input_tab_size = 8 # original tab size
|
||||
output_tab_size = 4 # new tab size
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef __DMENU_DIALOG_H__
|
||||
#define __DMENU_DIALOG_H__
|
||||
|
||||
|
||||
/**
|
||||
* dmenu dialog.
|
||||
*
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef __SCRIPT_DIALOG_H__
|
||||
#define __SCRIPT_DIALOG_H__
|
||||
|
||||
|
||||
/**
|
||||
* @param str The input string to parse
|
||||
*
|
||||
|
|
|
@ -71,7 +71,6 @@ int find_arg_uint ( const char * const key, unsigned int *val );
|
|||
*/
|
||||
int find_arg_int ( const char * const key, int *val );
|
||||
|
||||
|
||||
/**
|
||||
* @param key The key to search for
|
||||
* @param val Pointer to the string to set to the key value (if found)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
void history_set ( const char *filename, const char *entry ) __attribute__( ( nonnull ) );
|
||||
|
||||
|
||||
/**
|
||||
* @param filename The filename of the history cache.
|
||||
* @param entry The entry to remove
|
||||
|
@ -19,7 +18,6 @@ void history_set ( const char *filename, const char *entry ) __attribute__( ( no
|
|||
*/
|
||||
void history_remove ( const char *filename, const char *entry ) __attribute__( ( nonnull ) );
|
||||
|
||||
|
||||
/**
|
||||
* @param filename The filename of the history cache.
|
||||
* @param length The length of the returned list.
|
||||
|
|
|
@ -56,7 +56,6 @@ typedef enum _KeyBindingAction
|
|||
NUM_ABE
|
||||
} KeyBindingAction;
|
||||
|
||||
|
||||
/**
|
||||
* Parse the keybindings.
|
||||
* This should be called after the setting system is initialized.
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef enum
|
|||
typedef SwitcherMode ( *switcher_callback )( char **input, void *data );
|
||||
typedef void ( *switcher_free )( Switcher *data );
|
||||
|
||||
|
||||
typedef const char * ( *get_display_value )( unsigned int selected_line, void *data, int *state );
|
||||
/**
|
||||
* State returned by the rofi window.
|
||||
|
@ -64,7 +63,6 @@ typedef enum
|
|||
MENU_LOWER_MASK = 0x0000FFFF
|
||||
} MenuReturn;
|
||||
|
||||
|
||||
/**
|
||||
* @param tokens List of (input) tokens to match.
|
||||
* @param input The entry to match against.
|
||||
|
@ -76,8 +74,7 @@ typedef enum
|
|||
*
|
||||
* @returns 1 when it matches, 0 if not.
|
||||
*/
|
||||
typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensitive,
|
||||
unsigned int index, Switcher *data );
|
||||
typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensitive, unsigned int index, Switcher *data );
|
||||
|
||||
/**
|
||||
* @param sw the Switcher to show.
|
||||
|
@ -95,10 +92,9 @@ typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensi
|
|||
*
|
||||
* @returns The command issued (see MenuReturn)
|
||||
*/
|
||||
MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
||||
unsigned int *selected_line,
|
||||
unsigned int *next_pos,
|
||||
const char *message ) __attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
|
||||
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
|
||||
__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
|
||||
|
||||
/**
|
||||
* @param sig The caught signal
|
||||
*
|
||||
|
@ -268,7 +264,6 @@ struct _Switcher
|
|||
KeySym keysym;
|
||||
unsigned int modmask;
|
||||
|
||||
|
||||
/**
|
||||
* A switcher normally consists of the following parts:
|
||||
*/
|
||||
|
@ -313,7 +308,5 @@ struct _Switcher
|
|||
#define color_magenta_bold "\033[1;35m"
|
||||
#define color_cyan_bold "\033[1;36m"
|
||||
|
||||
|
||||
|
||||
int show_error_message ( const char *msg, int markup );
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,6 @@ typedef struct
|
|||
int changed;
|
||||
} textbox;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TB_AUTOHEIGHT = 1 << 0,
|
||||
|
@ -33,7 +32,6 @@ typedef enum
|
|||
TB_MARKUP = 1 << 20,
|
||||
} TextboxFlags;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// Render font normally
|
||||
|
@ -202,7 +200,6 @@ int textbox_get_font_width ( textbox *tb );
|
|||
*/
|
||||
double textbox_get_estimated_char_width ( void );
|
||||
|
||||
|
||||
/**
|
||||
* @param tb Handle to the textbox
|
||||
*
|
||||
|
@ -243,6 +240,5 @@ void textbox_delete ( textbox *tb, int pos, int dlen );
|
|||
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
|
||||
int textbox_get_estimated_char_height ( void );
|
||||
|
||||
|
||||
void textbox_text_markup ( textbox *tb, const char *text );
|
||||
#endif //ROFI_TEXTBOX_H
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef X11_ROFI_HELPER_H
|
||||
#define X11_ROFI_HELPER_H
|
||||
|
||||
|
||||
int window_get_prop ( Display *display, Window w, Atom prop,
|
||||
Atom *type, int *items,
|
||||
void *buffer, unsigned int bytes ) __attribute__ ( ( nonnull ( 4, 5 ) ) );
|
||||
|
@ -23,7 +22,6 @@ void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms,
|
|||
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
|
||||
int count );
|
||||
|
||||
|
||||
/**
|
||||
* Window info.
|
||||
*/
|
||||
|
@ -142,7 +140,6 @@ void x11_setup ( Display *display );
|
|||
*/
|
||||
void create_visual_and_colormap ( Display *display );
|
||||
|
||||
|
||||
/**
|
||||
* @param display Connection to the X server.
|
||||
* @param name String representing the color.
|
||||
|
|
|
@ -20,7 +20,6 @@ typedef enum
|
|||
*/
|
||||
void config_parse_xresource_options ( Display *display );
|
||||
|
||||
|
||||
/**
|
||||
* Parse commandline options.
|
||||
*/
|
||||
|
|
|
@ -57,7 +57,6 @@ typedef struct _DmenuModePrivateData
|
|||
unsigned int cmd_list_length;
|
||||
} DmenuModePrivateData;
|
||||
|
||||
|
||||
static char **get_dmenu ( unsigned int *length )
|
||||
{
|
||||
char buffer[1024];
|
||||
|
@ -96,7 +95,6 @@ static char ** dmenu_mode_get_data ( unsigned int *length, Switcher *sw )
|
|||
return rmpd->cmd_list;
|
||||
}
|
||||
|
||||
|
||||
static void parse_pair ( char *input, struct range_pair *item )
|
||||
{
|
||||
int index = 0;
|
||||
|
@ -209,7 +207,6 @@ static void dmenu_mode_free ( Switcher *sw )
|
|||
}
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) sw->private_data;
|
||||
|
||||
|
||||
g_strfreev ( pd->cmd_list );
|
||||
g_free ( pd->urgent_list );
|
||||
g_free ( pd->active_list );
|
||||
|
@ -295,8 +292,7 @@ int dmenu_switcher_dialog ( void )
|
|||
unsigned int cmd_list_length = 0;
|
||||
char **cmd_list = dmenu_mode.get_data ( &( cmd_list_length ), &dmenu_mode );
|
||||
|
||||
|
||||
int only_selected = FALSE;
|
||||
int only_selected = FALSE;
|
||||
if ( find_arg ( "-only-match" ) >= 0 || find_arg ( "-no-custom" ) >= 0 ) {
|
||||
only_selected = TRUE;
|
||||
if ( cmd_list_length == 0 ) {
|
||||
|
@ -392,7 +388,6 @@ int dmenu_switcher_dialog ( void )
|
|||
}
|
||||
} while ( restart );
|
||||
|
||||
|
||||
g_free ( input );
|
||||
dmenu_mode.destroy ( &dmenu_mode );
|
||||
return retv;
|
||||
|
|
|
@ -79,7 +79,6 @@ static void exec_cmd ( const char *cmd, int run_in_term )
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
execsh ( cmd, run_in_term );
|
||||
|
||||
/**
|
||||
|
@ -155,7 +154,6 @@ static char ** get_apps_external ( char **retv, unsigned int *length, unsigned i
|
|||
retv = g_realloc ( retv, ( ( *length ) + 2 ) * sizeof ( char* ) );
|
||||
retv[( *length )] = g_strdup ( buffer );
|
||||
|
||||
|
||||
( *length )++;
|
||||
}
|
||||
if ( fclose ( inp ) != 0 ) {
|
||||
|
@ -181,14 +179,12 @@ static char ** get_apps ( unsigned int *length )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
path = g_strdup_printf ( "%s/%s", cache_dir, RUN_CACHE_FILE );
|
||||
retv = history_get_list ( path, length );
|
||||
g_free ( path );
|
||||
// Keep track of how many where loaded as favorite.
|
||||
num_favorites = ( *length );
|
||||
|
||||
|
||||
path = g_strdup ( getenv ( "PATH" ) );
|
||||
|
||||
for ( const char *dirname = strtok ( path, ":" );
|
||||
|
@ -259,7 +255,6 @@ static char ** get_apps ( unsigned int *length )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ( *length ) > num_favorites ) {
|
||||
g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ),
|
||||
sort_func,
|
||||
|
@ -278,7 +273,6 @@ typedef struct _RunModePrivateData
|
|||
unsigned int cmd_list_length;
|
||||
} RunModePrivateData;
|
||||
|
||||
|
||||
static void run_mode_init ( Switcher *sw )
|
||||
{
|
||||
if ( sw->private_data == NULL ) {
|
||||
|
@ -333,7 +327,6 @@ static SwitcherMode run_mode_result ( int mretv, char **input, unsigned int sele
|
|||
return retv;
|
||||
}
|
||||
|
||||
|
||||
static void run_mode_destroy ( Switcher *sw )
|
||||
{
|
||||
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -39,10 +38,6 @@
|
|||
#include "dialogs/script.h"
|
||||
#include "helper.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static char **get_script_output ( const char *command, unsigned int *length )
|
||||
{
|
||||
char **retv = NULL;
|
||||
|
@ -102,7 +97,6 @@ typedef struct _ScriptModePrivateData
|
|||
unsigned int cmd_list_length;
|
||||
} ScriptModePrivateData;
|
||||
|
||||
|
||||
static void script_mode_init ( Switcher *sw )
|
||||
{
|
||||
if ( sw->private_data == NULL ) {
|
||||
|
@ -145,7 +139,6 @@ static SwitcherMode script_mode_result ( int mretv, char **input, unsigned int s
|
|||
new_list = execute_executor ( sw, *input, &new_length );
|
||||
}
|
||||
|
||||
|
||||
// If a new list was generated, use that an loop around.
|
||||
if ( new_list != NULL ) {
|
||||
g_strfreev ( rmpd->cmd_list );
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "i3-support.h"
|
||||
#include "dialogs/window.h"
|
||||
|
||||
|
||||
#define WINLIST 32
|
||||
|
||||
#define CLIENTTITLE 100
|
||||
|
@ -417,8 +416,6 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig
|
|||
// if we happen to have a window destroyed while we're working...
|
||||
pd->ids = winlist_new ();
|
||||
|
||||
|
||||
|
||||
// calc widths of fields
|
||||
for ( i = nwins - 1; i > -1; i-- ) {
|
||||
client *c;
|
||||
|
@ -549,7 +546,6 @@ static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input,
|
|||
return retv;
|
||||
}
|
||||
|
||||
|
||||
static void window_mode_destroy ( Switcher *sw )
|
||||
{
|
||||
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
|
||||
|
|
|
@ -84,9 +84,7 @@ char* fgets_s ( char* s, int n, FILE *iop, char sep )
|
|||
*
|
||||
* @returns TRUE to stop replacement, FALSE to continue
|
||||
*/
|
||||
static gboolean helper_eval_cb ( const GMatchInfo *info,
|
||||
GString *res,
|
||||
gpointer data )
|
||||
static gboolean helper_eval_cb ( const GMatchInfo *info, GString *res, gpointer data )
|
||||
{
|
||||
gchar *match;
|
||||
// Get the match
|
||||
|
@ -131,10 +129,7 @@ int helper_parse_setup ( char * string, char ***output, int *length, ... )
|
|||
|
||||
// Replace hits within {-\w+}.
|
||||
GRegex *reg = g_regex_new ( "{[-\\w]+}", 0, 0, NULL );
|
||||
char *res = g_regex_replace_eval ( reg,
|
||||
string, -1,
|
||||
0, 0, helper_eval_cb, h,
|
||||
NULL );
|
||||
char *res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb, h, NULL );
|
||||
// Free regex.
|
||||
g_regex_unref ( reg );
|
||||
// Destroy key-value storage.
|
||||
|
@ -147,8 +142,7 @@ int helper_parse_setup ( char * string, char ***output, int *length, ... )
|
|||
g_free ( res );
|
||||
// Throw error if shell parsing fails.
|
||||
if ( error ) {
|
||||
char *msg = g_strdup_printf ( "Failed to parse: '%s'\nError: '%s'", string,
|
||||
error->message );
|
||||
char *msg = g_strdup_printf ( "Failed to parse: '%s'\nError: '%s'", string, error->message );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
// print error.
|
||||
|
@ -190,9 +184,7 @@ char **tokenize ( const char *input, int case_sensitive )
|
|||
|
||||
// Iterate over tokens.
|
||||
// strtok should still be valid for utf8.
|
||||
for ( token = strtok_r ( str, " ", &saveptr );
|
||||
token != NULL;
|
||||
token = strtok_r ( NULL, " ", &saveptr ) ) {
|
||||
for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) {
|
||||
retv = g_realloc ( retv, sizeof ( char* ) * ( num_tokens + 2 ) );
|
||||
retv[num_tokens] = token_collate_key ( token, case_sensitive );
|
||||
retv[num_tokens + 1] = NULL;
|
||||
|
@ -368,19 +360,10 @@ int execute_generator ( const char * cmd )
|
|||
|
||||
int fd = -1;
|
||||
GError *error = NULL;
|
||||
g_spawn_async_with_pipes ( NULL,
|
||||
args,
|
||||
NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, &fd, NULL,
|
||||
&error );
|
||||
g_spawn_async_with_pipes ( NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &fd, NULL, &error );
|
||||
|
||||
if ( error != NULL ) {
|
||||
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd,
|
||||
error->message );
|
||||
char *msg = g_strdup_printf ( "Failed to execute: '%s'\nError: '%s'", cmd, error->message );
|
||||
error_dialog ( msg, FALSE );
|
||||
g_free ( msg );
|
||||
// print error.
|
||||
|
@ -391,7 +374,6 @@ int execute_generator ( const char * cmd )
|
|||
return fd;
|
||||
}
|
||||
|
||||
|
||||
int create_pid_file ( const char *pidfile )
|
||||
{
|
||||
if ( pidfile == NULL ) {
|
||||
|
@ -452,40 +434,32 @@ void config_sanity_check ( )
|
|||
GString *msg = g_string_new (
|
||||
"<big><b>The configuration failed to validate:</b></big>\n" );
|
||||
if ( config.element_height < 1 ) {
|
||||
g_string_append_printf (
|
||||
msg,
|
||||
"\t<b>config.element_height</b>=%d is invalid. An element needs to be atleast 1 line high.\n",
|
||||
config.element_height );
|
||||
g_string_append_printf ( msg, "\t<b>config.element_height</b>=%d is invalid. An element needs to be atleast 1 line high.\n",
|
||||
config.element_height );
|
||||
config.element_height = 1;
|
||||
found_error = TRUE;
|
||||
}
|
||||
if ( config.menu_columns == 0 ) {
|
||||
g_string_append_printf (
|
||||
msg,
|
||||
"\t<b>config.menu_columns</b>=%d is invalid. You need at least one visible column.\n",
|
||||
config.menu_columns );
|
||||
g_string_append_printf ( msg, "\t<b>config.menu_columns</b>=%d is invalid. You need at least one visible column.\n",
|
||||
config.menu_columns );
|
||||
config.menu_columns = 1;
|
||||
found_error = TRUE;
|
||||
}
|
||||
if ( config.menu_width == 0 ) {
|
||||
show_error_message (
|
||||
"<b>config.menu_width</b>=0 is invalid. You cannot have a window with no width.", TRUE );
|
||||
show_error_message ( "<b>config.menu_width</b>=0 is invalid. You cannot have a window with no width.", TRUE );
|
||||
config.menu_columns = 50;
|
||||
found_error = TRUE;
|
||||
}
|
||||
if ( !( config.location >= WL_CENTER && config.location <= WL_WEST ) ) {
|
||||
g_string_append_printf (
|
||||
msg, "\t<b>config.location</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||
config.location, WL_CENTER, WL_WEST );
|
||||
g_string_append_printf ( msg, "\t<b>config.location</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||
config.location, WL_CENTER, WL_WEST );
|
||||
config.location = WL_CENTER;
|
||||
found_error = 1;
|
||||
}
|
||||
if ( 0 ) {
|
||||
if ( !( config.line_margin <= 50 ) ) {
|
||||
g_string_append_printf (
|
||||
msg,
|
||||
"\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||
config.line_margin, 0, 50 );
|
||||
g_string_append_printf ( msg, "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n",
|
||||
config.line_margin, 0, 50 );
|
||||
config.line_margin = 2;
|
||||
found_error = 1;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,6 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
|
|||
return retv;
|
||||
}
|
||||
|
||||
|
||||
void history_set ( const char *filename, const char *entry )
|
||||
{
|
||||
if ( config.disable_history ) {
|
||||
|
|
|
@ -76,7 +76,6 @@ void i3_support_focus_window ( Window id )
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
// Formulate command
|
||||
snprintf ( command, upm, "[id=\"%lu\"] focus", id );
|
||||
// Prepare header.
|
||||
|
@ -141,7 +140,6 @@ void i3_support_free_internals ( void )
|
|||
|
||||
#else
|
||||
|
||||
|
||||
void i3_support_focus_window ( Window id )
|
||||
{
|
||||
fprintf ( stderr, "Trying to control i3, when i3 support is not enabled.\n" );
|
||||
|
|
110
source/keyb.c
110
source/keyb.c
|
@ -34,63 +34,36 @@ extern unsigned int NumlockMask;
|
|||
*/
|
||||
DefaultBinding bindings[NUM_ABE] =
|
||||
{
|
||||
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste",
|
||||
.keybinding =
|
||||
"Control+Shift+v,Shift+Insert", },
|
||||
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding =
|
||||
"Control+v,Insert", },
|
||||
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding =
|
||||
"Control+u", },
|
||||
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding =
|
||||
"Control+a", },
|
||||
{ .id = MOVE_END, .name = "kb-move-end", .keybinding =
|
||||
"Control+e", },
|
||||
{ .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", },
|
||||
{ .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", },
|
||||
{ .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", },
|
||||
{ .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", },
|
||||
{ .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", },
|
||||
{ .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
|
||||
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
|
||||
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding =
|
||||
"Left,Control+b" },
|
||||
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding =
|
||||
"Right,Control+f" },
|
||||
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding =
|
||||
"Control+Alt+h", },
|
||||
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding =
|
||||
"Control+Alt+d", },
|
||||
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding =
|
||||
"Delete,Control+d", },
|
||||
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding =
|
||||
"BackSpace,Control+h", },
|
||||
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding =
|
||||
"Control+j,Control+m,Return,KP_Enter", },
|
||||
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding =
|
||||
"Control+Return", },
|
||||
{ .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding =
|
||||
"Shift+Return", },
|
||||
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding =
|
||||
"Shift+Right,Control+Tab" },
|
||||
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding =
|
||||
"Shift+Left,Control+Shift+Tab" },
|
||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding =
|
||||
"grave,dead_grave" },
|
||||
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding =
|
||||
"Shift+Delete" },
|
||||
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding =
|
||||
"Control+Page_Up" },
|
||||
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding =
|
||||
"Control+Page_Down" },
|
||||
{ .id = ROW_UP, .name = "kb-row-up", .keybinding =
|
||||
"Up,Control+p,Shift+Tab" },
|
||||
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding =
|
||||
"Down,Control+n" },
|
||||
{ .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" },
|
||||
{ .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" },
|
||||
{ .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", },
|
||||
{ .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", },
|
||||
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
|
||||
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
|
||||
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
|
||||
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", },
|
||||
{ .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = "Shift+Return", },
|
||||
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
|
||||
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
|
||||
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },
|
||||
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" },
|
||||
{ .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" },
|
||||
{ .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" },
|
||||
{ .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab" },
|
||||
{ .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" },
|
||||
{ .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" },
|
||||
{ .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" },
|
||||
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding =
|
||||
"Page_Down" },
|
||||
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding =
|
||||
"Home,KP_Home" },
|
||||
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding =
|
||||
"End,KP_End" },
|
||||
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding =
|
||||
"Control+space" },
|
||||
{ .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" },
|
||||
{ .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" },
|
||||
{ .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" },
|
||||
{ .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" },
|
||||
{ .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape" },
|
||||
{ .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" },
|
||||
{ .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" },
|
||||
|
@ -102,27 +75,17 @@ DefaultBinding bindings[NUM_ABE] =
|
|||
{ .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" },
|
||||
{ .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" },
|
||||
{ .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" },
|
||||
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding =
|
||||
"Alt+Shift+1" },
|
||||
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding =
|
||||
"Alt+Shift+2" },
|
||||
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding =
|
||||
"Alt+Shift+3" },
|
||||
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding =
|
||||
"Alt+Shift+4" },
|
||||
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding =
|
||||
"Alt+Shift+5" },
|
||||
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding =
|
||||
"Alt+Shift+6" },
|
||||
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding =
|
||||
"Alt+Shift+7" },
|
||||
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding =
|
||||
"Alt+Shift+8" },
|
||||
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding =
|
||||
"Alt+Shift+9" },
|
||||
{ .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" },
|
||||
{ .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" },
|
||||
{ .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" },
|
||||
{ .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" },
|
||||
{ .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" },
|
||||
{ .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" },
|
||||
{ .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" },
|
||||
{ .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" },
|
||||
{ .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" },
|
||||
};
|
||||
|
||||
|
||||
void setup_abe ( void )
|
||||
{
|
||||
for ( int iter = 0; iter < NUM_ABE; iter++ ) {
|
||||
|
@ -133,8 +96,7 @@ void setup_abe ( void )
|
|||
abe[id].num_bindings = 0;
|
||||
abe[id].kb = NULL;
|
||||
|
||||
config_parser_add_option ( xrm_String,
|
||||
abe[id].name, (void * *) &( abe[id].keystr ) );
|
||||
config_parser_add_option ( xrm_String, abe[id].name, (void * *) &( abe[id].keystr ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
201
source/rofi.c
201
source/rofi.c
|
@ -130,7 +130,6 @@ static inline MainLoopEvent wait_for_xevent_or_timeout ( Display *display, int x
|
|||
return ML_XEVENT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Levenshtein Sorting.
|
||||
*/
|
||||
|
@ -199,9 +198,7 @@ static Window create_window ( Display *display )
|
|||
Window box = XCreateWindow ( display, DefaultRootWindow ( display ),
|
||||
0, 0, 200, 100, config.menu_bw, vinfo.depth, InputOutput,
|
||||
vinfo.visual, CWColormap | CWBorderPixel | CWBackPixel, &attr );
|
||||
XSelectInput ( display, box,
|
||||
KeyReleaseMask | KeyPressMask | ExposureMask |
|
||||
ButtonPressMask | StructureNotifyMask | FocusChangeMask );
|
||||
XSelectInput ( display, box, KeyReleaseMask | KeyPressMask | ExposureMask | ButtonPressMask | StructureNotifyMask | FocusChangeMask );
|
||||
|
||||
gc = XCreateGC ( display, box, 0, 0 );
|
||||
int line_style = LineOnOffDash;
|
||||
|
@ -215,15 +212,12 @@ static Window create_window ( Display *display )
|
|||
XSetForeground ( display, gc, color_separator ( display ) );
|
||||
// make it an unmanaged window
|
||||
if ( !normal_window_mode ) {
|
||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE],
|
||||
&netatoms[_NET_WM_STATE_ABOVE],
|
||||
1 );
|
||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_STATE], &netatoms[_NET_WM_STATE_ABOVE], 1 );
|
||||
XSetWindowAttributes sattr = { .override_redirect = True };
|
||||
XChangeWindowAttributes ( display, box, CWOverrideRedirect, &sattr );
|
||||
}
|
||||
else{
|
||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_WINDOW_TYPE],
|
||||
&netatoms[_NET_WM_WINDOW_TYPE_NORMAL], 1 );
|
||||
window_set_atom_prop ( display, box, netatoms[_NET_WM_WINDOW_TYPE], &netatoms[_NET_WM_WINDOW_TYPE_NORMAL], 1 );
|
||||
}
|
||||
|
||||
// Set the WM_NAME
|
||||
|
@ -353,7 +347,6 @@ static void calculate_window_position ( MenuState *state, const workarea *mon )
|
|||
state->y += config.y_offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param state Internal state of the menu.
|
||||
*
|
||||
|
@ -367,12 +360,10 @@ static void menu_calculate_rows_columns ( MenuState *state )
|
|||
|
||||
// Calculate the number or rows. We do this by getting the num_lines rounded up to X columns
|
||||
// (num elements is better name) then dividing by columns.
|
||||
state->max_rows = MIN ( state->menu_lines,
|
||||
(unsigned int) (
|
||||
( state->num_lines +
|
||||
( state->columns - state->num_lines % state->columns ) %
|
||||
state->columns ) / ( state->columns )
|
||||
) );
|
||||
state->max_rows = MIN ( state->menu_lines, (unsigned int) ( ( state->num_lines +
|
||||
( state->columns - state->num_lines %
|
||||
state->columns ) % state->columns ) /
|
||||
( state->columns ) ) );
|
||||
// Always have at least one row.
|
||||
state->max_rows = MAX ( 1, state->max_rows );
|
||||
|
||||
|
@ -382,8 +373,7 @@ static void menu_calculate_rows_columns ( MenuState *state )
|
|||
// If it would fit in one column, only use one column.
|
||||
if ( state->num_lines < state->max_elements ) {
|
||||
state->columns =
|
||||
( state->num_lines + ( state->max_rows - state->num_lines % state->max_rows ) %
|
||||
state->max_rows ) / state->max_rows;
|
||||
( state->num_lines + ( state->max_rows - state->num_lines % state->max_rows ) % state->max_rows ) / state->max_rows;
|
||||
state->max_elements = state->menu_lines * state->columns;
|
||||
}
|
||||
// Sanitize.
|
||||
|
@ -410,8 +400,7 @@ static void menu_calculate_window_and_element_width ( MenuState *state, workarea
|
|||
}
|
||||
else{
|
||||
// Calculate as float to stop silly, big rounding down errors.
|
||||
state->w = config.menu_width <
|
||||
101 ? ( mon->w / 100.0f ) * ( float ) config.menu_width : config.menu_width;
|
||||
state->w = config.menu_width < 101 ? ( mon->w / 100.0f ) * ( float ) config.menu_width : config.menu_width;
|
||||
// Compensate for border width.
|
||||
state->w -= config.menu_bw * 2;
|
||||
}
|
||||
|
@ -419,8 +408,7 @@ static void menu_calculate_window_and_element_width ( MenuState *state, workarea
|
|||
if ( state->columns > 0 ) {
|
||||
state->element_width = state->w - ( 2 * ( config.padding ) );
|
||||
// Divide by the # columns
|
||||
state->element_width =
|
||||
( state->element_width - ( state->columns - 1 ) * config.line_margin ) / state->columns;
|
||||
state->element_width = ( state->element_width - ( state->columns - 1 ) * config.line_margin ) / state->columns;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,9 +513,8 @@ inline static void menu_nav_up ( MenuState *state )
|
|||
*/
|
||||
inline static void menu_nav_down ( MenuState *state )
|
||||
{
|
||||
state->selected = state->selected < state->filtered_lines - 1 ? MIN (
|
||||
state->filtered_lines - 1, state->selected + 1 ) : 0;
|
||||
state->update = TRUE;
|
||||
state->selected = state->selected < state->filtered_lines - 1 ? MIN ( state->filtered_lines - 1, state->selected + 1 ) : 0;
|
||||
state->update = TRUE;
|
||||
}
|
||||
/**
|
||||
* @param state The current MenuState
|
||||
|
@ -715,8 +702,7 @@ static void menu_refilter ( MenuState *state )
|
|||
|
||||
// input changed
|
||||
for ( unsigned int i = 0; i < state->num_lines; i++ ) {
|
||||
int match = state->sw->token_match ( tokens, state->lines[i], config.case_sensitive, i,
|
||||
state->sw );
|
||||
int match = state->sw->token_match ( tokens, state->lines[i], config.case_sensitive, i, state->sw );
|
||||
|
||||
// If each token was matched, add it to list.
|
||||
if ( match ) {
|
||||
|
@ -754,15 +740,13 @@ static void menu_refilter ( MenuState *state )
|
|||
state->rchanged = TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void menu_draw ( MenuState *state )
|
||||
{
|
||||
unsigned int i, offset = 0;
|
||||
|
||||
// selected row is always visible.
|
||||
// If selected is visible do not scroll.
|
||||
if ( ( ( state->selected - ( state->last_offset ) ) < ( state->max_elements ) )
|
||||
&& ( state->selected >= ( state->last_offset ) ) ) {
|
||||
if ( ( ( state->selected - ( state->last_offset ) ) < ( state->max_elements ) ) && ( state->selected >= ( state->last_offset ) ) ) {
|
||||
offset = state->last_offset;
|
||||
}
|
||||
else{
|
||||
|
@ -782,8 +766,7 @@ static void menu_draw ( MenuState *state )
|
|||
unsigned int a_lines = MIN ( ( state->filtered_lines - offset ), state->max_elements );
|
||||
|
||||
// Calculate number of columns
|
||||
unsigned int columns = ( a_lines + ( state->max_rows - a_lines % state->max_rows ) %
|
||||
state->max_rows ) / state->max_rows;
|
||||
unsigned int columns = ( a_lines + ( state->max_rows - a_lines % state->max_rows ) % state->max_rows ) / state->max_rows;
|
||||
columns = MIN ( columns, state->columns );
|
||||
|
||||
// Update the handle length.
|
||||
|
@ -814,16 +797,12 @@ static void menu_draw ( MenuState *state )
|
|||
unsigned int ex = ( ( i ) / state->max_rows ) * ( element_width + config.line_margin );
|
||||
unsigned int ey = ( ( i ) % state->max_rows ) * ( element_height + config.line_margin );
|
||||
// Move it around.
|
||||
textbox_moveresize ( state->boxes[i],
|
||||
ex + x_offset, ey + y_offset,
|
||||
element_width, element_height );
|
||||
textbox_moveresize ( state->boxes[i], ex + x_offset, ey + y_offset, element_width, element_height );
|
||||
{
|
||||
TextBoxFontType type = ( ( ( i % state->max_rows ) & 1 ) == 0 ) ? NORMAL : ALT;
|
||||
int fstate = 0;
|
||||
const char *text = state->sw->mgrv ( state->line_map[i + offset], state->sw,
|
||||
&fstate );
|
||||
TextBoxFontType tbft = fstate |
|
||||
( ( i + offset ) == state->selected ? HIGHLIGHT : type );
|
||||
const char *text = state->sw->mgrv ( state->line_map[i + offset], state->sw, &fstate );
|
||||
TextBoxFontType tbft = fstate | ( ( i + offset ) == state->selected ? HIGHLIGHT : type );
|
||||
textbox_font ( state->boxes[i], tbft );
|
||||
textbox_text ( state->boxes[i], text );
|
||||
}
|
||||
|
@ -856,8 +835,7 @@ static void menu_update ( MenuState *state )
|
|||
menu_draw ( state );
|
||||
// Why do we need the special -1?
|
||||
XDrawLine ( display, main_window, gc, 0,
|
||||
state->line_height + ( config.padding ) * 1 + config.line_margin + 1,
|
||||
state->w,
|
||||
state->line_height + ( config.padding ) * 1 + config.line_margin + 1, state->w,
|
||||
state->line_height + ( config.padding ) * 1 + config.line_margin + 1 );
|
||||
if ( state->message_tb ) {
|
||||
XDrawLine ( display, main_window, gc,
|
||||
|
@ -867,10 +845,8 @@ static void menu_update ( MenuState *state )
|
|||
|
||||
if ( config.sidebar_mode == TRUE ) {
|
||||
XDrawLine ( display, main_window, gc,
|
||||
0,
|
||||
state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin,
|
||||
state->w,
|
||||
state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin );
|
||||
0, state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin,
|
||||
state->w, state->h - state->line_height - ( config.padding ) * 1 - 1 - config.line_margin );
|
||||
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
||||
textbox_draw ( switchers[j].tb );
|
||||
}
|
||||
|
@ -912,13 +888,11 @@ static void menu_resize ( MenuState *state )
|
|||
unsigned int sbw = config.line_margin + 8;
|
||||
scrollbar_move ( state->scrollbar, state->w - config.padding - sbw, state->top_offset );
|
||||
if ( config.sidebar_mode == TRUE ) {
|
||||
int width = ( state->w - ( 2 * ( config.padding ) +
|
||||
( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
||||
int width = ( state->w - ( 2 * ( config.padding ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
||||
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
||||
textbox_moveresize ( switchers[j].tb,
|
||||
config.padding + j * ( width + config.line_margin ),
|
||||
state->h - state->line_height - config.padding,
|
||||
width, state->line_height );
|
||||
state->h - state->line_height - config.padding, width, state->line_height );
|
||||
textbox_show ( switchers[j].tb );
|
||||
textbox_draw ( switchers[j].tb );
|
||||
}
|
||||
|
@ -928,8 +902,7 @@ static void menu_resize ( MenuState *state )
|
|||
*/
|
||||
{
|
||||
unsigned int last_length = state->max_elements;
|
||||
int element_height = state->line_height * config.element_height +
|
||||
config.line_margin;
|
||||
int element_height = state->line_height * config.element_height + config.line_margin;
|
||||
// Calculated new number of boxes.
|
||||
unsigned int h = ( state->h - state->top_offset );
|
||||
if ( config.sidebar_mode == TRUE ) {
|
||||
|
@ -948,21 +921,17 @@ static void menu_resize ( MenuState *state )
|
|||
int x_offset = config.padding;
|
||||
// Add newly added boxes.
|
||||
for ( unsigned int i = last_length; i < state->max_elements; i++ ) {
|
||||
state->boxes[i] = textbox_create ( main_window, &vinfo, map, 0,
|
||||
x_offset, y_offset,
|
||||
state->boxes[i] = textbox_create ( main_window, &vinfo, map, 0, x_offset, y_offset,
|
||||
state->element_width, element_height, NORMAL, "" );
|
||||
}
|
||||
scrollbar_resize ( state->scrollbar, -1,
|
||||
( state->max_rows ) * ( element_height ) - config.line_margin );
|
||||
scrollbar_resize ( state->scrollbar, -1, ( state->max_rows ) * ( element_height ) - config.line_margin );
|
||||
}
|
||||
|
||||
state->rchanged = TRUE;
|
||||
state->update = TRUE;
|
||||
}
|
||||
|
||||
MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
||||
unsigned int *selected_line,
|
||||
unsigned int *next_pos, const char *message )
|
||||
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
|
||||
{
|
||||
int shift = FALSE;
|
||||
MenuState state = {
|
||||
|
@ -1016,8 +985,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
state.line_height = textbox_get_estimated_char_height ();
|
||||
state.case_indicator = textbox_create ( main_window, &vinfo, map, TB_AUTOWIDTH,
|
||||
( config.padding ), ( config.padding ),
|
||||
0, state.line_height,
|
||||
NORMAL, "*" );
|
||||
0, state.line_height, NORMAL, "*" );
|
||||
// Height of a row.
|
||||
if ( config.menu_lines == 0 ) {
|
||||
// Autosize it.
|
||||
|
@ -1032,29 +1000,21 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
menu_calculate_window_and_element_width ( &state, &mon );
|
||||
|
||||
// Prompt box.
|
||||
state.prompt_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOWIDTH,
|
||||
( config.padding ),
|
||||
( config.padding ),
|
||||
state.prompt_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOWIDTH, ( config.padding ), ( config.padding ),
|
||||
0, state.line_height, NORMAL, prompt );
|
||||
// Entry box
|
||||
int entrybox_width = state.w
|
||||
- ( 2 * ( config.padding ) )
|
||||
int entrybox_width = state.w - ( 2 * ( config.padding ) )
|
||||
- textbox_get_width ( state.prompt_tb )
|
||||
- textbox_get_width ( state.case_indicator );
|
||||
|
||||
state.text = textbox_create ( main_window, &vinfo, map, TB_EDITABLE,
|
||||
( config.padding ) + textbox_get_width ( state.prompt_tb ),
|
||||
( config.padding ),
|
||||
entrybox_width, state.line_height,
|
||||
NORMAL,
|
||||
*input );
|
||||
( config.padding ) + textbox_get_width ( state.prompt_tb ), ( config.padding ),
|
||||
entrybox_width, state.line_height, NORMAL, *input );
|
||||
|
||||
state.top_offset = config.padding * 1 + state.line_height + 2 + config.line_margin * 2;
|
||||
|
||||
// Move indicator to end.
|
||||
textbox_move ( state.case_indicator,
|
||||
config.padding + textbox_get_width ( state.prompt_tb ) + entrybox_width,
|
||||
config.padding );
|
||||
textbox_move ( state.case_indicator, config.padding + textbox_get_width ( state.prompt_tb ) + entrybox_width, config.padding );
|
||||
|
||||
textbox_show ( state.text );
|
||||
textbox_show ( state.prompt_tb );
|
||||
|
@ -1065,14 +1025,9 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
|
||||
state.message_tb = NULL;
|
||||
if ( message ) {
|
||||
// state.top_offset += config.line_margin;
|
||||
state.message_tb = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT | TB_MARKUP,
|
||||
( config.padding ),
|
||||
state.top_offset,
|
||||
state.w - ( 2 * ( config.padding ) ),
|
||||
-1,
|
||||
NORMAL,
|
||||
message );
|
||||
( config.padding ), state.top_offset, state.w - ( 2 * ( config.padding ) ),
|
||||
-1, NORMAL, message );
|
||||
textbox_show ( state.message_tb );
|
||||
state.top_offset += textbox_get_height ( state.message_tb );
|
||||
state.top_offset += config.line_margin * 2 + 2;
|
||||
|
@ -1086,23 +1041,15 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
int x_offset = config.padding;
|
||||
|
||||
for ( unsigned int i = 0; i < state.max_elements; i++ ) {
|
||||
state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0,
|
||||
x_offset, y_offset,
|
||||
state.boxes[i] = textbox_create ( main_window, &vinfo, map, 0, x_offset, y_offset,
|
||||
state.element_width, element_height, NORMAL, "" );
|
||||
}
|
||||
if ( !config.hide_scrollbar ) {
|
||||
unsigned int sbw = config.line_margin + 8;
|
||||
state.scrollbar = scrollbar_create (
|
||||
main_window, &vinfo, map,
|
||||
state.w - config.padding - sbw,
|
||||
state.top_offset,
|
||||
sbw,
|
||||
( state.max_rows -
|
||||
1 ) *
|
||||
( element_height + config.line_margin ) + element_height );
|
||||
state.scrollbar = scrollbar_create ( main_window, &vinfo, map, state.w - config.padding - sbw, state.top_offset,
|
||||
sbw, ( state.max_rows - 1 ) * ( element_height + config.line_margin ) + element_height );
|
||||
}
|
||||
|
||||
|
||||
scrollbar_set_max_value ( state.scrollbar, state.num_lines );
|
||||
// filtered list
|
||||
state.line_map = g_malloc0_n ( state.num_lines, sizeof ( unsigned int ) );
|
||||
|
@ -1112,8 +1059,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
|
||||
// resize window vertically to suit
|
||||
// Subtract the margin of the last row.
|
||||
state.h = state.top_offset +
|
||||
( element_height + config.line_margin ) * ( state.max_rows ) - config.line_margin;
|
||||
state.h = state.top_offset + ( element_height + config.line_margin ) * ( state.max_rows ) - config.line_margin;
|
||||
state.h += config.padding;
|
||||
state.h += 0;
|
||||
// Add entry
|
||||
|
@ -1130,17 +1076,11 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
calculate_window_position ( &state, &mon );
|
||||
|
||||
if ( config.sidebar_mode == TRUE ) {
|
||||
int width =
|
||||
( state.w -
|
||||
( 2 * ( config.padding ) +
|
||||
( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
||||
int width = ( state.w - ( 2 * ( config.padding ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
|
||||
for ( unsigned int j = 0; j < num_switchers; j++ ) {
|
||||
switchers[j].tb = textbox_create ( main_window, &vinfo, map, TB_CENTER,
|
||||
config.padding + j * ( width + config.line_margin ),
|
||||
state.h - state.line_height - config.padding,
|
||||
width, state.line_height,
|
||||
( j == curr_switcher ) ? HIGHLIGHT : NORMAL,
|
||||
switchers[j].sw->name );
|
||||
switchers[j].tb = textbox_create ( main_window, &vinfo, map, TB_CENTER, config.padding + j * ( width + config.line_margin ),
|
||||
state.h - state.line_height - config.padding, width, state.line_height,
|
||||
( j == curr_switcher ) ? HIGHLIGHT : NORMAL, switchers[j].sw->name );
|
||||
textbox_show ( switchers[j].tb );
|
||||
}
|
||||
}
|
||||
|
@ -1156,9 +1096,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
state.quit = FALSE;
|
||||
menu_refilter ( &state );
|
||||
|
||||
for ( unsigned int i = 0;
|
||||
( *( state.selected_line ) ) < UINT32_MAX && !state.selected && i < state.filtered_lines;
|
||||
i++ ) {
|
||||
for ( unsigned int i = 0; ( *( state.selected_line ) ) < UINT32_MAX && !state.selected && i < state.filtered_lines; i++ ) {
|
||||
if ( state.line_map[i] == *( state.selected_line ) ) {
|
||||
state.selected = i;
|
||||
break;
|
||||
|
@ -1214,8 +1152,7 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
else if ( ev.type == ConfigureNotify ) {
|
||||
XConfigureEvent xce = ev.xconfigure;
|
||||
if ( xce.window == main_window ) {
|
||||
if ( state.w != (unsigned int) xce.width ||
|
||||
state.h != (unsigned int ) xce.height ) {
|
||||
if ( state.w != (unsigned int) xce.width || state.h != (unsigned int ) xce.height ) {
|
||||
state.w = xce.width;
|
||||
state.h = xce.height;
|
||||
menu_resize ( &state );
|
||||
|
@ -1263,13 +1200,10 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
|
||||
// Handling of paste
|
||||
if ( abe_test_action ( PASTE_PRIMARY, ev.xkey.state, key ) ) {
|
||||
XConvertSelection ( display, XA_PRIMARY,
|
||||
netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window,
|
||||
CurrentTime );
|
||||
XConvertSelection ( display, XA_PRIMARY, netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window, CurrentTime );
|
||||
}
|
||||
else if ( abe_test_action ( PASTE_SECONDARY, ev.xkey.state, key ) ) {
|
||||
XConvertSelection ( display, netatoms[CLIPBOARD],
|
||||
netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window,
|
||||
XConvertSelection ( display, netatoms[CLIPBOARD], netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window,
|
||||
CurrentTime );
|
||||
}
|
||||
else if ( abe_test_action ( MODE_PREVIOUS, ev.xkey.state, key ) ) {
|
||||
|
@ -1374,7 +1308,6 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt,
|
|||
} while ( ev.type != KeyRelease );
|
||||
}
|
||||
|
||||
|
||||
// Update input string.
|
||||
g_free ( *input );
|
||||
*input = g_strdup ( state.text->text );
|
||||
|
@ -1438,18 +1371,12 @@ void error_dialog ( const char *msg, int markup )
|
|||
main_window = create_window ( display );
|
||||
}
|
||||
|
||||
|
||||
menu_calculate_window_and_element_width ( &state, &mon );
|
||||
state.max_elements = 0;
|
||||
|
||||
state.text =
|
||||
textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||
( config.padding ),
|
||||
( config.padding ),
|
||||
( state.w - ( 2 * ( config.padding ) ) ),
|
||||
1,
|
||||
NORMAL,
|
||||
( msg != NULL ) ? msg : "" );
|
||||
state.text = textbox_create ( main_window, &vinfo, map, TB_AUTOHEIGHT + ( ( markup ) ? TB_MARKUP : 0 ),
|
||||
( config.padding ), ( config.padding ),
|
||||
( state.w - ( 2 * ( config.padding ) ) ), 1, NORMAL, ( msg != NULL ) ? msg : "" );
|
||||
textbox_show ( state.text );
|
||||
state.line_height = textbox_get_height ( state.text );
|
||||
|
||||
|
@ -1632,7 +1559,6 @@ static void handle_keypress ( XEvent *ev )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Help function. This calls man.
|
||||
*/
|
||||
|
@ -1645,7 +1571,6 @@ static void help ()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function bound by 'atexit'.
|
||||
* Cleanup globally allocated memory.
|
||||
|
@ -1676,7 +1601,6 @@ static void cleanup ()
|
|||
display = NULL;
|
||||
}
|
||||
|
||||
|
||||
// Cleaning up memory allocated by the Xresources file.
|
||||
config_xresource_free ();
|
||||
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
||||
|
@ -1709,12 +1633,9 @@ static void setup_switchers ( void )
|
|||
// Make a copy, as strtok will modify it.
|
||||
char *switcher_str = g_strdup ( config.switchers );
|
||||
// Split token on ','. This modifies switcher_str.
|
||||
for ( char *token = strtok_r ( switcher_str, ",", &savept );
|
||||
token != NULL;
|
||||
token = strtok_r ( NULL, ",", &savept ) ) {
|
||||
for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL; token = strtok_r ( NULL, ",", &savept ) ) {
|
||||
// Resize and add entry.
|
||||
switchers =
|
||||
(Mode *) g_realloc ( switchers, sizeof ( Mode ) * ( num_switchers + 1 ) );
|
||||
switchers = (Mode *) g_realloc ( switchers, sizeof ( Mode ) * ( num_switchers + 1 ) );
|
||||
switchers[num_switchers].tb = NULL;
|
||||
|
||||
// Window switcher.
|
||||
|
@ -1765,9 +1686,7 @@ static void setup_switchers ( void )
|
|||
// and re-alloc moves that pointer.
|
||||
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
||||
switchers[i].sw->keycfg = g_strdup_printf ( "key-%s", switchers[i].sw->name );
|
||||
config_parser_add_option ( xrm_String,
|
||||
switchers[i].sw->keycfg,
|
||||
(void * *) &( switchers[i].sw->keystr ) );
|
||||
config_parser_add_option ( xrm_String, switchers[i].sw->keycfg, (void * *) &( switchers[i].sw->keystr ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1791,7 +1710,6 @@ static inline void load_configuration_dynamic ( Display *display )
|
|||
config_parse_cmd_options_dynamic ( );
|
||||
}
|
||||
|
||||
|
||||
static void release_global_keybindings ()
|
||||
{
|
||||
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
||||
|
@ -1823,12 +1741,10 @@ static void print_global_keybindings ()
|
|||
fprintf ( stdout, "listening to the following keys:\n" );
|
||||
for ( unsigned int i = 0; i < num_switchers; i++ ) {
|
||||
if ( switchers[i].sw->keystr != NULL ) {
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on %s\n",
|
||||
switchers[i].sw->name, switchers[i].sw->keystr );
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on %s\n", switchers[i].sw->name, switchers[i].sw->keystr );
|
||||
}
|
||||
else {
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on <unspecified>\n",
|
||||
switchers[i].sw->name );
|
||||
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on <unspecified>\n", switchers[i].sw->name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1849,9 +1765,7 @@ static void reload_configuration ()
|
|||
XCloseDisplay ( temp_display );
|
||||
}
|
||||
else {
|
||||
fprintf (
|
||||
stderr,
|
||||
"Failed to get a new connection to the X11 server. No point in continuing.\n" );
|
||||
fprintf ( stderr, "Failed to get a new connection to the X11 server. No point in continuing.\n" );
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
@ -1968,7 +1882,6 @@ static int main_loop_signal_handler ( char command, int quiet )
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setup signal handling.
|
||||
* Block all the signals, start a signal processor thread to handle these events.
|
||||
|
@ -2160,7 +2073,6 @@ int main ( int argc, char *argv[] )
|
|||
print_global_keybindings ();
|
||||
}
|
||||
|
||||
|
||||
// Create a pipe to communicate between signal thread an main thread.
|
||||
int pfds[2];
|
||||
if ( pipe ( pfds ) != 0 ) {
|
||||
|
@ -2224,7 +2136,6 @@ int main ( int argc, char *argv[] )
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
SwitcherMode switcher_run ( char **input, Switcher *sw )
|
||||
{
|
||||
char *prompt = g_strdup_printf ( "%s:", sw->name );
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <X11/Xft/Xft.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
#include "rofi.h"
|
||||
#include "textbox.h"
|
||||
#include "keyb.h"
|
||||
|
@ -51,7 +50,6 @@ extern Display *display;
|
|||
XVisualInfo *visual_info;
|
||||
Colormap target_colormap;
|
||||
|
||||
|
||||
typedef struct _RowColor
|
||||
{
|
||||
XftColor fg;
|
||||
|
@ -62,20 +60,13 @@ typedef struct _RowColor
|
|||
} RowColor;
|
||||
|
||||
#define num_states 3
|
||||
RowColor colors[num_states];
|
||||
|
||||
RowColor colors[num_states];
|
||||
|
||||
PangoContext *p_context = NULL;
|
||||
|
||||
|
||||
// Xft text box, optionally editable
|
||||
textbox* textbox_create ( Window parent,
|
||||
XVisualInfo *vinfo,
|
||||
Colormap map,
|
||||
TextboxFlags flags,
|
||||
short x, short y, short w, short h,
|
||||
TextBoxFontType tbft,
|
||||
const char *text )
|
||||
textbox* textbox_create ( Window parent, XVisualInfo *vinfo, Colormap map, TextboxFlags flags, short x, short y, short w, short h,
|
||||
TextBoxFontType tbft, const char *text )
|
||||
{
|
||||
textbox *tb = g_malloc0 ( sizeof ( textbox ) );
|
||||
|
||||
|
@ -133,8 +124,6 @@ textbox* textbox_create ( Window parent,
|
|||
// auto height/width modes get handled here
|
||||
textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h );
|
||||
|
||||
|
||||
|
||||
// edit mode controls
|
||||
if ( tb->flags & TB_EDITABLE ) {
|
||||
tb->xim = XOpenIM ( display, NULL, NULL, NULL );
|
||||
|
@ -194,7 +183,6 @@ void textbox_text ( textbox *tb, const char *text )
|
|||
textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h );
|
||||
}
|
||||
|
||||
|
||||
tb->cursor = MAX ( 0, MIN ( ( int ) strlen ( text ), tb->cursor ) );
|
||||
}
|
||||
// set the default text to display
|
||||
|
@ -220,7 +208,6 @@ void textbox_text_markup ( textbox *tb, const char *text )
|
|||
textbox_moveresize ( tb, tb->x, tb->y, tb->w, tb->h );
|
||||
}
|
||||
|
||||
|
||||
tb->cursor = MAX ( 0, MIN ( ( int ) strlen ( text ), tb->cursor ) );
|
||||
}
|
||||
|
||||
|
@ -281,7 +268,6 @@ void textbox_hide ( textbox *tb )
|
|||
XUnmapWindow ( display, tb->window );
|
||||
}
|
||||
|
||||
|
||||
// will also unmap the window if still displayed
|
||||
void textbox_free ( textbox *tb )
|
||||
{
|
||||
|
@ -337,9 +323,6 @@ void textbox_draw ( textbox *tb )
|
|||
cursor_x = pos.x / PANGO_SCALE;
|
||||
}
|
||||
|
||||
// pango_layout_set_width ( tb->layout, PANGO_SCALE * ( tb->w - 2 * SIDE_MARGIN ) );
|
||||
|
||||
|
||||
// Skip the side MARGIN on the X axis.
|
||||
int x = PANGO_SCALE * SIDE_MARGIN;
|
||||
int y = 0;
|
||||
|
@ -576,7 +559,6 @@ int textbox_keypress ( textbox *tb, XEvent *ev )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ( !( tb->flags & TB_EDITABLE ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -656,8 +638,6 @@ int textbox_keypress ( textbox *tb, XEvent *ev )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***
|
||||
* Font setup.
|
||||
*/
|
||||
|
|
|
@ -59,17 +59,14 @@ const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) };
|
|||
unsigned int NumlockMask = 0;
|
||||
|
||||
// retrieve a property of any type from a window
|
||||
int window_get_prop ( Display *display, Window w, Atom prop,
|
||||
Atom *type, int *items,
|
||||
void *buffer, unsigned int bytes )
|
||||
int window_get_prop ( Display *display, Window w, Atom prop, Atom *type, int *items, void *buffer, unsigned int bytes )
|
||||
{
|
||||
int format;
|
||||
unsigned long nitems, nbytes;
|
||||
unsigned char *ret = NULL;
|
||||
memset ( buffer, 0, bytes );
|
||||
|
||||
if ( XGetWindowProperty ( display, w, prop, 0, bytes / 4, False, AnyPropertyType, type,
|
||||
&format, &nitems, &nbytes,
|
||||
if ( XGetWindowProperty ( display, w, prop, 0, bytes / 4, False, AnyPropertyType, type, &format, &nitems, &nbytes,
|
||||
&ret ) == Success && ret && *type != None && format ) {
|
||||
if ( format == 8 ) {
|
||||
memmove ( buffer, ret, MIN ( bytes, nitems ) );
|
||||
|
@ -109,8 +106,7 @@ char* window_get_text_prop ( Display *display, Window w, Atom atom )
|
|||
g_strlcpy ( res, ( char * ) prop.value, l );
|
||||
}
|
||||
}
|
||||
else if ( Xutf8TextPropertyToTextList ( display, &prop, &list,
|
||||
&count ) >= Success && count > 0 && *list ) {
|
||||
else if ( Xutf8TextPropertyToTextList ( display, &prop, &list, &count ) >= Success && count > 0 && *list ) {
|
||||
size_t l = strlen ( *list ) + 1;
|
||||
res = g_malloc ( l );
|
||||
// make clang-check happy.
|
||||
|
@ -131,25 +127,20 @@ int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, in
|
|||
{
|
||||
Atom type;
|
||||
int items;
|
||||
return window_get_prop ( display, w, atom, &type, &items, list,
|
||||
count * sizeof ( Atom ) ) && type == XA_ATOM ? items : 0;
|
||||
return window_get_prop ( display, w, atom, &type, &items, list, count * sizeof ( Atom ) ) && type == XA_ATOM ? items : 0;
|
||||
}
|
||||
|
||||
void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms, int count )
|
||||
{
|
||||
XChangeProperty ( display, w, prop, XA_ATOM, 32, PropModeReplace, ( unsigned char * ) atoms,
|
||||
count );
|
||||
XChangeProperty ( display, w, prop, XA_ATOM, 32, PropModeReplace, ( unsigned char * ) atoms, count );
|
||||
}
|
||||
|
||||
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list,
|
||||
int count )
|
||||
int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list, int count )
|
||||
{
|
||||
Atom type; int items;
|
||||
return window_get_prop ( display, w, atom, &type, &items, list, count *
|
||||
sizeof ( unsigned long ) ) && type == XA_CARDINAL ? items : 0;
|
||||
return window_get_prop ( display, w, atom, &type, &items, list, count * sizeof ( unsigned long ) ) && type == XA_CARDINAL ? items : 0;
|
||||
}
|
||||
|
||||
|
||||
int monitor_get_dimension ( Display *display, Screen *screen, int monitor, workarea *mon )
|
||||
{
|
||||
memset ( mon, 0, sizeof ( workarea ) );
|
||||
|
@ -187,8 +178,7 @@ void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workar
|
|||
|
||||
if ( info ) {
|
||||
for ( int i = 0; i < monitors; i++ ) {
|
||||
if ( INTERSECT ( x, y, 1, 1, info[i].x_org, info[i].y_org, info[i].width,
|
||||
info[i].height ) ) {
|
||||
if ( INTERSECT ( x, y, 1, 1, info[i].x_org, info[i].y_org, info[i].width, info[i].height ) ) {
|
||||
mon->x = info[i].x_org;
|
||||
mon->y = info[i].y_org;
|
||||
mon->w = info[i].width;
|
||||
|
@ -227,7 +217,6 @@ static int pointer_get ( Display *display, Window root, int *x, int *y )
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// determine which monitor holds the active window, or failing that the mouse pointer
|
||||
void monitor_active ( Display *display, workarea *mon )
|
||||
{
|
||||
|
@ -244,16 +233,12 @@ void monitor_active ( Display *display, workarea *mon )
|
|||
}
|
||||
fprintf ( stderr, "Failed to find selected monitor.\n" );
|
||||
}
|
||||
if ( window_get_prop ( display, root, netatoms[_NET_ACTIVE_WINDOW], &type, &count, &id,
|
||||
sizeof ( Window ) )
|
||||
&& type == XA_WINDOW && count > 0 ) {
|
||||
if ( window_get_prop ( display, root, netatoms[_NET_ACTIVE_WINDOW], &type, &count, &id, sizeof ( Window ) )
|
||||
&& type == XA_WINDOW && count > 0 ) {
|
||||
XWindowAttributes attr;
|
||||
if ( XGetWindowAttributes ( display, id, &attr ) ) {
|
||||
Window junkwin;
|
||||
if ( XTranslateCoordinates ( display, id, attr.root,
|
||||
-attr.border_width,
|
||||
-attr.border_width,
|
||||
&x, &y, &junkwin ) == True ) {
|
||||
if ( XTranslateCoordinates ( display, id, attr.root, -attr.border_width, -attr.border_width, &x, &y, &junkwin ) == True ) {
|
||||
if ( config.monitor == -2 ) {
|
||||
// place the menu above the window
|
||||
// if some window is focused, place menu above window, else fall
|
||||
|
@ -281,9 +266,7 @@ void monitor_active ( Display *display, workarea *mon )
|
|||
monitor_dimensions ( display, screen, 0, 0, mon );
|
||||
}
|
||||
|
||||
int window_send_message ( Display *display, Window target,
|
||||
Window subject, Atom atom,
|
||||
unsigned long protocol, unsigned long mask, Time time )
|
||||
int window_send_message ( Display *display, Window trg, Window subject, Atom atom, unsigned long protocol, unsigned long mask, Time time )
|
||||
{
|
||||
XEvent e;
|
||||
memset ( &e, 0, sizeof ( XEvent ) );
|
||||
|
@ -294,7 +277,7 @@ int window_send_message ( Display *display, Window target,
|
|||
e.xclient.data.l[1] = time;
|
||||
e.xclient.send_event = True;
|
||||
e.xclient.format = 32;
|
||||
int r = XSendEvent ( display, target, False, mask, &e ) ? 1 : 0;
|
||||
int r = XSendEvent ( display, trg, False, mask, &e ) ? 1 : 0;
|
||||
XFlush ( display );
|
||||
return r;
|
||||
}
|
||||
|
@ -334,10 +317,8 @@ void x11_grab_key ( Display *display, unsigned int modmask, KeySym key )
|
|||
XGrabKey ( display, keycode, modmask | LockMask, root, True, GrabModeAsync, GrabModeAsync );
|
||||
|
||||
if ( NumlockMask ) {
|
||||
XGrabKey ( display, keycode, modmask | NumlockMask, root, True, GrabModeAsync,
|
||||
GrabModeAsync );
|
||||
XGrabKey ( display, keycode, modmask | NumlockMask | LockMask, root, True, GrabModeAsync,
|
||||
GrabModeAsync );
|
||||
XGrabKey ( display, keycode, modmask | NumlockMask, root, True, GrabModeAsync, GrabModeAsync );
|
||||
XGrabKey ( display, keycode, modmask | NumlockMask | LockMask, root, True, GrabModeAsync, GrabModeAsync );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,8 +418,7 @@ void x11_set_window_opacity ( Display *display, Window box, unsigned int opacity
|
|||
// Scale 0-100 to 0 - UINT32_MAX.
|
||||
unsigned int opacity_set = ( unsigned int ) ( ( opacity / 100.0 ) * UINT32_MAX );
|
||||
// Set opacity.
|
||||
XChangeProperty ( display, box, netatoms[_NET_WM_WINDOW_OPACITY],
|
||||
XA_CARDINAL, 32, PropModeReplace,
|
||||
XChangeProperty ( display, box, netatoms[_NET_WM_WINDOW_OPACITY], XA_CARDINAL, 32, PropModeReplace,
|
||||
( unsigned char * ) &opacity_set, 1L );
|
||||
}
|
||||
|
||||
|
@ -455,7 +435,6 @@ static void x11_create_frequently_used_atoms ( Display *display )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static int ( *xerror )( Display *, XErrorEvent * );
|
||||
/**
|
||||
* @param d The connection to the X server.
|
||||
|
@ -467,8 +446,7 @@ static int display_oops ( Display *d, XErrorEvent *ee )
|
|||
{
|
||||
if ( ee->error_code == BadWindow
|
||||
|| ( ee->request_code == X_GrabButton && ee->error_code == BadAccess )
|
||||
|| ( ee->request_code == X_GrabKey && ee->error_code == BadAccess )
|
||||
) {
|
||||
|| ( ee->request_code == X_GrabKey && ee->error_code == BadAccess )) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -488,8 +466,6 @@ void x11_setup ( Display *display )
|
|||
x11_create_frequently_used_atoms ( display );
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern Colormap map;
|
||||
extern XVisualInfo vinfo;
|
||||
int truecolor = FALSE;
|
||||
|
@ -499,8 +475,7 @@ void create_visual_and_colormap ( Display *display )
|
|||
// Try to create TrueColor map
|
||||
if ( XMatchVisualInfo ( display, screen, 32, TrueColor, &vinfo ) ) {
|
||||
// Visual found, lets try to create map.
|
||||
map = XCreateColormap ( display, DefaultRootWindow (
|
||||
display ), vinfo.visual, AllocNone );
|
||||
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
|
||||
truecolor = TRUE;
|
||||
}
|
||||
// Failed to create map.
|
||||
|
|
|
@ -54,145 +54,145 @@ typedef struct
|
|||
*/
|
||||
static XrmOption xrmOptions[] = {
|
||||
{ xrm_String, "switchers",
|
||||
{ .str = &config.switchers },
|
||||
NULL },
|
||||
{ xrm_String, "modi", { .str = &config.switchers },
|
||||
NULL },
|
||||
{ xrm_Number, "opacity", { .num = &config.window_opacity },
|
||||
NULL },
|
||||
{ .str = &config.switchers },
|
||||
NULL },
|
||||
{ xrm_String, "modi", { .str = &config.switchers },
|
||||
NULL },
|
||||
{ xrm_Number, "opacity", { .num = &config.window_opacity },
|
||||
NULL },
|
||||
|
||||
{ xrm_SNumber, "width", { .snum = &config.menu_width },
|
||||
NULL },
|
||||
{ xrm_SNumber, "width", { .snum = &config.menu_width },
|
||||
NULL },
|
||||
|
||||
{ xrm_Number, "lines", { .num = &config.menu_lines },
|
||||
NULL },
|
||||
{ xrm_Number, "columns", { .num = &config.menu_columns },
|
||||
NULL },
|
||||
{ xrm_Number, "lines", { .num = &config.menu_lines },
|
||||
NULL },
|
||||
{ xrm_Number, "columns", { .num = &config.menu_columns },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "font", { .str = &config.menu_font },
|
||||
NULL },
|
||||
{ xrm_String, "font", { .str = &config.menu_font },
|
||||
NULL },
|
||||
/* Foreground color */
|
||||
{ xrm_String, "foreground", { .str = &config.menu_fg },
|
||||
NULL },
|
||||
{ xrm_String, "fg", { .str = &config.menu_fg },
|
||||
NULL },
|
||||
{ xrm_String, "background", { .str = &config.menu_bg },
|
||||
NULL },
|
||||
{ xrm_String, "bg", { .str = &config.menu_bg },
|
||||
NULL },
|
||||
{ xrm_String, "foreground", { .str = &config.menu_fg },
|
||||
NULL },
|
||||
{ xrm_String, "fg", { .str = &config.menu_fg },
|
||||
NULL },
|
||||
{ xrm_String, "background", { .str = &config.menu_bg },
|
||||
NULL },
|
||||
{ xrm_String, "bg", { .str = &config.menu_bg },
|
||||
NULL },
|
||||
|
||||
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled },
|
||||
NULL },
|
||||
{ xrm_String, "color-normal", { .str = &config.color_normal },
|
||||
NULL },
|
||||
{ xrm_String, "color-urgent", { .str = &config.color_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "color-active", { .str = &config.color_active },
|
||||
NULL },
|
||||
{ xrm_String, "color-window", { .str = &config.color_window },
|
||||
NULL },
|
||||
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled },
|
||||
NULL },
|
||||
{ xrm_String, "color-normal", { .str = &config.color_normal },
|
||||
NULL },
|
||||
{ xrm_String, "color-urgent", { .str = &config.color_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "color-active", { .str = &config.color_active },
|
||||
NULL },
|
||||
{ xrm_String, "color-window", { .str = &config.color_window },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "fg-active", { .str = &config.menu_fg_active },
|
||||
NULL },
|
||||
{ xrm_String, "fg-urgent", { .str = &config.menu_fg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg-active", { .str = &config.menu_hlfg_active },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg-urgent", { .str = &config.menu_hlfg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "fg-active", { .str = &config.menu_fg_active },
|
||||
NULL },
|
||||
{ xrm_String, "fg-urgent", { .str = &config.menu_fg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg-active", { .str = &config.menu_hlfg_active },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg-urgent", { .str = &config.menu_hlfg_urgent },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "bg-active", { .str = &config.menu_bg_active },
|
||||
NULL },
|
||||
{ xrm_String, "bg-urgent", { .str = &config.menu_bg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg-active", { .str = &config.menu_hlbg_active },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg-urgent", { .str = &config.menu_hlbg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "bg-active", { .str = &config.menu_bg_active },
|
||||
NULL },
|
||||
{ xrm_String, "bg-urgent", { .str = &config.menu_bg_urgent },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg-active", { .str = &config.menu_hlbg_active },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg-urgent", { .str = &config.menu_hlbg_urgent },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "background-alternate", { .str = &config.menu_bg_alt },
|
||||
NULL },
|
||||
{ xrm_String, "bgalt", { .str = &config.menu_bg_alt },
|
||||
NULL },
|
||||
{ xrm_String, "background-alternate", { .str = &config.menu_bg_alt },
|
||||
NULL },
|
||||
{ xrm_String, "bgalt", { .str = &config.menu_bg_alt },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg", { .str = &config.menu_hlfg },
|
||||
NULL },
|
||||
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg },
|
||||
NULL },
|
||||
{ xrm_String, "hlfg", { .str = &config.menu_hlfg },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg", { .str = &config.menu_hlbg },
|
||||
NULL },
|
||||
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg },
|
||||
NULL },
|
||||
{ xrm_String, "hlbg", { .str = &config.menu_hlbg },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "bordercolor", { .str = &config.menu_bc },
|
||||
NULL },
|
||||
{ xrm_String, "bc", { .str = &config.menu_bc },
|
||||
NULL },
|
||||
{ xrm_String, "bordercolor", { .str = &config.menu_bc },
|
||||
NULL },
|
||||
{ xrm_String, "bc", { .str = &config.menu_bc },
|
||||
NULL },
|
||||
|
||||
{ xrm_Number, "borderwidth", { .num = &config.menu_bw },
|
||||
NULL },
|
||||
{ xrm_Number, "bw", { .num = &config.menu_bw },
|
||||
NULL },
|
||||
{ xrm_Number, "borderwidth", { .num = &config.menu_bw },
|
||||
NULL },
|
||||
{ xrm_Number, "bw", { .num = &config.menu_bw },
|
||||
NULL },
|
||||
|
||||
{ xrm_Number, "location", { .num = &config.location },
|
||||
NULL },
|
||||
{ xrm_Number, "location", { .num = &config.location },
|
||||
NULL },
|
||||
|
||||
{ xrm_Number, "padding", { .num = &config.padding },
|
||||
NULL },
|
||||
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset },
|
||||
NULL },
|
||||
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset },
|
||||
NULL },
|
||||
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines },
|
||||
NULL },
|
||||
{ xrm_Number, "padding", { .num = &config.padding },
|
||||
NULL },
|
||||
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset },
|
||||
NULL },
|
||||
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset },
|
||||
NULL },
|
||||
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines },
|
||||
NULL },
|
||||
|
||||
{ xrm_String, "terminal", { .str = &config.terminal_emulator },
|
||||
NULL },
|
||||
{ xrm_String, "ssh-client", { .str = &config.ssh_client },
|
||||
NULL },
|
||||
{ xrm_String, "ssh-command", { .str = &config.ssh_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-command", { .str = &config.run_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-list-command", { .str = &config.run_list_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command },
|
||||
NULL },
|
||||
{ xrm_String, "terminal", { .str = &config.terminal_emulator },
|
||||
NULL },
|
||||
{ xrm_String, "ssh-client", { .str = &config.ssh_client },
|
||||
NULL },
|
||||
{ xrm_String, "ssh-command", { .str = &config.ssh_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-command", { .str = &config.run_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-list-command", { .str = &config.run_list_command },
|
||||
NULL },
|
||||
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command },
|
||||
NULL },
|
||||
|
||||
{ xrm_Boolean, "disable-history", { .num = &config.disable_history },
|
||||
NULL },
|
||||
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort },
|
||||
NULL },
|
||||
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive },
|
||||
NULL },
|
||||
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode },
|
||||
NULL },
|
||||
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit },
|
||||
NULL },
|
||||
{ xrm_SNumber, "eh", { .snum = &config.element_height },
|
||||
NULL },
|
||||
{ xrm_Boolean, "auto-select", { .num = &config.auto_select },
|
||||
NULL },
|
||||
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts },
|
||||
NULL },
|
||||
{ xrm_String, "combi-modi", { .str = &config.combi_modi },
|
||||
NULL },
|
||||
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy },
|
||||
NULL },
|
||||
{ xrm_Number, "monitor", { .snum = &config.monitor },
|
||||
NULL },
|
||||
{ xrm_Boolean, "disable-history", { .num = &config.disable_history },
|
||||
NULL },
|
||||
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort },
|
||||
NULL },
|
||||
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive },
|
||||
NULL },
|
||||
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode },
|
||||
NULL },
|
||||
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit },
|
||||
NULL },
|
||||
{ xrm_SNumber, "eh", { .snum = &config.element_height },
|
||||
NULL },
|
||||
{ xrm_Boolean, "auto-select", { .num = &config.auto_select },
|
||||
NULL },
|
||||
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts },
|
||||
NULL },
|
||||
{ xrm_String, "combi-modi", { .str = &config.combi_modi },
|
||||
NULL },
|
||||
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy },
|
||||
NULL },
|
||||
{ xrm_Number, "monitor", { .snum = &config.monitor },
|
||||
NULL },
|
||||
/* Alias for dmenu compatibility. */
|
||||
{ xrm_SNumber, "m", { .snum = &config.monitor },
|
||||
NULL },
|
||||
{ xrm_Number, "line-margin", { .num = &config.line_margin },
|
||||
NULL },
|
||||
{ xrm_String, "filter", { .str = &config.filter },
|
||||
NULL },
|
||||
{ xrm_String, "separator-style", { .str = &config.separator_style },
|
||||
NULL },
|
||||
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar },
|
||||
NULL }
|
||||
{ xrm_SNumber, "m", { .snum = &config.monitor },
|
||||
NULL },
|
||||
{ xrm_Number, "line-margin", { .num = &config.line_margin },
|
||||
NULL },
|
||||
{ xrm_String, "filter", { .str = &config.filter },
|
||||
NULL },
|
||||
{ xrm_String, "separator-style", { .str = &config.separator_style },
|
||||
NULL },
|
||||
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar },
|
||||
NULL }
|
||||
};
|
||||
|
||||
// Dynamic options.
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <history.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static int test = 0;
|
||||
|
||||
#define TASSERT( a ) { \
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <textbox.h>
|
||||
#include <rofi.h>
|
||||
|
||||
|
||||
static int test = 0;
|
||||
unsigned int normal_window_mode = 0;
|
||||
|
||||
|
@ -158,7 +157,6 @@ int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv )
|
|||
TASSERT ( strcmp ( box->text, "aapmies" ) == 0 );
|
||||
TASSERT ( box->cursor == 5 );
|
||||
|
||||
|
||||
textbox_font ( box, HIGHLIGHT );
|
||||
textbox_draw ( box );
|
||||
|
||||
|
|
Loading…
Reference in a new issue