Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrmcardle <riley@mremoteng.org>2012-01-13 08:14:16 +0400
committerrmcardle <riley@mremoteng.org>2012-01-13 08:14:16 +0400
commit8ada865202baff9c85aa83fc9eb64a30970bf3b0 (patch)
tree4f2025c5c2bb1247bcd182979869f35d8c4bff46
parente9844da78292b399b8a1a359c50caf2a4b42aec4 (diff)
Fix main window of parent not moving to top when the user clicks within the PuTTYNG window. Add #ifdef PUTTYNG around all PuTTYNG additions.
-rw-r--r--CMDLINE.C6
-rw-r--r--PUTTY.H2
-rw-r--r--WINDOWS/WINDOW.C43
3 files changed, 48 insertions, 3 deletions
diff --git a/CMDLINE.C b/CMDLINE.C
index 0ab869f0..6313d629 100644
--- a/CMDLINE.C
+++ b/CMDLINE.C
@@ -166,12 +166,14 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
{
int ret = 0;
+#ifdef PUTTYNG
if (!stricmp(p, "-hwndparent")) {
RETURN(2);
hwnd_parent = atoi(value);
return 2;
- }
- if (!strcmp(p, "-load")) {
+ }
+#endif // PUTTYNG
+ if (!strcmp(p, "-load")) {
RETURN(2);
/* This parameter must be processed immediately rather than being
* saved. */
diff --git a/PUTTY.H b/PUTTY.H
index 0e7ee3af..e4b5eb12 100644
--- a/PUTTY.H
+++ b/PUTTY.H
@@ -713,8 +713,10 @@ GLOBAL int loaded_session;
*/
GLOBAL char *cmdline_session_name;
+#ifdef PUTTYNG
GLOBAL int hwnd_parent;
#define IsZoomed(hWnd) TRUE
+#endif // PUTTYNG
struct RSAKey; /* be a little careful of scope */
diff --git a/WINDOWS/WINDOW.C b/WINDOWS/WINDOW.C
index e42e9d53..e6936c08 100644
--- a/WINDOWS/WINDOW.C
+++ b/WINDOWS/WINDOW.C
@@ -202,6 +202,11 @@ static int compose_state = 0;
static UINT wm_mousewheel = WM_MOUSEWHEEL;
+#ifdef PUTTYNG
+HWND hwnd_parent_main = NULL;
+HWND hwnd_last_active = NULL;
+#endif
+
/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
{
@@ -674,9 +679,11 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{
int winmode;
int exwinmode = 0;
+#ifdef PUTTYNG
if (hwnd_parent != 0)
winmode = WS_POPUP | WS_VSCROLL;
else {
+#endif // PUTTYNG
winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL;
if (cfg.resize_action == RESIZE_DISABLED)
winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
@@ -692,7 +699,13 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
guess_width, guess_height,
NULL, NULL, inst, NULL);
- SetParent(hwnd, (HWND)hwnd_parent); // Focus doesn't work correctly if this is passed into CreateWindow, so set it separately.
+#ifdef PUTTYNG
+ if (hwnd_parent != 0)
+ {
+ SetParent(hwnd, (HWND)hwnd_parent); // Focus doesn't work correctly if this is passed into CreateWindow, so set it separately.
+ hwnd_parent_main = GetAncestor((HWND)hwnd_parent, GA_ROOTOWNER); // the top level ancestor of hwnd_parent
+ }
+#endif // PUTTYNG
}
/*
@@ -2198,7 +2211,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
term_size(term, cfg.height, cfg.width, cfg.savelines);
/* Enable or disable the scroll bar, etc */
+#ifdef PUTTYNG
if (hwnd_parent == 0) {
+#endif
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
LONG nexflag, exflag =
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
@@ -2251,7 +2266,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
init_lvl = 2;
}
+#ifdef PUTTYNG
}
+#endif // PUTTYNG
/* Oops */
if (cfg.resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
@@ -2480,6 +2497,15 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
wp = wParam; lp = lParam;
last_mousemove = WM_MOUSEMOVE;
}
+
+#ifdef PUTTYNG
+ {
+ GUITHREADINFO thread_info;
+ thread_info.cbSize = sizeof(thread_info);
+ GetGUIThreadInfo(NULL, &thread_info);
+ hwnd_last_active = thread_info.hwndActive;
+ }
+#endif // PUTTYNG
}
/*
* Add the mouse position and message time to the random
@@ -2636,6 +2662,11 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
net_pending_errors();
return 0;
+#ifdef PUTTYNG
+ case WM_MOUSEACTIVATE:
+ if (hwnd_parent != 0 && hwnd_last_active != hwnd_parent_main)
+ BringWindowToTop(hwnd_parent_main);
+#endif // PUTTYNG
case WM_SETFOCUS:
term_set_focus(term, TRUE);
CreateCaret(hwnd, caretbm, font_width, font_height);
@@ -2768,12 +2799,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
case WM_MOVE:
sys_cursor_update();
break;
+#ifdef PUTTYNG
case WM_SIZE:
if (hwnd_parent != 0)
{
wParam = SIZE_MAXIMIZED;
was_zoomed = 0;
}
+#endif // PUTTYNG
#ifdef RDB_DEBUG_PATCH
debug((27, "WM_SIZE %s (%d,%d)",
@@ -5343,7 +5376,9 @@ void refresh_window(void *frontend)
*/
void set_zoomed(void *frontend, int zoomed)
{
+#ifdef PUTTYNG
if (hwnd_parent != 0) return;
+#endif // PUTTYNG
if (IsZoomed(hwnd)) {
if (!zoomed)
@@ -5439,7 +5474,9 @@ static void make_full_screen()
DWORD style;
RECT ss;
+#ifdef PUTTYNG
if (hwnd_parent != 0) return;
+#endif // PUTTYNG
assert(IsZoomed(hwnd));
@@ -5481,7 +5518,9 @@ static void clear_full_screen()
{
DWORD oldstyle, style;
+#ifdef PUTTYNG
if (hwnd_parent != 0) return;
+#endif // PUTTYNG
/* Reinstate the window furniture. */
style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE);
@@ -5514,7 +5553,9 @@ static void clear_full_screen()
*/
static void flip_full_screen()
{
+#ifdef PUTTYNG
if (hwnd_parent != 0) return;
+#endif // PUTTYNG
if (is_full_screen()) {
ShowWindow(hwnd, SW_RESTORE);