[gtk/debug-envvars-cleanup] wip: win32: Use the new debug macros



commit c7e10f171943bec103cf8ee380879a34a16d5d00
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 22 21:37:53 2022 -0400

    wip: win32: Use the new debug macros

 gdk/win32/gdkclipboard-win32.c     |  4 +-
 gdk/win32/gdkclipdrop-win32.c      | 61 +++++++++---------------------
 gdk/win32/gdkdevicemanager-win32.c | 76 ++++++++++++++++++--------------------
 3 files changed, 54 insertions(+), 87 deletions(-)
---
diff --git a/gdk/win32/gdkclipboard-win32.c b/gdk/win32/gdkclipboard-win32.c
index ce80019e56..cee91ed61f 100644
--- a/gdk/win32/gdkclipboard-win32.c
+++ b/gdk/win32/gdkclipboard-win32.c
@@ -188,7 +188,7 @@ gdk_win32_clipboard_store_async (GdkClipboard        *clipboard,
 
   if (content == NULL)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("storing empty clipboard: SUCCESS!\n"));
+      GDK_DEBUG (CLIPBOARD, "storing empty clipboard: SUCCESS!");
       g_task_return_boolean (store_task, TRUE);
       g_clear_object (&store_task);
       return;
@@ -199,7 +199,7 @@ gdk_win32_clipboard_store_async (GdkClipboard        *clipboard,
 
   if (!_gdk_win32_store_clipboard_contentformats (clipboard, store_task, formats))
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("clipdrop says there's nothing to store: SUCCESS!\n"));
+      GDK_DEBUG (CLIPBOARD, "clipdrop says there's nothing to store: SUCCESS!");
       g_task_return_boolean (store_task, TRUE);
       g_clear_object (&store_task);
 
diff --git a/gdk/win32/gdkclipdrop-win32.c b/gdk/win32/gdkclipdrop-win32.c
index ec15f0fabd..0465d075cb 100644
--- a/gdk/win32/gdkclipdrop-win32.c
+++ b/gdk/win32/gdkclipdrop-win32.c
@@ -528,7 +528,7 @@ clipboard_render_hdata_ready (GObject      *clipboard,
     {
       HANDLE handle;
       gboolean is_hdata;
-      GDK_NOTE(CLIPBOARD, g_printerr ("%p: failed to write HData-backed stream: %s\n", clipboard, 
error->message));
+      GDK_DEBUG (CLIPBOARD, "%p: failed to write HData-backed stream: %s", clipboard, error->message);
       g_error_free (error);
       g_output_stream_close (G_OUTPUT_STREAM (render_and_stream.stream), NULL, NULL);
       handle = gdk_win32_hdata_output_stream_get_handle (render_and_stream.stream, &is_hdata);
@@ -564,7 +564,7 @@ clipboard_render (gpointer user_data)
 
   if (stream == NULL)
     {
-      GDK_NOTE (SELECTION, g_printerr ("%p: failed create a HData-backed stream: %s\n", clipboard, 
error->message));
+      GDK_DEBUG (SELECTION, "%p: failed create a HData-backed stream: %s", clipboard, error->message);
       g_error_free (error);
       render->main_thread_data_handle = NULL;
       g_async_queue_push (clipdrop->clipboard_render_queue, render);
@@ -714,7 +714,7 @@ process_advertise (GdkWin32ClipboardThreadAdvertise *adv)
 
   if (g_get_monotonic_time () > adv->parent.end_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("An advertise task timed out\n"));
+      GDK_DEBUG (CLIPBOARD, "An advertise task timed out");
       send_response (adv->parent.item_type,
                      adv->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -724,7 +724,7 @@ process_advertise (GdkWin32ClipboardThreadAdvertise *adv)
 
   if (clipboard_thread_data->owner_change_time > adv->parent.start_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("An advertise task timed out due to ownership change\n"));
+      GDK_DEBUG (CLIPBOARD, "An advertise task timed out due to ownership change\n");
       send_response (adv->parent.item_type,
                      adv->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -793,7 +793,7 @@ process_store (GdkWin32ClipboardThreadStore *store)
 
   if (g_get_monotonic_time () > store->parent.end_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("A store task timed out\n"));
+      GDK_DEBUG (CLIPBOARD, g_printerr ("A store task timed out");
       send_response (store->parent.item_type,
                      store->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -803,7 +803,7 @@ process_store (GdkWin32ClipboardThreadStore *store)
 
   if (clipboard_thread_data->owner_change_time > store->parent.start_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("A store task timed out due to ownership change\n"));
+      GDK_DEBUG (CLIPBOARD, "A store task timed out due to ownership change");
       send_response (store->parent.item_type,
                      store->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -925,7 +925,7 @@ process_retrieve (GdkWin32ClipboardThreadRetrieve *retr)
 
   if (g_get_monotonic_time () > retr->parent.end_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("A retrieve task timed out\n"));
+      GDK_DEBUG (CLIPBOARD, "A retrieve task timed out");
       send_response (retr->parent.item_type,
                      retr->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -935,7 +935,7 @@ process_retrieve (GdkWin32ClipboardThreadRetrieve *retr)
 
   if (clipboard_thread_data->owner_change_time > retr->parent.start_time)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("A retrieve task timed out due to ownership change\n"));
+      GDK_DEBUG (CLIPBOARD, "A retrieve task timed out due to ownership change");
       send_response (retr->parent.item_type,
                      retr->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -945,7 +945,7 @@ process_retrieve (GdkWin32ClipboardThreadRetrieve *retr)
 
   if (GetClipboardSequenceNumber () > retr->sequence_number)
     {
-      GDK_NOTE (CLIPBOARD, g_printerr ("A retrieve task timed out due to data change\n"));
+      GDK_DEBUG (CLIPBOARD, "A retrieve task timed out due to data change");
       send_response (retr->parent.item_type,
                      retr->parent.opaque_task,
                      g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -1032,8 +1032,8 @@ process_retrieve (GdkWin32ClipboardThreadRetrieve *retr)
   stream = g_memory_input_stream_new_from_data (data, data_len, g_free);
   g_object_set_data (G_OBJECT (stream), "gdk-clipboard-stream-contenttype", (gpointer) pair->contentformat);
 
-  GDK_NOTE (CLIPBOARD, g_printerr ("reading clipboard data from a %" G_GSIZE_FORMAT "-byte buffer\n",
-                                   data_len));
+  GDK_DEBUG (CLIPBOARD, "reading clipboard data from a %" G_GSIZE_FORMAT "-byte buffer",
+                        data_len);
   send_input_stream (retr->parent.item_type,
                      retr->parent.opaque_task,
                      stream);
@@ -1226,32 +1226,7 @@ inner_clipboard_window_procedure (HWND   hwnd,
 
         hwnd_opener = GetOpenClipboardWindow ();
 
-        GDK_NOTE (DND, g_print (" drawclipboard owner: %p; opener %p ", hwnd_owner, hwnd_opener));
-
-#ifdef G_ENABLE_DEBUG
-        if (_gdk_debug_flags & GDK_DEBUG_DND)
-          {
-            /* FIXME: grab and print clipboard formats without opening the clipboard
-            if (clipboard_thread_data->clipboard_opened_for != INVALID_HANDLE_VALUE ||
-                OpenClipboard (hwnd))
-              {
-                UINT nFormat = 0;
-
-                while ((nFormat = EnumClipboardFormats (nFormat)) != 0)
-                  g_print ("%s ", _gdk_win32_cf_to_string (nFormat));
-
-                if (clipboard_thread_data->clipboard_opened_for == INVALID_HANDLE_VALUE)
-                  CloseClipboard ();
-              }
-            else
-              {
-                WIN32_API_FAILED ("OpenClipboard");
-              }
-             */
-          }
-#endif
-
-        GDK_NOTE (DND, g_print (" \n"));
+        GDK_DEBUG (DND, " drawclipboard owner: %p; opener %p", hwnd_owner, hwnd_opener);
 
         if (clipboard_thread_data->stored_hwnd_owner != hwnd_owner)
           {
@@ -1416,11 +1391,9 @@ _clipboard_window_procedure (HWND   hwnd,
 {
   LRESULT retval;
 
-  GDK_NOTE (EVENTS, g_print ("clipboard thread %s %p",
-                            _gdk_win32_message_to_string (message), hwnd));
   retval = inner_clipboard_window_procedure (hwnd, message, wparam, lparam);
-
-  GDK_NOTE (EVENTS, g_print (" => %" G_GINT64_FORMAT "\n", (gint64) retval));
+  GDK_DEBUG (EVENTS, "clipboard thread %s %p => %" G_GINT64_FORMAT,
+                     _gdk_win32_message_to_string (message), hwnd, (guint64) retval);
 
   return retval;
 }
@@ -2029,7 +2002,7 @@ _gdk_win32_add_w32format_to_pairs (UINT                      w32format,
   if (w32format_name != NULL)
     {
       interned_w32format_name = _gdk_win32_get_clipboard_format_name_as_interned_mimetype (w32format_name);
-      GDK_NOTE (DND, g_print ("Maybe add as-is format %s (%s) (0x%p)\n", w32format_name, 
interned_w32format_name, interned_w32format_name));
+      GDK_DEBUG (DND, "Maybe add as-is format %s (%s) (0x%p)", w32format_name, interned_w32format_name, 
interned_w32format_name);
       g_free (w32format_name);
 
       if (pairs && interned_w32format_name != 0)
@@ -2734,7 +2707,7 @@ _gdk_win32_add_contentformat_to_pairs (const char *contentformat,
     offset = 0;
 
   fmt.w32format = RegisterClipboardFormatW (&contentformat_w[offset]);
-  GDK_NOTE (DND, g_print ("Registered clipboard format %S as 0x%x\n", &contentformat_w[offset], 
fmt.w32format));
+  GDK_DEBUG (DND, "Registered clipboard format %S as 0x%x", &contentformat_w[offset], fmt.w32format);
   g_free (contentformat_w);
   fmt.contentformat = contentformat;
   fmt.transmute = FALSE;
@@ -2863,7 +2836,7 @@ clipboard_store_hdata_ready (GObject      *clipboard,
       HANDLE handle;
       gboolean is_hdata;
 
-      GDK_NOTE(CLIPBOARD, g_printerr ("Failed to write stream: %s\n", error->message));
+      GDK_DEBUG (CLIPBOARD, "Failed to write stream: %s", error->message);
       g_error_free (error);
       for (i = 0; i < prep->elements->len; i++)
         free_prep_element (&g_array_index (prep->elements, GdkWin32ClipboardStorePrepElement, i));
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index e5becd265f..047a42ab5d 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -418,13 +418,11 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
     return;
 
   (*p_WTInfoA) (WTI_INTERFACE, IFC_SPECVERSION, &specversion);
-  GDK_NOTE (INPUT, g_print ("Wintab interface version %d.%d\n",
-                           HIBYTE (specversion), LOBYTE (specversion)));
+  GDK_DEBUG (INPUT, "Wintab interface version %d.%d", HIBYTE (specversion), LOBYTE (specversion));
   (*p_WTInfoA) (WTI_INTERFACE, IFC_NDEVICES, &ndevices);
   (*p_WTInfoA) (WTI_INTERFACE, IFC_NCURSORS, &ncursors);
 #if DEBUG_WINTAB
-  GDK_NOTE (INPUT, g_print ("NDEVICES: %d, NCURSORS: %d\n",
-                           ndevices, ncursors));
+  GDK_DEBUG (INPUT, "NDEVICES: %d, NCURSORS: %d", ndevices, ncursors);
 #endif
   /* Create a dummy window to receive wintab events */
   wintab_window =
@@ -448,7 +446,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
       (*p_WTInfoW) (WTI_DEVICES + devix, DVC_NAME, devname);
       devname_utf8 = g_utf16_to_utf8 (devname, -1, NULL, NULL, NULL);
 #ifdef DEBUG_WINTAB
-      GDK_NOTE (INPUT, (g_print("Device %u: %s\n", devix, devname_utf8)));
+      GDK_DEBUG (INPUT, "Device %u: %s", devix, devname_utf8);
 #endif
       (*p_WTInfoA) (WTI_DEVICES + devix, DVC_NCSRTYPES, &ncsrtypes);
       (*p_WTInfoA) (WTI_DEVICES + devix, DVC_FIRSTCSR, &firstcsr);
@@ -467,16 +465,16 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
             defcontext_done = TRUE;
 #if DEBUG_WINTAB
           if (defcontext_done)
-            GDK_NOTE (INPUT, (g_print("Using device-specific default context\n")));
+            GDK_DEBUG (INPUT, "Using device-specific default context");
           else
-            GDK_NOTE (INPUT, (g_print("Note: Driver did not provide device specific default context info 
despite claiming to support version 1.1\n")));
+            GDK_DEBUG (INPUT, "Note: Driver did not provide device specific default context info despite 
claiming to support version 1.1");
 #endif
         }
 
       if (!defcontext_done)
         (*p_WTInfoA) (WTI_DEFSYSCTX, 0, &lc);
 #if DEBUG_WINTAB
-      GDK_NOTE (INPUT, (g_print("Default context:\n"), print_lc(&lc)));
+      GDK_NOTE(INPUT, gdk_debug_message ("Default context:"); print_lc (&lc));
 #endif
       lc.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;
       lc.lcStatus = 0;
@@ -492,8 +490,8 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
       lc.lcOutExtY = axis_y.axMax - axis_y.axMin + 1;
       lc.lcOutExtY = -lc.lcOutExtY; /* We want Y growing downward */
 #if DEBUG_WINTAB
-      GDK_NOTE (INPUT, (g_print("context for device %u:\n", devix),
-                       print_lc(&lc)));
+      GDK_NOTE (INPUT, gdk_debug_message ("context for device %u:", devix);
+                       print_lc(&lc));
 #endif
       hctx = g_new (HCTX, 1);
       if ((*hctx = (*p_WTOpenA) (GDK_SURFACE_HWND (wintab_window), &lc, TRUE)) == NULL)
@@ -501,8 +499,7 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
           g_warning ("gdk_input_wintab_init: WTOpen failed");
           return;
         }
-      GDK_NOTE (INPUT, g_print ("opened Wintab device %u %p\n",
-                                devix, *hctx));
+      GDK_DEBUG (INPUT, "opened Wintab device %u %p", devix, *hctx);
 
       wintab_contexts = g_list_append (wintab_contexts, hctx);
 #if 0
@@ -511,28 +508,29 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
       (*p_WTOverlap) (*hctx, TRUE);
 
 #if DEBUG_WINTAB
-      GDK_NOTE (INPUT, (g_print("context for device %u after WTOpen:\n", devix),
-                       print_lc(&lc)));
+      GDK_NOTE (INPUT, gdk_debug_message ("context for device %u after WTOpen:", devix),
+                       print_lc(&lc));
 #endif
       /* Increase packet queue size to reduce the risk of lost packets.
        * According to the specs, if the function fails we must try again
        * with a smaller queue size.
        */
-      GDK_NOTE (INPUT, g_print("Attempting to increase queue size\n"));
+      GDK_DEBUG (INPUT, "Attempting to increase queue size");
       for (i = 128; i >= 1; i >>= 1)
         {
           if ((*p_WTQueueSizeSet) (*hctx, i))
             {
-              GDK_NOTE (INPUT, g_print("Queue size set to %d\n", i));
+              GDK_DEBUG (INPUT, "Queue size set to %d", i);
               break;
             }
         }
       if (!i)
-        GDK_NOTE (INPUT, g_print("Whoops, no queue size could be set\n"));
+        GDK_DEBUG (INPUT, "Whoops, no queue size could be set");
       for (cursorix = firstcsr; cursorix < firstcsr + ncsrtypes; cursorix++)
         {
 #ifdef DEBUG_WINTAB
-          GDK_NOTE (INPUT, (g_print("Cursor %u:\n", cursorix), print_cursor (cursorix)));
+          GDK_NOTE (INPUT, gdk_debug_message ("Cursor %u:", cursorix);
+                           print_cursor (cursorix));
 #endif
           active = FALSE;
           (*p_WTInfoA) (WTI_CURSORS + cursorix, CSR_ACTIVE, &active);
@@ -630,10 +628,8 @@ wintab_init_check (GdkDeviceManagerWin32 *device_manager)
 
           device->last_axis_data = g_new (int, num_axes);
 
-          GDK_NOTE (INPUT, g_print ("device: (%u) %s axes: %d\n",
-                                    cursorix,
-                                    device_name,
-                                    num_axes));
+          GDK_DEBUG (INPUT, "device: (%u) %s axes: %d",
+                            cursorix, device_name, num_axes);
 
 #if 0
           for (i = 0; i < gdkdev->info.num_axes; i++)
@@ -677,7 +673,7 @@ wintab_default_display_notify_cb (GdkDisplayManager *display_manager)
   g_assert (display_manager != NULL);
 
   default_display_opened = TRUE;
-  GDK_NOTE (INPUT, g_print ("wintab init: doing delayed initialization\n"));
+  GDK_DEBUG (INPUT, "wintab init: doing delayed initialization");
   wintab_init_check (device_manager);
 }
 
@@ -807,8 +803,8 @@ _gdk_wintab_set_tablet_active (void)
   if (!wintab_contexts)
     return; /* No tablet devices found, or Wintab not initialized yet */
 
-  GDK_NOTE (INPUT, g_print ("_gdk_wintab_set_tablet_active: "
-                            "Bringing Wintab contexts to the top of the overlap order\n"));
+  GDK_DEBUG (INPUT, "_gdk_wintab_set_tablet_active: "
+                    "Bringing Wintab contexts to the top of the overlap order");
 
   tmp_list = wintab_contexts;
 
@@ -948,9 +944,9 @@ gdk_wintab_make_event (GdkDisplay *display,
   if (window)
     g_object_ref (window);
 
-  GDK_NOTE (EVENTS_OR_INPUT,
-           g_print ("gdk_wintab_make_event: window=%p %+g%+g\n",
-               window ? GDK_SURFACE_HWND (window) : NULL, x, y));
+  GDK_DEBUG (EVENTS_OR_INPUT,
+             "gdk_wintab_make_event: window=%p %+g%+g",
+             window ? GDK_SURFACE_HWND (window) : NULL, x, y);
 
   if (msg->message == WT_PACKET || msg->message == WT_CSRCHANGE)
     {
@@ -1011,7 +1007,7 @@ gdk_wintab_make_event (GdkDisplay *display,
        */
       if (_modal_operation_in_progress & GDK_WIN32_MODAL_OP_SIZEMOVE_MASK)
         {
-          GDK_NOTE (EVENTS_OR_INPUT, g_print ("... ignored when moving/sizing\n"));
+          GDK_DEBUG (EVENTS_OR_INPUT, "... ignored when moving/sizing");
           return NULL;
         }
 
@@ -1026,7 +1022,7 @@ gdk_wintab_make_event (GdkDisplay *display,
 
       if (window == NULL)
         {
-          GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n"));
+          GDK_DEBUG (EVENTS_OR_INPUT, "... is root");
           return NULL;
         }
 
@@ -1112,13 +1108,12 @@ gdk_wintab_make_event (GdkDisplay *display,
                                         event_y,
                                         axes);
                                           
-          GDK_NOTE (EVENTS_OR_INPUT,
-                    g_print ("WINTAB button %s:%d %g,%g\n",
-                             (event->event_type == GDK_BUTTON_PRESS ?
-                              "press" : "release"),
-                             ((GdkButtonEvent *) event)->button,
-                             ((GdkButtonEvent *) event)->x,
-                             ((GdkButtonEvent *) event)->y));
+          GDK_DEBUG (EVENTS_OR_INPUT, "WINTAB button %s:%d %g,%g",
+                                      (event->event_type == GDK_BUTTON_PRESS ?
+                                      "press" : "release"),
+                                      ((GdkButtonEvent *) event)->button,
+                                      ((GdkButtonEvent *) event)->x,
+                                     ((GdkButtonEvent *) event)->y);
         }
       else
         {
@@ -1143,10 +1138,9 @@ gdk_wintab_make_event (GdkDisplay *display,
                                         event_x,
                                         event_y,
                                         axes);
-          GDK_NOTE (EVENTS_OR_INPUT,
-                    g_print ("WINTAB motion: %g,%g\n",
-                             ((GdkMotionEvent *) event)->x,
-                             ((GdkMotionEvent *) event)->y));
+          GDK_DEBUG (EVENTS_OR_INPUT, "WINTAB motion: %g,%g",
+                                      ((GdkMotionEvent *) event)->x,
+                                      ((GdkMotionEvent *) event)->y);
         }
       return event;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]