1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-07-31 21:59:25 -04:00

Fix #348, give a warning when font failed to parse

This commit is contained in:
Dave Davenport 2016-03-01 19:48:18 +01:00
parent 8c950a984c
commit f05f0de583
9 changed files with 64 additions and 46 deletions

View file

@ -372,7 +372,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd )
x11_cache_create ();
// Check for i3
pd->config_i3_mode = i3_support_initialize ( xcb );
xcb_get_property_cookie_t c = xcb_ewmh_get_active_window ( &(xcb->ewmh), xcb->screen_nbr );
xcb_get_property_cookie_t c = xcb_ewmh_get_active_window ( &( xcb->ewmh ), xcb->screen_nbr );
if ( !xcb_ewmh_get_active_window_reply ( &xcb->ewmh, c, &curr_win_id, NULL ) ) {
curr_win_id = 0;
}

View file

@ -40,6 +40,9 @@
#include <pwd.h>
#include <ctype.h>
#include <xcb/xcb.h>
#include <pango/pango.h>
#include <pango/pango-fontmap.h>
#include <pango/pangocairo.h>
#include "helper.h"
#include "settings.h"
#include "x11-helper.h"
@ -576,6 +579,20 @@ int config_sanity_check ( void )
}
}
PangoFontDescription * pfd = NULL;
if ( config.menu_font ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
const char *fam = pango_font_description_get_family ( pfd );
int size = pango_font_description_get_size ( pfd );
if ( fam == NULL || size == 0 ) {
g_string_append_printf ( msg, "Pango failed to parse font: '%s'\n", config.menu_font );
g_string_append_printf ( msg, "Got font family: <b>%s</b> at size <b>%d</b>\n", fam ? fam : "{unknown}", size );
config.menu_font = NULL;
found_error = TRUE;
}
pango_font_description_free ( pfd );
}
if ( found_error ) {
g_string_append ( msg, "Please update your configuration." );
show_error_message ( msg->str, TRUE );

View file

@ -117,7 +117,7 @@ int i3_support_initialize ( xcb_stuff *xcb )
i3_support_free_internals ();
// Get atom for I3_SOCKET_PATH
i3_socket_path = window_get_text_prop ( xcb_stuff_get_root_window(xcb), netatoms[I3_SOCKET_PATH] );
i3_socket_path = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), netatoms[I3_SOCKET_PATH] );
// If we find it, go into i3 mode.
return ( i3_socket_path != NULL ) ? TRUE : FALSE;
}

View file

@ -496,13 +496,13 @@ static xcb_window_t __create_window ( MenuFlags menu_flags )
{ 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,map };
XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION, map };
xcb_window_t box = xcb_generate_id ( xcb->connection );
xcb_create_window ( xcb->connection,
depth->depth,
box,
xcb_stuff_get_root_window(xcb),
xcb_stuff_get_root_window ( xcb ),
0,
0,
200,
@ -532,9 +532,11 @@ static xcb_window_t __create_window ( MenuFlags menu_flags )
pango_cairo_font_map_set_resolution ( (PangoCairoFontMap *) font_map, (double) config.dpi );
}
// Setup font.
if ( config.menu_font ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
pango_context_set_font_description ( p, pfd );
pango_font_description_free ( pfd );
}
// Tell textbox to use this context.
textbox_set_pango_context ( p );
// cleanup
@ -543,12 +545,12 @@ static xcb_window_t __create_window ( MenuFlags menu_flags )
// // make it an unmanaged window
if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) && !config.fullscreen ) {
window_set_atom_prop ( box, xcb->ewmh._NET_WM_STATE, &(xcb->ewmh._NET_WM_STATE_ABOVE), 1 );
window_set_atom_prop ( box, xcb->ewmh._NET_WM_STATE, &( xcb->ewmh._NET_WM_STATE_ABOVE ), 1 );
uint32_t values[] = { 1 };
xcb_change_window_attributes ( xcb->connection, box, XCB_CW_OVERRIDE_REDIRECT, values );
}
else{
window_set_atom_prop ( box, xcb->ewmh._NET_WM_WINDOW_TYPE, &(xcb->ewmh._NET_WM_WINDOW_TYPE_NORMAL), 1 );
window_set_atom_prop ( box, xcb->ewmh._NET_WM_WINDOW_TYPE, &( xcb->ewmh._NET_WM_WINDOW_TYPE_NORMAL ), 1 );
}
if ( config.fullscreen ) {
xcb_atom_t atoms[] = {
@ -1268,7 +1270,7 @@ void rofi_view_setup_fake_transparency ( RofiViewState *state )
{
if ( fake_bg == NULL ) {
cairo_surface_t *s = cairo_xcb_surface_create ( xcb->connection,
xcb_stuff_get_root_window(xcb),
xcb_stuff_get_root_window ( xcb ),
root_visual,
xcb->screen->width_in_pixels,
xcb->screen->height_in_pixels );
@ -1552,7 +1554,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
// We grab this using the rootwindow (as dmenu does it).
// this seems to result in the smallest delay for most people.
if ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) {
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window(xcb) );
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) );
if ( !has_keyboard ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
@ -1724,7 +1726,7 @@ void rofi_view_error_dialog ( const char *msg, int markup )
// Try to grab the keyboard as early as possible.
// We grab this using the rootwindow (as dmenu does it).
// this seems to result in the smallest delay for most people.
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window(xcb));
int has_keyboard = take_keyboard ( xcb_stuff_get_root_window ( xcb ) );
if ( !has_keyboard ) {
fprintf ( stderr, "Failed to grab keyboard, even after %d uS.", 500 * 1000 );
return;

View file

@ -51,7 +51,6 @@
#include "x11-helper.h"
#include "xkb-internal.h"
struct _xcb_stuff xcb_int = {
.connection = NULL,
.screen = NULL,