mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
1b7cff4755
2002-01-10 Tor Lillqvist <tml@iki.fi> Apply the same fixes and improvements as to the gtk-1-3-win32-production branch: Bug fixes and cleanup of selection and DND functionality. Still doesn't work as well as the win32-production branch, though, but getting closer. After this, need to add Archaeopteryx Software's OLE2 DND support. * gdk/win32/gdkselection-win32.c (gdk_selection_owner_set, gdk_selection_send_notify, generate_selection_notify): Don't use SendMessage() to generate events for the same app, instead use gdk_event_put(). * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c * gdk/win32/gdkmain-win32.c * gdk/win32/gdkevents-win32.c: Thus, remove declaration, definition, initialisation and handling of gdk_selection_notify_msg, gdk_selection_request_msg and gdk_selection_clear_msg. * gdk/win32/gdkselection-win32.c (gdk_text_property_to_text_list, gdk_free_text_list, gdk_string_to_compound_text, gdk_free_compound_text): Implement trivially, witrh a text_list always having a single element, and a compound text always consisting of just a single (UTF-8!) string. Let's see how well this works. * gdk/win32/gdkselection-win32.c (gdk_selection_convert): Fix non-ASCII paste from the clipboard: Try getting the same formats from the Windows clipboard that gdk_property_change() puts there: CF_UNICODETEXT, UTF8_STRING or CF_TEXT+CF_LOCALE. * gdk/win32/gdkproperty-win32.c (gdk_property_change): When storing text on the clipboard, handle non-ASCII text correctly. The logic is as follows: If we have only ASCII characters, use CF_TEXT. Else, if we are on NT, use CF_UNICODETEXT. Else (we are on Win9x), if all the characters are present in the code page of some installed locale, use CF_TEXT and also set CF_LOCALE to that locale. Else (still on Win9x) store as RTF. We use a very simple RTF string, just the text, no fonts or other crap, with the non-ASCII characters as Unicode \uN keywords. Additionally, also store the UTF-8 string as such, under the format "UTF8_STRING", so that GDK can also paste from the Clipboard what it has copied there. (Thus no need to implement any RTF parser.) (find_common_locale): New function, implements the search for a locale for case 3 above. * gdk/win32/gdkglobals-win32.c: New global variables compound_text, text_uri_list, utf8_string, cf_rtf and cf_utf8_string. * gdk/win32/gdkim-win32.c (_gdk_ucs2_to_utf8): New function, converts from a wchar_t string to UTF-8. (_gdk_utf8_to_ucs2): Rename from _gdk_win32_nmbstowchar_ts. (_gdk_utf8_to_wcs): Rename from gdk_nmbstowchar_ts. * gdk/win32/gdkevents-win32.c (build_keypress_event): Use _gdk_ucs2_to_utf8(). * gdk/win32/gdkselection-win32.c: Remove some unnecessary logging. * gdk/win32/gdkdnd-win32.c: Plug memory leaks, the gdk_drag_context_ref() was called unnecessarily in a couple of places, meaning drag contexts were never freed. The same memory leaks seem to be present in gdk/linux-fb/gdkselection-fb.c, BTW. (gdk_drop_reply): For WIN32_DROPFILES drops, free the temporarily stored file list. * gdk/win32/gdkselection-win32.c: Clarify the use of the sel_prop_table. Now it is used only for storing the GDK_SELECTION "properties". The file names dropped with WM_DROPFILES -style DND is stored temporarily (between the drop and the target picking them up) in a separate place. Have a separate hash table to map selection atoms to owner windows. This used to be quite mixed up. (_gdk_dropfiles_store): New function, to store the dropped file list for the drop target to possibly fetch, and clear it afterwards, from gdk_drop_reply(). (gdk_selection_owner_get): Much simplified now.
261 lines
5.7 KiB
C
261 lines
5.7 KiB
C
/* GDK - The GIMP Drawing Kit
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
* Copyright (C) 1998-1999 Tor Lillqvist
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
/*
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
* files for a list of changes. These files are distributed with
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
#include <io.h>
|
|
|
|
#include "gdk.h"
|
|
#include "gdkkeysyms.h"
|
|
#include "gdkinternals.h"
|
|
#include "gdkprivate-win32.h"
|
|
#include "gdkinput-win32.h"
|
|
|
|
#include <objbase.h>
|
|
|
|
static gboolean gdk_synchronize = FALSE;
|
|
|
|
GdkArgDesc _gdk_windowing_args[] = {
|
|
{ "sync", GDK_ARG_BOOL, &gdk_synchronize, (GdkArgFunc) NULL},
|
|
{ "no-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
|
|
(GdkArgFunc) NULL},
|
|
{ "ignore-wintab", GDK_ARG_BOOL, &gdk_input_ignore_wintab,
|
|
(GdkArgFunc) NULL},
|
|
{ "event-func-from-window-proc",
|
|
GDK_ARG_BOOL, &gdk_event_func_from_window_proc,
|
|
(GdkArgFunc) NULL},
|
|
{ NULL }
|
|
};
|
|
|
|
int __stdcall
|
|
DllMain(HINSTANCE hinstDLL,
|
|
DWORD dwReason,
|
|
LPVOID reserved)
|
|
{
|
|
gdk_dll_hinstance = hinstDLL;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
gboolean
|
|
_gdk_windowing_init_check (int argc,
|
|
char **argv)
|
|
{
|
|
#ifdef HAVE_WINTAB
|
|
if (getenv ("GDK_IGNORE_WINTAB") != NULL)
|
|
gdk_input_ignore_wintab = TRUE;
|
|
#endif
|
|
if (getenv ("GDK_EVENT_FUNC_FROM_WINDOW_PROC") != NULL)
|
|
gdk_event_func_from_window_proc = TRUE;
|
|
|
|
if (gdk_synchronize)
|
|
GdiSetBatchLimit (1);
|
|
|
|
gdk_app_hmodule = GetModuleHandle (NULL);
|
|
gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
|
|
gdk_root_window = GetDesktopWindow ();
|
|
windows_version = GetVersion ();
|
|
|
|
CoInitialize (NULL);
|
|
|
|
cf_rtf = RegisterClipboardFormat ("Rich Text Format");
|
|
cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
|
|
|
|
utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
|
|
compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
|
|
text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
|
|
|
|
local_dnd = gdk_atom_intern ("LocalDndSelection", FALSE);
|
|
gdk_win32_dropfiles = gdk_atom_intern ("DROPFILES_DND", FALSE);
|
|
gdk_ole2_dnd = gdk_atom_intern ("OLE2_DND", FALSE);
|
|
|
|
_gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
|
|
|
|
_gdk_win32_selection_init ();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
gdk_win32_api_failed (const gchar *where,
|
|
gint line,
|
|
const gchar *api)
|
|
{
|
|
gchar *msg = g_win32_error_message (GetLastError ());
|
|
g_warning ("%s:%d: %s failed: %s", where, line, api, msg);
|
|
g_free (msg);
|
|
}
|
|
|
|
void
|
|
gdk_other_api_failed (const gchar *where,
|
|
gint line,
|
|
const gchar *api)
|
|
{
|
|
g_warning ("%s:%d: %s failed", where, line, api);
|
|
}
|
|
|
|
void
|
|
gdk_win32_gdi_failed (const gchar *where,
|
|
gint line,
|
|
const gchar *api)
|
|
{
|
|
/* On Win9x GDI calls are implemented in 16-bit code and thus
|
|
* don't set the 32-bit error code, sigh.
|
|
*/
|
|
if (IS_WIN_NT ())
|
|
gdk_win32_api_failed (where, line, api);
|
|
else
|
|
gdk_other_api_failed (where, line, api);
|
|
}
|
|
|
|
void
|
|
gdk_set_use_xshm (gboolean use_xshm)
|
|
{
|
|
/* Always on */
|
|
}
|
|
|
|
gboolean
|
|
gdk_get_use_xshm (void)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_width
|
|
*
|
|
* Return the width of the screen.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_width (void)
|
|
{
|
|
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->width;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_height
|
|
*
|
|
* Return the height of the screen.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_height (void)
|
|
{
|
|
return GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (_gdk_parent_root)->impl)->height;
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_width_mm
|
|
*
|
|
* Return the width of the screen in millimetres.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_width_mm (void)
|
|
{
|
|
return GetDeviceCaps (gdk_display_hdc, HORZSIZE);
|
|
}
|
|
|
|
/*
|
|
*--------------------------------------------------------------
|
|
* gdk_screen_height
|
|
*
|
|
* Return the height of the screen in millimetres.
|
|
*
|
|
* Arguments:
|
|
*
|
|
* Results:
|
|
*
|
|
* Side effects:
|
|
*
|
|
*--------------------------------------------------------------
|
|
*/
|
|
|
|
gint
|
|
gdk_screen_height_mm (void)
|
|
{
|
|
return GetDeviceCaps (gdk_display_hdc, VERTSIZE);
|
|
}
|
|
|
|
void
|
|
gdk_set_sm_client_id (const gchar* sm_client_id)
|
|
{
|
|
g_warning("gdk_set_sm_client_id %s", sm_client_id ? sm_client_id : "NULL");
|
|
}
|
|
|
|
void
|
|
gdk_beep (void)
|
|
{
|
|
Beep(1000, 50);
|
|
}
|
|
|
|
void
|
|
_gdk_windowing_exit (void)
|
|
{
|
|
_gdk_win32_dnd_exit ();
|
|
CoUninitialize ();
|
|
DeleteDC (gdk_display_hdc);
|
|
gdk_display_hdc = NULL;
|
|
}
|
|
|
|
gchar *
|
|
gdk_get_display (void)
|
|
{
|
|
return "Win32";
|
|
}
|