Tuesday, June 28, 2016

Re: How to make gvim ignore the TERM signal ?

On Tuesday, June 28, 2016 at 5:32:04 PM UTC+8, Tony Mechelynck wrote:
> I'm not 100% sure but I think SIGTERM is what (or one of the things
> that) Gvim with GNOME relies upon to save your session in a hurry when
> you log out of X11 (or shut down the whole system) with an open gvim;
> so if you want to ignore SIGTERM (which IMHO is not a very good idea)
> you "might" have to compile without GNOME.
>
>
> Best regards,
> Tony.
>

> > On Monday, June 27, 2016 at 6:40:07 PM UTC+8, Jacky Liu wrote:
> >> I'm using gvim as the user interface for my own application largely written in python, and I'm firing up matplotlib windows through vim's python interface to do data visualization and graphical operation, here I have an issue: I'm using Ubuntu 14.04 with Unity as the desktop environment, and only by the first time triggering will Unity bring the new matplotlib window on top of my gvim window, after the first time, Unity will only give me a notice in the launching area, and I have to manually switch to the newly created matplotlib window.
> >>
> >> I'm using PyQT4 as the backend inside matplotlib, here is the demo code:
> >>
> >> nnoremap \t :<C-u>py3 test_graphical_interface()<CR>
> >>
> >> python3 << EOF
> >>
> >> import matplotlib
> >> matplotlib.use("Qt4Agg", warn=True)
> >> import matplotlib.pyplot as pyplot
> >>
> >> from PyQt4 import QtGui, QtCore
> >>
> >> def test_graphical_interface():
> >>
> >> fig= pyplot.figure( \
> >> figsize= (3.0, 3.0), \
> >> dpi= 300, \
> >> facecolor= '#ffc0cb', \
> >> edgecolor= '#ffc0cb', \
> >> linewidth= 1.0
> >> )
> >> ax= fig.add_axes((0.1, 0.1, 0.8, 0.8), axis_bgcolor='black')
> >>
> >> manager= pyplot.get_current_fig_manager()
> >> manager.window.setWindowTitle('GIF testing')
> >>
> >> manager.window.showMaximized() # XXX: show up the graphical window
> >>
> >> EOF
> >>
> >>
> >>
> >> The following code I found online was also tried, yet it has no effect.
> >>
> >> manager.window.setWindowState(
> >> manager.window.windowState() & \
> >> ~QtCore.Qt.WindowMinimized | \
> >> QtCore.Qt.WindowActive
> >> )
> >>
> >> manager.window.setWindowFlags(
> >> manager.window.windowFlags() & \
> >> QtCore.Qt.WindowStaysOnTopHint
> >>
> >> )
> >>
> >> manager.window.setWindowFlags(
> >> manager.window.windowFlags() & \
> >> ~QtCore.Qt.WindowStaysOnTopHint
> >> )
> >>
> >> manager.window.raise_()
> >> manager.window.activateWindow()
> >>
> >>
> >>
> >> I realized this issue was in line with Unity's behaviour, like when you open up multiple image files with eog the viewer, only the first time opening will bring up the eog window, later opening up will only gives you notice in the launching area and Unity will not bring up new windows (having the new windows minimized and hidden below).
> >>
> >> After some try I realized two consecutive calls of window.show() will always bring up the window to the front as desired:
> >>
> >> manager.window.showNormal()
> >> manager.window.showMaximized()
> >>
> >> but a new problem occurred, when the matplotlib window is closed, gvim window will be closed as well, it looks like each call of the show() function will be registered, such that corresponding numbers of TERM signal will be generated later, first signal kills the graphical window, the second kills gvim.
> >>
> >> There are 3 options I can think of trying to solve the issue:
> >>
> >> 1. try to make gvim ignore the TERM signal, such that it can only be quitted by commands like :qall
> >> 2. try to alter the behaviour of Unity into always bringing up the new app windows to the top
> >> 3. keep trying within the Qt frame, like more methods of the manager.window object to see if a solution can be found
> >>
> >> Can someone enlighten me as to which option I should try with the most likelihood of success? Thanks.
> >
> >
> >
> > OK, I found a not so elegant solution:
> >
> > evalstr= "feedkeys(':py3 subprocess.Popen([''wmctrl'', ''-a'', ''" +"GIF testing"+ "''], shell=False)' . " + '"\<CR>")'
> > vim.eval(evalstr)
> >
> >
> > When in doubt, feedkeys.
> >
> > --
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
> > ---
> > You received this message because you are subscribed to the Google Groups "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.


You're right, I also realized that when I screwed up my Python program such that gvim stopped responding, I also have to rely on manually closing the window to quit gvim, so ignoring the TERM signal may not be an option. Fortunately the feedkeys() approach worked for me.




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: