Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
b7e7be20
Commit
b7e7be20
authored
Apr 06, 2011
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx: more hotkey improvements
parent
b497df76
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
12 deletions
+75
-12
modules/gui/macosx/intf.h
modules/gui/macosx/intf.h
+3
-0
modules/gui/macosx/intf.m
modules/gui/macosx/intf.m
+57
-10
modules/gui/macosx/simple_prefs.m
modules/gui/macosx/simple_prefs.m
+15
-2
No files found.
modules/gui/macosx/intf.h
View file @
b7e7be20
...
...
@@ -337,6 +337,8 @@ struct intf_sys_t
AppleRemote
*
o_remote
;
BOOL
b_remote_button_hold
;
/* true as long as the user holds the left,right,plus or minus on the remote control */
NSArray
*
o_usedHotkeys
;
}
+
(
VLCMain
*
)
sharedInstance
;
...
...
@@ -368,6 +370,7 @@ struct intf_sys_t
-
(
BOOL
)
hasDefinedShortcutKey
:(
NSEvent
*
)
o_event
;
-
(
NSString
*
)
VLCKeyToString
:(
NSString
*
)
theString
;
-
(
unsigned
int
)
VLCModifiersToCocoa
:(
NSString
*
)
theString
;
-
(
void
)
updateCurrentlyUsedHotkeys
;
-
(
void
)
initStrings
;
...
...
modules/gui/macosx/intf.m
View file @
b7e7be20
...
...
@@ -34,6 +34,7 @@
#include <vlc_keys.h>
#include <vlc_dialog.h>
#include <vlc_url.h>
#include <vlc_modules.h>
#include <unistd.h>
/* execl() */
#import "intf.h"
...
...
@@ -65,6 +66,8 @@ static void Run ( intf_thread_t *p_intf );
static
void
*
ManageThread
(
void
*
user_data
);
static
unsigned
int
VLCModifiersToCocoa
(
unsigned
int
i_key
);
static
void
updateProgressPanel
(
void
*
,
const
char
*
,
float
);
static
bool
checkProgressPanel
(
void
*
);
static
void
destroyProgressPanel
(
void
*
);
...
...
@@ -1325,7 +1328,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
-
(
NSString
*
)
VLCKeyToString
:(
NSString
*
)
theString
{
NSLog
(
@"got: %@"
,
theString
);
if
(
!
[
theString
isEqualToString
:
@""
])
{
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"Command"
withString
:
@""
];
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"Alt"
withString
:
@""
];
...
...
@@ -1334,7 +1336,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"+"
withString
:
@""
];
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"-"
withString
:
@""
];
}
NSLog
(
@"returning: %@"
,
theString
);
return
theString
;
}
...
...
@@ -1351,20 +1352,37 @@ unsigned int CocoaKeyToVLC( unichar i_key )
unsigned
int
i_pressed_modifiers
=
0
;
const
struct
hotkey
*
p_hotkeys
;
int
i
;
NSMutableString
*
tempString
=
[[[
NSMutableString
alloc
]
init
]
autorelease
];
NSMutableString
*
tempStringPlus
=
[[[
NSMutableString
alloc
]
init
]
autorelease
];
val
.
i_int
=
0
;
p_hotkeys
=
p_intf
->
p_libvlc
->
p_hotkeys
;
i_pressed_modifiers
=
[
o_event
modifierFlags
];
if
(
i_pressed_modifiers
&
NSShiftKeyMask
)
if
(
i_pressed_modifiers
&
NSShiftKeyMask
)
{
val
.
i_int
|=
KEY_MODIFIER_SHIFT
;
if
(
i_pressed_modifiers
&
NSControlKeyMask
)
[
tempString
appendString
:
@"Shift-"
];
[
tempStringPlus
appendString
:
@"Shift+"
];
}
if
(
i_pressed_modifiers
&
NSControlKeyMask
)
{
val
.
i_int
|=
KEY_MODIFIER_CTRL
;
if
(
i_pressed_modifiers
&
NSAlternateKeyMask
)
[
tempString
appendString
:
@"Ctrl-"
];
[
tempStringPlus
appendString
:
@"Ctrl+"
];
}
if
(
i_pressed_modifiers
&
NSAlternateKeyMask
)
{
val
.
i_int
|=
KEY_MODIFIER_ALT
;
if
(
i_pressed_modifiers
&
NSCommandKeyMask
)
[
tempString
appendString
:
@"Alt-"
];
[
tempStringPlus
appendString
:
@"Alt+"
];
}
if
(
i_pressed_modifiers
&
NSCommandKeyMask
)
{
val
.
i_int
|=
KEY_MODIFIER_COMMAND
;
[
tempString
appendString
:
@"Command-"
];
[
tempStringPlus
appendString
:
@"Command+"
];
}
[
tempString
appendString
:[[
o_event
charactersIgnoringModifiers
]
lowercaseString
]];
[
tempStringPlus
appendString
:[[
o_event
charactersIgnoringModifiers
]
lowercaseString
]];
key
=
[[
o_event
charactersIgnoringModifiers
]
characterAtIndex
:
0
];
...
...
@@ -1385,15 +1403,44 @@ unsigned int CocoaKeyToVLC( unichar i_key )
val
.
i_int
|=
CocoaKeyToVLC
(
key
);
if
(
p_hotkeys
[
i
].
psz_action
!=
NULL
)
if
(
[
o_usedHotkeys
indexOfObject
:
tempString
]
!=
NSNotFound
||
[
o_usedHotkeys
indexOfObject
:
tempStringPlus
]
!=
NSNotFound
)
{
var_Set
Integer
(
p_intf
->
p_libvlc
,
"key-pressed"
,
val
.
i_int
);
var_Set
(
p_intf
->
p_libvlc
,
"key-pressed"
,
val
);
return
YES
;
}
return
NO
;
}
-
(
void
)
updateCurrentlyUsedHotkeys
{
NSMutableArray
*
o_tempArray
=
[[
NSMutableArray
alloc
]
init
];
/* Get the main Module */
module_t
*
p_main
=
module_get_main
();
assert
(
p_main
);
unsigned
confsize
;
module_config_t
*
p_config
;
p_config
=
module_config_get
(
p_main
,
&
confsize
);
for
(
size_t
i
=
0
;
i
<
confsize
;
i
++
)
{
module_config_t
*
p_item
=
p_config
+
i
;
if
(
(
p_item
->
i_type
&
CONFIG_ITEM
)
&&
p_item
->
psz_name
!=
NULL
&&
!
strncmp
(
p_item
->
psz_name
,
"key-"
,
4
)
&&
!
EMPTY_STR
(
p_item
->
psz_text
)
)
{
if
(
p_item
->
value
.
psz
)
[
o_tempArray
addObject
:
[
NSString
stringWithUTF8String
:
p_item
->
value
.
psz
]];
}
}
module_config_free
(
p_config
);
module_release
(
p_main
);
o_usedHotkeys
=
[[
NSArray
alloc
]
initWithArray
:
o_usedHotkeys
copyItems
:
YES
];
}
#pragma mark -
#pragma mark Other objects getters
...
...
modules/gui/macosx/simple_prefs.m
View file @
b7e7be20
...
...
@@ -84,6 +84,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"Ctrl"
withString
:
[
NSString
stringWithUTF8String
:
"
\xE2\x8C\x83
"
]];
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"+"
withString
:
@""
];
theString
=
[
theString
stringByReplacingOccurrencesOfString
:
@"-"
withString
:
@""
];
theString
=
[
theString
capitalizedString
];
}
else
theString
=
[
NSString
stringWithString
:
_NS
(
"Not Set"
)];
...
...
@@ -104,7 +105,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
[
o_sprefs_win
setToolbar
:
o_sprefs_toolbar
];
/* setup useful stuff */
o_hotkeysNonUseableKeys
=
[[
NSArray
arrayWithObjects
:
@"Command-c"
,
@"Command-x"
,
@"Command-v"
,
@"Command-a"
,
@"Command-,"
,
@"Command-h"
,
@"Command-Alt-h"
,
@"Command-Shift-o"
,
@"Command-o"
,
@"Command-d"
,
@"Command-n"
,
@"Command-s"
,
@"Command-z"
,
@"Command-l"
,
@"Command-r"
,
@"Command-
0"
,
@"Command-1"
,
@"Command-2"
,
@"Command-
3"
,
@"Command-m"
,
@"Command-w"
,
@"Command-Shift-w"
,
@"Command-Shift-c"
,
@"Command-Shift-p"
,
@"Command-i"
,
@"Command-e"
,
@"Command-Shift-e"
,
@"Command-b"
,
@"Command-Shift-m"
,
@"Command-Ctrl-m"
,
@"Command-?"
,
@"Command-Alt-?"
,
nil
]
retain
];
o_hotkeysNonUseableKeys
=
[[
NSArray
arrayWithObjects
:
@"Command-c"
,
@"Command-x"
,
@"Command-v"
,
@"Command-a"
,
@"Command-,"
,
@"Command-h"
,
@"Command-Alt-h"
,
@"Command-Shift-o"
,
@"Command-o"
,
@"Command-d"
,
@"Command-n"
,
@"Command-s"
,
@"Command-z"
,
@"Command-l"
,
@"Command-r"
,
@"Command-3"
,
@"Command-m"
,
@"Command-w"
,
@"Command-Shift-w"
,
@"Command-Shift-c"
,
@"Command-Shift-p"
,
@"Command-i"
,
@"Command-e"
,
@"Command-Shift-e"
,
@"Command-b"
,
@"Command-Shift-m"
,
@"Command-Ctrl-m"
,
@"Command-?"
,
@"Command-Alt-?"
,
nil
]
retain
];
}
#define CreateToolbarItem( o_name, o_desc, o_img, sel ) \
...
...
@@ -1241,6 +1242,11 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
b_hotkeyChanged
=
YES
;
i_returnValue
=
[
o_hotkeySettings
indexOfObject
:
o_keyInTransition
];
if
(
i_returnValue
!=
NSNotFound
)
[
o_hotkeySettings
replaceObjectAtIndex
:
i_returnValue
withObject
:
[
NSString
string
]];
NSString
*
tempString
;
tempString
=
[
o_keyInTransition
stringByReplacingOccurrencesOfString
:
@"-"
withString
:
@"+"
];
i_returnValue
=
[
o_hotkeySettings
indexOfObject
:
tempString
];
if
(
i_returnValue
!=
NSNotFound
)
[
o_hotkeySettings
replaceObjectAtIndex
:
i_returnValue
withObject
:
[
NSString
string
]];
...
...
@@ -1284,8 +1290,9 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
-
(
BOOL
)
changeHotkeyTo
:
(
NSString
*
)
theKey
{
NSInteger
i_returnValue
;
NSInteger
i_returnValue
,
i_returnValue2
;
i_returnValue
=
[
o_hotkeysNonUseableKeys
indexOfObject
:
theKey
];
if
(
i_returnValue
!=
NSNotFound
||
[
theKey
isEqualToString
:
@""
]
)
{
[
o_hotkeys_change_keys_lbl
setStringValue
:
_NS
(
"Invalid combination"
)];
...
...
@@ -1298,10 +1305,16 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
[
o_hotkeys_change_keys_lbl
setStringValue
:
[
self
OSXStringKeyToString
:
theKey
]];
i_returnValue
=
[
o_hotkeySettings
indexOfObject
:
theKey
];
i_returnValue2
=
[
o_hotkeySettings
indexOfObject
:
[
theKey
stringByReplacingOccurrencesOfString
:
@"-"
withString
:
@"+"
]];
if
(
i_returnValue
!=
NSNotFound
)
[
o_hotkeys_change_taken_lbl
setStringValue
:
[
NSString
stringWithFormat
:
_NS
(
"This combination is already taken by
\"
%@
\"
."
),
[
o_hotkeyDescriptions
objectAtIndex
:
i_returnValue
]]];
else
if
(
i_returnValue2
!=
NSNotFound
)
[
o_hotkeys_change_taken_lbl
setStringValue
:
[
NSString
stringWithFormat
:
_NS
(
"This combination is already taken by
\"
%@
\"
."
),
[
o_hotkeyDescriptions
objectAtIndex
:
i_returnValue2
]]];
else
[
o_hotkeys_change_taken_lbl
setStringValue
:
@""
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment