Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

A couple of new features #32

Merged
merged 52 commits into from
May 20, 2012
Merged

A couple of new features #32

merged 52 commits into from
May 20, 2012

Conversation

peaches
Copy link
Contributor

@peaches peaches commented May 20, 2012

It's probably unlikely you'll accept the pull request, but it's just a way of letting you know of some of the things I've implemented for SuperPutty that you might want to port back to your official version.

This version requires .NET 4.0, but I think it's very possible to port this back to an older version of .NET. In addition, I made a couple of patches to DockPanel Suite to get a couple of the features working, you might want to grab the .dll. If that does not work for you, I can post up my patched version.

If you have any questions, feel free to ask!

Oh yea, given this huge of a feature change, you can expect a lot of bugs :(.

peaches added 30 commits May 8, 2012 00:11
I don't know why this was sleeping for 1000ms before. It creates
a visibile delay and "feels" laggy. Since I am unsure why it's here,
I am reducing it significantly to give it a slightly better feel
when closing the tabs.
I made some modifications to DockPanel suite to allow for direct
access to the tabs. This allows for the "previous" and "next" action
hotkey.
Multiple hotkeys are set now and it is a little more robust than
the previous implementation. With the modified DockPanel suite, we
have the ability to cycle between the tabs!
Also moved the base.OnHandleDestroyed before our code because that
triggers the HandleDestroyed event. We are hooking into this event
from PuttyPanel, and we need to make sure that the handle to the
putty window is still available.
This is useful because the IDockContent is what allows us to focus
the putty window when the tab is selected.
Because I am moving away from RegisterHotkey function. The reason is
that RegisterHotKey only allows one key combination globally. This
means that any other app wanting to use a similar hotkey is not allowed
to do so. As a result, this is preparation for moving towards
WH_KEYBOARD_LL to do the hooking of the keyboard.

Since someone already wrote something really good for WH_KEYBOARD_LL
hooking, it makes no sense for me to rewrite it. As a result, I am
upgrading to .NET 4.0 to be able to utilize their class.
This means the GlobalHotkeys now need to be able to keep its own
state about the keyboard. A little more work here, but better than
to take over the entire global hotkey space.
In certain states, when we are in another window that does not belong
to us, any key trigger will lose focus on the the window. Removing
hotkey parsing fixes it from the original KeyboardListener code.
We can't rely on Process.MainWindowTitle because it doesn't change.
We need to hook into the EVENT_OBJECT_NAMECHANGE event and check
if it is the process that we are interested in. This will be used
later for mintty process to check when the title changes and update
the tab and window accordingly.
When the mintty title changes, the text for the tab gets changed
but the window does not. I'm still unsure if I will add the
functionality for the window title change because it doesn't seem
useful.
This change hooks into a mouse click on the title bar and resize
event to keep the children window focused. A further hack needed
to be done on the title bar click because we can't intercept the
WH_NCLBUTTONUP event, it gets swallowed up for one reason or
another. A way around this is to detect MOUSEMOVE after a
BUTTONDOWN.
We send the message manually to draw the window as always active.
We then short circuit the message by setting the result to true and
never calling the base WndProc.
Since it was using a local variable, this could cause the program
crash, boo!
At first I tried the WM_ACTIVATE, didn't work because the event
does not give enough information (or I misused it) to determine
if you are activated from a child or an external window.

Then I tried a hook on EVENT_SYSTEM_FOREGROUND, but for some reason,
the event gets swallowed randomly. So it would sometimes activate
the child and sometimes it wouldn't.

The final solution that did work is a SHELLHOOK to detect when a
window is activated. Using the trick of determining if the activated
window is a child or not and set the focus properly.
This is a visual improvement to increase the viewable area of the
children window.
This was an odd bug and I don't know why refresh() fixes it, but
it does, so I'm sticking with it :).
This is to easily differentiate between a development SuperPutty
and the normal version of SuperPutty that I am using.
There were instances when using Window + <number> where SuperPutty
did not activate. This forces it to appear at the top.
This is so that I can have a release version while working on edits
for the debug version.
Another hack for my quest to have the putty window properly focused.
This deals with when you maximize/restore and minimize & restore.
Previously, the putty window will lose focus. Not anymore!
peaches added 22 commits May 15, 2012 02:48
Things were getting a bit messy with winapi functions being set
everywhere and constants being set everywhere. This is an initial
attempt to refactor out all of that and put it into one place for
easier usage in the future.
When there's output in a tab that's not in the foreground, the tab
title changes its color to red. This requires a modification in
DockPanel Suite to allow for a change in the text color and a way
to refresh the content individually when updates were made.

This also required a change in mintty to output its content on stdout
when passing in "-l -" option in the command line. You can follow
the issue at code.google.com/p/mintty/issues/detail?id=337, hopefully
the patch gets accepted. Otherwise, I will provide the mintty version
with that change along with this application.
So now if the session tree view is opened, there will be a check
mark right by the option in View. The same goes for the quick connect
toolbar.
Going for the minimal look here. With the new Alt + H hotkey, we can
now hide the top menu.
For the null exception, it's when the last tab gets closed and the
code tries to focus on ActiveDocument. Since it no longer exists, a
null pointer exception is thrown.

The second bug is on the creation of the first tab. It needs to be
focused after it is created.
This was causing an annoying warning. It also looks like a few lines
down that proto is already assigned directly into the SessionData object
so this variable is not needed for anything temporary.
We were defining the Finalize method, which the compiler gave us a
warning. Not sure how things worked in previous versions of .NET, but
a breakpoint inside the Finalize never got hit. Effectively, I am not
sure if we ever unhooked the WinEvent. I moved the unhook to the
OnHandleDestroyed method, which gets executed when the panel is closed.
This gives a better look/feel on the inner window. At least on
Win7, there's no more raised border for the inner child window.
Temporarily remove the old code to see if it causes any problems,
I have seen none so far. Now the title of the window and the title
of the tab is synchronized with each other.
Not sure what is going on here, reverting back to WS_BORDER instead
of using WS_CAPTION. Still need to fix the bug where the line feed
gets inserted when minimized and maximized.
This happens when putty closes and then it tries to focus on the
current Pane. The pane no longer exists, so we need to put in a check
for it.
This only exists in mintty. When the window gets minimized, the width
gets set to 0. So the child mintty window's width get set to 0. This
somehow caused an "enter key" behavior behavior on the mintty window
and the prompt goes down one line. I don't even know how I found this
bug, it's mainly luck :).
When we call OnHandleDestroyed after killing off the child window.
The event for the HandleDestroyed event inside of ctlPuttyPanel tries
to retrieve the child handle and gets 0. As a result, it does not
remove the child handle from frmSupperPutty.children mapping. Since
we rely on the size of this dictionary for selecting tabs, we are now
going off of the end of the tab index. Null pointer :(.
Since a lot of our code depends on a ctlPuttyPanel instance, we've
been getting it from Content[1]. However, this will not work if there
is a session tree view that is currently being displayed. As a result,
we are retrieving the first one from our own mapping, hopefully this
should be the last of the wrong type, though very unlikely :(.
First fix: Remove child panel mapping when we are closing out the
child window. This was insignificant before, but now that we are
relying on the content of this mapping to get a valid ctlPuttyPanel,
we need to prune old instances. Otherwise we will be having problems
with null references.

Second fix: Changing tabs between a putty tab and a mintty tab does
not result in the title being changed. It could have been the case
between mintty windows as well, but I didn't notice it then. Anyway,
this now updates the window's text when the tabs are being changed.
There was never a reset for the hasData private variable. This variable
determines if it will have to update the color, and if it does, it will
only happen once when unfocused. The problem was that this variable never
got reset back to false. So the text color only changed once, ever.
@phendryx
Copy link
Owner

Wow! Seriously, nice job! I left the project alone because I spent days
trying to get the activate stuff to work properly and never got it working.
You did that! I will merge this in, however, it needs some cleaning up, UI
wise. But, that is always the case of an open source project.

I have to travel to Chicago today for work and will be returning later this
week. I will release a new version with these changes, as I am sure the
userbase of superputty would love some of the changes you have added.

This has sparked my interest in coding on this project again. Thank you! :)

-Paul

On Sun, May 20, 2012 at 4:53 AM, akngo <
[email protected]

wrote:

It's probably unlikely you'll accept the pull request, but it's just a way
of letting you know of some of the things I've implemented for SuperPutty
that you might want to port back to your official version.

This version requires .NET 4.0, but I think it's very possible to port
this back to an older version of .NET. In addition, I made a couple of
patches to DockPanel Suite to get a couple of the features working, you
might want to grab the .dll. If that does not work for you, I can post up
my patched version.

If you have any questions, feel free to ask!

You can merge this Pull Request by running:

git pull https://github.com/akngo/superputty mintty_hotkey

Or you can view, comment on it, or merge it online at:

#32

-- Commit Summary --

  • Adding initial support for mintty and hotkeys.
  • Upgrading sln to VS2010.
  • Removing icon path, build break.
  • Decrease thread sleep time.
  • Setting default value for mintty if it exists.
  • Changing tabindex in putty find dialog.
  • Adding a custom binary of DockPanel Suite.
  • Adding in generic hotkey support and previous/next.
  • Removing the child from children list when destroyed.
  • Changing signature so it doesn't give "stack unbalanced" errors.
  • Make it so that the IDockContent is returned.
  • Upgrade to .NET 4.
  • Changing GlobalHotkeys to use new KeyboardListener
  • Fixing a bug where another window loses focus.
  • Adding hotkeys from ctrl+1 to ctrl+9
  • Adding process title tracker.
  • Change tab text on mintty window title change.
  • Update readme to specify changes for this repo.
  • Adding hacks to keep children windows focused.
  • Hook into NCACTIVATE to never allow inactive.
  • Forgot to use the member variable.
  • Refactoring code for event handling.
  • Adding file, forgot to add to prev commit.
  • Finally, an alt tab solution that works!
  • Allow hiding of the quick connect bar at top.
  • Tab selection didn't focus the correct child.
  • Making title bar pink in debug mode.
  • Ensuring that SuperPutty always show on activate.
  • Different mutex for putty release/debug.
  • More hacks for focusing on putty.
  • Clean up a bit of code.
  • Extracted WinAPI functions into its own class.
  • Refactor some more to remove some constants.
  • Tab title color now changes when there's output.
  • Adding in state for view menu items.
  • Adding hotkey to hide/show top menu.
  • Fix bugs on initial create and null exception.
  • Removing the proto string.
  • Removing another compiler warning.
  • Removing additional styles from putty.
  • Replace the window title with the tab title.
  • Fix a bug where on minimize/maximize.
  • Fix null exception in DockContentHandler.
  • Adding WS_EXSTYLE constants.
  • Fixed an annoying bug that caused new lines.
  • This time it's a better border for both mintty and putty.
  • Fixed bug where handle is lost.
  • Ensuring a ctlPuttyPanel is retrieved.
  • Two fixes, didn't know why I didn't commit earlier
  • Making sure tab text color gets reset/changed.
  • Update the readme with additional information!

-- File Changes --

M README.txt (72)
M SuperPutty.sln (7)
M SuperPutty/Classes/CLI.cs (2)
M SuperPutty/Classes/Database.cs (6)
A SuperPutty/Classes/GlobalHotkeys.cs (154)
A SuperPutty/Classes/KeyboardListener.cs (399)
A SuperPutty/Classes/RestoreFromMinimizedTracker.cs (25)
A SuperPutty/Classes/WinAPI.cs (1173)
A SuperPutty/Classes/WindowEventHandler.cs (46)
A SuperPutty/Classes/WindowTitleTracker.cs (30)
M SuperPutty/Program.cs (9)
M SuperPutty/Properties/Resources.Designer.cs (46)
M SuperPutty/SessionTreeview.Designer.cs (229)
M SuperPutty/SessionTreeview.cs (11)
M SuperPutty/SuperPutty.csproj (72)
M SuperPutty/ctlApplicationPanel.cs (1115)
M SuperPutty/ctlPuttyPanel.Designer.cs (189)
M SuperPutty/ctlPuttyPanel.cs (97)
M SuperPutty/dlgFindPutty.Designer.cs (58)
M SuperPutty/dlgFindPutty.cs (26)
M SuperPutty/frmSuperPutty.Designer.cs (929)
M SuperPutty/frmSuperPutty.cs (515)
M SuperPutty/frmSuperPutty.resx (22)
M bin/System.Data.SQLite.DLL (0)
M bin/WeifenLuo.WinFormsUI.Docking.dll (0)

-- Patch Links --

https://github.com/phendryx/superputty/pull/32.patch
https://github.com/phendryx/superputty/pull/32.diff


Reply to this email directly or view it on GitHub:
#32

phendryx added a commit that referenced this pull request May 20, 2012
@phendryx phendryx merged commit b4ab177 into phendryx:master May 20, 2012
@peaches
Copy link
Contributor Author

peaches commented May 21, 2012

Oh wow, I was surprised to see this merged so quickly :). I am guessing that
also meant that you already compiled and do a quick run on the project. There
are still a few quirks with the activation stuff, but I think for the most part,
it works as intended.

In its current state right now, this merge deals with #17 and #18. For the UI
stuff, I can help with the cleanup, most of my tests has been with mintty and
not putty. There's probably a few bugs on that side that I've introduced.

I certainly hope that the transition to .NET 4 won't be that bad. But you'll have a
better idea on how to approach this than I do.

Some of the currently opened issues are pretty interesting, I might take a stab
at one or two of them in the next few weeks. Anything for priorities?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants