diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-05-28 17:34:53 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-05-28 17:34:53 +0200 |
commit | fff06fc88046be27394b131c252c95658e43a1c7 (patch) | |
tree | 65de0b84f7542ecc2b827899de672ea6dcda114a | |
parent | 5e946b8383e425ca3bccb2a3cca51e06df2c6106 (diff) |
Don't keep pointer to inputbar/main_box
-rw-r--r-- | include/view-internal.h | 4 | ||||
-rw-r--r-- | source/view.c | 19 | ||||
-rw-r--r-- | source/widgets/widget.c | 12 |
3 files changed, 19 insertions, 16 deletions
diff --git a/include/view-internal.h b/include/view-internal.h index edf0f63a..1dd8ebfb 100644 --- a/include/view-internal.h +++ b/include/view-internal.h @@ -52,10 +52,6 @@ struct RofiViewState int refilter; /** Widget representing the main container. */ box *main_window; - /** Main #box widget holding different elements. */ - box *main_box; - /** #box widget packing the input bar widgets. */ - box *input_bar; /** #textbox showing the prompt in the input bar. */ textbox *prompt; /** #textbox with the user input in the input bar. */ diff --git a/source/view.c b/source/view.c index 2a938adb..269b2592 100644 --- a/source/view.c +++ b/source/view.c @@ -1590,20 +1590,18 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, * MAINBOX */ if ( strcmp ( name, "mainbox") == 0 ){ - state->main_box = box_create ( strbox, BOX_VERTICAL ); - box_add ( (box *)parent_widget, WIDGET ( state->main_box ), TRUE, 0 ); - wid = WIDGET ( state->main_box ); + wid = (widget *)box_create ( strbox, BOX_VERTICAL ); + box_add ( (box *)parent_widget, WIDGET ( wid ), TRUE, 0 ); defaults = "inputbar,message,listview"; } /** * INPUTBAR */ else if ( strcmp ( name, "inputbar" ) == 0 ){ - state->input_bar = box_create ( strbox, BOX_HORIZONTAL ); - wid = WIDGET( state->input_bar ); + wid = (widget *)box_create ( strbox, BOX_HORIZONTAL ); defaults = "prompt,entry,case-indicator"; - box_add ( (box *)parent_widget, WIDGET ( state->input_bar ), FALSE, 0 ); + box_add ( (box *)parent_widget, WIDGET ( wid ), FALSE, 0 ); } /** * PROMPT @@ -1777,11 +1775,11 @@ int rofi_view_error_dialog ( const char *msg, int markup ) state->finalize = process_result; state->main_window = box_create ( "window.box", BOX_VERTICAL ); - state->main_box = box_create ( "window.mainbox.message.box", BOX_VERTICAL ); - box_add ( state->main_window, WIDGET ( state->main_box ), TRUE, 0 ); + box *box = box_create ( "window.mainbox.message.box", BOX_VERTICAL ); + box_add ( state->main_window, WIDGET ( box ), TRUE, 0 ); state->text = textbox_create ( "window.mainbox.message.textbox", ( TB_AUTOHEIGHT | TB_WRAP ) + ( ( markup ) ? TB_MARKUP : 0 ), NORMAL, ( msg != NULL ) ? msg : "" ); - box_add ( state->main_box, WIDGET ( state->text ), TRUE, 1 ); + box_add ( box, WIDGET ( state->text ), TRUE, 1 ); // Make sure we enable fixed num lines when in normal window mode. if ( ( CacheState.flags & MENU_NORMAL_WINDOW ) == MENU_NORMAL_WINDOW ) { @@ -1914,12 +1912,9 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text ) // Within padding of window. x_offset -= widget_padding_get_right ( WIDGET ( state->main_window ) ); // Within the border of widget. - x_offset -= widget_padding_get_right ( WIDGET ( state->main_box ) ); - x_offset -= widget_padding_get_right ( WIDGET ( state->input_bar ) ); x_offset -= widget_get_width ( WIDGET ( state->case_indicator ) ); x_offset -= widget_get_width ( WIDGET ( state->overlay ) ); int top_offset = widget_padding_get_top ( WIDGET ( state->main_window ) ); - top_offset += widget_padding_get_top ( WIDGET ( state->main_box ) ); widget_move ( WIDGET ( state->overlay ), x_offset, top_offset ); // We want to queue a repaint. rofi_view_queue_redraw ( ); diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 13875e58..f715af08 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -442,6 +442,9 @@ gboolean widget_motion_notify ( widget *wid, xcb_motion_notify_event_t *xme ) int widget_padding_get_left ( const widget *wid ) { + if ( wid == NULL ) { + return 0; + } int distance = distance_get_pixel ( wid->padding.left, ORIENTATION_HORIZONTAL ); distance += distance_get_pixel ( wid->border.left, ORIENTATION_HORIZONTAL ); distance += distance_get_pixel ( wid->margin.left, ORIENTATION_HORIZONTAL ); @@ -449,6 +452,9 @@ int widget_padding_get_left ( const widget *wid ) } int widget_padding_get_right ( const widget *wid ) { + if ( wid == NULL ) { + return 0; + } int distance = distance_get_pixel ( wid->padding.right, ORIENTATION_HORIZONTAL ); distance += distance_get_pixel ( wid->border.right, ORIENTATION_HORIZONTAL ); distance += distance_get_pixel ( wid->margin.right, ORIENTATION_HORIZONTAL ); @@ -456,6 +462,9 @@ int widget_padding_get_right ( const widget *wid ) } int widget_padding_get_top ( const widget *wid ) { + if ( wid == NULL ) { + return 0; + } int distance = distance_get_pixel ( wid->padding.top, ORIENTATION_VERTICAL ); distance += distance_get_pixel ( wid->border.top, ORIENTATION_VERTICAL ); distance += distance_get_pixel ( wid->margin.top, ORIENTATION_VERTICAL ); @@ -463,6 +472,9 @@ int widget_padding_get_top ( const widget *wid ) } int widget_padding_get_bottom ( const widget *wid ) { + if ( wid == NULL ) { + return 0; + } int distance = distance_get_pixel ( wid->padding.bottom, ORIENTATION_VERTICAL ); distance += distance_get_pixel ( wid->border.bottom, ORIENTATION_VERTICAL ); distance += distance_get_pixel ( wid->margin.bottom, ORIENTATION_VERTICAL ); |