mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Remove xlib dependency, add xcb-util-xrm.
This commit is contained in:
parent
77a0800ccf
commit
a7922cc07c
5 changed files with 35 additions and 48 deletions
|
@ -1,5 +1,6 @@
|
||||||
v1.unrelease
|
v1.unrelease
|
||||||
- Remove fuzzy option
|
- Remove fuzzy option
|
||||||
|
- Remove xlib dependency (xcb-xrm)
|
||||||
|
|
||||||
v1.1.0
|
v1.1.0
|
||||||
New Features
|
New Features
|
||||||
|
|
|
@ -93,8 +93,7 @@ dnl ---------------------------------------------------------------------
|
||||||
dnl PKG_CONFIG based dependencies
|
dnl PKG_CONFIG based dependencies
|
||||||
dnl ---------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------
|
||||||
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40])
|
PKG_CHECK_MODULES([glib], [glib-2.0 >= 2.40])
|
||||||
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-xinerama xcb-icccm])
|
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon >= 0.5.0 xkbcommon-x11 xcb-ewmh xcb-xinerama xcb-icccm xcb-xrm])
|
||||||
PKG_CHECK_MODULES([x11], [x11 x11-xcb])
|
|
||||||
PKG_CHECK_MODULES([pango], [pango pangocairo])
|
PKG_CHECK_MODULES([pango], [pango pangocairo])
|
||||||
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
|
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
|
||||||
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0])
|
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0])
|
||||||
|
|
|
@ -87,12 +87,6 @@ void config_parse_xresource_options_dynamic ( xcb_stuff *xcb );
|
||||||
*/
|
*/
|
||||||
void config_parse_xresource_options_dynamic_file ( const char *filename );
|
void config_parse_xresource_options_dynamic_file ( const char *filename );
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the Xresourced system.
|
|
||||||
*
|
|
||||||
* @ingroup CONFXResources
|
|
||||||
*/
|
|
||||||
void config_parse_xresource_init ( void );
|
|
||||||
/**
|
/**
|
||||||
* Free any allocated memory.
|
* Free any allocated memory.
|
||||||
*
|
*
|
||||||
|
|
|
@ -780,10 +780,6 @@ int main ( int argc, char *argv[] )
|
||||||
exit ( EXIT_FAILURE );
|
exit ( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
TICK_N ( "Startup Notification" );
|
TICK_N ( "Startup Notification" );
|
||||||
|
|
||||||
// Initialize Xresources subsystem.
|
|
||||||
config_parse_xresource_init ();
|
|
||||||
TICK_N ( "Initialize Xresources system" );
|
|
||||||
// Setup keybinding
|
// Setup keybinding
|
||||||
setup_abe ();
|
setup_abe ();
|
||||||
TICK_N ( "Setup abe" );
|
TICK_N ( "Setup abe" );
|
||||||
|
|
|
@ -29,14 +29,15 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <X11/X.h>
|
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <xcb/xkb.h>
|
#include <xcb/xkb.h>
|
||||||
|
#include <xcb/xcb_xrm.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <xkbcommon/xkbcommon-compose.h>
|
#include <xkbcommon/xkbcommon-compose.h>
|
||||||
#include <xkbcommon/xkbcommon-x11.h>
|
#include <xkbcommon/xkbcommon-x11.h>
|
||||||
#include <X11/Xresource.h>
|
#include <glib.h>
|
||||||
#include "xcb.h"
|
#include "xcb.h"
|
||||||
|
#include "xcb-internal.h"
|
||||||
#include "x11-helper.h"
|
#include "x11-helper.h"
|
||||||
#include "rofi.h"
|
#include "rofi.h"
|
||||||
#include "xrmoptions.h"
|
#include "xrmoptions.h"
|
||||||
|
@ -196,27 +197,27 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu
|
||||||
num_extra_options++;
|
num_extra_options++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void config_parser_set ( XrmOption *option, XrmValue *xrmValue )
|
static void config_parser_set ( XrmOption *option, char *xrmValue )
|
||||||
{
|
{
|
||||||
if ( option->type == xrm_String ) {
|
if ( option->type == xrm_String ) {
|
||||||
if ( ( option )->mem != NULL ) {
|
if ( ( option )->mem != NULL ) {
|
||||||
g_free ( option->mem );
|
g_free ( option->mem );
|
||||||
option->mem = NULL;
|
option->mem = NULL;
|
||||||
}
|
}
|
||||||
*( option->value.str ) = g_strndup ( xrmValue->addr, xrmValue->size );
|
*( option->value.str ) = g_strdup ( xrmValue );
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
( option )->mem = *( option->value.str );
|
( option )->mem = *( option->value.str );
|
||||||
}
|
}
|
||||||
else if ( option->type == xrm_Number ) {
|
else if ( option->type == xrm_Number ) {
|
||||||
*( option->value.num ) = (unsigned int) strtoul ( xrmValue->addr, NULL, 10 );
|
*( option->value.num ) = (unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 );
|
||||||
}
|
}
|
||||||
else if ( option->type == xrm_SNumber ) {
|
else if ( option->type == xrm_SNumber ) {
|
||||||
*( option->value.snum ) = (int) strtol ( xrmValue->addr, NULL, 10 );
|
*( option->value.snum ) = (int) g_ascii_strtoll ( xrmValue, NULL, 10 );
|
||||||
}
|
}
|
||||||
else if ( option->type == xrm_Boolean ) {
|
else if ( option->type == xrm_Boolean ) {
|
||||||
if ( xrmValue->size > 0 &&
|
if ( strlen ( xrmValue ) > 0 &&
|
||||||
g_ascii_strncasecmp ( xrmValue->addr, "true", xrmValue->size ) == 0 ) {
|
g_ascii_strcasecmp ( xrmValue, "true" ) == 0 ) {
|
||||||
*( option->value.num ) = TRUE;
|
*( option->value.num ) = TRUE;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -224,14 +225,12 @@ static void config_parser_set ( XrmOption *option, XrmValue *xrmValue )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( option->type == xrm_Char ) {
|
else if ( option->type == xrm_Char ) {
|
||||||
*( option->value.charc ) = helper_parse_char ( xrmValue->addr );
|
*( option->value.charc ) = helper_parse_char ( xrmValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __config_parse_xresource_options ( XrmDatabase xDB )
|
static void __config_parse_xresource_options ( xcb_xrm_database_t *xDB )
|
||||||
{
|
{
|
||||||
char * xrmType;
|
|
||||||
XrmValue xrmValue;
|
|
||||||
const char * namePrefix = "rofi";
|
const char * namePrefix = "rofi";
|
||||||
const char * classPrefix = "rofi";
|
const char * classPrefix = "rofi";
|
||||||
|
|
||||||
|
@ -241,8 +240,12 @@ static void __config_parse_xresource_options ( XrmDatabase xDB )
|
||||||
name = g_strdup_printf ( "%s.%s", namePrefix, xrmOptions[i].name );
|
name = g_strdup_printf ( "%s.%s", namePrefix, xrmOptions[i].name );
|
||||||
class = g_strdup_printf ( "%s.%s", classPrefix, xrmOptions[i].name );
|
class = g_strdup_printf ( "%s.%s", classPrefix, xrmOptions[i].name );
|
||||||
|
|
||||||
if ( XrmGetResource ( xDB, name, class, &xrmType, &xrmValue ) ) {
|
char *xrmValue = NULL;
|
||||||
config_parser_set ( &( xrmOptions[i] ), &xrmValue );
|
if ( xcb_xrm_resource_get_string ( xDB, name, class, &xrmValue ) == 0 ) {
|
||||||
|
config_parser_set ( &( xrmOptions[i] ), xrmValue );
|
||||||
|
}
|
||||||
|
if ( xrmValue ) {
|
||||||
|
free ( xrmValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free ( class );
|
g_free ( class );
|
||||||
|
@ -251,13 +254,10 @@ static void __config_parse_xresource_options ( XrmDatabase xDB )
|
||||||
}
|
}
|
||||||
void config_parse_xresource_options ( xcb_stuff *xcb )
|
void config_parse_xresource_options ( xcb_stuff *xcb )
|
||||||
{
|
{
|
||||||
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
xcb_xrm_database_t *xDB = xcb_xrm_database_from_default ( xcb->connection );
|
||||||
if ( name ) {
|
if ( xDB ) {
|
||||||
// Map Xresource entries to rofi config options.
|
|
||||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
|
||||||
__config_parse_xresource_options ( xDB );
|
__config_parse_xresource_options ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
xcb_xrm_database_free ( xDB );
|
||||||
g_free ( name );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void config_parse_xresource_options_file ( const char *filename )
|
void config_parse_xresource_options_file ( const char *filename )
|
||||||
|
@ -266,12 +266,12 @@ void config_parse_xresource_options_file ( const char *filename )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Map Xresource entries to rofi config options.
|
// Map Xresource entries to rofi config options.
|
||||||
XrmDatabase xDB = XrmGetFileDatabase ( filename );
|
xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
|
||||||
if ( xDB == NULL ) {
|
if ( xDB == NULL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__config_parse_xresource_options ( xDB );
|
__config_parse_xresource_options ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
xcb_xrm_database_free ( xDB );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,10 +334,8 @@ void config_parse_cmd_options_dynamic ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
|
static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB )
|
||||||
{
|
{
|
||||||
char * xrmType;
|
|
||||||
XrmValue xrmValue;
|
|
||||||
const char * namePrefix = "rofi";
|
const char * namePrefix = "rofi";
|
||||||
const char * classPrefix = "rofi";
|
const char * classPrefix = "rofi";
|
||||||
|
|
||||||
|
@ -346,8 +344,12 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
|
||||||
|
|
||||||
name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name );
|
name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name );
|
||||||
class = g_strdup_printf ( "%s.%s", classPrefix, extra_options[i].name );
|
class = g_strdup_printf ( "%s.%s", classPrefix, extra_options[i].name );
|
||||||
if ( XrmGetResource ( xDB, name, class, &xrmType, &xrmValue ) ) {
|
char *xrmValue = NULL;
|
||||||
config_parser_set ( &( extra_options[i] ), &xrmValue );
|
if ( xcb_xrm_resource_get_string ( xDB, name, class, &xrmValue ) == 0 ) {
|
||||||
|
config_parser_set ( &( extra_options[i] ), xrmValue );
|
||||||
|
}
|
||||||
|
if ( xrmValue ) {
|
||||||
|
free ( xrmValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free ( class );
|
g_free ( class );
|
||||||
|
@ -359,9 +361,9 @@ void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
|
||||||
{
|
{
|
||||||
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
||||||
if ( name ) {
|
if ( name ) {
|
||||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
xcb_xrm_database_t *xDB = xcb_xrm_database_from_string ( name );
|
||||||
__config_parse_xresource_options_dynamic ( xDB );
|
__config_parse_xresource_options_dynamic ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
xcb_xrm_database_free ( xDB );
|
||||||
g_free ( name );
|
g_free ( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,12 +373,12 @@ void config_parse_xresource_options_dynamic_file ( const char *filename )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Map Xresource entries to rofi config options.
|
// Map Xresource entries to rofi config options.
|
||||||
XrmDatabase xDB = XrmGetFileDatabase ( filename );
|
xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
|
||||||
if ( xDB == NULL ) {
|
if ( xDB == NULL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
__config_parse_xresource_options_dynamic ( xDB );
|
__config_parse_xresource_options_dynamic ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
xcb_xrm_database_free ( xDB );
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_xresource_free ( void )
|
void config_xresource_free ( void )
|
||||||
|
@ -590,11 +592,6 @@ void config_parse_xresources_theme_dump ( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_parse_xresource_init ( void )
|
|
||||||
{
|
|
||||||
XrmInitialize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static char * config_parser_return_display_help_entry ( XrmOption *option )
|
static char * config_parser_return_display_help_entry ( XrmOption *option )
|
||||||
{
|
{
|
||||||
switch ( option->type )
|
switch ( option->type )
|
||||||
|
|
Loading…
Reference in a new issue