Resolve modifier mask conflicts on X11

On X11 key codes and modifiers can have many-to-many relationship, i.e.
a key can activate several modifiers, and a modifier may be activated
by several keys. This patch handles these cases, the logic is borrowed from Qt4.

Task-number: QTBUG-31572
Change-Id: Ide4eb890ec723c68afafe0576d8285440a47d7b0
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>