mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
feat: add "AutoPlace" action
The AutoPlace action will apply placement_find_best() to an active view, moving it to a position on its output that will minimize overlap with other views.
This commit is contained in:
parent
4b6239ee0c
commit
e3cd189769
3 changed files with 20 additions and 1 deletions
|
|
@ -219,6 +219,10 @@ Actions are used in menus and keyboard/mouse bindings.
|
||||||
*output_name* The name of virtual output. If not supplied, will remove the
|
*output_name* The name of virtual output. If not supplied, will remove the
|
||||||
last virtual output added.
|
last virtual output added.
|
||||||
|
|
||||||
|
*<action name="AutoPlace" />*
|
||||||
|
Use the automatic placement policy to move the active window to a
|
||||||
|
position on its output that will minimize overlap with other windows.
|
||||||
|
|
||||||
*<action name="None" />*
|
*<action name="None" />*
|
||||||
If used as the only action for a binding: clear an earlier defined binding.
|
If used as the only action for a binding: clear an earlier defined binding.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,10 @@
|
||||||
<action name="MoveTo" x="0" y="0" />
|
<action name="MoveTo" x="0" y="0" />
|
||||||
<action name="ToggleAlwaysOnBottom"/>
|
<action name="ToggleAlwaysOnBottom"/>
|
||||||
</windowRule>
|
</windowRule>
|
||||||
|
<windowRule identifier="org.qutebrowser.qutebrowser">
|
||||||
|
<action name="ResizeTo" width="1024" y="800" />
|
||||||
|
<action name="AutoPlace"/>
|
||||||
|
</windowRule>
|
||||||
</windowRules>
|
</windowRules>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
|
||||||
11
src/action.c
11
src/action.c
|
|
@ -16,6 +16,7 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
#include "placement.h"
|
||||||
#include "regions.h"
|
#include "regions.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
@ -100,6 +101,7 @@ enum action_type {
|
||||||
ACTION_TYPE_FOR_EACH,
|
ACTION_TYPE_FOR_EACH,
|
||||||
ACTION_TYPE_VIRTUAL_OUTPUT_ADD,
|
ACTION_TYPE_VIRTUAL_OUTPUT_ADD,
|
||||||
ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE,
|
ACTION_TYPE_VIRTUAL_OUTPUT_REMOVE,
|
||||||
|
ACTION_TYPE_AUTO_PLACE,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *action_names[] = {
|
const char *action_names[] = {
|
||||||
|
|
@ -146,6 +148,7 @@ const char *action_names[] = {
|
||||||
"ForEach",
|
"ForEach",
|
||||||
"VirtualOutputAdd",
|
"VirtualOutputAdd",
|
||||||
"VirtualOutputRemove",
|
"VirtualOutputRemove",
|
||||||
|
"AutoPlace",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -940,6 +943,14 @@ actions_run(struct view *activator, struct server *server,
|
||||||
output_remove_virtual(server, output_name);
|
output_remove_virtual(server, output_name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTION_TYPE_AUTO_PLACE:
|
||||||
|
if (view) {
|
||||||
|
int x = 0, y = 0;
|
||||||
|
if (placement_find_best(view, &x, &y)) {
|
||||||
|
view_move(view, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ACTION_TYPE_INVALID:
|
case ACTION_TYPE_INVALID:
|
||||||
wlr_log(WLR_ERROR, "Not executing unknown action");
|
wlr_log(WLR_ERROR, "Not executing unknown action");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue