Skip to content

Commit

Permalink
Fix Timeout Unexpected close bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Hollow Man <[email protected]>
  • Loading branch information
HollowMan6 committed May 7, 2021
1 parent 2039c5b commit 6e91666
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 14 additions & 5 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const IBusInputSourceIndicater = GObject.registerClass(
}

set inputindhid(inputindhid) {
this.hideTime = inputindhid * 1000;
this.hideTime = inputindhid;
}

_connectPanelService(panelService) {
Expand Down Expand Up @@ -205,14 +205,23 @@ const IBusInputSourceIndicater = GObject.registerClass(
_updateVisibility(sourceToggle = false) {
this.visible = !CandidatePopup.visible;
if (this.onlyOnToggle) this.visible = this.onlyOnToggle && sourceToggle;
if (this._lastTimeOut) {
GLib.source_remove(this._lastTimeOut);
this._lastTimeOut = null;
}
if (this.visible) {
this.setPosition(this._dummyCursor, 0);
this.open(BoxPointer.PopupAnimation[this.animation]);
this.get_parent().set_child_above_sibling(this, null);
GLib.timeout_add(GLib.PRIORITY_DEFAULT, this.hideTime, () => {
this.close(BoxPointer.PopupAnimation[this.animation]);
return GLib.SOURCE_REMOVE;
});
this._lastTimeOut = GLib.timeout_add_seconds(
GLib.PRIORITY_DEFAULT,
this.hideTime,
() => {
this.close(BoxPointer.PopupAnimation[this.animation]);
this._lastTimeOut = null;
return GLib.SOURCE_REMOVE;
}
);
} else {
this.close(BoxPointer.PopupAnimation[this.animation]);
}
Expand Down
6 changes: 2 additions & 4 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const CustomizeIBus = GObject.registerClass(
this._field_use_indicator = new Gtk.Switch();
this._field_indicator_only_toggle = new Gtk.Switch();

let adjustment = this._createAdjustment(Fields.INPUTINDHID, 1);
let adjustment = this._createAdjustment(Fields.INPUTINDHID);
this._field_indicator_hide_time = new Gtk.Scale({
adjustment,
draw_value: true,
Expand Down Expand Up @@ -614,7 +614,7 @@ const CustomizeIBus = GObject.registerClass(
this._updateIBusVersion();
}

_createAdjustment(key, step) {
_createAdjustment(key) {
let schemaKey = gsettings.settings_schema.get_key(key);
let [type, variant] = schemaKey.get_range().deep_unpack();
if (type !== "range")
Expand All @@ -623,8 +623,6 @@ const CustomizeIBus = GObject.registerClass(
let adj = new Gtk.Adjustment({
lower,
upper,
step_increment: step,
page_increment: step,
});
gsettings.bind(key, adj, "value", Gio.SettingsBindFlags.DEFAULT);
return adj;
Expand Down

0 comments on commit 6e91666

Please sign in to comment.