Index: examples/ex_monitorinfo.c
===================================================================
--- examples/ex_monitorinfo.c	(revision 13851)
+++ examples/ex_monitorinfo.c	(working copy)
@@ -8,6 +8,8 @@
 {
    ALLEGRO_MONITOR_INFO info;
    int num_adapters;
+   int main_adapter;
+   int active_adapter;
    int i, j;
 
    if (!al_init()) {
@@ -15,12 +17,20 @@
       return 1;
    }
 
-   open_log();
+   open_log_monospace();
 
    num_adapters = al_get_num_video_adapters();
 
    log_printf("%d adapters found...\n", num_adapters);
 
+   main_adapter = al_get_main_adapter();
+
+   log_printf("Main adapter is %d\n", main_adapter);
+
+   active_adapter = al_get_active_adapter();
+
+   log_printf("Active adapter is %d\n", active_adapter);
+
    for (i = 0; i < num_adapters; i++) {
       al_get_monitor_info(i, &info);
       log_printf("Adapter %d: ", i);
Index: include/allegro5/display.h
===================================================================
--- include/allegro5/display.h	(revision 13851)
+++ include/allegro5/display.h	(working copy)
@@ -152,6 +152,8 @@
 /* Stuff for multihead/window management */
 AL_FUNC(int, al_get_num_video_adapters, (void));
 AL_FUNC(void, al_get_monitor_info, (int adapter, ALLEGRO_MONITOR_INFO *info));
+AL_FUNC(int, al_get_main_adapter, (void));
+AL_FUNC(int, al_get_active_adapter, (void));
 AL_FUNC(int, al_get_new_display_adapter, (void));
 AL_FUNC(void, al_set_new_display_adapter, (int adapter));
 AL_FUNC(void, al_set_new_window_position, (int x, int y));
Index: include/allegro5/internal/aintern_system.h
===================================================================
--- include/allegro5/internal/aintern_system.h	(revision 13851)
+++ include/allegro5/internal/aintern_system.h	(working copy)
@@ -25,6 +25,8 @@
    void (*shutdown_system)(void);
    int (*get_num_video_adapters)(void);
    void (*get_monitor_info)(int adapter, ALLEGRO_MONITOR_INFO *info);
+   int (*get_main_adapter)(void);
+   int (*get_active_adapter)(void);
    ALLEGRO_MOUSE_CURSOR *(*create_mouse_cursor)(ALLEGRO_BITMAP *bmp, int x_focus, int y_focus);
    void (*destroy_mouse_cursor)(ALLEGRO_MOUSE_CURSOR *cursor);
    bool (*get_cursor_position)(int *ret_x, int *ret_y);
Index: src/display.c
===================================================================
--- src/display.c	(revision 13851)
+++ src/display.c	(working copy)
@@ -1,6 +1,6 @@
-/*         ______   ___    ___ 
- *        /\  _  \ /\_ \  /\_ \ 
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -45,20 +45,20 @@
    system = al_get_system_driver();
    driver = system->vt->get_display_driver();
    display = driver->create_display(w, h);
-   
+
    if (!display) {
       ALLEGRO_DEBUG("Failed to create display (NULL)\n");
       return NULL;
    }
-   
+
    display->vertex_cache = 0;
    display->num_cache_vertices = 0;
    display->cache_enabled = false;
    display->vertex_cache_size = 0;
    display->cache_texture = 0;
-   
+
    display->display_invalidated = 0;
-   
+
    _al_vector_init(&display->bitmaps, sizeof(ALLEGRO_BITMAP*));
 
    if (display->extra_settings.settings[ALLEGRO_COMPATIBLE_DISPLAY])
@@ -391,6 +391,40 @@
 }
 
 
+/* Function: al_get_main_adapter
+ */
+int al_get_main_adapter(void)
+{
+   ALLEGRO_SYSTEM *system = al_get_system_driver();
+
+   if (system && system->vt && system->vt->get_main_adapter) {
+      return system->vt->get_main_adapter();
+   }
+
+   return 0;
+}
+
+
+/* Function: al_get_active_adapter
+ */
+int al_get_active_adapter(void)
+{
+   int adapter = -1;
+
+   ALLEGRO_SYSTEM *system = al_get_system_driver();
+
+   if (system && system->vt && system->vt->get_active_adapter) {
+      adapter = system->vt->get_active_adapter();
+   }
+
+   if (adapter < 0) {
+      return al_get_main_adapter();
+   }
+
+   return adapter;
+}
+
+
 /* Function: al_set_window_position
  */
 void al_set_window_position(ALLEGRO_DISPLAY *display, int x, int y)
Index: src/gp2xwiz/wiz_system.c
===================================================================
--- src/gp2xwiz/wiz_system.c	(revision 13851)
+++ src/gp2xwiz/wiz_system.c	(working copy)
@@ -1,6 +1,6 @@
-/*         ______   ___    ___ 
- *        /\  _  \ /\_ \  /\_ \ 
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -153,6 +153,8 @@
    gp2xwiz_vt->shutdown_system = gp2xwiz_shutdown_system;
    gp2xwiz_vt->get_num_video_adapters = gp2xwiz_get_num_video_adapters;
    gp2xwiz_vt->get_monitor_info = gp2xwiz_get_monitor_info;
+   /*gp2xwiz_vt->get_main_adapter*/
+   /*gp2xwiz_vt->get_active_adapter*/
    gp2xwiz_vt->get_cursor_position = gp2xwiz_get_cursor_position;
    gp2xwiz_vt->get_path = _al_unix_get_path;
    gp2xwiz_vt->inhibit_screensaver = gp2xwiz_inhibit_screensaver;
Index: src/iphone/iphone_system.c
===================================================================
--- src/iphone/iphone_system.c	(revision 13851)
+++ src/iphone/iphone_system.c	(working copy)
@@ -85,6 +85,8 @@
     //xglx_vt->shutdown_system = xglx_shutdown_system;
     vt->get_num_video_adapters = iphone_get_num_video_adapters;
     vt->get_monitor_info = iphone_get_monitor_info;
+    /*vt->get_main_adapter*/
+    /*vt->get_active_adapter*/
     vt->get_cursor_position = iphone_get_cursor_position;
     vt->get_path = _al_iphone_get_path;
     //xglx_vt->inhibit_screensaver = xglx_inhibit_screensaver;
Index: src/macosx/system.m
===================================================================
--- src/macosx/system.m	(revision 13851)
+++ src/macosx/system.m	(working copy)
@@ -1,6 +1,6 @@
-/*         ______   ___    ___ 
- *        /\  _  \ /\_ \  /\_ \ 
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -70,7 +70,7 @@
  *  Tell the dock about us; the origins of this hack are unknown, but it's
  *  currently the only way to make a Cocoa app to work when started from a
  *  console.
- *  For the future, (10.3 and above) investigate TranformProcessType in the 
+ *  For the future, (10.3 and above) investigate TranformProcessType in the
  *  HIServices framework.
  */
 static void osx_tell_dock(void)
@@ -118,7 +118,7 @@
 static ALLEGRO_SYSTEM* osx_sys_init(int flags)
 {
    (void)flags;
-   
+
 #ifdef OSX_BOOTSTRAP_DETECTION
    /* If we're in the 'dead bootstrap' environment, the Mac driver won't work. */
    if (!_al_osx_bootstrap_ok()) {
@@ -128,7 +128,7 @@
    /* Initialise the vt and display list */
    osx_system.vt = _al_system_osx_driver();
    _al_vector_init(&osx_system.displays, sizeof(ALLEGRO_DISPLAY*));
-  
+
    if (osx_bundle == NULL) {
        /* If in a bundle, the dock will recognise us automatically */
        osx_tell_dock();
@@ -170,11 +170,11 @@
    CGDirectDisplayID display;
    CFArrayRef modes;
    CFIndex i;
-   
+
    if (extras)
       depth = extras->settings[ALLEGRO_COLOR_SIZE];
    memset(&temp, 0, sizeof(ALLEGRO_EXTRA_DISPLAY_SETTINGS));
-   
+
    display = CGMainDisplayID();
    /* Get display ID for the requested display */
    if (adapter > 0) {
@@ -190,7 +190,7 @@
        */
       display = (CGDirectDisplayID) [display_id pointerValue];
    }
-   
+
    _al_vector_free(&osx_display_modes);
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
    /* Note: modes is owned by OSX and must not be released */
@@ -226,7 +226,7 @@
       number = CFDictionaryGetValue(dict, kCGDisplayRefreshRate);
       CFNumberGetValue(number, kCFNumberIntType, &mode->refresh_rate);
       ALLEGRO_INFO("Mode %d is %dx%d@%dHz\n", (int)i, mode->width, mode->height, mode->refresh_rate);
-      
+
       number = CFDictionaryGetValue(dict, kCGDisplayBitsPerPixel);
       CFNumberGetValue(number, kCFNumberIntType, &temp.settings[ALLEGRO_COLOR_SIZE]);
       number = CFDictionaryGetValue(dict, kCGDisplaySamplesPerPixel);
@@ -319,11 +319,11 @@
 
       /* Yes, it's fine */
       amode = (ALLEGRO_DISPLAY_MODE *)_al_vector_alloc_back(&osx_display_modes);
-      amode->width = CGDisplayModeGetWidth(mode); 
-      amode->height = CGDisplayModeGetHeight(mode); 
+      amode->width = CGDisplayModeGetWidth(mode);
+      amode->height = CGDisplayModeGetHeight(mode);
       amode->refresh_rate = mode_refresh_rate;
       ALLEGRO_INFO("Mode %d is %dx%d@%dHz\n", (int)i, amode->width, amode->height, amode->refresh_rate);
-      
+
       temp.settings[ALLEGRO_COLOR_SIZE] = bpp;
       ALLEGRO_INFO("Mode %d has %d bits per pixel, %d samples per pixel and %d bits per sample\n",
                   (int)i, temp.settings[ALLEGRO_COLOR_SIZE], samples, value);
@@ -361,7 +361,7 @@
 /* osx_get_num_video_adapters:
  * Return the number of video adapters i.e displays
  */
-static int osx_get_num_video_adapters(void) 
+static int osx_get_num_video_adapters(void)
 {
    NSArray *screen_list;
    int num = 0;
@@ -377,7 +377,7 @@
 /* osx_get_monitor_info:
  * Return the details of one monitor
  */
-static void osx_get_monitor_info(int adapter, ALLEGRO_MONITOR_INFO* info) 
+static void osx_get_monitor_info(int adapter, ALLEGRO_MONITOR_INFO* info)
 {
 /*
    int count = osx_get_num_video_adapters();
@@ -406,9 +406,27 @@
    }
 }
 
+/* osx_get_main_adapter:
+ * Returns index of main adapter.
+ * On Mac OS main adapter is always first one.
+ */
+static int osx_get_main_adapter(void)
+{
+   return 0;
+}
+
+/* osx_get_active_adapter:
+ * Returns index of active adapter (that with focus).
+ */
+static int osx_get_active_adapter(void)
+{
+   return [NSScreen mainScreen];
+}
+
+
 /* osx_inhibit_screensaver:
  * Stops the screen dimming/screen saver activation if inhibit is true
- * otherwise re-enable normal behaviour. The last call takes force (i.e 
+ * otherwise re-enable normal behaviour. The last call takes force (i.e
  * it does not count the calls to inhibit/uninhibit.
  * Always returns true
  */
@@ -432,13 +450,13 @@
    int h = al_get_bitmap_height(bmp);
    NSImage* img = [[NSImage alloc] initWithSize: NSMakeSize((float) w, (float) h)];
    NSBitmapImageRep* rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL // Allocate memory yourself
-      pixelsWide:w 
-      pixelsHigh:h 
-      bitsPerSample: 8 
-      samplesPerPixel: 4 
-      hasAlpha:YES 
-      isPlanar:NO 
-      colorSpaceName:NSDeviceRGBColorSpace 
+      pixelsWide:w
+      pixelsHigh:h
+      bitsPerSample: 8
+      samplesPerPixel: 4
+      hasAlpha:YES
+      isPlanar:NO
+      colorSpaceName:NSDeviceRGBColorSpace
       bytesPerRow: 0 // Calculate yourself
       bitsPerPixel:0 ];// Calculate yourself
    al_lock_bitmap(bmp, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
@@ -462,7 +480,7 @@
 
 /* This works as long as there is only one screen */
 /* Not clear from docs how mouseLocation works if > 1 */
-static bool osx_get_cursor_position(int *x, int *y) 
+static bool osx_get_cursor_position(int *x, int *y)
 {
    NSPoint p = [NSEvent mouseLocation];
    NSRect r = [[NSScreen mainScreen] frame];
@@ -509,12 +527,14 @@
       vt->get_display_driver = _al_osx_get_display_driver;
       vt->get_keyboard_driver = _al_osx_get_keyboard_driver;
       vt->get_mouse_driver = _al_osx_get_mouse_driver;
-      vt->get_joystick_driver = _al_osx_get_joystick_driver; 
+      vt->get_joystick_driver = _al_osx_get_joystick_driver;
       vt->get_num_display_modes = _al_osx_get_num_display_modes;
       vt->get_display_mode = _al_osx_get_display_mode;
       vt->shutdown_system = osx_sys_exit;
       vt->get_num_video_adapters = osx_get_num_video_adapters;
       vt->get_monitor_info = osx_get_monitor_info;
+      vt->get_main_adapter = osx_get_main_adapter;
+      vt->get_active_adapter = osx_get_active_adapter;
       vt->create_mouse_cursor = _al_osx_create_mouse_cursor;
       vt->destroy_mouse_cursor = _al_osx_destroy_mouse_cursor;
       vt->get_cursor_position = osx_get_cursor_position;
@@ -523,7 +543,7 @@
       vt->thread_init = osx_thread_init;
       vt->thread_exit = osx_thread_exit;
    };
-      
+
    return vt;
 }
 
@@ -711,11 +731,11 @@
  * Currently just sends a window close event to all windows.
  * This is a bit unsatisfactory
  */
-void _al_osx_post_quit(void) 
+void _al_osx_post_quit(void)
 {
    unsigned int i;
    _AL_VECTOR* dpys = &al_get_system_driver()->displays;
-   // Iterate through all existing displays 
+   // Iterate through all existing displays
    for (i = 0; i < _al_vector_size(dpys); ++i) {
       ALLEGRO_DISPLAY* dpy = *(ALLEGRO_DISPLAY**) _al_vector_ref(dpys, i);
       ALLEGRO_EVENT_SOURCE* src = &(dpy->es);
Index: src/system.c
===================================================================
--- src/system.c	(revision 13851)
+++ src/system.c	(working copy)
@@ -1,6 +1,6 @@
-/*         ______   ___    ___ 
- *        /\  _  \ /\_ \  /\_ \ 
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -93,7 +93,7 @@
       active_sysdrv = NULL;
       /* active_sysdrv is not accessible here so we copied it */
       al_destroy_config(temp);
- 
+
       while (!_al_vector_is_empty(&_al_system_interfaces))
          _al_vector_delete_at(&_al_system_interfaces, _al_vector_size(&_al_system_interfaces)-1);
       _al_vector_free(&_al_system_interfaces);
@@ -168,7 +168,7 @@
       return false;
    }
    if (((a & 0x00ff0000) >> 16) & 1) {
-      
+
       if ((a & 0x0000ff00) != (b & 0x0000ff00)) {
          return false;
       }
@@ -185,7 +185,7 @@
    ALLEGRO_SYSTEM bootstrap;
    ALLEGRO_SYSTEM *real_system;
    int library_version = al_get_allegro_version();
-   
+
    if (active_sysdrv) {
       return true;
    }
@@ -199,7 +199,7 @@
 #ifdef ALLEGRO_CFG_PTHREADS_TLS
    _al_pthreads_tls_init();
 #endif
-   
+
    _al_vector_init(&_al_system_interfaces, sizeof(ALLEGRO_SYSTEM_INTERFACE *));
 
    /* We want active_sysdrv->config to be available as soon as
@@ -231,7 +231,7 @@
       active_sysdrv = NULL;
       return false;
    }
-   
+
    active_sysdrv = real_system;
    active_sysdrv->config = bootstrap.config;
 
@@ -259,6 +259,9 @@
    /* Clear errnos set while searching for config files. */
    al_set_errno(0);
 
+   /* Set active adapter as default one. */
+   al_set_new_display_adapter(al_get_active_adapter());
+
    return true;
 }
 
Index: src/win/wsystem.c
===================================================================
--- src/win/wsystem.c	(revision 13851)
+++ src/win/wsystem.c	(working copy)
@@ -1,6 +1,6 @@
-/*         ______   ___    ___ 
- *        /\  _  \ /\_ \  /\_ \ 
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___ 
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
@@ -15,6 +15,10 @@
  *      Heavily modified by Trent Gamblin.
  */
 
+/* We want Windows XP API */
+#define WINVER 0x0501
+#define _WIN32_WINNT 0x0501
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -35,7 +39,6 @@
 
 #include <windows.h>
 
-
 #include <mmsystem.h>
 
 /* FIXME: should we check for psapi _WIN32_IE and shlobj?
@@ -175,7 +178,7 @@
       d3d_available = false;
 #endif
 #endif
-   
+
    return &_al_win_system->system;
 }
 
@@ -328,46 +331,140 @@
 
 static int win_get_num_video_adapters(void)
 {
-   DISPLAY_DEVICE dd;
-   int count = 0;
-   int c = 0;
+   return (int)GetSystemMetrics(SM_CMONITORS);
+}
 
-   memset(&dd, 0, sizeof(dd));
-   dd.cb = sizeof(dd);
+typedef enum WIN_GET_MONITOR_INFO_MODE
+{
+   WIN_QUERY_ADAPTER,
+   WIN_SEEK_PRIMARY,
+   WIN_SEEK_ADAPTER
+} WIN_GET_MONITOR_INFO_MODE;
 
-   while (EnumDisplayDevices(NULL, count, &dd, 0) != false) {
-      if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
-         c++;
-      count++;
+typedef struct WIN_GET_MONITOR_INFO_CALLBACK_DATA
+{
+   WIN_GET_MONITOR_INFO_MODE mode;
+   int adapter;
+   ALLEGRO_MONITOR_INFO* info;
+   HMONITOR monitor;
+   BOOL done;
+} WIN_GET_MONITOR_INFO_CALLBACK_DATA;
+
+static BOOL CALLBACK win_get_monitor_info_callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
+{
+   MONITORINFOEX monitor_info;
+   WIN_GET_MONITOR_INFO_CALLBACK_DATA* data = (WIN_GET_MONITOR_INFO_CALLBACK_DATA*)dwData;
+
+   if ((data->mode == WIN_QUERY_ADAPTER) && (data->adapter > 0)) {
+      --data->adapter;
+      return TRUE;
    }
 
-   return c;
+   memset(&monitor_info, 0, sizeof(monitor_info));
+   monitor_info.cbSize = sizeof(monitor_info);
+
+   GetMonitorInfo(hMonitor, (MONITORINFO*)&monitor_info);
+
+   if (data->mode == WIN_SEEK_PRIMARY) {
+      if (monitor_info.dwFlags & MONITORINFOF_PRIMARY) {
+         data->done = TRUE;
+         return FALSE;
+      }
+      else {
+         ++data->adapter;
+         return TRUE;
+      }
+   }
+
+   if (data->mode == WIN_SEEK_ADAPTER) {
+      if (hMonitor == data->monitor) {
+         data->done = TRUE;
+         return FALSE;
+      }
+      else {
+         ++data->adapter;
+         return TRUE;
+      }
+   }
+
+   data->info->x1 = monitor_info.rcMonitor.left;
+   data->info->y1 = monitor_info.rcMonitor.top;
+   data->info->x2 = monitor_info.rcMonitor.right;
+   data->info->y2 = monitor_info.rcMonitor.bottom;
+   data->done     = TRUE;
+
+   return FALSE;
 }
 
 static void win_get_monitor_info(int adapter, ALLEGRO_MONITOR_INFO *info)
 {
-   DISPLAY_DEVICE dd;
-   DEVMODE dm;
+   WIN_GET_MONITOR_INFO_CALLBACK_DATA data;
+   memset(&data, 0, sizeof(data));
+   data.mode    = WIN_QUERY_ADAPTER;
+   data.adapter = adapter;
+   data.info    = info;
 
-   memset(&dd, 0, sizeof(dd));
-   dd.cb = sizeof(dd);
-   EnumDisplayDevices(NULL, adapter, &dd, 0);
+   EnumDisplayMonitors(NULL, NULL, win_get_monitor_info_callback, (LPARAM)&data);
 
-   memset(&dm, 0, sizeof(dm));
-   dm.dmSize = sizeof(dm);
-   EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm);
+   if (!data.done) {
+      memset(info, 0, sizeof(ALLEGRO_MONITOR_INFO));
+   }
+}
 
-   ASSERT(dm.dmFields & DM_PELSHEIGHT);
-   ASSERT(dm.dmFields & DM_PELSWIDTH);
-   /* Disabled this assertion for now as it fails under Wine 1.2. */
-   /* ASSERT(dm.dmFields & DM_POSITION); */
+static int win_get_main_adapter(void)
+{
+   WIN_GET_MONITOR_INFO_CALLBACK_DATA data;
+   memset(&data, 0, sizeof(data));
+   data.mode    = WIN_SEEK_PRIMARY;
+   data.adapter = 0;
 
-   info->x1 = dm.dmPosition.x;
-   info->y1 = dm.dmPosition.y;
-   info->x2 = info->x1 + dm.dmPelsWidth;
-   info->y2 = info->y1 + dm.dmPelsHeight;
+   EnumDisplayMonitors(NULL, NULL, win_get_monitor_info_callback, (LPARAM)&data);
+
+   if (data.done) {
+      return data.adapter;
+   }
+
+   return 0;
 }
 
+static int win_get_active_adapter(void)
+{
+   HWND hwnd;
+   WNDCLASS null_window_class =
+   {
+      0, DefWindowProc, 0, 0,
+      (HINSTANCE)GetModuleHandle(NULL),
+      NULL, NULL, NULL, NULL,
+      "win_get_active_adapter_null_window"
+   };
+
+   WIN_GET_MONITOR_INFO_CALLBACK_DATA data;
+   memset(&data, 0, sizeof(data));
+   data.mode    = WIN_SEEK_ADAPTER;
+   data.adapter = 0;
+
+   RegisterClass(&null_window_class);
+
+   hwnd = CreateWindow(null_window_class.lpszClassName, "Hidden",
+      0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+      CW_USEDEFAULT, NULL, NULL, null_window_class.hInstance, NULL);
+
+   data.monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
+
+   DestroyWindow(hwnd);
+
+   UnregisterClass(null_window_class.lpszClassName, null_window_class.hInstance);
+
+   EnumDisplayMonitors(NULL, NULL, win_get_monitor_info_callback, (LPARAM)&data);
+
+   if (data.done) {
+      return data.adapter;
+   }
+
+   /* Negative value will cause fallback to main adapter. */
+   return -1;
+}
+
 static bool win_get_cursor_position(int *ret_x, int *ret_y)
 {
    POINT p;
@@ -455,7 +552,7 @@
 
          return al_create_path(path);
       } break;
-      
+
       default:
          return NULL;
    }
@@ -526,6 +623,8 @@
    vt->create_mouse_cursor = _al_win_create_mouse_cursor;
    vt->destroy_mouse_cursor = _al_win_destroy_mouse_cursor;
    vt->get_monitor_info = win_get_monitor_info;
+   vt->get_main_adapter = win_get_main_adapter;
+   vt->get_active_adapter = win_get_active_adapter;
    vt->get_cursor_position = win_get_cursor_position;
    vt->get_path = win_get_path;
    vt->inhibit_screensaver = win_inhibit_screensaver;
Index: src/x/xfullscreen.c
===================================================================
--- src/x/xfullscreen.c	(revision 13851)
+++ src/x/xfullscreen.c	(working copy)
@@ -14,6 +14,8 @@
     void (*get_display_offset)(ALLEGRO_SYSTEM_XGLX *, int, int *, int *);
     int (*get_num_adapters)(ALLEGRO_SYSTEM_XGLX *);
     void (*get_monitor_info)(ALLEGRO_SYSTEM_XGLX *, int, ALLEGRO_MONITOR_INFO *);
+    int (*get_main_adapter)(ALLEGRO_SYSTEM_XGLX *);
+    int (*get_active_adapter)(ALLEGRO_SYSTEM_XGLX *);
 };
 
 
@@ -94,7 +96,7 @@
 {
    if (adapter < 0 || adapter >= s->xinerama_screen_count)
       return;
-   
+
    mi->x1 = s->xinerama_screen_info[adapter].x_org;
    mi->y1 = s->xinerama_screen_info[adapter].y_org;
    mi->x2 = mi->x1 + s->xinerama_screen_info[adapter].width;
@@ -222,7 +224,7 @@
 
    if (adapter < 0 || adapter >= s->xrandr_output_count)
       return NULL;
-      
+
    int i;
    for (i = 0; i < s->xrandr_res->nmode; i++) {
       if (s->xrandr_res->modes[i].id == s->xrandr_outputs[adapter]->modes[id]) {
@@ -266,7 +268,7 @@
    else {
       ALLEGRO_DEBUG("xrandr: new mode: %dx%d@%d old mode: %dx%d@%d.\n", w,h,refresh, cur_mode->width, cur_mode->height, cur_refresh_rate);
    }
-   
+
    mode_idx = _al_xglx_fullscreen_select_mode(s, d->xscreen, w, h, format, refresh);
    if (mode_idx == -1) {
       ALLEGRO_DEBUG("xrandr: mode %dx%d@%d not found.\n", w,h,refresh);
@@ -340,7 +342,7 @@
 {
    if (adapter < 0 || adapter >= s->xrandr_output_count)
       return;
-   
+
    ASSERT(s->xrandr_stored_modes[adapter]);
    ALLEGRO_DEBUG("xfullscreen: _al_xsys_xrandr_restore_mode (%d, %d)\n",
                  s->xrandr_stored_modes[adapter]->width, s->xrandr_stored_modes[adapter]->height);
@@ -371,7 +373,7 @@
                     crtc_info->noutput);
 
    XRRFreeCrtcInfo(crtc_info);
-    
+
    if (ok != 0) {
       ALLEGRO_ERROR("XRandR failed to restore mode.\n");
    }
@@ -483,6 +485,8 @@
       mmon_interface.get_display_offset    = _al_xsys_xrandr_get_display_offset;
       mmon_interface.get_num_adapters      = _al_xsys_xrandr_get_num_adapters;
       mmon_interface.get_monitor_info      = _al_xsys_xrandr_get_monitor_info;
+      mmon_interface.get_main_adapter      = NULL;
+      mmon_interface.get_active_adapter    = NULL;
    }
 
    _al_mutex_unlock(&s->lock);
@@ -747,6 +751,8 @@
          mmon_interface.get_display_offset    = _al_xsys_xfvm_get_display_offset;
          mmon_interface.get_num_adapters      = _al_xsys_xfvm_get_num_adapters;
          mmon_interface.get_monitor_info      = _al_xsys_xfvm_get_monitor_info;
+         mmon_interface.get_main_adapter      = NULL;
+         mmon_interface.get_active_adapter    = NULL;
       }
    }
 
@@ -896,7 +902,7 @@
 
    if (!init_mmon_interface(s))
       return -1;
-   
+
    if (adapter == -1)
       adapter = get_default_adapter();
 
@@ -1013,6 +1019,28 @@
    mmon_interface.get_monitor_info(s, adapter, info);
 }
 
+int _al_xglx_get_main_adapter(ALLEGRO_SYSTEM_XGLX *s)
+{
+   if (!init_mmon_interface(s))
+      return 0;
+
+   if (!mmon_interface.get_main_adapter)
+      return 0;
+
+   return mmon_interface.get_main_adapter(s);
+}
+
+int _al_xglx_get_active_adapter(ALLEGRO_SYSTEM_XGLX *s)
+{
+   if (!init_mmon_interface(s))
+      return -1; /* Negative value will cause fallback to main adapter. */
+
+   if (!mmon_interface.get_active_adapter)
+      return -1; /* Negative value will cause fallback to main adapter. */
+
+   return mmon_interface.get_active_adapter(s);
+}
+
 int _al_xglx_get_num_video_adapters(ALLEGRO_SYSTEM_XGLX *s)
 {
    if (!init_mmon_interface(s))
@@ -1059,7 +1087,7 @@
 
    XSendEvent(x11, DefaultRootWindow(x11), False,
       SubstructureRedirectMask | SubstructureNotifyMask, &xev);
-   
+
    if (value == 2) {
       /* Only wait for a resize if toggling. */
       _al_display_xglx_await_resize(display, old_resize_count, true);
Index: src/x/xsystem.c
===================================================================
--- src/x/xsystem.c	(revision 13851)
+++ src/x/xsystem.c	(working copy)
@@ -110,20 +110,20 @@
        * Most older X11 implementations are not thread-safe no matter what, so
        * we simply cannot sit inside a blocking XNextEvent from another thread
        * if another thread also uses X11 functions.
-       * 
+       *
        * The usual use of XNextEvent is to only call it from the main thread. We
        * could of course do this for A5, just needs some slight adjustments to
        * the events system (polling for an Allegro event would call a function
        * of the system driver).
-       * 
+       *
        * As an alternative, we can use locking. This however can never fully
        * work, as for example OpenGL implementations also will access X11, in a
        * way we cannot know and cannot control (and we can't require users to
        * only call graphics functions inside a lock).
-       * 
+       *
        * However, most X11 implementations are somewhat thread safe, and do
        * use locking quite a bit themselves, so locking mostly does work.
-       * 
+       *
        * (Yet another alternative might be to use a separate X11 display
        * connection for graphics output.)
        *
@@ -308,6 +308,20 @@
    _al_xglx_get_monitor_info(system, adapter, info);
 }
 
+static int xglx_get_main_adapter()
+{
+   ALLEGRO_SYSTEM_XGLX *system = (void *)al_get_system_driver();
+
+   return _al_xglx_get_main_adapter(system);
+}
+
+static int xglx_get_active_adapter()
+{
+   ALLEGRO_SYSTEM_XGLX *system = (void *)al_get_system_driver();
+
+   return _al_xglx_get_active_adapter(system);
+}
+
 static bool xglx_get_cursor_position(int *ret_x, int *ret_y)
 {
    ALLEGRO_SYSTEM_XGLX *system = (void *)al_get_system_driver();
@@ -366,6 +380,8 @@
    xglx_vt->shutdown_system = xglx_shutdown_system;
    xglx_vt->get_num_video_adapters = xglx_get_num_video_adapters;
    xglx_vt->get_monitor_info = xglx_get_monitor_info;
+   xglx_vt->get_main_adapter = xglx_get_main_adapter;
+   xglx_vt->get_active_adapter = xglx_get_active_adapter;
    xglx_vt->create_mouse_cursor = _al_xwin_create_mouse_cursor;
    xglx_vt->destroy_mouse_cursor = _al_xwin_destroy_mouse_cursor;
    xglx_vt->get_cursor_position = xglx_get_cursor_position;
