Package: fluxbox
Version: 1.1.1-2
The attached patch adds a "-centered" option which centers the fbrun popup on
the screen. The reason for this is that fluxbox will otherwise try to position
this very small window somewhere that is not occupied by other windows, which
requires you to then search for the window in unoccupied areas of the screen.
It's just a minor inconvenience.
Just for the record: The fbrun manpage then also needs adjustment.
Thanks!
Uli
--- fluxbox-1.1.1/util/fbrun/main.cc 2008-01-15 10:50:53.000000000 +0100
+++ main.cc 2009-10-10 11:40:44.000000000 +0200
@@ -60,6 +60,7 @@ void showUsage(const char *progname) {
" -display [display string] Display name"<<endl<<
" -pos [x] [y] Window position in pixels"<<endl<<
" -nearmouse Window position near mouse"<<endl<<
+ " -centered Window position centered on screen"<<endl<<
" -fg [color name] Foreground text color"<<endl<<
" -bg [color name] Background color"<<endl<<
" -na Disable antialias"<<endl<<
@@ -74,6 +75,7 @@ int main(int argc, char **argv) {
bool set_height = false, set_width=false; // use height/width of font by default
bool set_pos = false; // set position
bool near_mouse = false; // popup near mouse
+ bool centered = false; // popup centered on screen
bool antialias = true; // antialias text
string fontname; // font name
string title("Run program"); // default title
@@ -105,6 +107,9 @@ int main(int argc, char **argv) {
} else if (strcmp(argv[i], "-nearmouse") == 0) {
set_pos = true;
near_mouse = true;
+ } else if (strcmp(argv[i], "-centered") == 0) {
+ set_pos = true;
+ centered = true;
} else if (strcmp(argv[i], "-fg") == 0 && i+1 < argc) {
foreground = argv[++i];
} else if (strcmp(argv[i], "-bg") == 0 && i+1 < argc) {
@@ -213,6 +218,20 @@ int main(int argc, char **argv) {
}
}
+ if (centered) {
+ Display* dpy = FbTk::App::instance()->display();
+ unsigned int root_w = WidthOfScreen(DefaultScreenOfDisplay(dpy));
+ unsigned int root_h = HeightOfScreen(DefaultScreenOfDisplay(dpy));
+ x = (root_w-fbrun.width())/2;
+ y = (root_h-fbrun.height())/2;
+ /* TODO: this will center the popup on the root window, but in
+ the case of Xinerama it should rather center it on one screen.
+ Question remains on which of them ... maybe use the one the
+ pointer is in, like the code for 'nearmouse' does? Alternatively,
+ allow defining a 'main' screen, that should then be applied to
+ the 'nearmouse' handling, too. */
+ }
+
if (set_pos)
fbrun.move(x, y);