@@ -17,6 +17,19 @@ const CUSTOM_KEYS_SCHEMA = "org.cinnamon.desktop.keybindings.custom-keybinding";
1717
1818const MEDIA_KEYS_SCHEMA = "org.cinnamon.desktop.keybindings.media-keys" ;
1919
20+ const REPEATABLE_MEDIA_KEYS = [
21+ MK . VOLUME_UP ,
22+ MK . VOLUME_UP_QUIET ,
23+ MK . VOLUME_DOWN ,
24+ MK . VOLUME_DOWN_QUIET ,
25+ MK . SCREEN_BRIGHTNESS_UP ,
26+ MK . SCREEN_BRIGHTNESS_DOWN ,
27+ MK . KEYBOARD_BRIGHTNESS_UP ,
28+ MK . KEYBOARD_BRIGHTNESS_DOWN ,
29+ MK . REWIND ,
30+ MK . FORWARD ,
31+ ] ;
32+
2033const OBSOLETE_MEDIA_KEYS = [
2134 MK . VIDEO_OUT ,
2235 MK . ROTATE_VIDEO
@@ -70,10 +83,10 @@ KeybindingManager.prototype = {
7083 this . setup_custom_keybindings ( ) ;
7184 } ,
7285
73- addHotKey : function ( name , bindings_string , callback ) {
86+ addHotKey : function ( name , bindings_string , callback , flags ) {
7487 if ( ! bindings_string )
7588 return false ;
76- return this . addHotKeyArray ( name , bindings_string . split ( "::" ) , callback ) ;
89+ return this . addHotKeyArray ( name , bindings_string . split ( "::" ) , callback , flags ) ;
7790 } ,
7891
7992 _makeXletKey : function ( xlet , name , binding ) {
@@ -108,7 +121,7 @@ KeybindingManager.prototype = {
108121 * }
109122 */
110123
111- addXletHotKey : function ( xlet , name , bindings_string , callback ) {
124+ addXletHotKey : function ( xlet , name , bindings_string , callback , flags ) {
112125 this . _removeMatchingXletBindings ( xlet , name ) ;
113126
114127 if ( ! bindings_string )
@@ -131,7 +144,7 @@ KeybindingManager.prototype = {
131144
132145 xlet_set . set ( instanceId , callback ) ;
133146
134- this . _queueCommitXletHotKey ( xlet_key , binding , xlet_set ) ;
147+ this . _queueCommitXletHotKey ( xlet_key , binding , xlet_set , flags ) ;
135148 }
136149 } ,
137150
@@ -225,15 +238,15 @@ KeybindingManager.prototype = {
225238 this . _removeMatchingXletBindings ( xlet , name ) ;
226239 } ,
227240
228- _queueCommitXletHotKey : function ( xlet_key , binding , xlet_set ) {
241+ _queueCommitXletHotKey : function ( xlet_key , binding , xlet_set , flags ) {
229242 let id = xlet_set . get ( "commitTimeoutId" ) ?? 0 ;
230243
231244 if ( id > 0 ) {
232245 GLib . source_remove ( id ) ;
233246 }
234247
235248 id = GLib . idle_add ( GLib . PRIORITY_DEFAULT , ( ) => {
236- this . addHotKeyArray ( xlet_key , [ binding ] , this . _xletCallback . bind ( this , xlet_key ) ) ;
249+ this . addHotKeyArray ( xlet_key , [ binding ] , this . _xletCallback . bind ( this , xlet_key ) , flags ) ;
237250 xlet_set . set ( "commitTimeoutId" , 0 ) ;
238251 return GLib . SOURCE_REMOVE ;
239252 } ) ;
@@ -253,7 +266,7 @@ KeybindingManager.prototype = {
253266 return [ Meta . KeyBindingAction . NONE , undefined ] ;
254267 } ,
255268
256- addHotKeyArray : function ( name , bindings , callback ) {
269+ addHotKeyArray : function ( name , bindings , callback , flags = Meta . KeyBindingFlags . IGNORE_AUTOREPEAT ) {
257270 let [ existing_action_id , entry ] = this . _lookupEntry ( name ) ;
258271
259272 if ( entry !== undefined ) {
@@ -278,8 +291,8 @@ KeybindingManager.prototype = {
278291 return true ;
279292 }
280293
281- action_id = global . display . add_custom_keybinding ( name , bindings , callback ) ;
282- // log(`set keybinding: ${name}, bindings: ${bindings} - action id: ${action_id}`);
294+ action_id = global . display . add_custom_keybinding_full ( name , bindings , flags , callback ) ;
295+ // log(`set keybinding: ${name}, bindings: ${bindings}, flags: ${flags} - action id: ${action_id}`);
283296
284297 if ( action_id === Meta . KeyBindingAction . NONE ) {
285298 global . logError ( "Warning, unable to bind hotkey with name '" + name + "'. The selected keybinding could already be in use." ) ;
@@ -340,21 +353,31 @@ KeybindingManager.prototype = {
340353 continue ;
341354 }
342355
356+ let flags = REPEATABLE_MEDIA_KEYS . includes ( i )
357+ ? Meta . KeyBindingFlags . NONE
358+ : Meta . KeyBindingFlags . IGNORE_AUTOREPEAT ;
359+
343360 let bindings = this . media_key_settings . get_strv ( CinnamonDesktop . desktop_get_media_key_string ( i ) ) ;
344361 this . addHotKeyArray ( "media-keys-" + i . toString ( ) ,
345362 bindings ,
346- Lang . bind ( this , this . on_global_media_key_pressed , i ) ) ;
363+ Lang . bind ( this , this . on_global_media_key_pressed , i ) ,
364+ flags ) ;
347365 }
348366
349367 for ( let i = MK . SEPARATOR + 1 ; i < MK . LAST ; i ++ ) {
350368 if ( is_obsolete_mk ( i ) ) {
351369 continue ;
352370 }
353371
372+ let flags = REPEATABLE_MEDIA_KEYS . includes ( i )
373+ ? Meta . KeyBindingFlags . NONE
374+ : Meta . KeyBindingFlags . IGNORE_AUTOREPEAT ;
375+
354376 let bindings = this . media_key_settings . get_strv ( CinnamonDesktop . desktop_get_media_key_string ( i ) ) ;
355377 this . addHotKeyArray ( "media-keys-" + i . toString ( ) ,
356378 bindings ,
357- Lang . bind ( this , this . on_media_key_pressed , i ) ) ;
379+ Lang . bind ( this , this . on_media_key_pressed , i ) ,
380+ flags ) ;
358381 }
359382 return true ;
360383 } ,
0 commit comments