mirror of
https://github.com/davatorium/rofi.git
synced 2025-04-14 17:43:01 -04:00
Allow user to specify location of switcher
This commit is contained in:
parent
6e242c197e
commit
f72a60580f
3 changed files with 52 additions and 0 deletions
|
@ -26,6 +26,8 @@ simpleswitcher \- a simple EWMH window switcher
|
|||
.RB [ \-snow ]
|
||||
.RB [ \-term
|
||||
.IR terminal ]
|
||||
.RB [ \-loc
|
||||
.IR position ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.I simpleswitcher
|
||||
|
@ -160,6 +162,11 @@ Specify what terminal to start (default x-terminal-emulator)
|
|||
.RS
|
||||
simpleswitcher -term xterm
|
||||
.RE
|
||||
.TP
|
||||
.B -loc
|
||||
Specify where the window should be located.
|
||||
(0 center, 1 north-east,2 north, 3 north-west, etc)
|
||||
.P
|
||||
.SH Switch between modi
|
||||
Type '?'<enter> to switch between window list and run mode.
|
||||
.SH SEE ALSO
|
||||
|
|
|
@ -36,6 +36,18 @@ void* reallocate( void *ptr, unsigned long bytes );
|
|||
|
||||
void catch_exit( __attribute__( ( unused ) ) int sig );
|
||||
|
||||
typedef enum _WindowLocation {
|
||||
CENTER = 0,
|
||||
NORTH_WEST = 1,
|
||||
NORTH = 2,
|
||||
NORTH_EAST = 3,
|
||||
EAST = 4,
|
||||
EAST_SOUTH = 5,
|
||||
SOUTH = 6,
|
||||
SOUTH_WEST = 7,
|
||||
WEST = 8
|
||||
} WindowLocation;
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*/
|
||||
|
@ -62,6 +74,7 @@ typedef struct _Settings {
|
|||
char * window_key;
|
||||
char * run_key;
|
||||
char * ssh_key;
|
||||
WindowLocation location;
|
||||
} Settings;
|
||||
|
||||
extern Settings config;
|
||||
|
|
|
@ -96,6 +96,7 @@ Settings config = {
|
|||
.window_key = "F12",
|
||||
.run_key = "mod1+F2",
|
||||
.ssh_key = "mod1+F3",
|
||||
.location = CENTER
|
||||
};
|
||||
|
||||
|
||||
|
@ -869,6 +870,35 @@ int menu( char **lines, char **input, char *prompt, Time *time, int *shift,
|
|||
// Subtract the margin of the last row.
|
||||
int h = line_height * ( max_lines+1 ) + INNER_MARGIN*2 - row_margin+LINE_MARGIN;
|
||||
int y = mon.y + ( mon.h - h )/2;
|
||||
|
||||
switch(config.location)
|
||||
{
|
||||
case NORTH_WEST:
|
||||
x=mon.x;
|
||||
case NORTH:
|
||||
y=mon.y;
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
y=mon.y;
|
||||
case EAST:
|
||||
x=mon.x+mon.w-w;
|
||||
break;
|
||||
case EAST_SOUTH:
|
||||
x=mon.x+mon.w-w;
|
||||
case SOUTH:
|
||||
y=mon.y+mon.h-h;
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
y=mon.y+mon.h-h;
|
||||
case WEST:
|
||||
x=mon.x;
|
||||
break;
|
||||
case CENTER:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
XMoveResizeWindow( display, box, x, y, w, h );
|
||||
XMapRaised( display, box );
|
||||
|
||||
|
@ -1316,6 +1346,8 @@ int main( int argc, char *argv[] )
|
|||
find_arg_int( argc, argv, "-width",&( config.menu_width ) );
|
||||
find_arg_int( argc, argv, "-lines",&( config.menu_lines ) );
|
||||
|
||||
find_arg_int( argc, argv, "-loc", &( config.location ) );
|
||||
|
||||
#ifdef I3
|
||||
// Check for i3
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue