Heya, Here's another patch, this one adds a new window placement mode called 'Under Mouse'. This mode is listed on the configuration menu, so there's no funny ./configure options, just select it from the menu.
One thing to note, there's nothing handling window placement over/under the titlebar or the slit. I don't really use either, but it may get irritating if you do. :P ftp://beer.dct.com/pub/WindowManagers/Blackbox/patches/blackbox-0.62.1-under_mouse_placement.diff Thanks, Mike
diff -ruN blackbox-0.62.1.old/nls/C/Configmenu.m blackbox-0.62.1/nls/C/Configmenu.m --- blackbox-0.62.1.old/nls/C/Configmenu.m Tue Jun 13 00:13:21 2000 +++ blackbox-0.62.1/nls/C/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Smart Placement (Columns) $ #Cascade # Cascade Placement +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Left to Right $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/da_DK/Configmenu.m blackbox-0.62.1/nls/da_DK/Configmenu.m --- blackbox-0.62.1.old/nls/da_DK/Configmenu.m Tue Aug 8 02:33:48 2000 +++ blackbox-0.62.1/nls/da_DK/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Intelligent placering (Søjler) $ #Cascade # Kaskade placering +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Fra venstre mod højre $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/de_DE/Configmenu.m blackbox-0.62.1/nls/de_DE/Configmenu.m --- blackbox-0.62.1.old/nls/de_DE/Configmenu.m Wed Jan 16 21:12:18 2002 +++ blackbox-0.62.1/nls/de_DE/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Optimale Plazierung (Spalten) $ #Cascade # Verschobene Plazierung +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Von links nach rechts $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/es_ES/Configmenu.m blackbox-0.62.1/nls/es_ES/Configmenu.m --- blackbox-0.62.1.old/nls/es_ES/Configmenu.m Wed May 31 17:42:50 2000 +++ blackbox-0.62.1/nls/es_ES/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Ubicación inteligente (columnas) $ #Cascade # Ubicación en cascada +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # De izquierda a derecha $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/et_EE/Configmenu.m blackbox-0.62.1/nls/et_EE/Configmenu.m --- blackbox-0.62.1.old/nls/et_EE/Configmenu.m Wed May 31 17:42:51 2000 +++ blackbox-0.62.1/nls/et_EE/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Arukas paigutus (tulbad) $ #Cascade # Kaskaadis +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Vasakult paremale $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/fr_FR/Configmenu.m blackbox-0.62.1/nls/fr_FR/Configmenu.m --- blackbox-0.62.1.old/nls/fr_FR/Configmenu.m Sun Jun 4 11:18:07 2000 +++ blackbox-0.62.1/nls/fr_FR/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Disposition futée (Colonnes) $ #Cascade # Disposition en cascade +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # De gauche à droite $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/it_IT/Configmenu.m blackbox-0.62.1/nls/it_IT/Configmenu.m --- blackbox-0.62.1.old/nls/it_IT/Configmenu.m Mon Jan 7 13:30:00 2002 +++ blackbox-0.62.1/nls/it_IT/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Posizionamento Intelligente (Colonne) $ #Cascade # Posizionamento a Cascata +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # da Sinistra a Destra $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/ja_JP/Configmenu.m blackbox-0.62.1/nls/ja_JP/Configmenu.m --- blackbox-0.62.1.old/nls/ja_JP/Configmenu.m Mon Dec 10 20:38:16 2001 +++ blackbox-0.62.1/nls/ja_JP/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # ¸¤¯ÇÛÃÖ (Îó) $ #Cascade # ¤º¤é¤·¤ÆÇÛÃÖ +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # º¸¤«¤é±¦¤Ø $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/nl_NL/Configmenu.m blackbox-0.62.1/nls/nl_NL/Configmenu.m --- blackbox-0.62.1.old/nls/nl_NL/Configmenu.m Sat Jan 19 10:24:00 2002 +++ blackbox-0.62.1/nls/nl_NL/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Optimale plaatsing (kolommen) $ #Cascade # Trapsgewijs +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Van links naar rechts $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/pt_BR/Configmenu.m blackbox-0.62.1/nls/pt_BR/Configmenu.m --- blackbox-0.62.1.old/nls/pt_BR/Configmenu.m Wed May 31 17:42:49 2000 +++ blackbox-0.62.1/nls/pt_BR/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Posicionamento em Coluna $ #Cascade # Posicionamento em Cascata +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Esquerda para Direita $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/ru_RU/Configmenu.m blackbox-0.62.1/nls/ru_RU/Configmenu.m --- blackbox-0.62.1.old/nls/ru_RU/Configmenu.m Wed May 31 17:42:51 2000 +++ blackbox-0.62.1/nls/ru_RU/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # "õÍÎÏÅ" ÒÁÓÐÏÌÏÖÅÎÉÅ (ÐÏ ×ÅÒÔÉËÁÌÉ) $ #Cascade # ëÁÓËÁÄÏÍ +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # óÌÅ×Á ÎÁÐÒÁ×Ï $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/sl_SI/Configmenu.m blackbox-0.62.1/nls/sl_SI/Configmenu.m --- blackbox-0.62.1.old/nls/sl_SI/Configmenu.m Wed Jan 16 01:56:16 2002 +++ blackbox-0.62.1/nls/sl_SI/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Pametno postavljanje (stolpci) $ #Cascade # Kaskadno postavljanje +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Od leve proti desni $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/sv_SE/Configmenu.m blackbox-0.62.1/nls/sv_SE/Configmenu.m --- blackbox-0.62.1.old/nls/sv_SE/Configmenu.m Mon Aug 14 08:41:36 2000 +++ blackbox-0.62.1/nls/sv_SE/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Smart placering (Kolumner) $ #Cascade # Kaskadplacering +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Från vänster $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/tr_TR/Configmenu.m blackbox-0.62.1/nls/tr_TR/Configmenu.m --- blackbox-0.62.1.old/nls/tr_TR/Configmenu.m Wed May 31 17:42:50 2000 +++ blackbox-0.62.1/nls/tr_TR/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # Akýllý yerleþim( Sütunlar ) $ #Cascade # Cascade Placement +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # Soldan saða $ #RightLeft diff -ruN blackbox-0.62.1.old/nls/zh_CN/Configmenu.m blackbox-0.62.1/nls/zh_CN/Configmenu.m --- blackbox-0.62.1.old/nls/zh_CN/Configmenu.m Sat Jan 26 10:10:28 2002 +++ blackbox-0.62.1/nls/zh_CN/Configmenu.m Wed Mar 6 18:49:41 2002 @@ -28,6 +28,8 @@ # ×Ô¶¯·ÅÖÃ(ÁÐ) $ #Cascade # ²ãµþ·ÅÖà +$ #UnderMouse +# Under Mouse Placement $ #LeftRight # ´Ó×óµ½ÓÒ $ #RightLeft diff -ruN blackbox-0.62.1.old/src/Configmenu.cc blackbox-0.62.1/src/Configmenu.cc --- blackbox-0.62.1.old/src/Configmenu.cc Sun Dec 30 00:54:05 2001 +++ blackbox-0.62.1/src/Configmenu.cc Wed Mar 6 18:49:41 2002 @@ -215,6 +215,9 @@ BScreen::ColSmartPlacement); insert(i18n->getMessage(ConfigmenuSet, ConfigmenuCascade, "Cascade Placement"), BScreen::CascadePlacement); + insert(i18n->getMessage(ConfigmenuSet, ConfigmenuUnderMouse, + "Under Mouse Placement"), + BScreen::UnderMousePlacement); insert(i18n->getMessage(ConfigmenuSet, ConfigmenuLeftRight, "Left to Right"), BScreen::LeftRight); insert(i18n->getMessage(ConfigmenuSet, ConfigmenuRightLeft, @@ -237,6 +240,10 @@ case BScreen::CascadePlacement: setItemSelected(2, True); break; + + case BScreen::UnderMousePlacement: + setItemSelected(3, True); + break; } Bool rl = (configmenu->screen->getRowPlacementDirection() == @@ -267,6 +274,7 @@ setItemSelected(0, True); setItemSelected(1, False); setItemSelected(2, False); + setItemSelected(3, False); break; @@ -276,6 +284,7 @@ setItemSelected(0, False); setItemSelected(1, True); setItemSelected(2, False); + setItemSelected(3, False); break; @@ -285,38 +294,49 @@ setItemSelected(0, False); setItemSelected(1, False); setItemSelected(2, True); + setItemSelected(3, False); + + break; + + case BScreen::UnderMousePlacement: + configmenu->screen->savePlacementPolicy(item->function()); + + setItemSelected(0, False); + setItemSelected(1, False); + setItemSelected(2, False); + setItemSelected(3, True); break; case BScreen::LeftRight: configmenu->screen->saveRowPlacementDirection(BScreen::LeftRight); - setItemSelected(3, True); - setItemSelected(4, False); + setItemSelected(4, True); + setItemSelected(5, False); break; case BScreen::RightLeft: configmenu->screen->saveRowPlacementDirection(BScreen::RightLeft); - setItemSelected(3, False); - setItemSelected(4, True); + setItemSelected(4, False); + setItemSelected(5, True); break; case BScreen::TopBottom: configmenu->screen->saveColPlacementDirection(BScreen::TopBottom); - setItemSelected(5, True); - setItemSelected(6, False); + setItemSelected(6, True); + setItemSelected(7, False); break; case BScreen::BottomTop: configmenu->screen->saveColPlacementDirection(BScreen::BottomTop); - setItemSelected(5, False); - setItemSelected(6, True); + setItemSelected(6, False); + setItemSelected(7, True); break; } diff -ruN blackbox-0.62.1.old/src/Screen.hh blackbox-0.62.1/src/Screen.hh --- blackbox-0.62.1.old/src/Screen.hh Tue Jan 8 22:51:02 2002 +++ blackbox-0.62.1/src/Screen.hh Wed Mar 6 18:49:41 2002 @@ -319,8 +319,8 @@ void updateNetizenWindowRaise(Window); void updateNetizenWindowLower(Window); - enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, LeftRight, - RightLeft, TopBottom, BottomTop }; + enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, + UnderMousePlacement, LeftRight, RightLeft, TopBottom, BottomTop }; enum { LeftJustify = 1, RightJustify, CenterJustify }; enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet }; enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure, diff -ruN blackbox-0.62.1.old/src/Workspace.cc blackbox-0.62.1/src/Workspace.cc --- blackbox-0.62.1.old/src/Workspace.cc Wed Jan 16 01:37:47 2002 +++ blackbox-0.62.1/src/Workspace.cc Wed Mar 6 18:57:02 2002 @@ -352,6 +352,58 @@ LinkedListIterator<BlackboxWindow> it(windowList); switch (screen->getPlacementPolicy()) { + + case BScreen::UnderMousePlacement: { + int rx, ry, wx, wy; + unsigned int mask; + Window junk, root_return; + int screenWidth = screen->getWidth(), screenHeight = screen->getHeight(); + + XQueryPointer(screen->getBaseDisplay()->getXDisplay(), + win->getClientWindow(), &root_return, &junk, + &rx, &ry, &wx, &wy, &mask); + + /* target position is mouse pointer - (win[height|width] / 2) */ + test_x = rx - (win_w / 2); + test_y = ry - (win_h / 2); + + /* + * The window will always be inside the screen with the following. This + * may not be the desired effect, perhaps you might not mind the window + * being partially off the screen on the +/- x axis. + * + * Titlebar being off the top of the screen may be a bit more irritating... + * + * Adjust accordingly. + */ + + if(test_x < 0) + test_x = 0; + + if(test_y < 0) + test_y = 0; + + if((test_x + win_w) >= screenWidth) + test_x = screenWidth - win_w; + + if((test_y + win_h) >= screenHeight) + test_y = screenHeight - win_h; + + /* + * FIXME: + * As is, windows will be placed over/under the toolbar/slit. + * I personally don't use the slit, and the toolbar is hidden, so it's + * not a big deal, for others it might be. + */ + + place_x = test_x; + place_y = test_y; + + placed = True; + + break; + } + case BScreen::RowSmartPlacement: { test_y = (screen->getColPlacementDirection() == BScreen::TopBottom) ? start_pos : screen->getHeight() - win_h - start_pos; diff -ruN blackbox-0.62.1.old/src/blackbox.cc blackbox-0.62.1/src/blackbox.cc --- blackbox-0.62.1.old/src/blackbox.cc Sat Jan 12 05:17:26 2002 +++ blackbox-0.62.1/src/blackbox.cc Wed Mar 6 18:49:41 2002 @@ -1047,6 +1047,10 @@ char *placement = (char *) 0; switch (screen->getPlacementPolicy()) { + case BScreen::UnderMousePlacement: + placement = "UnderMousePlacement"; + break; + case BScreen::CascadePlacement: placement = "CascadePlacement"; break; @@ -1459,6 +1463,8 @@ screen->savePlacementPolicy(BScreen::RowSmartPlacement); else if (! strncasecmp(value.addr, "ColSmartPlacement", value.size)) screen->savePlacementPolicy(BScreen::ColSmartPlacement); + else if (! strncasecmp(value.addr, "UnderMousePlacement", value.size)) + screen->savePlacementPolicy(BScreen::UnderMousePlacement); else screen->savePlacementPolicy(BScreen::CascadePlacement); } else {