summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2025-08-15 07:20:47 -0400
committerLuke from DC <[email protected]>2025-09-09 19:51:09 +0000
commitb5292ba66132104256590631b2d2b7a1c92ad934 (patch)
tree3d83ea535c11942428a57af64263af5f71837205
parent4a2eebdd0f20a9ea4f60d63fe03837f9a39350ba (diff)
downloadmarco-b5292ba66132104256590631b2d2b7a1c92ad934.tar.bz2
marco-b5292ba66132104256590631b2d2b7a1c92ad934.tar.xz
window: Add configurable mouse actions for titlebar
Adds support for configurable mouse actions on window titlebars, including middle-click and scroll wheel events. New actions added: - close: Close the window - raise: Raise window to top - toggle_stick: Toggle sticky state (all workspaces) - toggle_above: Toggle always-on-top state Fixes #425 Fixes #787 Note: requries matching mate-control-center changes to work properly
-rw-r--r--src/core/prefs.c30
-rw-r--r--src/include/common.h12
-rw-r--r--src/include/prefs.h4
-rw-r--r--src/org.mate.marco.gschema.xml40
-rw-r--r--src/ui/frames.c95
5 files changed, 166 insertions, 15 deletions
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 032bba8f..844b1a06 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -109,6 +109,8 @@ static MetaWrapStyle wrap_style = META_WRAP_NONE;
static MetaActionTitlebar action_double_click_titlebar = META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE;
static MetaActionTitlebar action_middle_click_titlebar = META_ACTION_TITLEBAR_LOWER;
static MetaActionTitlebar action_right_click_titlebar = META_ACTION_TITLEBAR_MENU;
+static MetaActionTitlebar action_scroll_up_titlebar = META_ACTION_TITLEBAR_NONE;
+static MetaActionTitlebar action_scroll_down_titlebar = META_ACTION_TITLEBAR_NONE;
static gboolean application_based = FALSE;
static gboolean disable_workarounds = FALSE;
static gboolean auto_raise = FALSE;
@@ -336,6 +338,16 @@ static MetaEnumPreference preferences_enum[] =
META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
(gint *) &action_right_click_titlebar,
},
+ { "action-scroll-up-titlebar",
+ KEY_GENERAL_SCHEMA,
+ META_PREF_ACTION_SCROLL_UP_TITLEBAR,
+ (gint *) &action_scroll_up_titlebar,
+ },
+ { "action-scroll-down-titlebar",
+ KEY_GENERAL_SCHEMA,
+ META_PREF_ACTION_SCROLL_DOWN_TITLEBAR,
+ (gint *) &action_scroll_down_titlebar,
+ },
{ "placement-mode",
KEY_GENERAL_SCHEMA,
META_PREF_PLACEMENT_MODE,
@@ -1645,6 +1657,12 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_ACTION_RIGHT_CLICK_TITLEBAR:
return "ACTION_RIGHT_CLICK_TITLEBAR";
+ case META_PREF_ACTION_SCROLL_UP_TITLEBAR:
+ return "ACTION_SCROLL_UP_TITLEBAR";
+
+ case META_PREF_ACTION_SCROLL_DOWN_TITLEBAR:
+ return "ACTION_SCROLL_DOWN_TITLEBAR";
+
case META_PREF_AUTO_RAISE:
return "AUTO_RAISE";
@@ -2299,6 +2317,18 @@ meta_prefs_get_action_right_click_titlebar (void)
return action_right_click_titlebar;
}
+MetaActionTitlebar
+meta_prefs_get_action_scroll_up_titlebar (void)
+{
+ return action_scroll_up_titlebar;
+}
+
+MetaActionTitlebar
+meta_prefs_get_action_scroll_down_titlebar (void)
+{
+ return action_scroll_down_titlebar;
+}
+
gboolean
meta_prefs_get_auto_raise (void)
{
diff --git a/src/include/common.h b/src/include/common.h
index 9febd63c..031274f6 100644
--- a/src/include/common.h
+++ b/src/include/common.h
@@ -192,14 +192,20 @@ typedef enum
typedef enum
{
- META_ACTION_TITLEBAR_TOGGLE_SHADE,
+ META_ACTION_TITLEBAR_CLOSE,
+ META_ACTION_TITLEBAR_MINIMIZE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY,
META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY,
- META_ACTION_TITLEBAR_MINIMIZE,
- META_ACTION_TITLEBAR_NONE,
+ META_ACTION_TITLEBAR_TOGGLE_SHADE,
+ META_ACTION_TITLEBAR_SHADE,
+ META_ACTION_TITLEBAR_UNSHADE,
+ META_ACTION_TITLEBAR_RAISE,
META_ACTION_TITLEBAR_LOWER,
+ META_ACTION_TITLEBAR_TOGGLE_STICK,
+ META_ACTION_TITLEBAR_TOGGLE_ABOVE,
META_ACTION_TITLEBAR_MENU,
+ META_ACTION_TITLEBAR_NONE,
META_ACTION_TITLEBAR_LAST
} MetaActionTitlebar;
diff --git a/src/include/prefs.h b/src/include/prefs.h
index efb2242b..e34f1b14 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -39,6 +39,8 @@ typedef enum
META_PREF_ACTION_DOUBLE_CLICK_TITLEBAR,
META_PREF_ACTION_MIDDLE_CLICK_TITLEBAR,
META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
+ META_PREF_ACTION_SCROLL_UP_TITLEBAR,
+ META_PREF_ACTION_SCROLL_DOWN_TITLEBAR,
META_PREF_AUTO_RAISE,
META_PREF_AUTO_RAISE_DELAY,
META_PREF_THEME,
@@ -124,6 +126,8 @@ void meta_prefs_get_button_layout (MetaButtonLayout *butt
MetaActionTitlebar meta_prefs_get_action_double_click_titlebar (void);
MetaActionTitlebar meta_prefs_get_action_middle_click_titlebar (void);
MetaActionTitlebar meta_prefs_get_action_right_click_titlebar (void);
+MetaActionTitlebar meta_prefs_get_action_scroll_up_titlebar (void);
+MetaActionTitlebar meta_prefs_get_action_scroll_down_titlebar (void);
MetaPlacementMode meta_prefs_get_placement_mode (void);
diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml
index c8766b44..731ffc11 100644
--- a/src/org.mate.marco.gschema.xml
+++ b/src/org.mate.marco.gschema.xml
@@ -20,15 +20,21 @@
<value nick="frame_flash" value="2"/>
</enum>
<enum id="org.mate.Marco.ActionTitlebar">
- <value nick="toggle_shade" value="0"/>
- <value nick="toggle_maximize" value="1"/>
- <value nick="toggle_maximize_horizontally" value="2"/>
- <value nick="toggle_maximize_vertically" value="3"/>
- <value nick="minimize" value="4"/>
- <value nick="none" value="5"/>
- <value nick="lower" value="6"/>
- <value nick="menu" value="7"/>
- <value nick="last" value="8"/>
+ <value nick="close" value="0"/>
+ <value nick="minimize" value="1"/>
+ <value nick="toggle_maximize" value="2"/>
+ <value nick="toggle_maximize_horizontally" value="3"/>
+ <value nick="toggle_maximize_vertically" value="4"/>
+ <value nick="toggle_shade" value="5"/>
+ <value nick="shade" value="6"/>
+ <value nick="unshade" value="7"/>
+ <value nick="raise" value="8"/>
+ <value nick="lower" value="9"/>
+ <value nick="toggle_stick" value="10"/>
+ <value nick="toggle_above" value="11"/>
+ <value nick="menu" value="12"/>
+ <value nick="none" value="13"/>
+ <value nick="last" value="14"/>
</enum>
<enum id="org.mate.Marco.placement_type">
<value value="0" nick="automatic"/>
@@ -83,17 +89,27 @@
<key name="action-double-click-titlebar" enum="org.mate.Marco.ActionTitlebar">
<default>'toggle_maximize'</default>
<summary>Action on title bar double-click</summary>
- <description>This option determines the effects of double-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, and 'none' which will not do anything.</description>
+ <description>This option determines the effects of double-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'unshade' which will unroll the window, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, 'raise' which will raise the window above all others, 'close' which will close the window, 'toggle_stick' which will toggle the window's sticky state, 'toggle_above' which will toggle the window's always-on-top state, and 'none' which will not do anything.</description>
</key>
<key name="action-middle-click-titlebar" enum="org.mate.Marco.ActionTitlebar">
<default>'lower'</default>
<summary>Action on title bar middle-click</summary>
- <description>This option determines the effects of middle-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, and 'none' which will not do anything.</description>
+ <description>This option determines the effects of middle-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'unshade' which will unroll the window, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, 'raise' which will raise the window above all others, 'close' which will close the window, 'toggle_stick' which will toggle the window's sticky state, 'toggle_above' which will toggle the window's always-on-top state, and 'none' which will not do anything.</description>
</key>
<key name="action-right-click-titlebar" enum="org.mate.Marco.ActionTitlebar">
<default>'menu'</default>
<summary>Action on title bar right-click</summary>
- <description>This option determines the effects of right-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, and 'none' which will not do anything.</description>
+ <description>This option determines the effects of right-clicking on the title bar. Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'unshade' which will unroll the window, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, 'raise' which will raise the window above all others, 'close' which will close the window, 'toggle_stick' which will toggle the window's sticky state, 'toggle_above' which will toggle the window's always-on-top state, and 'none' which will not do anything.</description>
+ </key>
+ <key name="action-scroll-up-titlebar" enum="org.mate.Marco.ActionTitlebar">
+ <default>'none'</default>
+ <summary>Action on title bar scroll up</summary>
+ <description>This option determines the effects of scrolling up on the title bar (using mouse wheel or touchpad). Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'unshade' which will unroll the window, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, 'raise' which will raise the window above all others, 'close' which will close the window, 'toggle_stick' which will toggle the window's sticky state, 'toggle_above' which will toggle the window's always-on-top state, and 'none' which will not do anything.</description>
+ </key>
+ <key name="action-scroll-down-titlebar" enum="org.mate.Marco.ActionTitlebar">
+ <default>'none'</default>
+ <summary>Action on title bar scroll down</summary>
+ <description>This option determines the effects of scrolling down on the title bar (using mouse wheel or touchpad). Current valid options are 'toggle_shade', which will shade/unshade the window, 'toggle_maximize' which will maximize/unmaximize the window, 'toggle_maximize_horizontally' and 'toggle_maximize_vertically' which will maximize/unmaximize the window in that direction only, 'minimize' which will minimize the window, 'shade' which will roll the window up, 'unshade' which will unroll the window, 'menu' which will display the window menu, 'lower' which will put the window behind all the others, 'raise' which will raise the window above all others, 'close' which will close the window, 'toggle_stick' which will toggle the window's sticky state, 'toggle_above' which will toggle the window's always-on-top state, and 'none' which will not do anything.</description>
</key>
<key name="auto-raise" type="b">
<default>false</default>
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 19c14c56..1d45a38a 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -1576,6 +1576,71 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
event->time);
break;
+ case META_ACTION_TITLEBAR_CLOSE:
+ meta_core_delete (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow,
+ event->time);
+ break;
+
+ case META_ACTION_TITLEBAR_RAISE:
+ meta_core_user_raise (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow);
+ break;
+
+ case META_ACTION_TITLEBAR_SHADE:
+ meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+ META_CORE_GET_FRAME_FLAGS, &flags,
+ META_CORE_GET_END);
+ if ((flags & META_FRAME_ALLOWS_SHADE) && !(flags & META_FRAME_SHADED))
+ {
+ meta_core_shade (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow,
+ event->time);
+ }
+ break;
+
+ case META_ACTION_TITLEBAR_UNSHADE:
+ meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+ META_CORE_GET_FRAME_FLAGS, &flags,
+ META_CORE_GET_END);
+ if ((flags & META_FRAME_ALLOWS_SHADE) && (flags & META_FRAME_SHADED))
+ {
+ meta_core_unshade (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow,
+ event->time);
+ }
+ break;
+
+ case META_ACTION_TITLEBAR_TOGGLE_STICK:
+ {
+ MetaFrameFlags flags;
+ meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+ META_CORE_GET_FRAME_FLAGS, &flags,
+ META_CORE_GET_END);
+ if (flags & META_FRAME_STUCK)
+ meta_core_unstick (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow);
+ else
+ meta_core_stick (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow);
+ }
+ break;
+
+ case META_ACTION_TITLEBAR_TOGGLE_ABOVE:
+ {
+ MetaFrameFlags flags;
+ meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
+ META_CORE_GET_FRAME_FLAGS, &flags,
+ META_CORE_GET_END);
+ if (flags & META_FRAME_ABOVE)
+ meta_core_unmake_above (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow);
+ else
+ meta_core_make_above (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ frame->xwindow);
+ }
+ break;
+
case META_ACTION_TITLEBAR_LAST:
break;
}
@@ -1611,6 +1676,24 @@ meta_frame_right_click_event(MetaUIFrame *frame,
}
static gboolean
+meta_frame_scroll_up_event (MetaUIFrame *frame,
+ GdkEventButton *event)
+{
+ int action = meta_prefs_get_action_scroll_up_titlebar();
+
+ return meta_frame_titlebar_event (frame, event, action);
+}
+
+static gboolean
+meta_frame_scroll_down_event (MetaUIFrame *frame,
+ GdkEventButton *event)
+{
+ int action = meta_prefs_get_action_scroll_down_titlebar();
+
+ return meta_frame_titlebar_event (frame, event, action);
+}
+
+static gboolean
meta_frames_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
@@ -1851,6 +1934,18 @@ meta_frames_button_press_event (GtkWidget *widget,
{
return meta_frame_right_click_event (frame, event);
}
+ else if (event->button == 4) /* scroll up */
+ {
+ /* Only handle scroll on titlebar, not on other frame controls */
+ if (control == META_FRAME_CONTROL_TITLE)
+ return meta_frame_scroll_up_event (frame, event);
+ }
+ else if (event->button == 5) /* scroll down */
+ {
+ /* Only handle scroll on titlebar, not on other frame controls */
+ if (control == META_FRAME_CONTROL_TITLE)
+ return meta_frame_scroll_down_event (frame, event);
+ }
return TRUE;
}