Simplify some code, more comments. (90% docu)

This commit is contained in:
Dave Davenport 2016-10-25 22:45:11 +02:00
parent 89cf6d2d63
commit 163934fa8c
7 changed files with 34 additions and 11 deletions

View File

@ -35,6 +35,7 @@ struct _widget
/** update widget implementation function */
void ( *update )( struct _widget * );
/** Handle mouse motion, used for dragging */
gboolean (*motion_notify)( struct _widget *, xcb_motion_notify_event_t * );
/** widget clicked callback */

View File

@ -443,6 +443,7 @@ static int dmenu_token_match ( const Mode *sw, GRegex **tokens, unsigned int ind
}
#include "mode-private.h"
/** dmenu Mode object. */
Mode dmenu_mode =
{
.name = "dmenu",

View File

@ -53,6 +53,8 @@
* Name of the history file where previously choosen commands are stored.
*/
#define RUN_CACHE_FILE "rofi-3.runcache"
/** The log domain of this dialog. */
#define LOG_DOMAIN "Dialogs.Run"
/**

View File

@ -27,6 +27,9 @@ typedef struct
char *comment;
} DefaultBinding;
/**
* Data structure holding all the action keybinding.
*/
ActionBindingEntry abe[NUM_ABE];
/**
@ -141,6 +144,9 @@ void cleanup_abe ( void )
}
}
/**
* Array holding actions that should be trigger on release.
*/
static gboolean _abe_trigger_on_release[NUM_ABE] = { 0 };
static gboolean abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key )

View File

@ -67,6 +67,8 @@
// Pidfile.
char *pidfile = NULL;
const char *cache_dir = NULL;
/** global structure holding the keyboard status */
struct xkb_stuff xkb = {
.xcb_connection = NULL,
.context = NULL,
@ -77,18 +79,24 @@ struct xkb_stuff xkb = {
.state = NULL
}
};
/** Path to the configuration file */
char *config_path = NULL;
// Array of modi.
/** Array holding all activated modi. */
Mode **modi = NULL;
/** Number of activated modi in #modi array */
unsigned int num_modi = 0;
// Current selected switcher.
/** Current selected mode */
unsigned int curr_switcher = 0;
/** Glib main loop. */
GMainLoop *main_loop = NULL;
/** GWater xcb source, signalling events from the X server */
GWaterXcbSource *main_loop_source = NULL;
/** Flag indicating we are in dmenu mode. */
static int dmenu_mode = FALSE;
/** Rofi's return code */
int return_code = EXIT_SUCCESS;
void process_result ( RofiViewState *state );
@ -500,6 +508,7 @@ static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_CONTINUE;
}
/** X server error depth. to handle nested errors. */
static int error_trap_depth = 0;
static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay )
{
@ -600,6 +609,14 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
return G_SOURCE_REMOVE;
}
/**
* @param argc number of input arguments.
* @param argv array of the input arguments.
*
* Main application entry point.
*
* @returns return code of rofi.
*/
int main ( int argc, char *argv[] )
{
TIMINGS_START ();

View File

@ -58,6 +58,7 @@
#include "view.h"
#include "view-internal.h"
/** The Rofi View log domain */
#define LOG_DOMAIN "View"
#include "xcb.h"

View File

@ -46,13 +46,8 @@
#include "helper.h"
#include <rofi.h>
#define OVERLAP( a, b, c, \
d ) ( ( ( a ) == ( c ) && \
( b ) == ( d ) ) || \
MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 )
#define INTERSECT( x, y, w, h, x1, y1, w1, \
h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), \
( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
/** Checks if the if x and y is inside rectangle. */
#define INTERSECT( x,y, x1, y1, w1, h1 ) ( ( ((x) >= (x1)) && ((x) < (x1+w1)) ) && ( ((y) >= (y1)) && ((y) < (y1+h1)) ) )
#include "x11-helper.h"
#include "xkb-internal.h"
@ -347,7 +342,7 @@ static void monitor_dimensions ( int x, int y, workarea *mon )
mon->h = xcb->screen->height_in_pixels;
for ( workarea *iter = xcb->monitors; iter; iter = iter->next ) {
if ( INTERSECT ( x, y, 1, 1, iter->x, iter->y, iter->w, iter->h ) ) {
if ( INTERSECT ( x, y, iter->x, iter->y, iter->w, iter->h ) ) {
*mon = *iter;
break;
}