Re: Weird KDE Bug in LyX

2016-07-08 Thread Guillaume Munch

Le 08/07/2016 21:01, Richard Heck a écrit :

On 07/08/2016 03:33 PM, Guillaume Munch wrote:

Le 05/07/2016 21:30, Guillaume Munch a écrit :



Please try the attached.


I'll soon commit the fix to master. This is a delicate code path so
even if I tried to be very careful, there will be no backport without
a test.


I'd think this is not for 2.2.1. We can commit soon after that release
and let it get tested there.



Agreed.




Re: Weird KDE Bug in LyX

2016-07-08 Thread Richard Heck
On 07/08/2016 04:01 PM, Richard Heck wrote:
> On 07/08/2016 03:33 PM, Guillaume Munch wrote:
>> Le 05/07/2016 21:30, Guillaume Munch a écrit :
>>>
>>> Please try the attached.
>> I'll soon commit the fix to master. This is a delicate code path so
>> even if I tried to be very careful, there will be no backport without
>> a test. 
> I'd think this is not for 2.2.1. We can commit soon after that release
> and let it get tested there.

..commit to 2.2.x, I mean. It's fine for master, as far as I'm concerned.

Richard



Re: Weird KDE Bug in LyX

2016-07-08 Thread Richard Heck
On 07/08/2016 03:33 PM, Guillaume Munch wrote:
> Le 05/07/2016 21:30, Guillaume Munch a écrit :
>>
>>
>> Please try the attached.
>
> I'll soon commit the fix to master. This is a delicate code path so
> even if I tried to be very careful, there will be no backport without
> a test. 

I'd think this is not for 2.2.1. We can commit soon after that release
and let it get tested there.

Richard



Re: Weird KDE Bug in LyX

2016-07-08 Thread Guillaume Munch

Le 05/07/2016 21:30, Guillaume Munch a écrit :



Please try the attached.



I'll soon commit the fix to master. This is a delicate code path so even 
if I tried to be very careful, there will be no backport without a test. 
Moreover it would be nice to know if #10119 (issues with Control+M for 
Italian OS X users) has anything to do with it.



Guillaume



Re: Weird KDE Bug in LyX

2016-07-05 Thread Guillaume Munch

Le 02/07/2016 23:43, Guillaume Munch a écrit :



On the other hand, it is possible to prioritise LyX shortcuts by using
the shortcut override mechanism. This would solve both bugs
http://www.lyx.org/trac/ticket/10261 and
http://www.lyx.org/trac/ticket/10119 (probably),
and alleviate the occasional developer's or translator's mistake in
assigning accelerators.




Please try the attached.
>From e1a330df038c7f89e17e94e4338d005507b657c2 Mon Sep 17 00:00:00 2001
From: Guillaume Munch 
Date: Mon, 4 Jul 2016 04:23:32 +0200
Subject: [PATCH] Prioritize the shortcuts from the work areas

* Fix bug #10261 : KDE smartly adds conflicting accelerators.

* Maybe fix #10119?

* Prevent bugs like #9495 in the future.

This patch adds a conflicting accelerator in the source view panel (M) for
demonstration purposes.

Issues:

* It does not appear possible to prevent Ubuntu's Unity from grabbing the
  accelerators for the menus. For instance Alt+A always opens _Affichage in the
  French localization.
---
 src/frontends/qt4/GuiApplication.cpp | 42 +---
 src/frontends/qt4/GuiApplication.h   |  3 +++
 src/frontends/qt4/GuiKeySymbol.cpp   |  2 +-
 src/frontends/qt4/GuiKeySymbol.h |  2 +-
 src/frontends/qt4/GuiPrefs.cpp   |  3 +++
 src/frontends/qt4/GuiWorkArea.cpp| 41 +++
 src/frontends/qt4/GuiWorkArea.h  |  5 -
 src/frontends/qt4/ui/ViewSourceUi.ui |  2 +-
 8 files changed, 79 insertions(+), 21 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp
index 6586207..3ddcdbd 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -2115,19 +2115,43 @@ void GuiApplication::handleKeyFunc(FuncCode action)
 }
 
 
+//Keep this in sync with GuiApplication::processKeySym below
+bool GuiApplication::queryKeySym(KeySymbol const & keysym,
+ KeyModifier state) const
+{
+	// Do nothing if we have nothing
+	if (!keysym.isOK() || keysym.isModifier())
+		return false;
+	// Do a one-deep top-level lookup for cancel and meta-fake keys.
+	KeySequence seq;
+	FuncRequest func = seq.addkey(keysym, state);
+	// When not cancel or meta-fake, do the normal lookup.
+	if ((func.action() != LFUN_CANCEL) && (func.action() != LFUN_META_PREFIX)) {
+		seq = d->keyseq;
+		func = seq.addkey(keysym, (state | d->meta_fake_bit));
+	}
+	// Maybe user can only reach the key via holding down shift.
+	// Let's see. But only if shift is the only modifier
+	if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier)
+		// If addkey looked up a command and did not find further commands then
+		// seq has been reset at this point
+		func = seq.addkey(keysym, NoModifier);
+
+	LYXERR(Debug::KEY, " Key (queried) [action=" << func.action() << "]["
+	   << seq.print(KeySequence::Portable) << ']');
+	return func.action() != LFUN_UNKNOWN_ACTION;
+}
+
+
+//Keep this in sync with GuiApplication::queryKeySym above
 void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
 {
 	LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
 
 	// Do nothing if we have nothing (JMarc)
-	if (!keysym.isOK()) {
-		LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
-		if (current_view_)
-			current_view_->restartCursor();
-		return;
-	}
-
-	if (keysym.isModifier()) {
+	if (!keysym.isOK() || keysym.isModifier()) {
+		if (!keysym.isOK())
+			LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
 		if (current_view_)
 			current_view_->restartCursor();
 		return;
@@ -2173,6 +2197,8 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
 	// Let's see. But only if shift is the only modifier
 	if (func.action() == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
 		LYXERR(Debug::KEY, "Trying without shift");
+		// If addkey looked up a command and did not find further commands then
+		// seq has been reset at this point
 		func = d->keyseq.addkey(keysym, NoModifier);
 		LYXERR(Debug::KEY, "Action now " << func.action());
 	}
diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h
index 861810d..de6013d 100644
--- a/src/frontends/qt4/GuiApplication.h
+++ b/src/frontends/qt4/GuiApplication.h
@@ -165,6 +165,9 @@ public:
 #endif
 	}
 
+	/// return true if the key is part of a shortcut
+	bool queryKeySym(KeySymbol const & key, KeyModifier state) const;
+	///
 	void processKeySym(KeySymbol const & key, KeyModifier state);
 	/// return the status bar state string
 	docstring viewStatusMessage();
diff --git a/src/frontends/qt4/GuiKeySymbol.cpp b/src/frontends/qt4/GuiKeySymbol.cpp
index d058bce..ef9425d 100644
--- a/src/frontends/qt4/GuiKeySymbol.cpp
+++ b/src/frontends/qt4/GuiKeySymbol.cpp
@@ -612,7 +612,7 @@ static char encode(string const & encoding, QString const & str)
 #endif
 
 
-void setKeySymbol(KeySymbol * sym, QKeyEvent * ev)
+void setKeySymbol(KeySymbol * sym, QKeyEvent 

Re: Weird KDE Bug in LyX

2016-07-04 Thread Richard Heck

On 07/04/2016 10:36 AM, José Abílio Matos wrote:

On Friday, July 1, 2016 9:51:08 AM WEST Richard Heck wrote:

Add

[Development]
AutoCheckAccelerators=false
CopyWidgetText=false

to $HOME/.config/kdeglobals

Richard

Thank you Richard, when that happens it can be really annoying. Trying to
change a paragraph layout with Alt+P  and then changing an
unrelated document is really confusing and surprising.

I tested and it works.


Hopefully, it will also get fixed upstream.

Richard



Re: Weird KDE Bug in LyX

2016-07-04 Thread José Abílio Matos
On Friday, July 1, 2016 9:51:08 AM WEST Richard Heck wrote:
> Add
> 
> [Development]
> AutoCheckAccelerators=false
> CopyWidgetText=false
> 
> to $HOME/.config/kdeglobals
> 
> Richard

Thank you Richard, when that happens it can be really annoying. Trying to 
change a paragraph layout with Alt+P  and then changing an 
unrelated document is really confusing and surprising.

I tested and it works.

Regards,
-- 
José Abílio



Re: Weird KDE Bug in LyX

2016-07-02 Thread Guillaume Munch

Le 30/06/2016 22:26, Richard Heck a écrit :


For anyone running LyX 2.2.0 under KDE (or using a KDE-based window
manager, or anything of that sort):

There is an annoying new feature, KDE's "accelerator manager", that
automatically adds shortcuts. This causes conflicts and so forth in many
Qt-based programs, when those programs are run with Qt5. If you are
experiencing this issue, please see
 http://www.lyx.org/trac/ticket/10261#comment:16
for a workaround.




On the other hand, it is possible to prioritise LyX shortcuts by using
the shortcut override mechanism. This would solve both bugs
http://www.lyx.org/trac/ticket/10261 and
http://www.lyx.org/trac/ticket/10119 (probably),
and alleviate the occasional developer's or translator's mistake in
assigning accelerators.

Guillaume



Re: Weird KDE Bug in LyX

2016-07-01 Thread Richard Heck

On 07/01/2016 05:21 AM, José Abílio Matos wrote:

On Thursday, June 30, 2016 4:26:40 PM WEST Richard Heck wrote:

For anyone running LyX 2.2.0 under KDE (or using a KDE-based window
manager, or anything of that sort):

There is an annoying new feature, KDE's "accelerator manager", that
automatically adds shortcuts. This causes conflicts and so forth in many
Qt-based programs, when those programs are run with Qt5. If you are
experiencing this issue, please see
  http://www.lyx.org/trac/ticket/10261#comment:16
for a workaround.

Richard Heck

I reported that in March:
http://permalink.gmane.org/gmane.editors.lyx.devel/160859

I would like to see a workaround since it is really annoying but I do not seem
able to access the tracker.


Add

[Development]
AutoCheckAccelerators=false
CopyWidgetText=false

to $HOME/.config/kdeglobals

Richard



Re: Weird KDE Bug in LyX

2016-07-01 Thread José Abílio Matos
On Thursday, June 30, 2016 4:26:40 PM WEST Richard Heck wrote:
> For anyone running LyX 2.2.0 under KDE (or using a KDE-based window
> manager, or anything of that sort):
> 
> There is an annoying new feature, KDE's "accelerator manager", that
> automatically adds shortcuts. This causes conflicts and so forth in many
> Qt-based programs, when those programs are run with Qt5. If you are
> experiencing this issue, please see
>  http://www.lyx.org/trac/ticket/10261#comment:16
> for a workaround.
> 
> Richard Heck

I reported that in March:
http://permalink.gmane.org/gmane.editors.lyx.devel/160859

I would like to see a workaround since it is really annoying but I do not seem 
able to access the tracker.

-- 
José Abílio