1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-02-03 15:34:54 -05:00

Allow X parsed colors

This commit is contained in:
Dave Davenport 2016-03-05 16:33:18 +01:00
parent 7aa289d90c
commit bfd338dfc8
3 changed files with 49 additions and 36 deletions

View file

@ -32,22 +32,22 @@ ActionBindingEntry abe[NUM_ABE];
*/
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 = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", },
{ .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", },
{ .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 = 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" },

View file

@ -463,13 +463,13 @@ static void check_is_ascii ( thread_state *t, G_GNUC_UNUSED gpointer user_data )
static xcb_window_t __create_window ( MenuFlags menu_flags )
{
uint32_t selmask = XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
uint32_t selval[] = {
uint32_t selmask = XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
uint32_t selval[] = {
0,
0,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,
XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,
map
};

View file

@ -566,24 +566,37 @@ Color color_get ( const char *const name )
color.pixel = strtoul ( &cname[5], NULL, 16 );
}
else if ( strncmp ( cname, "#", 1 ) == 0 ) {
unsigned long val = strtoul ( &cname[1], NULL, 16 );
ssize_t length = strlen(&cname[1]);
switch ( length ) {
case 3:
color.a = 0xff;
color.r = 16*((val&0xF00)>>8);
color.g = 16*((val&0x0F0)>>4);
color.b = 16*(val&0x00F);
break;
case 6:
color.pixel = val;
color.a = 0xff;
break;
case 8:
color.pixel = val;
break;
default:
break;
unsigned long val = strtoul ( &cname[1], NULL, 16 );
ssize_t length = strlen ( &cname[1] );
switch ( length )
{
case 3:
color.a = 0xff;
color.r = 16 * ( ( val & 0xF00 ) >> 8 );
color.g = 16 * ( ( val & 0x0F0 ) >> 4 );
color.b = 16 * ( val & 0x00F );
break;
case 6:
color.pixel = val;
color.a = 0xff;
break;
case 8:
color.pixel = val;
break;
default:
break;
}
}
else {
xcb_alloc_named_color_cookie_t cc = xcb_alloc_named_color ( xcb->connection,
map, strlen ( cname ), cname );
xcb_alloc_named_color_reply_t *r = xcb_alloc_named_color_reply ( xcb->connection, cc, NULL );
if ( r ) {
color.a = 0xFF;
color.r = r->visual_red;
color.g = r->visual_green;
color.b = r->visual_blue;
free ( r );
}
}
g_free ( copy );