2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
*Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
|
|
|
|
*
|
|
|
|
*Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
*"Software"), to deal in the Software without restriction, including
|
|
|
|
*without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
*distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
*permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
*the following conditions:
|
|
|
|
*
|
|
|
|
*The above copyright notice and this permission notice shall be
|
|
|
|
*included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
*EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
*MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
*NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
|
|
|
|
*ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
|
|
*CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
*WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*Except as contained in this notice, the name of Harold L Hunt II
|
|
|
|
*shall not be used in advertising or otherwise to promote the sale, use
|
|
|
|
*or other dealings in this Software without prior written authorization
|
|
|
|
*from Harold L Hunt II.
|
|
|
|
*
|
|
|
|
* Authors: Harold L Hunt II
|
|
|
|
* Earle F. Philhower III
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XWIN_CONFIG_H
|
|
|
|
#include <xwin-config.h>
|
|
|
|
#endif
|
|
|
|
#include "win.h"
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <sys/cygwin.h>
|
|
|
|
#endif
|
|
|
|
#include <shellapi.h>
|
|
|
|
#include "winprefs.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* References to external globals
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef XWIN_CLIPBOARD
|
2012-06-10 07:21:05 -06:00
|
|
|
extern Bool g_fClipboardStarted;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* Local function prototypes
|
|
|
|
*/
|
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winChangeDepthDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winAboutDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winDrawURLWindow(LPARAM lParam);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winOverrideURLButton(HWND hdlg, int id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winUnoverrideURLButton(HWND hdlg, int id);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Owner-draw a button as a URL
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winDrawURLWindow(LPARAM lParam)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DRAWITEMSTRUCT *draw;
|
|
|
|
char str[256];
|
|
|
|
RECT rect;
|
|
|
|
HFONT font;
|
|
|
|
COLORREF crText;
|
|
|
|
|
|
|
|
draw = (DRAWITEMSTRUCT *) lParam;
|
|
|
|
GetWindowText(draw->hwndItem, str, sizeof(str));
|
|
|
|
str[255] = 0;
|
|
|
|
GetClientRect(draw->hwndItem, &rect);
|
|
|
|
|
|
|
|
/* Color the button depending upon its state */
|
|
|
|
if (draw->itemState & ODS_SELECTED)
|
|
|
|
crText = RGB(128 + 64, 0, 0);
|
|
|
|
else if (draw->itemState & ODS_FOCUS)
|
|
|
|
crText = RGB(0, 128 + 64, 0);
|
|
|
|
else
|
|
|
|
crText = RGB(0, 0, 128 + 64);
|
|
|
|
SetTextColor(draw->hDC, crText);
|
|
|
|
|
|
|
|
/* Create font 8 high, standard dialog font */
|
|
|
|
font = CreateFont(-8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
|
|
|
|
0, 0, 0, 0, 0, "MS Sans Serif");
|
|
|
|
if (!font) {
|
|
|
|
ErrorF("winDrawURLWindow: Unable to create URL font, bailing.\n");
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Draw it */
|
|
|
|
SetBkMode(draw->hDC, OPAQUE);
|
|
|
|
SelectObject(draw->hDC, font);
|
|
|
|
DrawText(draw->hDC, str, strlen(str), &rect, DT_LEFT | DT_VCENTER);
|
|
|
|
/* Delete the created font, replace it with stock font */
|
|
|
|
DeleteObject(SelectObject(draw->hDC, GetStockObject(ANSI_VAR_FONT)));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WndProc for overridden buttons
|
|
|
|
*/
|
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WNDPROC origCB = NULL;
|
|
|
|
HCURSOR cursor;
|
|
|
|
|
|
|
|
/* If it's a SetCursor message, tell it to the hand */
|
|
|
|
if (msg == WM_SETCURSOR) {
|
|
|
|
cursor = LoadCursor(NULL, IDC_HAND);
|
|
|
|
if (cursor)
|
|
|
|
SetCursor(cursor);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
origCB = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
|
|
/* Otherwise fall through to original WndProc */
|
|
|
|
if (origCB)
|
|
|
|
return CallWindowProc(origCB, hwnd, msg, wParam, lParam);
|
|
|
|
else
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register and unregister the custom WndProc
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winOverrideURLButton(HWND hwnd, int id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WNDPROC origCB;
|
|
|
|
|
|
|
|
origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id),
|
|
|
|
GWLP_WNDPROC, (LONG_PTR) winURLWndProc);
|
|
|
|
SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, (LONG_PTR) origCB);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winUnoverrideURLButton(HWND hwnd, int id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
WNDPROC origCB;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, 0);
|
|
|
|
if (origCB)
|
|
|
|
SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_WNDPROC, (LONG_PTR) origCB);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Center a dialog window in the desktop window
|
2010-07-27 13:02:24 -06:00
|
|
|
* and set small and large icons to X icons.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
winInitDialog(HWND hwndDlg)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
HWND hwndDesk;
|
|
|
|
RECT rc, rcDlg, rcDesk;
|
|
|
|
HICON hIcon, hIconSmall;
|
|
|
|
|
|
|
|
hwndDesk = GetParent(hwndDlg);
|
|
|
|
if (!hwndDesk || IsIconic(hwndDesk))
|
|
|
|
hwndDesk = GetDesktopWindow();
|
|
|
|
|
|
|
|
/* Remove minimize and maximize buttons */
|
|
|
|
SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE)
|
|
|
|
& ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
|
|
|
|
|
|
|
|
/* Set Window not to show in the task bar */
|
|
|
|
SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
|
|
|
|
GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);
|
|
|
|
|
|
|
|
/* Center dialog window in the screen. Not done for multi-monitor systems, where
|
|
|
|
* it is likely to end up split across the screens. In that case, it appears
|
|
|
|
* near the Tray icon.
|
|
|
|
*/
|
|
|
|
if (GetSystemMetrics(SM_CMONITORS) > 1) {
|
|
|
|
/* Still need to refresh the frame change. */
|
|
|
|
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GetWindowRect(hwndDesk, &rcDesk);
|
|
|
|
GetWindowRect(hwndDlg, &rcDlg);
|
|
|
|
CopyRect(&rc, &rcDesk);
|
|
|
|
|
|
|
|
OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
|
|
|
|
OffsetRect(&rc, -rc.left, -rc.top);
|
|
|
|
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
|
|
|
|
|
|
|
|
SetWindowPos(hwndDlg,
|
|
|
|
HWND_TOPMOST,
|
|
|
|
rcDesk.left + (rc.right / 2),
|
|
|
|
rcDesk.top + (rc.bottom / 2),
|
|
|
|
0, 0, SWP_NOSIZE | SWP_FRAMECHANGED);
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#ifdef XWIN_MULTIWINDOW
|
2012-06-10 07:21:05 -06:00
|
|
|
if (g_hIconX)
|
|
|
|
hIcon = g_hIconX;
|
|
|
|
else
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#ifdef XWIN_MULTIWINDOW
|
2012-06-10 07:21:05 -06:00
|
|
|
if (g_hSmallIconX)
|
|
|
|
hIconSmall = g_hSmallIconX;
|
|
|
|
else
|
2010-07-27 13:02:24 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
hIconSmall = LoadImage(g_hInstance,
|
|
|
|
MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON),
|
|
|
|
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
PostMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
|
|
|
|
PostMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Display the Exit dialog box
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
winDisplayExitDialog(winPrivScreenPtr pScreenPriv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
int liveClients = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Count up running clients (clients[0] is serverClient) */
|
|
|
|
for (i = 1; i < currentMaxClients; i++)
|
|
|
|
if (clients[i] != NullClient)
|
|
|
|
liveClients++;
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(XWIN_MULTIWINDOW)
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Count down server internal clients */
|
|
|
|
if (pScreenPriv->pScreenInfo->fMultiWindow)
|
|
|
|
liveClients -= 2; /* multiwindow window manager & XMsgProc */
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
#if defined(XWIN_CLIPBOARD)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (g_fClipboardStarted)
|
|
|
|
liveClients--; /* clipboard manager */
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* A user reported that this sometimes drops below zero. just eye-candy. */
|
|
|
|
if (liveClients < 0)
|
|
|
|
liveClients = 0;
|
|
|
|
|
|
|
|
/* Don't show the exit confirmation dialog if SilentExit & no clients,
|
|
|
|
or ForceExit, is enabled */
|
|
|
|
if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit) {
|
|
|
|
if (g_hDlgExit != NULL) {
|
|
|
|
DestroyWindow(g_hDlgExit);
|
|
|
|
g_hDlgExit = NULL;
|
|
|
|
}
|
|
|
|
PostMessage(pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreenPriv->iConnectedClients = liveClients;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Check if dialog already exists */
|
|
|
|
if (g_hDlgExit != NULL) {
|
|
|
|
/* Dialog box already exists, display it */
|
|
|
|
ShowWindow(g_hDlgExit, SW_SHOWDEFAULT);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* User has lost the dialog. Show them where it is. */
|
|
|
|
SetForegroundWindow(g_hDlgExit);
|
|
|
|
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Create dialog box */
|
|
|
|
g_hDlgExit = CreateDialogParam(g_hInstance,
|
|
|
|
"EXIT_DIALOG",
|
|
|
|
pScreenPriv->hwndScreen,
|
|
|
|
winExitDlgProc, (int) pScreenPriv);
|
|
|
|
|
|
|
|
/* Show the dialog box */
|
|
|
|
ShowWindow(g_hDlgExit, SW_SHOW);
|
|
|
|
|
|
|
|
/* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
|
|
|
|
SetForegroundWindow(g_hDlgExit);
|
|
|
|
|
|
|
|
/* Set focus to the Cancel button */
|
|
|
|
PostMessage(g_hDlgExit, WM_NEXTDLGCTL,
|
|
|
|
(WPARAM) GetDlgItem(g_hDlgExit, IDCANCEL), TRUE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#define CONNECTED_CLIENTS_FORMAT "There %s currently %d client%s connected."
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Exit dialog window procedure
|
|
|
|
*/
|
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static winPrivScreenPtr s_pScreenPriv = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Branch on message type */
|
|
|
|
switch (message) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case WM_INITDIALOG:
|
2012-06-10 07:21:05 -06:00
|
|
|
{
|
|
|
|
char *pszConnectedClients;
|
|
|
|
|
|
|
|
/* Store pointers to private structures for future use */
|
|
|
|
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
|
|
|
|
|
|
|
winInitDialog(hDialog);
|
|
|
|
|
|
|
|
/* Format the connected clients string */
|
|
|
|
if (asprintf(&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
|
|
|
|
(s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
|
|
|
|
s_pScreenPriv->iConnectedClients,
|
|
|
|
(s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* Set the number of connected clients */
|
|
|
|
SetWindowText(GetDlgItem(hDialog, IDC_CLIENTS_CONNECTED),
|
|
|
|
pszConnectedClients);
|
|
|
|
free(pszConnectedClients);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
/* Send message to call the GiveUp function */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
|
|
|
|
DestroyWindow(g_hDlgExit);
|
|
|
|
g_hDlgExit = NULL;
|
|
|
|
|
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
|
|
|
DestroyWindow(g_hDlgExit);
|
|
|
|
g_hDlgExit = NULL;
|
|
|
|
|
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_NCMOUSEMOVE:
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Show the cursor if it is hidden */
|
|
|
|
if (g_fSoftwareCursor && !g_fCursor) {
|
|
|
|
g_fCursor = TRUE;
|
|
|
|
ShowCursor(TRUE);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
2012-06-10 07:21:05 -06:00
|
|
|
DestroyWindow(g_hDlgExit);
|
|
|
|
g_hDlgExit = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display the Depth Change dialog box
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Check if dialog already exists */
|
|
|
|
if (g_hDlgDepthChange != NULL) {
|
|
|
|
/* Dialog box already exists, display it */
|
|
|
|
ShowWindow(g_hDlgDepthChange, SW_SHOWDEFAULT);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* User has lost the dialog. Show them where it is. */
|
|
|
|
SetForegroundWindow(g_hDlgDepthChange);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Display a notification to the user that the visual
|
|
|
|
* will not be displayed until the Windows display depth
|
|
|
|
* is restored to the original value.
|
|
|
|
*/
|
|
|
|
g_hDlgDepthChange = CreateDialogParam(g_hInstance,
|
|
|
|
"DEPTH_CHANGE_BOX",
|
|
|
|
pScreenPriv->hwndScreen,
|
|
|
|
winChangeDepthDlgProc,
|
|
|
|
(int) pScreenPriv);
|
|
|
|
/* Show the dialog box */
|
|
|
|
ShowWindow(g_hDlgDepthChange, SW_SHOW);
|
|
|
|
|
|
|
|
ErrorF("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
|
|
|
|
(int) g_hDlgDepthChange);
|
|
|
|
ErrorF("winDisplayDepthChangeDialog - GetLastError: %d\n",
|
|
|
|
(int) GetLastError());
|
|
|
|
|
|
|
|
/* Minimize the display window */
|
|
|
|
ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process messages for the dialog that is displayed for
|
|
|
|
* disruptive screen depth changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winChangeDepthDlgProc(HWND hwndDialog, UINT message,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static winPrivScreenPtr s_pScreenPriv = NULL;
|
|
|
|
static winScreenInfo *s_pScreenInfo = NULL;
|
|
|
|
static ScreenPtr s_pScreen = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winChangeDepthDlgProc\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Branch on message type */
|
|
|
|
switch (message) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_INITDIALOG\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Store pointers to private structures for future use */
|
|
|
|
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
|
|
|
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
|
|
|
|
s_pScreen = s_pScreenInfo->pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
|
|
|
|
"s_pScreenInfo: %08x, s_pScreen: %08x\n",
|
|
|
|
s_pScreenPriv, s_pScreenInfo, s_pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
|
|
|
|
"current bpp: %d\n",
|
|
|
|
s_pScreenInfo->dwBPP,
|
|
|
|
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
winInitDialog(hwndDialog);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_DISPLAYCHANGE:
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
|
|
|
|
"new bpp: %d\n",
|
|
|
|
s_pScreenInfo->dwBPP,
|
|
|
|
GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Dismiss the dialog if the display returns to the original depth */
|
|
|
|
if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) ==
|
|
|
|
s_pScreenInfo->dwBPP) {
|
|
|
|
ErrorF("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Depth has been restored, dismiss dialog */
|
|
|
|
DestroyWindow(g_hDlgDepthChange);
|
|
|
|
g_hDlgDepthChange = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Flag that we have a valid screen depth */
|
|
|
|
s_pScreenPriv->fBadDepth = FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
2013-06-07 11:28:45 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* User dismissed the dialog, hide it until the
|
|
|
|
* display mode is restored.
|
|
|
|
*/
|
|
|
|
ShowWindow(g_hDlgDepthChange, SW_HIDE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
2013-06-07 11:28:45 -06:00
|
|
|
winDebug("winChangeDepthDlgProc - WM_CLOSE\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DestroyWindow(g_hDlgAbout);
|
|
|
|
g_hDlgAbout = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display the About dialog box
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
winDisplayAboutDialog(winPrivScreenPtr pScreenPriv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Check if dialog already exists */
|
|
|
|
if (g_hDlgAbout != NULL) {
|
|
|
|
/* Dialog box already exists, display it */
|
|
|
|
ShowWindow(g_hDlgAbout, SW_SHOWDEFAULT);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* User has lost the dialog. Show them where it is. */
|
|
|
|
SetForegroundWindow(g_hDlgAbout);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*
|
|
|
|
* Display the about box
|
|
|
|
*/
|
|
|
|
g_hDlgAbout = CreateDialogParam(g_hInstance,
|
|
|
|
"ABOUT_BOX",
|
|
|
|
pScreenPriv->hwndScreen,
|
|
|
|
winAboutDlgProc, (int) pScreenPriv);
|
|
|
|
|
|
|
|
/* Show the dialog box */
|
|
|
|
ShowWindow(g_hDlgAbout, SW_SHOW);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
|
|
|
|
SetForegroundWindow(g_hDlgAbout);
|
|
|
|
|
|
|
|
/* Set focus to the OK button */
|
|
|
|
PostMessage(g_hDlgAbout, WM_NEXTDLGCTL,
|
|
|
|
(WPARAM) GetDlgItem(g_hDlgAbout, IDOK), TRUE);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Process messages for the about dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static wBOOL CALLBACK
|
2012-06-10 07:21:05 -06:00
|
|
|
winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static winPrivScreenPtr s_pScreenPriv = NULL;
|
|
|
|
static winScreenInfo *s_pScreenInfo = NULL;
|
|
|
|
static ScreenPtr s_pScreen = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winAboutDlgProc\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Branch on message type */
|
|
|
|
switch (message) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case WM_INITDIALOG:
|
|
|
|
#if CYGDEBUG
|
2012-06-10 07:21:05 -06:00
|
|
|
winDebug("winAboutDlgProc - WM_INITDIALOG\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Store pointers to private structures for future use */
|
|
|
|
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
|
|
|
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
|
|
|
|
s_pScreen = s_pScreenInfo->pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
winInitDialog(hwndDialog);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Override the URL buttons */
|
|
|
|
winOverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
|
|
|
|
winOverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
|
|
|
winOverrideURLButton(hwndDialog, ID_ABOUT_UG);
|
|
|
|
winOverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_DRAWITEM:
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Draw the URL buttons as needed */
|
|
|
|
winDrawURLWindow(lParam);
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_NCMOUSEMOVE:
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Show the cursor if it is hidden */
|
|
|
|
if (g_fSoftwareCursor && !g_fCursor) {
|
|
|
|
g_fCursor = TRUE;
|
|
|
|
ShowCursor(TRUE);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDOK:
|
|
|
|
case IDCANCEL:
|
2013-06-07 11:28:45 -06:00
|
|
|
winDebug("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
DestroyWindow(g_hDlgAbout);
|
|
|
|
g_hDlgAbout = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Restore window procedures for URL buttons */
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_UG);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
case ID_ABOUT_CHANGELOG:
|
|
|
|
{
|
|
|
|
int iReturn;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef __CYGWIN__
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *pszCygPath = "/usr/X11R6/share/doc/"
|
|
|
|
"xorg-x11-xwin/changelog.html";
|
|
|
|
char pszWinPath[MAX_PATH + 1];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Convert the POSIX path to a Win32 path */
|
|
|
|
cygwin_conv_to_win32_path(pszCygPath, pszWinPath);
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *pszWinPath = "http://x.cygwin.com/"
|
|
|
|
"devel/server/changelog.html";
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
iReturn = (int) ShellExecute(NULL,
|
|
|
|
"open",
|
|
|
|
pszWinPath, NULL, NULL, SW_MAXIMIZE);
|
|
|
|
if (iReturn < 32) {
|
|
|
|
ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
|
|
|
|
"ShellExecute failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case ID_ABOUT_WEBSITE:
|
|
|
|
{
|
|
|
|
const char *pszPath = __VENDORDWEBSUPPORT__;
|
|
|
|
int iReturn;
|
|
|
|
|
|
|
|
iReturn = (int) ShellExecute(NULL,
|
|
|
|
"open",
|
|
|
|
pszPath, NULL, NULL, SW_MAXIMIZE);
|
|
|
|
if (iReturn < 32) {
|
|
|
|
ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
|
|
|
|
"ShellExecute failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case ID_ABOUT_UG:
|
|
|
|
{
|
|
|
|
const char *pszPath = "http://x.cygwin.com/docs/ug/";
|
|
|
|
int iReturn;
|
|
|
|
|
|
|
|
iReturn = (int) ShellExecute(NULL,
|
|
|
|
"open",
|
|
|
|
pszPath, NULL, NULL, SW_MAXIMIZE);
|
|
|
|
if (iReturn < 32) {
|
|
|
|
ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
|
|
|
|
"ShellExecute failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case ID_ABOUT_FAQ:
|
|
|
|
{
|
|
|
|
const char *pszPath = "http://x.cygwin.com/docs/faq/";
|
|
|
|
int iReturn;
|
|
|
|
|
|
|
|
iReturn = (int) ShellExecute(NULL,
|
|
|
|
"open",
|
|
|
|
pszPath, NULL, NULL, SW_MAXIMIZE);
|
|
|
|
if (iReturn < 32) {
|
|
|
|
ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
|
|
|
|
"ShellExecute failed: %d\n", iReturn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
2013-06-07 11:28:45 -06:00
|
|
|
winDebug("winAboutDlgProc - WM_CLOSE\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DestroyWindow(g_hDlgAbout);
|
|
|
|
g_hDlgAbout = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Fix to make sure keyboard focus isn't trapped */
|
|
|
|
PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Restore window procedures for URL buttons */
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_UG);
|
|
|
|
winUnoverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|