diff options
author | Perberos <[email protected]> | 2011-11-06 19:14:03 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-11-06 19:14:03 -0300 |
commit | f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e (patch) | |
tree | 5bc248a29ae93e5534428e6908a94d50d419ceb9 /src/eggsmclient-win32.c | |
parent | def492f92d29f294c62d94ef562dd6271bd9b84b (diff) | |
download | mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.bz2 mate-terminal-f2a13175e5a3a38d1340d2fff5e03f8c2e0d8f8e.tar.xz |
aplicando formato allman
Diffstat (limited to 'src/eggsmclient-win32.c')
-rw-r--r-- | src/eggsmclient-win32.c | 309 |
1 files changed, 156 insertions, 153 deletions
diff --git a/src/eggsmclient-win32.c b/src/eggsmclient-win32.c index a762c6c..745b265 100644 --- a/src/eggsmclient-win32.c +++ b/src/eggsmclient-win32.c @@ -66,31 +66,32 @@ typedef struct _EggSMClientWin32 EggSMClientWin32; typedef struct _EggSMClientWin32Class EggSMClientWin32Class; -struct _EggSMClientWin32 { - EggSMClient parent; +struct _EggSMClientWin32 +{ + EggSMClient parent; - HANDLE message_event, response_event; + HANDLE message_event, response_event; - volatile GSourceFunc event; - volatile gboolean will_quit; + volatile GSourceFunc event; + volatile gboolean will_quit; }; struct _EggSMClientWin32Class { - EggSMClientClass parent_class; + EggSMClientClass parent_class; }; static void sm_client_win32_startup (EggSMClient *client, - const char *client_id); + const char *client_id); static void sm_client_win32_will_quit (EggSMClient *client, - gboolean will_quit); + gboolean will_quit); static gboolean sm_client_win32_end_session (EggSMClient *client, - EggSMClientEndStyle style, - gboolean request_confirmation); + EggSMClientEndStyle style, + gboolean request_confirmation); static GSource *g_win32_handle_source_add (HANDLE handle, GSourceFunc callback, - gpointer user_data); + gpointer user_data); static gboolean got_message (gpointer user_data); static void sm_client_thread (gpointer data); @@ -99,79 +100,79 @@ G_DEFINE_TYPE (EggSMClientWin32, egg_sm_client_win32, EGG_TYPE_SM_CLIENT) static void egg_sm_client_win32_init (EggSMClientWin32 *win32) { - ; + ; } static void egg_sm_client_win32_class_init (EggSMClientWin32Class *klass) { - EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass); + EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass); - sm_client_class->startup = sm_client_win32_startup; - sm_client_class->will_quit = sm_client_win32_will_quit; - sm_client_class->end_session = sm_client_win32_end_session; + sm_client_class->startup = sm_client_win32_startup; + sm_client_class->will_quit = sm_client_win32_will_quit; + sm_client_class->end_session = sm_client_win32_end_session; } EggSMClient * egg_sm_client_win32_new (void) { - return g_object_new (EGG_TYPE_SM_CLIENT_WIN32, NULL); + return g_object_new (EGG_TYPE_SM_CLIENT_WIN32, NULL); } static void sm_client_win32_startup (EggSMClient *client, - const char *client_id) + const char *client_id) { - EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; + EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; - win32->message_event = CreateEvent (NULL, FALSE, FALSE, NULL); - win32->response_event = CreateEvent (NULL, FALSE, FALSE, NULL); - g_win32_handle_source_add (win32->message_event, got_message, win32); - _beginthread (sm_client_thread, 0, client); + win32->message_event = CreateEvent (NULL, FALSE, FALSE, NULL); + win32->response_event = CreateEvent (NULL, FALSE, FALSE, NULL); + g_win32_handle_source_add (win32->message_event, got_message, win32); + _beginthread (sm_client_thread, 0, client); } static void sm_client_win32_will_quit (EggSMClient *client, - gboolean will_quit) + gboolean will_quit) { - EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; + EggSMClientWin32 *win32 = (EggSMClientWin32 *)client; - win32->will_quit = will_quit; - SetEvent (win32->response_event); + win32->will_quit = will_quit; + SetEvent (win32->response_event); } static gboolean sm_client_win32_end_session (EggSMClient *client, - EggSMClientEndStyle style, - gboolean request_confirmation) + EggSMClientEndStyle style, + gboolean request_confirmation) { - UINT uFlags = EWX_LOGOFF; - - switch (style) - { - case EGG_SM_CLIENT_END_SESSION_DEFAULT: - case EGG_SM_CLIENT_LOGOUT: - uFlags = EWX_LOGOFF; - break; - case EGG_SM_CLIENT_REBOOT: - uFlags = EWX_REBOOT; - break; - case EGG_SM_CLIENT_SHUTDOWN: - uFlags = EWX_POWEROFF; - break; - } - - /* There's no way to make ExitWindowsEx() show a logout dialog, so - * we ignore @request_confirmation. - */ + UINT uFlags = EWX_LOGOFF; + + switch (style) + { + case EGG_SM_CLIENT_END_SESSION_DEFAULT: + case EGG_SM_CLIENT_LOGOUT: + uFlags = EWX_LOGOFF; + break; + case EGG_SM_CLIENT_REBOOT: + uFlags = EWX_REBOOT; + break; + case EGG_SM_CLIENT_SHUTDOWN: + uFlags = EWX_POWEROFF; + break; + } + + /* There's no way to make ExitWindowsEx() show a logout dialog, so + * we ignore @request_confirmation. + */ #ifdef SHTDN_REASON_FLAG_PLANNED - ExitWindowsEx (uFlags, SHTDN_REASON_FLAG_PLANNED); + ExitWindowsEx (uFlags, SHTDN_REASON_FLAG_PLANNED); #else - ExitWindowsEx (uFlags, 0); + ExitWindowsEx (uFlags, 0); #endif - return TRUE; + return TRUE; } @@ -180,174 +181,176 @@ sm_client_win32_end_session (EggSMClient *client, static gboolean emit_quit_requested (gpointer smclient) { - gdk_threads_enter (); - egg_sm_client_quit_requested (smclient); - gdk_threads_leave (); + gdk_threads_enter (); + egg_sm_client_quit_requested (smclient); + gdk_threads_leave (); - return FALSE; + return FALSE; } static gboolean emit_quit (gpointer smclient) { - EggSMClientWin32 *win32 = smclient; + EggSMClientWin32 *win32 = smclient; - gdk_threads_enter (); - egg_sm_client_quit (smclient); - gdk_threads_leave (); + gdk_threads_enter (); + egg_sm_client_quit (smclient); + gdk_threads_leave (); - SetEvent (win32->response_event); - return FALSE; + SetEvent (win32->response_event); + return FALSE; } static gboolean emit_quit_cancelled (gpointer smclient) { - EggSMClientWin32 *win32 = smclient; + EggSMClientWin32 *win32 = smclient; - gdk_threads_enter (); - egg_sm_client_quit_cancelled (smclient); - gdk_threads_leave (); + gdk_threads_enter (); + egg_sm_client_quit_cancelled (smclient); + gdk_threads_leave (); - SetEvent (win32->response_event); - return FALSE; + SetEvent (win32->response_event); + return FALSE; } static gboolean got_message (gpointer smclient) { - EggSMClientWin32 *win32 = smclient; + EggSMClientWin32 *win32 = smclient; - win32->event (win32); - return TRUE; + win32->event (win32); + return TRUE; } /* Windows HANDLE GSource */ -typedef struct { - GSource source; - GPollFD pollfd; +typedef struct +{ + GSource source; + GPollFD pollfd; } GWin32HandleSource; static gboolean g_win32_handle_source_prepare (GSource *source, gint *timeout) { - *timeout = -1; - return FALSE; + *timeout = -1; + return FALSE; } static gboolean g_win32_handle_source_check (GSource *source) { - GWin32HandleSource *hsource = (GWin32HandleSource *)source; + GWin32HandleSource *hsource = (GWin32HandleSource *)source; - return hsource->pollfd.revents; + return hsource->pollfd.revents; } static gboolean g_win32_handle_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data) { - return (*callback) (user_data); + return (*callback) (user_data); } static void g_win32_handle_source_finalize (GSource *source) { - ; + ; } -GSourceFuncs g_win32_handle_source_funcs = { - g_win32_handle_source_prepare, - g_win32_handle_source_check, - g_win32_handle_source_dispatch, - g_win32_handle_source_finalize +GSourceFuncs g_win32_handle_source_funcs = +{ + g_win32_handle_source_prepare, + g_win32_handle_source_check, + g_win32_handle_source_dispatch, + g_win32_handle_source_finalize }; static GSource * g_win32_handle_source_add (HANDLE handle, GSourceFunc callback, gpointer user_data) { - GWin32HandleSource *hsource; - GSource *source; - - source = g_source_new (&g_win32_handle_source_funcs, sizeof (GWin32HandleSource)); - hsource = (GWin32HandleSource *)source; - hsource->pollfd.fd = (int)handle; - hsource->pollfd.events = G_IO_IN; - hsource->pollfd.revents = 0; - g_source_add_poll (source, &hsource->pollfd); - - g_source_set_callback (source, callback, user_data, NULL); - g_source_attach (source, NULL); - return source; + GWin32HandleSource *hsource; + GSource *source; + + source = g_source_new (&g_win32_handle_source_funcs, sizeof (GWin32HandleSource)); + hsource = (GWin32HandleSource *)source; + hsource->pollfd.fd = (int)handle; + hsource->pollfd.events = G_IO_IN; + hsource->pollfd.revents = 0; + g_source_add_poll (source, &hsource->pollfd); + + g_source_set_callback (source, callback, user_data, NULL); + g_source_attach (source, NULL); + return source; } /* logout-listener thread */ LRESULT CALLBACK sm_client_win32_window_procedure (HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM lParam) + UINT message, + WPARAM wParam, + LPARAM lParam) { - EggSMClientWin32 *win32 = - (EggSMClientWin32 *)GetWindowLongPtr (hwnd, GWLP_USERDATA); + EggSMClientWin32 *win32 = + (EggSMClientWin32 *)GetWindowLongPtr (hwnd, GWLP_USERDATA); - switch (message) - { - case WM_QUERYENDSESSION: - win32->event = emit_quit_requested; - SetEvent (win32->message_event); - - WaitForSingleObject (win32->response_event, INFINITE); - return win32->will_quit; - - case WM_ENDSESSION: - if (wParam) - { - /* The session is ending */ - win32->event = emit_quit; - } - else + switch (message) { - /* Nope, the session *isn't* ending */ - win32->event = emit_quit_cancelled; + case WM_QUERYENDSESSION: + win32->event = emit_quit_requested; + SetEvent (win32->message_event); + + WaitForSingleObject (win32->response_event, INFINITE); + return win32->will_quit; + + case WM_ENDSESSION: + if (wParam) + { + /* The session is ending */ + win32->event = emit_quit; + } + else + { + /* Nope, the session *isn't* ending */ + win32->event = emit_quit_cancelled; + } + + SetEvent (win32->message_event); + WaitForSingleObject (win32->response_event, INFINITE); + + return 0; + + default: + return DefWindowProc (hwnd, message, wParam, lParam); } - - SetEvent (win32->message_event); - WaitForSingleObject (win32->response_event, INFINITE); - - return 0; - - default: - return DefWindowProc (hwnd, message, wParam, lParam); - } } static void sm_client_thread (gpointer smclient) { - HINSTANCE instance; - WNDCLASSEXW wcl; - ATOM klass; - HWND window; - MSG msg; - - instance = GetModuleHandle (NULL); - - memset (&wcl, 0, sizeof (WNDCLASSEX)); - wcl.cbSize = sizeof (WNDCLASSEX); - wcl.lpfnWndProc = sm_client_win32_window_procedure; - wcl.hInstance = instance; - wcl.lpszClassName = L"EggSmClientWindow"; - klass = RegisterClassEx (&wcl); - - window = CreateWindowEx (0, MAKEINTRESOURCE (klass), - L"EggSmClientWindow", 0, - 10, 10, 50, 50, GetDesktopWindow (), - NULL, instance, NULL); - SetWindowLongPtr (window, GWLP_USERDATA, (LONG_PTR)smclient); - - /* main loop */ - while (GetMessage (&msg, NULL, 0, 0)) - DispatchMessage (&msg); + HINSTANCE instance; + WNDCLASSEXW wcl; + ATOM klass; + HWND window; + MSG msg; + + instance = GetModuleHandle (NULL); + + memset (&wcl, 0, sizeof (WNDCLASSEX)); + wcl.cbSize = sizeof (WNDCLASSEX); + wcl.lpfnWndProc = sm_client_win32_window_procedure; + wcl.hInstance = instance; + wcl.lpszClassName = L"EggSmClientWindow"; + klass = RegisterClassEx (&wcl); + + window = CreateWindowEx (0, MAKEINTRESOURCE (klass), + L"EggSmClientWindow", 0, + 10, 10, 50, 50, GetDesktopWindow (), + NULL, instance, NULL); + SetWindowLongPtr (window, GWLP_USERDATA, (LONG_PTR)smclient); + + /* main loop */ + while (GetMessage (&msg, NULL, 0, 0)) + DispatchMessage (&msg); } |