Skip to content

Commit

Permalink
Add null check to device in InputEvent's handler (#3511)
Browse files Browse the repository at this point in the history
* Add a device null check to InputContext.cpp

* remove ibus IM override

* Send parent window to IM in TextEditor
  • Loading branch information
Rio6 committed Nov 5, 2021
1 parent f76a263 commit c07d399
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ PellelNitram <starwars31337@gmail.com>
Plailect <plailect@gmail.com>
Pēteris Birkants <peteris.birkants@gmail.com>
Rasmus Thomsen <oss@cogitri.dev>
Rio Liu <rio.liu@r26.me>
Rob Frohne <rob.frohne@wallawalla.edu>
Romano Giannetti <romano@rgtti.com>
Ruo Li <rli@math.pku.edu.cn>
Expand Down
3 changes: 1 addition & 2 deletions src/control/XournalMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ void ensure_input_model_compatibility() {
if (imModule != nullptr) {
std::string imModuleString{imModule};
if (imModuleString == "xim" || imModuleString == "gcin") {
g_setenv("GTK_IM_MODULE", "ibus", true);
g_warning("Unsupported input method: %s, changed to: ibus", imModule);
g_warning("Unsupported input method: %s", imModule);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TextEditor::TextEditor(XojPageView* gui, GtkWidget* widget, Text* text, bool own
g_object_get(settings, "gtk-cursor-blink-timeout", &this->cursorBlinkTimeout, nullptr);

this->imContext = gtk_im_multicontext_new();
gtk_im_context_set_client_window(this->imContext, gtk_widget_get_window(this->widget));
gtk_im_context_set_client_window(this->imContext, gtk_widget_get_parent_window(this->widget));
gtk_im_context_focus_in(this->imContext);

g_signal_connect(this->imContext, "commit", G_CALLBACK(iMCommitCallback), this);
Expand Down
6 changes: 5 additions & 1 deletion src/gui/inputdevices/InputContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ auto InputContext::eventCallback(GtkWidget* widget, GdkEvent* event, InputContex
auto InputContext::handle(GdkEvent* sourceEvent) -> bool {
printDebug(sourceEvent);

GdkDevice* sourceDevice = gdk_event_get_source_device(sourceEvent);
if (sourceDevice == NULL) {
return false;
}

InputEvent event = InputEvents::translateEvent(sourceEvent, this->getSettings());

// Add the device to the list of known devices if it is currently unknown
GdkDevice* sourceDevice = gdk_event_get_source_device(sourceEvent);
GdkInputSource inputSource = gdk_device_get_source(sourceDevice);
if (inputSource != GDK_SOURCE_KEYBOARD && gdk_device_get_device_type(sourceDevice) != GDK_DEVICE_TYPE_MASTER &&
this->knownDevices.find(std::string(event.deviceName)) == this->knownDevices.end()) {
Expand Down

0 comments on commit c07d399

Please sign in to comment.