Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xfce4-power-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xfce
xfce4-power-manager
Commits
b28d987e
Commit
b28d987e
authored
1 year ago
by
Brian Tarricone
Committed by
Gaël Bonithon
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Ungrab brightness keys when not handling them
Closes
#33
(cherry picked from commit
488d3471
)
parent
d4003ff1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/xfpm-backlight.c
+17
-0
17 additions, 0 deletions
src/xfpm-backlight.c
src/xfpm-button.c
+77
-4
77 additions, 4 deletions
src/xfpm-button.c
src/xfpm-button.h
+3
-0
3 additions, 0 deletions
src/xfpm-button.h
with
97 additions
and
4 deletions
src/xfpm-backlight.c
+
17
−
0
View file @
b28d987e
...
...
@@ -281,6 +281,20 @@ xfpm_backlight_button_pressed_cb (XfpmButton *button, XfpmButtonKey type, XfpmBa
xfpm_backlight_show
(
backlight
,
level
);
}
static
void
xfpm_backlight_handle_brightness_keys_changed
(
XfpmBacklight
*
backlight
)
{
gboolean
handle_keys
=
FALSE
;
g_object_get
(
G_OBJECT
(
backlight
->
priv
->
conf
),
HANDLE_BRIGHTNESS_KEYS
,
&
handle_keys
,
NULL
);
XFPM_DEBUG
(
"handle_brightness_keys changed to %s"
,
handle_keys
?
"TRUE"
:
"FALSE"
);
xfpm_button_set_handle_brightness_keys
(
backlight
->
priv
->
button
,
handle_keys
);
}
static
void
xfpm_backlight_brightness_on_ac_settings_changed
(
XfpmBacklight
*
backlight
)
{
...
...
@@ -438,6 +452,9 @@ xfpm_backlight_init (XfpmBacklight *backlight)
BRIGHTNESS_SWITCH
,
backlight
->
priv
->
brightness_switch
,
NULL
);
xfpm_button_set_handle_brightness_keys
(
backlight
->
priv
->
button
,
handle_keys
);
g_signal_connect_object
(
backlight
->
priv
->
conf
,
"notify::"
HANDLE_BRIGHTNESS_KEYS
,
G_CALLBACK
(
xfpm_backlight_handle_brightness_keys_changed
),
backlight
,
G_CONNECT_SWAPPED
);
g_signal_connect_object
(
backlight
->
priv
->
idle
,
"alarm-expired"
,
G_CALLBACK
(
xfpm_backlight_alarm_timeout_cb
),
backlight
,
0
);
...
...
This diff is collapsed.
Click to expand it.
src/xfpm-button.c
+
77
−
4
View file @
b28d987e
...
...
@@ -64,6 +64,7 @@ struct XfpmButtonPrivate
{
GdkScreen
*
screen
;
GdkWindow
*
window
;
gboolean
handle_brightness_keys
;
guint16
mapped_buttons
;
};
...
...
@@ -182,6 +183,39 @@ xfpm_button_xevent_key (XfpmButton *button, guint keysym , XfpmButtonKey key)
return
TRUE
;
}
static
void
xfpm_button_ungrab
(
XfpmButton
*
button
,
guint
keysym
,
XfpmButtonKey
key
)
{
Display
*
display
;
GdkDisplay
*
gdisplay
;
guint
modmask
=
AnyModifier
;
guint
keycode
=
XKeysymToKeycode
(
gdk_x11_get_default_xdisplay
(),
keysym
);
if
(
keycode
==
0
)
{
XFPM_DEBUG
(
"could not map keysym %x to keycode
\n
"
,
keysym
);
return
;
}
display
=
gdk_x11_get_default_xdisplay
();
gdisplay
=
gdk_display_get_default
();
gdk_x11_display_error_trap_push
(
gdisplay
);
XUngrabKey
(
display
,
keycode
,
modmask
,
GDK_WINDOW_XID
(
button
->
priv
->
window
));
XUngrabKey
(
display
,
keycode
,
LockMask
|
modmask
,
GDK_WINDOW_XID
(
button
->
priv
->
window
));
gdk_display_flush
(
gdisplay
);
gdk_x11_display_error_trap_pop_ignored
(
gdisplay
);
XFPM_DEBUG_ENUM
(
key
,
XFPM_TYPE_BUTTON_KEY
,
"Ungrabbed key %li "
,
(
long
int
)
keycode
);
xfpm_key_map
[
key
].
key_code
=
0
;
xfpm_key_map
[
key
].
key
=
0
;
}
static
void
xfpm_button_setup
(
XfpmButton
*
button
)
{
...
...
@@ -204,11 +238,14 @@ xfpm_button_setup (XfpmButton *button)
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_Sleep
,
BUTTON_SLEEP
)
)
button
->
priv
->
mapped_buttons
|=
SLEEP_KEY
;
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessUp
,
BUTTON_MON_BRIGHTNESS_UP
)
)
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_UP
;
if
(
button
->
priv
->
handle_brightness_keys
)
{
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessUp
,
BUTTON_MON_BRIGHTNESS_UP
)
)
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_UP
;
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessDown
,
BUTTON_MON_BRIGHTNESS_DOWN
)
)
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_DOWN
;
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessDown
,
BUTTON_MON_BRIGHTNESS_DOWN
)
)
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_DOWN
;
}
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_Battery
,
BUTTON_BATTERY
))
button
->
priv
->
mapped_buttons
|=
BATTERY_KEY
;
...
...
@@ -244,6 +281,7 @@ xfpm_button_init (XfpmButton *button)
{
button
->
priv
=
xfpm_button_get_instance_private
(
button
);
button
->
priv
->
handle_brightness_keys
=
FALSE
;
button
->
priv
->
mapped_buttons
=
0
;
button
->
priv
->
screen
=
NULL
;
button
->
priv
->
window
=
NULL
;
...
...
@@ -282,3 +320,38 @@ xfpm_button_get_mapped (XfpmButton *button)
return
button
->
priv
->
mapped_buttons
;
}
void
xfpm_button_set_handle_brightness_keys
(
XfpmButton
*
button
,
gboolean
handle_brightness_keys
)
{
g_return_if_fail
(
XFPM_IS_BUTTON
(
button
));
if
(
button
->
priv
->
handle_brightness_keys
!=
handle_brightness_keys
)
{
button
->
priv
->
handle_brightness_keys
=
handle_brightness_keys
;
if
(
handle_brightness_keys
)
{
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessUp
,
BUTTON_MON_BRIGHTNESS_UP
))
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_UP
;
if
(
xfpm_button_xevent_key
(
button
,
XF86XK_MonBrightnessDown
,
BUTTON_MON_BRIGHTNESS_DOWN
))
button
->
priv
->
mapped_buttons
|=
BRIGHTNESS_KEY_DOWN
;
}
else
{
if
((
button
->
priv
->
mapped_buttons
&
BRIGHTNESS_KEY_UP
)
!=
0
)
{
xfpm_button_ungrab
(
button
,
XF86XK_MonBrightnessUp
,
BUTTON_MON_BRIGHTNESS_UP
);
button
->
priv
->
mapped_buttons
&=
~
(
BRIGHTNESS_KEY_UP
);
}
if
((
button
->
priv
->
mapped_buttons
&
BRIGHTNESS_KEY_DOWN
)
!=
0
)
{
xfpm_button_ungrab
(
button
,
XF86XK_MonBrightnessDown
,
BUTTON_MON_BRIGHTNESS_DOWN
);
button
->
priv
->
mapped_buttons
&=
~
(
BRIGHTNESS_KEY_DOWN
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/xfpm-button.h
+
3
−
0
View file @
b28d987e
...
...
@@ -50,6 +50,9 @@ GType xfpm_button_get_type (void) G_GNUC_CONST;
XfpmButton
*
xfpm_button_new
(
void
);
guint16
xfpm_button_get_mapped
(
XfpmButton
*
button
)
G_GNUC_PURE
;
void
xfpm_button_set_handle_brightness_keys
(
XfpmButton
*
button
,
gboolean
handle_brightness_keys
);
G_END_DECLS
#endif
/* __XFPM_BUTTON_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment