extension.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const Main = imports.ui.main;
  2. const WindowAttentionHandler = imports.ui.windowAttentionHandler;
  3. const Shell = imports.gi.Shell;
  4. const Lang = imports.lang;
  5. function StealMyFocus() {
  6. this._init();
  7. }
  8. function WindowIsReadyRemover() {
  9. this._init();
  10. }
  11. StealMyFocus.prototype = {
  12. _init : function() {
  13. this._tracker = Shell.WindowTracker.get_default();
  14. this._handlerid = global.display.connect('window-demands-attention', Lang.bind(this, this._onWindowDemandsAttention));
  15. },
  16. _onWindowDemandsAttention: function(display, window) {
  17. Main.activateWindow(window);
  18. },
  19. destroy: function () {
  20. global.display.disconnect(this._handlerid);
  21. }
  22. }
  23. WindowIsReadyRemover.prototype = {
  24. _init : function() {
  25. this._tracker = Shell.WindowTracker.get_default();
  26. log('Disabling Window Is Ready Notification')
  27. global.display.disconnect(Main.windowAttentionHandler._windowDemandsAttentionId);
  28. },
  29. destroy: function () {
  30. global.display.disconnect(this._handlerid);
  31. }
  32. }
  33. let windowIsReadyRemover;
  34. let stealmyfocus;
  35. function init() {
  36. }
  37. function enable() {
  38. stealmyfocus = new StealMyFocus();
  39. windowIsReadyRemover = new WindowIsReadyRemover();
  40. }
  41. function disable() {
  42. stealmyfocus.destroy();
  43. windowIsReadyRemover.destroy();
  44. }