After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748325 - W32: GDK backend has some code repetition
W32: GDK backend has some code repetition
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Win32
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-04-22 19:27 UTC by LRN
Modified: 2018-04-15 00:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
W32: Fold some repeatedly used chunks of code into a function (6.60 KB, patch)
2015-04-22 19:28 UTC, LRN
none Details | Review
W32: GDK backend optimization (9.29 KB, patch)
2015-04-28 19:48 UTC, LRN
none Details | Review
W32: GDK backend optimization (9.35 KB, patch)
2015-04-29 21:33 UTC, LRN
reviewed Details | Review

Description LRN 2015-04-22 19:27:54 UTC
The code related to getting window that contains certain point
Comment 1 LRN 2015-04-22 19:28:02 UTC
Created attachment 302178 [details] [review]
W32: Fold some repeatedly used chunks of code into a function
Comment 2 Ignacio Casal Quinteiro (nacho) 2015-04-23 06:41:18 UTC
Review of attachment 302178 [details] [review]:

See the comments.

::: gdk/win32/gdkevents-win32.c
@@ +452,2 @@
 static GdkWindow *
+window_from_point (POINT pt, gboolean *ignore_leave, HWND *synaptics_quirk_msg_hwnd)

split parameters

@@ +476,3 @@
+     this window */
+  if ((ignore_leave || synaptics_quirk_msg_hwnd != NULL) &&
+      GetClassNameA (hwnd, classname, sizeof(classname)) &&

please use the W method instead

@@ +491,3 @@
+	    hwndc = ChildWindowFromPoint (hwnd, point);
+	    ClientToScreen (hwnd, &point);
+	  } while (hwndc != hwnd && (hwnd = hwndc, 1));

this coding style for do while is wrong
Comment 3 LRN 2015-04-23 09:10:45 UTC
(In reply to Ignacio Casal Quinteiro (nacho) from comment #2)
> Review of attachment 302178 [details] [review] [review]:
> 
> See the comments.

Note that code here is a copy-paste, so most style weirdness is from the original code.

> @@ +476,3 @@
> +     this window */
> +  if ((ignore_leave || synaptics_quirk_msg_hwnd != NULL) &&
> +      GetClassNameA (hwnd, classname, sizeof(classname)) &&
> 
> please use the W method instead

Unnecessary. This is intended for a specific check (SYNAPSIS_ICON_WINDOW_CLASS), not generic use.
Comment 4 Alexander Larsson 2015-04-27 14:52:13 UTC
Review of attachment 302178 [details] [review]:

I'm not sure the helper is really helping making the code easier to read in the synaptics case, especially since it handles everything a bit differently there (i.e. we ignore the return value in that case and use an out parameter only.
Actually I'm not even sure that case is right. As it now adds a PtInRect() call that was not there before.

Maybe a better approach is to add another helper hwnd_is_synapsis(), and then have the window_from_point helper not have any synapsis magic.
Then for the ignore_leave case one can just call window_from_point(), and then ignore_leave = hwnd_is_synapsis (window->handle).

For the other case, its different enough that we can just not use the helper there.
Comment 5 LRN 2015-04-27 15:36:27 UTC
(In reply to Alexander Larsson from comment #4)
> Review of attachment 302178 [details] [review] [review]:
> 
> I'm not sure the helper is really helping making the code easier to read in
> the synaptics case, especially since it handles everything a bit differently
> there (i.e. we ignore the return value in that case and use an out parameter
> only.
> Actually I'm not even sure that case is right. As it now adds a PtInRect()
> call that was not there before.
> 
> Maybe a better approach is to add another helper hwnd_is_synapsis(), and
> then have the window_from_point helper not have any synapsis magic.
> Then for the ignore_leave case one can just call window_from_point(), and
> then ignore_leave = hwnd_is_synapsis (window->handle).
> 
> For the other case, its different enough that we can just not use the helper
> there.

Right. What i wanted the most is for someone to verify that i haven't messed up and that my folded code does the same thing original code did. I'll see about making the changes you've mentioned.
Comment 6 LRN 2015-04-28 19:48:57 UTC
Created attachment 302529 [details] [review]
W32: GDK backend optimization

Restructured the code as suggested.

Merged code from bug 748328 (because there's no intermediate coordinate
fix commit between them anymore).
Comment 7 Ignacio Casal Quinteiro (nacho) 2015-04-28 20:07:21 UTC
Review of attachment 302529 [details] [review]:

See nitpicks

::: gdk/win32/gdkevents-win32.c
@@ +411,3 @@
 
+static GdkWindow *
+_gdk_window_from_point (POINT pt, HWND hwnd, GdkWindow *guess)

I still think this should be split

@@ +442,3 @@
+   */
+  return GetClassNameA (hwnd, classname, sizeof(classname)) &&
+      strcmp (classname, SYNAPSIS_ICON_WINDOW_CLASS) == 0;

align these

@@ +446,3 @@
+
+static HWND
+synaptics_hack (HWND hwnd, POINT *pt)

same here with the split
Comment 8 LRN 2015-04-29 21:33:50 UTC
Created attachment 302613 [details] [review]
W32: GDK backend optimization

v2:
* Fixed nitpicks
* Removed a stray hwnd from _gdk_window_from_point()
Comment 9 Ignacio Casal Quinteiro (nacho) 2015-12-11 14:15:45 UTC
Review of attachment 302613 [details] [review]:

Minor comment and feel free to push it after fixing that.

::: gdk/win32/gdkevents-win32.c
@@ +438,3 @@
+  char classname[64];
+
+  /* The synapitics trackpad drivers have this irritating

typo in synapitics
Comment 10 Matthias Clasen 2018-02-10 05:24:04 UTC
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
Comment 11 Matthias Clasen 2018-04-15 00:31:24 UTC
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla.

If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab:

https://gitlab.gnome.org/GNOME/gtk/issues/new