mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Simplify some code, more comments. (90% docu)
This commit is contained in:
parent
89cf6d2d63
commit
163934fa8c
7 changed files with 34 additions and 11 deletions
|
@ -35,6 +35,7 @@ struct _widget
|
||||||
/** update widget implementation function */
|
/** update widget implementation function */
|
||||||
void ( *update )( struct _widget * );
|
void ( *update )( struct _widget * );
|
||||||
|
|
||||||
|
/** Handle mouse motion, used for dragging */
|
||||||
gboolean (*motion_notify)( struct _widget *, xcb_motion_notify_event_t * );
|
gboolean (*motion_notify)( struct _widget *, xcb_motion_notify_event_t * );
|
||||||
|
|
||||||
/** widget clicked callback */
|
/** widget clicked callback */
|
||||||
|
|
|
@ -443,6 +443,7 @@ static int dmenu_token_match ( const Mode *sw, GRegex **tokens, unsigned int ind
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "mode-private.h"
|
#include "mode-private.h"
|
||||||
|
/** dmenu Mode object. */
|
||||||
Mode dmenu_mode =
|
Mode dmenu_mode =
|
||||||
{
|
{
|
||||||
.name = "dmenu",
|
.name = "dmenu",
|
||||||
|
|
|
@ -53,6 +53,8 @@
|
||||||
* Name of the history file where previously choosen commands are stored.
|
* Name of the history file where previously choosen commands are stored.
|
||||||
*/
|
*/
|
||||||
#define RUN_CACHE_FILE "rofi-3.runcache"
|
#define RUN_CACHE_FILE "rofi-3.runcache"
|
||||||
|
|
||||||
|
/** The log domain of this dialog. */
|
||||||
#define LOG_DOMAIN "Dialogs.Run"
|
#define LOG_DOMAIN "Dialogs.Run"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,9 @@ typedef struct
|
||||||
char *comment;
|
char *comment;
|
||||||
} DefaultBinding;
|
} DefaultBinding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure holding all the action keybinding.
|
||||||
|
*/
|
||||||
ActionBindingEntry abe[NUM_ABE];
|
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_trigger_on_release[NUM_ABE] = { 0 };
|
||||||
|
|
||||||
static gboolean abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key )
|
static gboolean abe_test_action ( KeyBindingAction action, unsigned int mask, xkb_keysym_t key )
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
// Pidfile.
|
// Pidfile.
|
||||||
char *pidfile = NULL;
|
char *pidfile = NULL;
|
||||||
const char *cache_dir = NULL;
|
const char *cache_dir = NULL;
|
||||||
|
|
||||||
|
/** global structure holding the keyboard status */
|
||||||
struct xkb_stuff xkb = {
|
struct xkb_stuff xkb = {
|
||||||
.xcb_connection = NULL,
|
.xcb_connection = NULL,
|
||||||
.context = NULL,
|
.context = NULL,
|
||||||
|
@ -77,18 +79,24 @@ struct xkb_stuff xkb = {
|
||||||
.state = NULL
|
.state = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Path to the configuration file */
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
// Array of modi.
|
/** Array holding all activated modi. */
|
||||||
Mode **modi = NULL;
|
Mode **modi = NULL;
|
||||||
|
/** Number of activated modi in #modi array */
|
||||||
unsigned int num_modi = 0;
|
unsigned int num_modi = 0;
|
||||||
// Current selected switcher.
|
/** Current selected mode */
|
||||||
unsigned int curr_switcher = 0;
|
unsigned int curr_switcher = 0;
|
||||||
|
|
||||||
|
/** Glib main loop. */
|
||||||
GMainLoop *main_loop = NULL;
|
GMainLoop *main_loop = NULL;
|
||||||
|
/** GWater xcb source, signalling events from the X server */
|
||||||
GWaterXcbSource *main_loop_source = NULL;
|
GWaterXcbSource *main_loop_source = NULL;
|
||||||
|
|
||||||
|
/** Flag indicating we are in dmenu mode. */
|
||||||
static int dmenu_mode = FALSE;
|
static int dmenu_mode = FALSE;
|
||||||
|
/** Rofi's return code */
|
||||||
int return_code = EXIT_SUCCESS;
|
int return_code = EXIT_SUCCESS;
|
||||||
|
|
||||||
void process_result ( RofiViewState *state );
|
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;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** X server error depth. to handle nested errors. */
|
||||||
static int error_trap_depth = 0;
|
static int error_trap_depth = 0;
|
||||||
static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay )
|
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;
|
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[] )
|
int main ( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
TIMINGS_START ();
|
TIMINGS_START ();
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "view-internal.h"
|
#include "view-internal.h"
|
||||||
|
|
||||||
|
/** The Rofi View log domain */
|
||||||
#define LOG_DOMAIN "View"
|
#define LOG_DOMAIN "View"
|
||||||
|
|
||||||
#include "xcb.h"
|
#include "xcb.h"
|
||||||
|
|
|
@ -46,13 +46,8 @@
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
#include <rofi.h>
|
#include <rofi.h>
|
||||||
#define OVERLAP( a, b, c, \
|
/** Checks if the if x and y is inside rectangle. */
|
||||||
d ) ( ( ( a ) == ( c ) && \
|
#define INTERSECT( x,y, x1, y1, w1, h1 ) ( ( ((x) >= (x1)) && ((x) < (x1+w1)) ) && ( ((y) >= (y1)) && ((y) < (y1+h1)) ) )
|
||||||
( 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 ) ) )
|
|
||||||
#include "x11-helper.h"
|
#include "x11-helper.h"
|
||||||
#include "xkb-internal.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;
|
mon->h = xcb->screen->height_in_pixels;
|
||||||
|
|
||||||
for ( workarea *iter = xcb->monitors; iter; iter = iter->next ) {
|
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;
|
*mon = *iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue