Advertisement
Guest User

conf_snap_wndw_placeareas_patch

a guest
Jan 5th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.77 KB | None | 0 0
  1. commit 658e5f76a07a4aad5ed30d82770081849b58d2f2
  2. Author: roel <RoelKl.UI.n@gmail.com>
  3. Date: Sat Jan 5 20:58:12 2019 +0100
  4.  
  5. compiles and shows options in window manager tweaks correctly, not tested
  6. yet if the placement actually works already.
  7.  
  8. Signed-off-by: picobyte <RoelKl.UI.n@gmail.com>
  9.  
  10. diff --git a/defaults/defaults b/defaults/defaults
  11. index cf3d8703..5b2a7f72 100644
  12. --- a/defaults/defaults
  13. +++ b/defaults/defaults
  14. @@ -30,6 +30,8 @@ mousewheel_rollup=true
  15. move_opacity=100
  16. placement_mode=center
  17. placement_ratio=20
  18. +horizontal_placement_areas=2
  19. +vertical_placement_areas=2
  20. popup_opacity=100
  21. prevent_focus_stealing=false
  22. raise_delay=250
  23. diff --git a/settings-dialogs/tweaks-settings.c b/settings-dialogs/tweaks-settings.c
  24. index d5f711be..a34f899a 100644
  25. --- a/settings-dialogs/tweaks-settings.c
  26. +++ b/settings-dialogs/tweaks-settings.c
  27. @@ -205,6 +205,8 @@ wm_tweaks_dialog_configure_widgets (GtkBuilder *builder)
  28. GtkWidget *placement_ratio_scale = GTK_WIDGET (gtk_builder_get_object (builder, "placement_ratio_scale"));
  29. GtkWidget *placement_center_option = GTK_WIDGET (gtk_builder_get_object (builder, "placement_center_option"));
  30. GtkWidget *placement_mouse_option = GTK_WIDGET (gtk_builder_get_object (builder, "placement_mouse_option"));
  31. + GtkWidget *horizontal_placement_areas = GTK_WIDGET (gtk_builder_get_object (builder, "horizontal_placement_areas"));
  32. + GtkWidget *vertical_placement_areas = GTK_WIDGET (gtk_builder_get_object (builder, "vertical_placement_areas"));
  33.  
  34. /* Compositing tab */
  35. GtkWidget *use_compositing_check = GTK_WIDGET (gtk_builder_get_object (builder, "use_compositing_check"));
  36. @@ -398,7 +400,14 @@ wm_tweaks_dialog_configure_widgets (GtkBuilder *builder)
  37. "/general/placement_ratio",
  38. G_TYPE_INT,
  39. (GObject *) gtk_range_get_adjustment (GTK_RANGE (placement_ratio_scale)), "value");
  40. -
  41. + xfconf_g_property_bind (xfwm4_channel,
  42. + "/general/horizontal_placement_areas",
  43. + G_TYPE_INT,
  44. + (GObject *) gtk_range_get_adjustment (GTK_RANGE (horizontal_placement_areas)), "value");
  45. + xfconf_g_property_bind (xfwm4_channel,
  46. + "/general/vertical_placement_areas",
  47. + G_TYPE_INT,
  48. + (GObject *) gtk_range_get_adjustment (GTK_RANGE (vertical_placement_areas)), "value");
  49. /* Compositing tab */
  50. xfconf_g_property_bind (xfwm4_channel,
  51. "/general/use_compositing",
  52. diff --git a/settings-dialogs/xfwm4-tweaks-dialog.glade b/settings-dialogs/xfwm4-tweaks-dialog.glade
  53. index 9e2cee50..5e662399 100644
  54. --- a/settings-dialogs/xfwm4-tweaks-dialog.glade
  55. +++ b/settings-dialogs/xfwm4-tweaks-dialog.glade
  56. @@ -39,6 +39,20 @@
  57. <property name="step_increment">1</property>
  58. <property name="page_increment">10</property>
  59. </object>
  60. + <object class="GtkAdjustment" id="adjustment7">
  61. + <property name="lower">1</property>
  62. + <property name="upper">10</property>
  63. + <property name="value">2</property>
  64. + <property name="step_increment">1</property>
  65. + <property name="page_increment">0</property>
  66. + </object>
  67. + <object class="GtkAdjustment" id="adjustment8">
  68. + <property name="lower">1</property>
  69. + <property name="upper">10</property>
  70. + <property name="value">2</property>
  71. + <property name="step_increment">1</property>
  72. + <property name="page_increment">0</property>
  73. + </object>
  74. <object class="XfceTitledDialog" id="main-dialog">
  75. <property name="can_focus">False</property>
  76. <property name="title" translatable="yes">Window Manager Tweaks</property>
  77. @@ -821,6 +835,70 @@ when switching via keyboard shortcuts</property>
  78. <property name="position">2</property>
  79. </packing>
  80. </child>
  81. + <child>
  82. + <object class="GtkLabel" id="label28">
  83. + <property name="visible">True</property>
  84. + <property name="can_focus">False</property>
  85. + <property name="xalign">0</property>
  86. + <property name="label" translatable="yes">_Horizontal number of areas for window snapping:</property>
  87. + <property name="use_underline">True</property>
  88. + <property name="mnemonic_widget">horizontal_placement_areas</property>
  89. + </object>
  90. + <packing>
  91. + <property name="expand">False</property>
  92. + <property name="fill">False</property>
  93. + <property name="position">3</property>
  94. + </packing>
  95. + </child>
  96. + <child>
  97. + <object class="GtkScale" id="horizontal_placement_areas">
  98. + <property name="visible">True</property>
  99. + <property name="can_focus">True</property>
  100. + <property name="orientation">horizontal</property>
  101. + <property name="adjustment">adjustment7</property>
  102. + <property name="restrict_to_fill_level">False</property>
  103. + <property name="digits">0</property>
  104. + <property name="draw_value">True</property>
  105. + <property name="value-pos">GTK_POS_LEFT</property>
  106. + </object>
  107. + <packing>
  108. + <property name="expand">True</property>
  109. + <property name="fill">True</property>
  110. + <property name="position">4</property>
  111. + </packing>
  112. + </child>
  113. + <child>
  114. + <object class="GtkLabel" id="label31">
  115. + <property name="visible">True</property>
  116. + <property name="can_focus">False</property>
  117. + <property name="xalign">0</property>
  118. + <property name="label" translatable="yes">_Vertical number of areas for window snapping:</property>
  119. + <property name="use_underline">True</property>
  120. + <property name="mnemonic_widget">vertical_placement_areas</property>
  121. + </object>
  122. + <packing>
  123. + <property name="expand">False</property>
  124. + <property name="fill">False</property>
  125. + <property name="position">5</property>
  126. + </packing>
  127. + </child>
  128. + <child>
  129. + <object class="GtkScale" id="vertical_placement_areas">
  130. + <property name="visible">True</property>
  131. + <property name="can_focus">True</property>
  132. + <property name="orientation">horizontal</property>
  133. + <property name="adjustment">adjustment8</property>
  134. + <property name="restrict_to_fill_level">False</property>
  135. + <property name="digits">0</property>
  136. + <property name="draw_value">True</property>
  137. + <property name="value-pos">GTK_POS_LEFT</property>
  138. + </object>
  139. + <packing>
  140. + <property name="expand">True</property>
  141. + <property name="fill">True</property>
  142. + <property name="position">6</property>
  143. + </packing>
  144. + </child>
  145. </object>
  146. <packing>
  147. <property name="position">4</property>
  148. diff --git a/src/placement.c b/src/placement.c
  149. index a643ef08..d2d919ba 100644
  150. --- a/src/placement.c
  151. +++ b/src/placement.c
  152. @@ -735,14 +735,14 @@ centerPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
  153. }
  154.  
  155. static void
  156. -mousePlacement (Client * c, int full_x, int full_y, int full_w, int full_h, int mx, int my)
  157. +mousePlacement (Client * c, int full_x, int full_y, int full_w, int full_h, int mx, int my, int hdiv, int vdiv)
  158. {
  159. g_return_if_fail (c != NULL);
  160.  
  161. TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
  162.  
  163. - c->x = mx + frameExtentLeft(c) - frameExtentWidth(c) / 2;
  164. - c->y = my + frameExtentTop(c) - frameExtentHeight(c) / 2;
  165. + c->x = mx + frameExtentLeft(c) - frameExtentWidth(c) / hdiv;
  166. + c->y = my + frameExtentTop(c) - frameExtentHeight(c) / vdiv;
  167.  
  168. c->x = MIN (c->x, full_x + full_w - frameExtentWidth(c) + frameExtentLeft(c));
  169. c->y = MIN (c->y, full_y + full_h - frameExtentHeight(c) + frameExtentTop(c));
  170. @@ -828,7 +828,17 @@ clientInitPosition (Client * c)
  171. {
  172. if (screen_info->params->placement_mode == PLACE_MOUSE)
  173. {
  174. - mousePlacement (c, full_x, full_y, full_w, full_h, msx, msy);
  175. + int hdiv = screen_info->params->horizontal_placement_areas;
  176. + if (hdiv < 1 || hdiv > 10)
  177. + {
  178. + hdiv = 2;
  179. + }
  180. + int vdiv = screen_info->params->vertical_placement_areas;
  181. + if (vdiv < 1 || vdiv > 10)
  182. + {
  183. + vdiv = 2;
  184. + }
  185. + mousePlacement (c, full_x, full_y, full_w, full_h, msx, msy, hdiv, vdiv);
  186. }
  187. else
  188. {
  189. diff --git a/src/settings.c b/src/settings.c
  190. index 7dbcffc6..b8dcbb5a 100644
  191. --- a/src/settings.c
  192. +++ b/src/settings.c
  193. @@ -680,6 +680,8 @@ loadSettings (ScreenInfo *screen_info)
  194. {"move_opacity", NULL, G_TYPE_INT, TRUE},
  195. {"placement_mode", NULL, G_TYPE_STRING, TRUE},
  196. {"placement_ratio", NULL, G_TYPE_INT, TRUE},
  197. + {"horizontal_placement_areas", NULL, G_TYPE_INT, TRUE},
  198. + {"vertical_placement_areas", NULL, G_TYPE_INT, TRUE},
  199. {"popup_opacity", NULL, G_TYPE_INT, TRUE},
  200. {"prevent_focus_stealing", NULL, G_TYPE_BOOLEAN, TRUE},
  201. {"raise_delay", NULL, G_TYPE_INT, TRUE},
  202. @@ -798,6 +800,10 @@ loadSettings (ScreenInfo *screen_info)
  203. CLAMP (getIntValue ("popup_opacity", rc), 0, 100);
  204. screen_info->params->placement_ratio =
  205. CLAMP (getIntValue ("placement_ratio", rc), 0, 100);
  206. + screen_info->params->horizontal_placement_areas =
  207. + CLAMP (getIntValue ("horizontal_placement_areas", rc), 1, 10);
  208. + screen_info->params->vertical_placement_areas =
  209. + CLAMP (getIntValue ("vertical_placement_areas", rc), 1, 10);
  210. screen_info->params->shadow_opacity =
  211. CLAMP (getIntValue ("shadow_opacity", rc), 0, 100);
  212. screen_info->params->show_app_icon =
  213. @@ -1194,6 +1200,14 @@ cb_xfwm4_channel_property_changed(XfconfChannel *channel, const gchar *property_
  214. {
  215. screen_info->params->placement_ratio = CLAMP (g_value_get_int(value), 0, 100);
  216. }
  217. + else if (!strcmp (name, "horizontal_placement_areas"))
  218. + {
  219. + screen_info->params->horizontal_placement_areas = CLAMP (g_value_get_int(value), 1, 10);
  220. + }
  221. + else if (!strcmp (name, "vertical_placement_areas"))
  222. + {
  223. + screen_info->params->vertical_placement_areas = CLAMP (g_value_get_int(value), 1, 10);
  224. + }
  225. else if (!strcmp (name, "cycle_tabwin_mode"))
  226. {
  227. screen_info->params->cycle_tabwin_mode = CLAMP (g_value_get_int(value), 0, 1);
  228. diff --git a/src/settings.h b/src/settings.h
  229. index 334acdd4..0fc4cd8b 100644
  230. --- a/src/settings.h
  231. +++ b/src/settings.h
  232. @@ -181,6 +181,8 @@ struct _XfwmParams
  233. int move_opacity;
  234. int placement_mode;
  235. int placement_ratio;
  236. + int horizontal_placement_areas;
  237. + int vertical_placement_areas;
  238. int popup_opacity;
  239. int raise_delay;
  240. int resize_opacity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement