Avoid key repeat for the screenshot key binding

This commit is contained in:
Matthias Clasen 2009-11-25 02:54:28 +00:00
parent dc8d2a0693
commit ff33ff6843
2 changed files with 123 additions and 1 deletions

View File

@ -1,7 +1,9 @@
%define _default_patch_fuzz 999
Summary: Unobtrusive window manager
Name: metacity
Version: 2.28.0
Release: 1%{?dist}
Release: 10%{?dist}
URL: http://download.gnome.org/sources/metacity/
Source0: http://download.gnome.org/sources/metacity/2.28/metacity-%{version}.tar.bz2
# http://bugzilla.gnome.org/show_bug.cgi?id=558723
@ -16,6 +18,16 @@ Patch7: 0001-bell-increase-bell-rate-limit-from-1-s-to-1-100ms.patch
Patch8: 0001-sound-ask-libcanberra-to-cache-alert-desktop-switch-.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=593358
Patch9: 0001-tooltip-set-window-type-hint-for-self-drawn-tooltips.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=336750
Patch10: screenshot-forkbomb.patch
# fedora specific patches
Patch11: workspaces.patch
Patch12: fresh-tooltips.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=600864
# https://bugzilla.redhat.com/show_bug.cgi?id=533239
Patch13: metacity-dont-do-bad-stuff-on-sigterm.patch
License: GPLv2+
Group: User Interface/Desktops
@ -81,6 +93,10 @@ API. This package exists purely for technical reasons.
%patch7 -p1 -b .bell
%patch8 -p1 -b .sound-cache
%patch9 -p1 -b .tooltip
%patch10 -p1 -b .screenshot-forkbomb
%patch11 -p1 -b .workspaces
%patch12 -p1 -b .fresh-tooltips
%patch13 -p1 -b .sigterm
# force regeneration
rm src/metacity.schemas
@ -188,6 +204,28 @@ fi
%{_mandir}/man1/metacity-window-demo.1.gz
%changelog
* Tue Nov 24 2009 Matthias Clasen <mclasen@redhat.com> - 2.28.0-10
- Disable key repeat for screenshot keybinding (#506369)
* Thu Nov 05 2009 Ray Strode <rstrode@redhat.com> 2.28.0-9
- One stab at the metacity patch
* Thu Nov 05 2009 Ray Strode <rstrode@redhat.com> 2.28.0-8
- Minor clean ups to last patch based on feedback from
Owen
* Thu Nov 05 2009 Ray Strode <rstrode@redhat.com> 2.28.0-7
- Don't do bad things on sigterm
* Wed Oct 28 2009 Matthias Clasen <mclasen@redhat.cm> - 2.28.0-6
- Make tooltips look sharper
* Wed Oct 21 2009 Matthias Clasen <mclasen@redhat.cm> - 2.28.0-4
- Make tooltips look match GTK+
* Thu Oct 15 2009 Matthias Clasen <mclasen@redhat.cm> - 2.28.0-3
- Tweak the default number of workspaces
* Tue Sep 22 2009 Matthias Clasen <mclasen@redhat.cm> - 2.28.0-1
- Update to 2.28.0

84
screenshot-forkbomb.patch Normal file
View File

@ -0,0 +1,84 @@
--- metacity-2.28.0/src/include/all-keybindings.h 2009-09-08 16:55:35.000000000 -0400
+++ hacked/src/include/all-keybindings.h 2009-11-24 21:32:04.351687546 -0500
@@ -76,6 +76,7 @@
#define BINDING_PER_WINDOW 0x01
#define BINDING_REVERSES 0x02
#define BINDING_IS_REVERSED 0x04
+#define BINDING_NO_REPEAT 0x08
#endif /* _BINDINGS_DEFINED_CONSTANTS */
@@ -234,9 +235,9 @@
keybind (run_command_31, handle_run_command, 30, 0, NULL, NULL)
keybind (run_command_32, handle_run_command, 31, 0, NULL, NULL)
-keybind (run_command_screenshot, handle_run_command, 32, 0, "Print",
+keybind (run_command_screenshot, handle_run_command, 32, BINDING_NO_REPEAT, "Print",
_("Take a screenshot"))
-keybind (run_command_window_screenshot, handle_run_command, 33, 0,"<Alt>Print",
+keybind (run_command_window_screenshot, handle_run_command, 33, BINDING_NO_REPEAT, "<Alt>Print",
_("Take a screenshot of a window"))
keybind (run_command_terminal, handle_run_terminal, 0, 0, NULL, _("Run a terminal"))
--- metacity-2.28.0/src/core/keybindings.c 2009-09-08 16:55:35.000000000 -0400
+++ hacked/src/core/keybindings.c 2009-11-24 21:37:02.614687728 -0500
@@ -122,6 +122,7 @@
unsigned int mask;
MetaVirtualModifier modifiers;
const MetaKeyHandler *handler;
+ gboolean repeating;
};
#define keybind(name, handler, param, flags, stroke, description) \
@@ -1172,10 +1173,6 @@
{
int i;
- /* we used to have release-based bindings but no longer. */
- if (event->type == KeyRelease)
- return FALSE;
-
/*
* TODO: This would be better done with a hash table;
* it doesn't suit to use O(n) for such a common operation.
@@ -1185,12 +1182,12 @@
const MetaKeyHandler *handler = bindings[i].handler;
if ((!on_window && handler->flags & BINDING_PER_WINDOW) ||
- event->type != KeyPress ||
+ (event->type == KeyRelease && !(handler->flags & BINDING_NO_REPEAT)) ||
bindings[i].keycode != event->xkey.keycode ||
((event->xkey.state & 0xff & ~(display->ignored_modifier_mask)) !=
bindings[i].mask))
continue;
-
+
/*
* window must be non-NULL for on_window to be true,
* and so also window must be non-NULL if we get here and
@@ -2370,6 +2367,25 @@
const char *command;
GError *err;
+ if (event->type == KeyRelease)
+ {
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Key release, binding %s\n",
+ binding->name);
+ binding->repeating = FALSE;
+ return;
+ }
+
+ if (binding->repeating)
+ {
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Key repeat ignored, binding %s\n",
+ binding->name);
+ return;
+ }
+
+ binding->repeating = TRUE;
+
command = meta_prefs_get_command (which);
if (command == NULL)