mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 717613 - Make sure the primary selection is not updated too often in the Source Editor; r=rcampbell
This commit is contained in:
parent
a23fc1e763
commit
bfe616562e
@ -62,6 +62,14 @@ const ORION_IFRAME = "data:text/html;charset=utf8,<!DOCTYPE html>" +
|
||||
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
/**
|
||||
* The primary selection update delay. On Linux, the X11 primary selection is
|
||||
* updated to hold the currently selected text.
|
||||
*
|
||||
* @type number
|
||||
*/
|
||||
const PRIMARY_SELECTION_DELAY = 100;
|
||||
|
||||
/**
|
||||
* Predefined themes for syntax highlighting. This objects maps
|
||||
* SourceEditor.THEMES to Orion CSS files.
|
||||
@ -157,6 +165,7 @@ SourceEditor.prototype = {
|
||||
_annotationModel: null,
|
||||
_dragAndDrop: null,
|
||||
_currentLineAnnotation: null,
|
||||
_primarySelectionTimeout: null,
|
||||
_mode: null,
|
||||
_expandTab: null,
|
||||
_tabSize: null,
|
||||
@ -567,16 +576,34 @@ SourceEditor.prototype = {
|
||||
}
|
||||
|
||||
if (Services.appinfo.OS == "Linux") {
|
||||
let text = this.getText(aEvent.newValue.start, aEvent.newValue.end);
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
let window = this.parentElement.ownerDocument.defaultView;
|
||||
|
||||
clipboardHelper.copyStringToClipboard(text,
|
||||
Ci.nsIClipboard.kSelectionClipboard);
|
||||
if (this._primarySelectionTimeout) {
|
||||
window.clearTimeout(this._primarySelectionTimeout);
|
||||
}
|
||||
this._primarySelectionTimeout =
|
||||
window.setTimeout(this._updatePrimarySelection.bind(this),
|
||||
PRIMARY_SELECTION_DELAY);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the X11 PRIMARY buffer to hold the current selection.
|
||||
* @private
|
||||
*/
|
||||
_updatePrimarySelection: function SE__updatePrimarySelection()
|
||||
{
|
||||
this._primarySelectionTimeout = null;
|
||||
|
||||
let text = this.getSelectedText();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
clipboardHelper.copyStringToClipboard(text,
|
||||
Ci.nsIClipboard.kSelectionClipboard);
|
||||
},
|
||||
|
||||
/**
|
||||
* Highlight the current line using the Orion annotation model.
|
||||
*
|
||||
@ -1303,6 +1330,12 @@ SourceEditor.prototype = {
|
||||
}
|
||||
this._onOrionSelection = null;
|
||||
|
||||
if (this._primarySelectionTimeout) {
|
||||
let window = this.parentElement.ownerDocument.defaultView;
|
||||
window.clearTimeout(this._primarySelectionTimeout);
|
||||
this._primarySelectionTimeout = null;
|
||||
}
|
||||
|
||||
this._view.destroy();
|
||||
this.ui.destroy();
|
||||
this.ui = null;
|
||||
|
Loading…
Reference in New Issue
Block a user