⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 magnifier_8c-source.html

📁 在Linux下实现magnification功能
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00435"></a>00435         XSetWMHints (GDK_WINDOW_XDISPLAY (widget-&gt;window),<a name="l00436"></a>00436                      GDK_WINDOW_XWINDOW (widget-&gt;window), &amp;wm_hints);<a name="l00437"></a>00437         <a name="l00438"></a>00438         XSetWMProtocols (GDK_WINDOW_XDISPLAY (widget-&gt;window),<a name="l00439"></a>00439                          GDK_WINDOW_XWINDOW (widget-&gt;window), wm_window_protocols, 2);<a name="l00440"></a>00440 <a name="l00441"></a>00441         net_wm_window_type = gdk_x11_get_xatom_by_name_for_display <a name="l00442"></a>00442                 (target_display, <span class="stringliteral">"_NET_WM_WINDOW_TYPE"</span>);<a name="l00443"></a>00443 <a name="l00444"></a>00444         <span class="keywordflow">if</span> (net_wm_window_type &amp;&amp; wm_type_atoms[0])<a name="l00445"></a>00445                 XChangeProperty (GDK_WINDOW_XDISPLAY (widget-&gt;window),<a name="l00446"></a>00446                                  GDK_WINDOW_XWINDOW (widget-&gt;window),<a name="l00447"></a>00447                                  net_wm_window_type,<a name="l00448"></a>00448                                  XA_ATOM, 32, PropModeReplace,<a name="l00449"></a>00449                                  (guchar *)wm_type_atoms,<a name="l00450"></a>00450                                  1);<a name="l00451"></a>00451 <span class="preprocessor">#else</span><a name="l00452"></a>00452 <span class="preprocessor"></span><span class="preprocessor">#endif</span><a name="l00453"></a>00453 <span class="preprocessor"></span>        <span class="comment">/* TODO: make sure this works/is reset if the DISPLAY </span><a name="l00454"></a>00454 <span class="comment">         * (as well as the SCREEN) changes.</span><a name="l00455"></a>00455 <span class="comment">         */</span><a name="l00456"></a>00456 <a name="l00457"></a>00457         XSetErrorHandler (<a class="code" href="magnifier_8c.html#982b55bded4a2601c71a180a2450e751">magnifier_x_error_handler</a>);<a name="l00458"></a>00458 }<a name="l00459"></a>00459 <a name="l00460"></a>00460 GdkWindow*<a name="l00461"></a><a class="code" href="magnifier_8h.html#ca7d287432d79d9d72aef38adb4fa3eb">00461</a> <a class="code" href="magnifier_8c.html#ca7d287432d79d9d72aef38adb4fa3eb">magnifier_get_root</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier)<a name="l00462"></a>00462 {<a name="l00463"></a>00463     <span class="keywordflow">if</span> (!magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#5ab4d39e5bb2aa9bd1fd989de9c50c9e">root</a> &amp;&amp; magnifier-&gt;<a class="code" href="structMagnifier.html#2e085c3a4d47b26635ed0438680f5632">source_display</a>) {<a name="l00464"></a>00464         magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#5ab4d39e5bb2aa9bd1fd989de9c50c9e">root</a> = gdk_screen_get_root_window (<a name="l00465"></a>00465             gdk_display_get_screen (magnifier-&gt;<a class="code" href="structMagnifier.html#2e085c3a4d47b26635ed0438680f5632">source_display</a>,<a name="l00466"></a>00466                                     magnifier-&gt;<a class="code" href="structMagnifier.html#6ded5f49dfbcb6122347c3f047217d3b">source_screen_num</a>));<a name="l00467"></a>00467     }<a name="l00468"></a>00468     <span class="keywordflow">return</span> magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#5ab4d39e5bb2aa9bd1fd989de9c50c9e">root</a>;<a name="l00469"></a>00469 }<a name="l00470"></a>00470 <a name="l00471"></a>00471 <span class="keyword">static</span> gint<a name="l00472"></a><a class="code" href="magnifier_8c.html#d758108ab419c5fefa34b4edc2954100">00472</a> <a class="code" href="magnifier_8c.html#d758108ab419c5fefa34b4edc2954100">magnifier_parse_display_name</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier, gchar *full_display_string,<a name="l00473"></a>00473                               gchar **display_name)<a name="l00474"></a>00474 {<a name="l00475"></a>00475         gchar *screen_ptr;<a name="l00476"></a>00476         gchar **strings;<a name="l00477"></a>00477         <a name="l00478"></a>00478         <span class="keywordflow">if</span> (display_name != NULL) {<a name="l00479"></a>00479                 strings = g_strsplit (full_display_string, <span class="stringliteral">":"</span>, 2);<a name="l00480"></a>00480                 *display_name = strings [0];<a name="l00481"></a>00481                 <span class="keywordflow">if</span> (strings [1] != NULL)<a name="l00482"></a>00482                         g_free (strings [1]);<a name="l00483"></a>00483         }<a name="l00484"></a>00484 <a name="l00485"></a>00485         screen_ptr = rindex (full_display_string, <span class="charliteral">'.'</span>);<a name="l00486"></a>00486         <span class="keywordflow">if</span> (screen_ptr != NULL) {<a name="l00487"></a>00487                 <span class="keywordflow">return</span> (gint) strtol (++screen_ptr, NULL, 10);<a name="l00488"></a>00488         }<a name="l00489"></a>00489         <span class="keywordflow">return</span> 0;<a name="l00490"></a>00490 }<a name="l00491"></a>00491 <a name="l00492"></a>00492 <span class="keyword">static</span> <span class="keywordtype">void</span><a name="l00493"></a><a class="code" href="magnifier_8c.html#5d8b1dcf3e0cf7b420c2fe60e879a411">00493</a> <a class="code" href="magnifier_8c.html#5d8b1dcf3e0cf7b420c2fe60e879a411">magnifier_get_display_rect_bounds</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier, <a class="code" href="structGNOME__Magnifier__RectBounds__type.html">GNOME_Magnifier_RectBounds</a> *rect_bounds, gboolean is_target)<a name="l00494"></a>00494 {<a name="l00495"></a>00495     <span class="keywordflow">if</span> (is_target)<a name="l00496"></a>00496     {<a name="l00497"></a>00497         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a> = 0;<a name="l00498"></a>00498         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a> = gdk_screen_get_width (<a name="l00499"></a>00499             gdk_display_get_screen (magnifier-&gt;<a class="code" href="structMagnifier.html#23d4c44ae2496cc1494d7691b81e47bc">target_display</a>,<a name="l00500"></a>00500                                     magnifier-&gt;<a class="code" href="structMagnifier.html#bd18b53abfb094b1f878b8a9d238060e">target_screen_num</a>));<a name="l00501"></a>00501         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#24de0d98768b0b42dc53ab51950760c0">y1</a> = 0;<a name="l00502"></a>00502         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a> = gdk_screen_get_height (<a name="l00503"></a>00503             gdk_display_get_screen (magnifier-&gt;<a class="code" href="structMagnifier.html#23d4c44ae2496cc1494d7691b81e47bc">target_display</a>,<a name="l00504"></a>00504                                     magnifier-&gt;<a class="code" href="structMagnifier.html#bd18b53abfb094b1f878b8a9d238060e">target_screen_num</a>));<a name="l00505"></a>00505 <a name="l00506"></a>00506     }<a name="l00507"></a>00507     <span class="keywordflow">else</span> <a name="l00508"></a>00508     {<a name="l00509"></a>00509         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a> = 0;<a name="l00510"></a>00510         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a> = gdk_screen_get_width (<a name="l00511"></a>00511             gdk_display_get_screen (magnifier-&gt;<a class="code" href="structMagnifier.html#2e085c3a4d47b26635ed0438680f5632">source_display</a>,<a name="l00512"></a>00512                                     magnifier-&gt;<a class="code" href="structMagnifier.html#6ded5f49dfbcb6122347c3f047217d3b">source_screen_num</a>));<a name="l00513"></a>00513         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#24de0d98768b0b42dc53ab51950760c0">y1</a> = 0;<a name="l00514"></a>00514         rect_bounds-&gt;<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a> = gdk_screen_get_height (<a name="l00515"></a>00515             gdk_display_get_screen (magnifier-&gt;<a class="code" href="structMagnifier.html#2e085c3a4d47b26635ed0438680f5632">source_display</a>,<a name="l00516"></a>00516                                     magnifier-&gt;<a class="code" href="structMagnifier.html#6ded5f49dfbcb6122347c3f047217d3b">source_screen_num</a>));<a name="l00517"></a>00517 <a name="l00518"></a>00518     }<a name="l00519"></a>00519 }<a name="l00520"></a>00520 <a name="l00521"></a>00521 <span class="keyword">static</span> <span class="keywordtype">void</span><a name="l00522"></a><a class="code" href="magnifier_8c.html#5d03b9ff4244a9c29761615eeae742fb">00522</a> <a class="code" href="magnifier_8c.html#5d03b9ff4244a9c29761615eeae742fb">magnifier_adjust_source_size</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier)<a name="l00523"></a>00523 {<a name="l00524"></a>00524         <a class="code" href="structGNOME__Magnifier__RectBounds__type.html">GNOME_Magnifier_RectBounds</a> rect_bounds; <a name="l00525"></a>00525         gdouble vfract_top, vfract_bottom, hfract_left, hfract_right;<a name="l00526"></a>00526         <a class="code" href="magnifier_8c.html#5d8b1dcf3e0cf7b420c2fe60e879a411">magnifier_get_display_rect_bounds</a> (magnifier, &amp;rect_bounds, FALSE);<a name="l00527"></a>00527         hfract_left = (double) (magnifier-&gt;<a class="code" href="structMagnifier.html#261dde452415adc226171e6c9e6f21bf">target_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a>) / (double) rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>;<a name="l00528"></a>00528         vfract_top = (<span class="keywordtype">double</span>) (magnifier-&gt;<a class="code" href="structMagnifier.html#261dde452415adc226171e6c9e6f21bf">target_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#24de0d98768b0b42dc53ab51950760c0">y1</a>) / (<span class="keywordtype">double</span>) rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a>;<a name="l00529"></a>00529         hfract_right = (double) (rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a> - magnifier-&gt;<a class="code" href="structMagnifier.html#261dde452415adc226171e6c9e6f21bf">target_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>) / (double) rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>;<a name="l00530"></a>00530         vfract_bottom = (<span class="keywordtype">double</span>) (rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a> - magnifier-&gt;<a class="code" href="structMagnifier.html#261dde452415adc226171e6c9e6f21bf">target_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a>) / (<span class="keywordtype">double</span>) rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a>;<a name="l00531"></a>00531         <span class="comment">/* we make our 'source' rectangle the largest available subsection which we aren't occupying */</span><a name="l00532"></a>00532 <span class="preprocessor">#ifdef HAVE_COMPOSITE</span><a name="l00533"></a>00533 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (!g_getenv (<span class="stringliteral">"MAGNIFIER_IGNORE_COMPOSITE"</span>)) {<a name="l00534"></a>00534                 magnifier-&gt;<a class="code" href="structMagnifier.html#ae209aab6157f0a0946e2b1a78cb00e8">source_bounds</a> = rect_bounds;<a name="l00535"></a>00535         } <span class="keywordflow">else</span><a name="l00536"></a>00536 <span class="preprocessor">#endif</span><a name="l00537"></a>00537 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (MAX (hfract_left, hfract_right) &gt; MAX (vfract_top, vfract_bottom))  <span class="comment">/* vertical split, approximately */</span><a name="l00538"></a>00538         {<a name="l00539"></a>00539                 <span class="keywordflow">if</span> (hfract_right &gt; hfract_left) {<a name="l00540"></a>00540                         magnifier-&gt;<a class="code" href="structMagnifier.html#ae209aab6157f0a0946e2b1a78cb00e8">source_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a> = magnifier-&gt;<a class="code" href="structMagnifier.html#261dde452415adc226171e6c9e6f21bf">target_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>;<a name="l00541"></a>00541                         magnifier-&gt;<a class="code" href="structMagnifier.html#ae209aab6157f0a0946e2b1a78cb00e8">source_bounds</a>.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a> = rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>;<a name="l00542"></a>00542                 }<a name="l00543"></a>00543                 <span class="keywordflow">else</span> <a name="l00544"></a>00544                 {<a n

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -